@@ -104,7 +104,6 @@ hi(0)
104
104
//│ contLoop: while (true) {
105
105
//│ if (this.pc === 4) {
106
106
//│ res2 = res3;
107
- //│ globalThis.Predef.__stackOffset = curOffset;
108
107
//│ return res2;
109
108
//│ }
110
109
//│ break;
@@ -121,7 +120,6 @@ hi(0)
121
120
//│ return res3;
122
121
//│ }
123
122
//│ res2 = res3;
124
- //│ globalThis.Predef.__stackOffset = curOffset;
125
123
//│ return res2;
126
124
//│ });
127
125
//│ }
@@ -179,7 +177,7 @@ sum(10000)
179
177
//│ JS (unsanitized):
180
178
//│ let sum3, res1, handleBlock$3;
181
179
//│ sum3 = function sum(n) {
182
- //│ let scrut, tmp, tmp1, tmp2, prevDepth, diff, diffGeqLimit, handlerExists, scrut1, dummy, res2, res3, Cont$;
180
+ //│ let scrut, tmp, tmp1, tmp2, offsetGtDepth, prevDepth, diff, diffGeqLimit, handlerExists, scrut1, dummy, res2, res3, Cont$;
183
181
//│ Cont$ = function Cont$(pc1) { return new Cont$.class(pc1); };
184
182
//│ Cont$.class = class Cont$ extends globalThis.Predef.__Cont.class {
185
183
//│ constructor(pc) {
@@ -194,7 +192,7 @@ sum(10000)
194
192
//│ res2 = value$;
195
193
//│ }
196
194
//│ contLoop: while (true) {
197
- //│ if (this.pc === 3 ) {
195
+ //│ if (this.pc === 4 ) {
198
196
//│ scrut = n == 0;
199
197
//│ if (scrut === true) {
200
198
//│ return 0;
@@ -217,11 +215,20 @@ sum(10000)
217
215
//│ } else if (this.pc === 1) {
218
216
//│ tmp2 = res3;
219
217
//│ globalThis.Predef.__stackDepth = prevDepth;
218
+ //│ offsetGtDepth = prevDepth < globalThis.Predef.__stackOffset;
219
+ //│ if (offsetGtDepth === true) {
220
+ //│ globalThis.Predef.__stackOffset = prevDepth;
221
+ //│ this.pc = 3;
222
+ //│ continue contLoop;
223
+ //│ }
224
+ //│ this.pc = 3;
225
+ //│ continue contLoop;
226
+ //│ } else if (this.pc === 3) {
220
227
//│ tmp1 = tmp2;
221
228
//│ return n + tmp1;
222
229
//│ } else if (this.pc === 0) {
223
230
//│ dummy = res2;
224
- //│ this.pc = 3 ;
231
+ //│ this.pc = 4 ;
225
232
//│ continue contLoop;
226
233
//│ }
227
234
//│ break;
@@ -257,6 +264,10 @@ sum(10000)
257
264
//│ }
258
265
//│ tmp2 = res3;
259
266
//│ globalThis.Predef.__stackDepth = prevDepth;
267
+ //│ offsetGtDepth = prevDepth < globalThis.Predef.__stackOffset;
268
+ //│ if (offsetGtDepth === true) {
269
+ //│ globalThis.Predef.__stackOffset = prevDepth;
270
+ //│ }
260
271
//│ tmp1 = tmp2;
261
272
//│ return n + tmp1;
262
273
//│ }
@@ -279,13 +290,12 @@ sum(10000)
279
290
//│ this.pc = pc;
280
291
//│ }
281
292
//│ resume(value$) {
282
- //│ if (this.pc === 5 ) {
293
+ //│ if (this.pc === 6 ) {
283
294
//│ res4 = value$;
284
295
//│ }
285
296
//│ contLoop: while (true) {
286
- //│ if (this.pc === 5 ) {
297
+ //│ if (this.pc === 6 ) {
287
298
//│ res3 = res4;
288
- //│ globalThis.Predef.__stackOffset = curOffset;
289
299
//│ return res3;
290
300
//│ }
291
301
//│ break;
@@ -297,12 +307,11 @@ sum(10000)
297
307
//│ globalThis.Predef.__stackOffset = globalThis.Predef.__stackDepth;
298
308
//│ res4 = resume();
299
309
//│ if (res4 instanceof globalThis.Predef.__EffectSig.class) {
300
- //│ res4.tail.next = new Cont$1.class(5 );
310
+ //│ res4.tail.next = new Cont$1.class(6 );
301
311
//│ res4.tail = res4.tail.next;
302
312
//│ return res4;
303
313
//│ }
304
314
//│ res3 = res4;
305
- //│ globalThis.Predef.__stackOffset = curOffset;
306
315
//│ return res3;
307
316
//│ });
308
317
//│ }
@@ -317,11 +326,11 @@ sum(10000)
317
326
//│ this.pc = pc;
318
327
//│ }
319
328
//│ resume(value$) {
320
- //│ if (this.pc === 4 ) {
329
+ //│ if (this.pc === 5 ) {
321
330
//│ res2 = value$;
322
331
//│ }
323
332
//│ contLoop: while (true) {
324
- //│ if (this.pc === 4 ) {
333
+ //│ if (this.pc === 5 ) {
325
334
//│ return res2;
326
335
//│ }
327
336
//│ break;
@@ -334,7 +343,7 @@ sum(10000)
334
343
//│ globalThis.Predef.__stackHandler = stackHandler;
335
344
//│ res2 = sum3(10000);
336
345
//│ if (res2 instanceof globalThis.Predef.__EffectSig.class) {
337
- //│ res2.tail.next = new Cont$(4 );
346
+ //│ res2.tail.next = new Cont$(5 );
338
347
//│ return globalThis.Predef.__handleBlockImpl(res2, stackHandler);
339
348
//│ }
340
349
//│ return res2;
@@ -475,7 +484,6 @@ hi(0)
475
484
//│ ═══[RUNTIME ERROR] Error: This code requires effect handler instrumentation but was compiled without it.
476
485
477
486
478
- :fixme
479
487
:stackSafe 1000
480
488
:handler
481
489
:expect 100010000
@@ -485,4 +493,4 @@ fun sum(n) =
485
493
n + sum(n - 1)
486
494
fun bad() = sum(10000) + sum(10000)
487
495
bad()
488
- //│ ═══[RUNTIME ERROR] RangeError: Maximum call stack size exceeded
496
+ //│ = 100010000
0 commit comments