Skip to content

Commit 812d1c7

Browse files
Ben Lernerjpolitz
authored andcommitted
eachLoop was simply broken: it did not restore the stack properly
1 parent b30c437 commit 812d1c7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/js/base/runtime.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,10 +3132,17 @@ function (Namespace, jsnums, codePoint, util, exnStackParser, loader, seedrandom
31323132
}
31333133
while(true) {
31343134
started = true;
3135-
if(i >= stop) { ++thisRuntime.GAS; return thisRuntime.nothing; }
3135+
if(i >= stop) {
3136+
++thisRuntime.GAS;
3137+
return thisRuntime.nothing;
3138+
}
31363139
var res = fun.app(i);
31373140

3138-
if (isContinuation(res)) { return res; }
3141+
if (thisRuntime.isContinuation(res)) {
3142+
res.stack[thisRuntime.EXN_STACKHEIGHT++] =
3143+
thisRuntime.makeActivationRecord("eachLoop", restart, true, [], [i, started, elD]);
3144+
return res;
3145+
}
31393146

31403147
if (--thisRuntime.RUNGAS <= 0) {
31413148
thisRuntime.EXN_STACKHEIGHT = 0;
@@ -3144,12 +3151,7 @@ function (Namespace, jsnums, codePoint, util, exnStackParser, loader, seedrandom
31443151
else { i = i + 1; }
31453152
}
31463153
}
3147-
var res = restart();
3148-
if(isContinuation(res)) {
3149-
res.stack[thisRuntime.EXN_STACKHEIGHT++] =
3150-
thisRuntime.makeActivationRecord("eachLoop", restart, true, [], [i, started]);
3151-
}
3152-
return res;
3154+
return restart();
31533155
}
31543156

31553157
var RUN_ACTIVE = false;
@@ -5090,6 +5092,7 @@ function (Namespace, jsnums, codePoint, util, exnStackParser, loader, seedrandom
50905092
});
50915093
});
50925094
instantiated.fail(function(val) { return resumer.error(val); });
5095+
return instantiated;
50935096
});
50945097
}
50955098
},

0 commit comments

Comments
 (0)