Skip to content

Commit f2a02ba

Browse files
authored
Merge pull request #16 from s-ludwig/reentrancy
Move globals in threadcontext into a struct contained in CallContext.
2 parents 8c73720 + 2e44e20 commit f2a02ba

20 files changed

Lines changed: 205 additions & 189 deletions

engine/source/dmdscript/darguments.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Darguments : Dobject
4545
Identifier *[] parameters, Value[] arglist)
4646

4747
{
48-
super(cc, Dobject.getPrototype());
48+
super(cc, Dobject.getPrototype(cc));
4949

5050
this.actobj = actobj;
5151
this.parameters = parameters;

engine/source/dmdscript/darray.d

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class DarrayConstructor : Dfunction
4444
{
4545
this(CallContext* cc)
4646
{
47-
super(cc, 1, Dfunction_prototype);
47+
super(cc, 1, cc.tc.Dfunction_prototype);
4848
name = "Array";
4949
}
5050

@@ -951,10 +951,10 @@ class DarrayPrototype : Darray
951951
{
952952
this(CallContext* cc)
953953
{
954-
super(cc, Dobject_prototype);
955-
Dobject f = Dfunction_prototype;
954+
super(cc, cc.tc.Dobject_prototype);
955+
Dobject f = cc.tc.Dfunction_prototype;
956956

957-
Put(cc, TEXT_constructor, Darray_constructor, DontEnum);
957+
Put(cc, TEXT_constructor, cc.tc.Darray_constructor, DontEnum);
958958

959959
static enum NativeFunctionData[] nfd =
960960
[
@@ -987,7 +987,7 @@ class Darray : Dobject
987987

988988
this(CallContext* cc)
989989
{
990-
this(cc, getPrototype());
990+
this(cc, getPrototype(cc));
991991
}
992992

993993
this(CallContext* cc, Dobject prototype)
@@ -1193,22 +1193,22 @@ class Darray : Dobject
11931193
}
11941194

11951195

1196-
static Dfunction getConstructor()
1196+
static Dfunction getConstructor(CallContext* cc)
11971197
{
1198-
return Darray_constructor;
1198+
return cc.tc.Darray_constructor;
11991199
}
12001200

1201-
static Dobject getPrototype()
1201+
static Dobject getPrototype(CallContext* cc)
12021202
{
1203-
return Darray_prototype;
1203+
return cc.tc.Darray_prototype;
12041204
}
12051205

12061206
static void initialize(CallContext* cc)
12071207
{
1208-
Darray_constructor = new DarrayConstructor(cc);
1209-
Darray_prototype = new DarrayPrototype(cc);
1208+
cc.tc.Darray_constructor = new DarrayConstructor(cc);
1209+
cc.tc.Darray_prototype = new DarrayPrototype(cc);
12101210

1211-
Darray_constructor.Put(cc, TEXT_prototype, Darray_prototype, DontEnum | ReadOnly);
1211+
cc.tc.Darray_constructor.Put(cc, TEXT_prototype, cc.tc.Darray_prototype, DontEnum | ReadOnly);
12121212
}
12131213
}
12141214

engine/source/dmdscript/dboolean.d

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DbooleanConstructor : Dfunction
3333
{
3434
this(CallContext* cc)
3535
{
36-
super(cc, 1, Dfunction_prototype);
36+
super(cc, 1, cc.tc.Dfunction_prototype);
3737
name = "Boolean";
3838
}
3939

@@ -118,10 +118,10 @@ class DbooleanPrototype : Dboolean
118118
{
119119
this(CallContext* cc)
120120
{
121-
super(cc, Dobject_prototype);
121+
super(cc, cc.tc.Dobject_prototype);
122122
//Dobject f = Dfunction_prototype;
123123

124-
Put(cc, TEXT_constructor, Dboolean_constructor, DontEnum);
124+
Put(cc, TEXT_constructor, cc.tc.Dboolean_constructor, DontEnum);
125125

126126
static enum NativeFunctionData[] nfd =
127127
[
@@ -140,7 +140,7 @@ class Dboolean : Dobject
140140
{
141141
this(CallContext* cc, d_boolean b)
142142
{
143-
super(cc, Dboolean.getPrototype());
143+
super(cc, Dboolean.getPrototype(cc));
144144
value.putVboolean(b);
145145
classname = TEXT_Boolean;
146146
}
@@ -152,22 +152,22 @@ class Dboolean : Dobject
152152
classname = TEXT_Boolean;
153153
}
154154

155-
static Dfunction getConstructor()
155+
static Dfunction getConstructor(CallContext* cc)
156156
{
157-
return Dboolean_constructor;
157+
return cc.tc.Dboolean_constructor;
158158
}
159159

160-
static Dobject getPrototype()
160+
static Dobject getPrototype(CallContext* cc)
161161
{
162-
return Dboolean_prototype;
162+
return cc.tc.Dboolean_prototype;
163163
}
164164

165165
static void initialize(CallContext* cc)
166166
{
167-
Dboolean_constructor = new DbooleanConstructor(cc);
168-
Dboolean_prototype = new DbooleanPrototype(cc);
167+
cc.tc.Dboolean_constructor = new DbooleanConstructor(cc);
168+
cc.tc.Dboolean_prototype = new DbooleanPrototype(cc);
169169

170-
Dboolean_constructor.Put(cc, TEXT_prototype, Dboolean_prototype, DontEnum | DontDelete | ReadOnly);
170+
cc.tc.Dboolean_constructor.Put(cc, TEXT_prototype, cc.tc.Dboolean_prototype, DontEnum | DontDelete | ReadOnly);
171171
}
172172
}
173173

engine/source/dmdscript/ddate.d

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class DdateConstructor : Dfunction
189189
{
190190
this(CallContext* cc)
191191
{
192-
super(cc, 7, Dfunction_prototype);
192+
super(cc, 7, cc.tc.Dfunction_prototype);
193193
name = "Date";
194194

195195
static enum NativeFunctionData[] nfd =
@@ -1442,11 +1442,11 @@ class DdatePrototype : Ddate
14421442
{
14431443
this(CallContext* cc)
14441444
{
1445-
super(cc, Dobject_prototype);
1445+
super(cc, cc.tc.Dobject_prototype);
14461446

1447-
Dobject f = Dfunction_prototype;
1447+
Dobject f = cc.tc.Dfunction_prototype;
14481448

1449-
Put(cc, TEXT_constructor, Ddate_constructor, DontEnum);
1449+
Put(cc, TEXT_constructor, cc.tc.Ddate_constructor, DontEnum);
14501450

14511451
static enum NativeFunctionData[] nfd =
14521452
[
@@ -1511,14 +1511,14 @@ class Ddate : Dobject
15111511
{
15121512
this(CallContext* cc, d_number n)
15131513
{
1514-
super(cc, Ddate.getPrototype());
1514+
super(cc, Ddate.getPrototype(cc));
15151515
classname = TEXT_Date;
15161516
value.putVnumber(n);
15171517
}
15181518

15191519
this(CallContext* cc, d_time n)
15201520
{
1521-
super(cc, Ddate.getPrototype());
1521+
super(cc, Ddate.getPrototype(cc));
15221522
classname = TEXT_Date;
15231523
value.putVtime(n);
15241524
}
@@ -1532,23 +1532,23 @@ class Ddate : Dobject
15321532

15331533
static void initialize(CallContext* cc)
15341534
{
1535-
Ddate_constructor = new DdateConstructor(cc);
1536-
Ddate_prototype = new DdatePrototype(cc);
1535+
cc.tc.Ddate_constructor = new DdateConstructor(cc);
1536+
cc.tc.Ddate_prototype = new DdatePrototype(cc);
15371537

1538-
Ddate_constructor.Put(cc, TEXT_prototype, Ddate_prototype,
1538+
cc.tc.Ddate_constructor.Put(cc, TEXT_prototype, cc.tc.Ddate_prototype,
15391539
DontEnum | DontDelete | ReadOnly);
15401540

1541-
assert(Ddate_prototype.proptable.table.length != 0);
1541+
assert(cc.tc.Ddate_prototype.proptable.table.length != 0);
15421542
}
15431543

1544-
static Dfunction getConstructor()
1544+
static Dfunction getConstructor(CallContext* cc)
15451545
{
1546-
return Ddate_constructor;
1546+
return cc.tc.Ddate_constructor;
15471547
}
15481548

1549-
static Dobject getPrototype()
1549+
static Dobject getPrototype(CallContext* cc)
15501550
{
1551-
return Ddate_prototype;
1551+
return cc.tc.Ddate_prototype;
15521552
}
15531553
}
15541554

engine/source/dmdscript/ddeclaredfunction.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ class DdeclaredFunction : Dfunction
4040

4141
this(CallContext* cc, FunctionDefinition fd)
4242
{
43-
super(cc, cast(uint)fd.parameters.length, Dfunction.getPrototype());
44-
assert(Dfunction.getPrototype());
43+
super(cc, cast(uint)fd.parameters.length, Dfunction.getPrototype(cc));
44+
assert(Dfunction.getPrototype(cc));
4545
assert(internal_prototype);
4646
this.fd = fd;
4747

4848
Dobject o;
4949

5050
// ECMA 3 13.2
51-
o = new Dobject(cc, Dobject.getPrototype()); // step 9
51+
o = new Dobject(cc, Dobject.getPrototype(cc)); // step 9
5252
Put(cc, TEXT_prototype, o, DontEnum); // step 11
5353
o.Put(cc, TEXT_constructor, this, DontEnum); // step 10
5454
}
@@ -193,7 +193,7 @@ class DdeclaredFunction : Dfunction
193193

194194
v = Get(TEXT_prototype);
195195
if(v.isPrimitive())
196-
proto = Dobject.getPrototype();
196+
proto = Dobject.getPrototype(cc);
197197
else
198198
proto = v.toObject(cc);
199199
othis = new Dobject(cc, proto);

engine/source/dmdscript/derror.d

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DerrorConstructor : Dfunction
3636
{
3737
this(CallContext* cc)
3838
{
39-
super(cc, 1, Dfunction_prototype);
39+
super(cc, 1, cc.tc.Dfunction_prototype);
4040
}
4141

4242
override void* Construct(CallContext *cc, Value *ret, Value[] arglist)
@@ -104,11 +104,11 @@ class DerrorPrototype : Derror
104104
{
105105
this(CallContext* cc)
106106
{
107-
super(cc, Dobject_prototype);
108-
Dobject f = Dfunction_prototype;
107+
super(cc, cc.tc.Dobject_prototype);
108+
Dobject f = cc.tc.Dfunction_prototype;
109109
//d_string m = d_string_ctor(DTEXT("Error.prototype.message"));
110110

111-
Put(cc, TEXT_constructor, Derror_constructor, DontEnum);
111+
Put(cc, TEXT_constructor, cc.tc.Derror_constructor, DontEnum);
112112

113113
static enum NativeFunctionData[] nfd =
114114
[
@@ -131,7 +131,7 @@ class Derror : Dobject
131131
{
132132
this(CallContext* cc, Value * m, Value * v2)
133133
{
134-
super(cc, getPrototype());
134+
super(cc, getPrototype(cc));
135135
classname = TEXT_Error;
136136

137137
immutable(char)[] msg;
@@ -166,22 +166,22 @@ class Derror : Dobject
166166
classname = TEXT_Error;
167167
}
168168

169-
static Dfunction getConstructor()
169+
static Dfunction getConstructor(CallContext* cc)
170170
{
171-
return Derror_constructor;
171+
return cc.tc.Derror_constructor;
172172
}
173173

174-
static Dobject getPrototype()
174+
static Dobject getPrototype(CallContext* cc)
175175
{
176-
return Derror_prototype;
176+
return cc.tc.Derror_prototype;
177177
}
178178

179179
static void initialize(CallContext* cc)
180180
{
181-
Derror_constructor = new DerrorConstructor(cc);
182-
Derror_prototype = new DerrorPrototype(cc);
181+
cc.tc.Derror_constructor = new DerrorConstructor(cc);
182+
cc.tc.Derror_prototype = new DerrorPrototype(cc);
183183

184-
Derror_constructor.Put(cc, TEXT_prototype, Derror_prototype, DontEnum | DontDelete | ReadOnly);
184+
cc.tc.Derror_constructor.Put(cc, TEXT_prototype, cc.tc.Derror_prototype, DontEnum | DontDelete | ReadOnly);
185185
}
186186
}
187187

engine/source/dmdscript/dfunction.d

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DfunctionConstructor : Dfunction
4141
{
4242
this(CallContext* cc)
4343
{
44-
super(cc, 1, Dfunction_prototype);
44+
super(cc, 1, cc.tc.Dfunction_prototype);
4545

4646
// Actually put in later by Dfunction::initialize()
4747
//unsigned attributes = DontEnum | DontDelete | ReadOnly;
@@ -261,13 +261,13 @@ class DfunctionPrototype : Dfunction
261261
{
262262
this(CallContext* cc)
263263
{
264-
super(cc, 0, Dobject_prototype);
264+
super(cc, 0, cc.tc.Dobject_prototype);
265265

266266
uint attributes = DontEnum;
267267

268268
classname = TEXT_Function;
269269
name = "prototype";
270-
Put(cc, TEXT_constructor, Dfunction_constructor, attributes);
270+
Put(cc, TEXT_constructor, cc.tc.Dfunction_constructor, attributes);
271271

272272
static enum NativeFunctionData[] nfd =
273273
[
@@ -297,7 +297,7 @@ class Dfunction : Dobject
297297

298298
this(CallContext* cc, d_uint32 length)
299299
{
300-
this(cc, length, Dfunction.getPrototype());
300+
this(cc, length, Dfunction.getPrototype(cc));
301301
}
302302

303303
this(CallContext* cc, d_uint32 length, Dobject prototype)
@@ -375,24 +375,24 @@ class Dfunction : Dobject
375375
}
376376

377377

378-
static Dfunction getConstructor()
378+
static Dfunction getConstructor(CallContext* cc)
379379
{
380-
return Dfunction_constructor;
380+
return cc.tc.Dfunction_constructor;
381381
}
382382

383-
static Dobject getPrototype()
383+
static Dobject getPrototype(CallContext* cc)
384384
{
385-
return Dfunction_prototype;
385+
return cc.tc.Dfunction_prototype;
386386
}
387387

388388
static void initialize(CallContext* cc)
389389
{
390-
Dfunction_constructor = new DfunctionConstructor(cc);
391-
Dfunction_prototype = new DfunctionPrototype(cc);
390+
cc.tc.Dfunction_constructor = new DfunctionConstructor(cc);
391+
cc.tc.Dfunction_prototype = new DfunctionPrototype(cc);
392392

393-
Dfunction_constructor.Put(cc, TEXT_prototype, Dfunction_prototype, DontEnum | DontDelete | ReadOnly);
393+
cc.tc.Dfunction_constructor.Put(cc, TEXT_prototype, cc.tc.Dfunction_prototype, DontEnum | DontDelete | ReadOnly);
394394

395-
Dfunction_constructor.internal_prototype = Dfunction_prototype;
396-
Dfunction_constructor.proptable.previous = Dfunction_prototype.proptable;
395+
cc.tc.Dfunction_constructor.internal_prototype = cc.tc.Dfunction_prototype;
396+
cc.tc.Dfunction_constructor.proptable.previous = cc.tc.Dfunction_prototype.proptable;
397397
}
398398
}

0 commit comments

Comments
 (0)