@@ -73,7 +73,7 @@ and admin_instr' =
73
73
| Frame of int * frame * code
74
74
| Handler of int * catch list * code
75
75
| Handle of handle_table * code
76
- | Suspending of tag_inst * value stack * ref_ option * ctxt
76
+ | Suspending of tag_inst * value stack * ( int32 * ref_) option * ctxt
77
77
78
78
and ctxt = code -> code
79
79
and handle_table = (tag_inst * idx) list * tag_inst list
@@ -413,10 +413,13 @@ let rec step (c : config) : config =
413
413
| Switch (x , y ), Ref (ContRef {contents = None } ) :: vs ->
414
414
vs, [Trapping " continuation already consumed" @@ e.at]
415
415
416
- | Switch (x , y ), Ref (ContRef {contents = Some (n , ctxt )} as cont ) :: vs ->
416
+ | Switch (x , y ), Ref (ContRef ({contents = Some (n , ctxt )} as cont )) :: vs ->
417
+ let FuncT (ts, _) = func_type_of_cont_type c.frame.inst (cont_type c.frame.inst x) in
418
+ let FuncT (ts', _) = as_cont_func_ref_type (Lib.List. last ts) in
419
+ let arity = Lib.List32. length ts' in
417
420
let tagt = tag c.frame.inst y in
418
421
let args, vs' = i32_split (Int32. sub n 1l ) vs e.at in
419
- vs', [Suspending (tagt, args, Some cont, fun code -> code) @@ e.at]
422
+ vs', [Suspending (tagt, args, Some (arity, ContRef cont) , fun code -> code) @@ e.at]
420
423
421
424
| ReturnCall x , vs ->
422
425
(match (step {c with code = (vs, [Plain (Call x) @@ e.at])}).code with
@@ -1292,11 +1295,10 @@ let rec step (c : config) : config =
1292
1295
[Ref (ContRef (ref (Some (Lib.List32. length ts, ctxt'))))] @ vs1 @ vs,
1293
1296
[Plain (Br (List. assq tagt hs)) @@ e.at]
1294
1297
1295
- | Handle ((_, hs) as hso, (vs', {it = Suspending (tagt, vs1, Some (ContRef ({contents = Some (_, ctxt)} as cont)), ctxt'); at} :: es')), vs
1298
+ | Handle ((_, hs) as hso, (vs', {it = Suspending (tagt, vs1, Some (ar, ContRef ({contents = Some (_, ctxt)} as cont)), ctxt'); at} :: es')), vs
1296
1299
when List. memq tagt hs ->
1297
- let FuncT (_, ts) = func_type_of_tag_type c.frame.inst (Tag. type_of tagt) in
1298
1300
let ctxt'' code = compose (ctxt' code) (vs', es') in
1299
- let cont' = Ref (ContRef (ref (Some (Int32. add ( Lib.List32. length ts) 1l , ctxt'')))) in
1301
+ let cont' = Ref (ContRef (ref (Some (ar , ctxt'')))) in
1300
1302
let args = cont' :: vs1 in
1301
1303
cont := None ;
1302
1304
vs' @ vs, [Handle (hso, ctxt (args, [] )) @@ e.at]
0 commit comments