You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cce2fed
Browse filesBrowse the repository at this point in the historyBrowse files
Run every script call in CppiaAdoptInstances on a worker
On Linux, musl and 32-bit Linux the JIT pass listed the first pass's new
module as still loaded, with its two instances and four closures: the main
thread had called its code through Dynamic, and the stale values those
calls left on its stack kept it. Windows happened to overwrite them. Every
call into script code now runs on a joined worker, and the main thread
only collects and prints.
CppiaAdoptInstances needs threads, which Emscripten does not have, so it
is on its skip list.
varrows= [for (rinreport) '${r.name} moved ${r.moved}'+ (r.reason==null?"":': ${r.reason}')];
55
+
rows.sort(Reflect.compare);
56
+
lines.push('report: ${rows.join(", ")}');
57
+
}
58
+
59
+
staticfunctionuseMoved() {
60
+
// Moved, with their fields as they were
61
+
lines.push('counter runs the new code: ${counter.step() ==16&&counter.version() =="v2 counter"}');
62
+
lines.push('the subclass runs its new override: ${doubler.step() ==20&&doubler.version() =="v2 counter"}');
63
+
varstepper:Stepper=counter;
64
+
lines.push('the host interface reaches the new code: ${stepper.step() ==26}');
65
+
varcounterClass=next.resolveClass("Counter");
66
+
lines.push('they are of the new classes: ${Type.getClass(counter) ==counterClass&&Std.isOfType(counter, counterClass) &&Std.isOfType(doubler, counterClass) &&Type.getClass(doubler) ==next.resolveClass("Doubler")}');
55
67
}
56
68
57
-
// The old code runs on a worker too, so nothing it leaves on the stack
58
-
// keeps the old module
59
69
staticfunctionuseOld() {
60
-
staysOld=reshaped.version() =="v1";
61
-
keepsOld=bound() ==27&&counter.step() ==37;
70
+
// Stayed
71
+
lines.push('the reshaped instance keeps its class: ${reshaped.version() =="v1"}');
72
+
lines.push('the bound method keeps the old code: ${bound() ==27&&counter.step() ==37}');
73
+
}
74
+
75
+
staticfunctiondropOld() {
76
+
bound=null;
77
+
reshaped=null;
78
+
}
79
+
80
+
staticfunctiondropAll() {
81
+
counter=doubler=null;
82
+
untypednext.release();
83
+
next=null;
62
84
}
63
85
64
86
staticfunctionretained():String {
@@ -71,38 +93,19 @@ class Main {
71
93
72
94
staticfunctionmain() {
73
95
dir=haxe.io.Path.directory(Sys.programPath());
74
-
varstepper:Stepper=null;
75
96
for (jitin [false, true]) {
76
97
Host.enableJit(jit);
98
+
lines= [];
77
99
untyped__cpp__("runJoined({0})", loadOld);
78
100
untyped__cpp__("runJoined({0})", adopt);
79
-
80
-
varrows= [for (rinreport) '${r.name} moved ${r.moved}'+ (r.reason==null?"":': ${r.reason}')];
Sys.println('jit $jit: counter runs the new code: ${counter.step() ==16&&counter.version() =="v2 counter"}');
86
-
Sys.println('jit $jit: the subclass runs its new override: ${doubler.step() ==20&&doubler.version() =="v2 counter"}');
87
-
stepper=counter;
88
-
Sys.println('jit $jit: the host interface reaches the new code: ${stepper.step() ==26}');
89
-
varcounterClass=next.resolveClass("Counter");
90
-
Sys.println('jit $jit: they are of the new classes: ${Type.getClass(counter) ==counterClass&&Std.isOfType(counter, counterClass) &&Std.isOfType(doubler, counterClass) &&Type.getClass(doubler) ==next.resolveClass("Doubler")}');
91
-
92
-
// Stayed
101
+
untyped__cpp__("runJoined({0})", useMoved);
93
102
untyped__cpp__("runJoined({0})", useOld);
94
-
Sys.println('jit $jit: the reshaped instance keeps its class: $staysOld');
95
-
Sys.println('jit $jit: the bound method keeps the old code: $keepsOld');
96
-
Sys.println('jit $jit: the old module keeps only what stayed: ${retained()}');
97
-
98
-
bound=null;
99
-
reshaped=null;
100
-
untyped__cpp__("runJoined({0})", () -> {});
101
-
Sys.println('jit $jit: and is freed once they go: "${retained()}"');
102
-
103
-
counter=doubler=null;
104
-
untypednext.release();
105
-
next=null;
103
+
lines.push('the old module keeps only what stayed: ${retained()}');
104
+
untyped__cpp__("runJoined({0})", dropOld);
105
+
lines.push('and is freed once they go: "${retained()}"');
0 commit comments