@@ -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
@@ -104,15 +104,6 @@ let is_jumping e =
104
104
105
105
let compose (vs1 , es1 ) (vs2 , es2 ) = vs1 @ vs2, es1 @ es2
106
106
107
- let switcher_contref_arity contarg =
108
- match contarg with
109
- | RefT (_ , DefHT def ) ->
110
- (match as_cont_str_type (expand_def_type def) with
111
- | ContT (DefHT def ) ->
112
- let FuncT (ts, _) = as_func_str_type (expand_def_type def) in
113
- Lib.List32. length ts
114
- | _ -> assert false )
115
- | _ -> assert false
116
107
117
108
(* Configurations *)
118
109
@@ -422,14 +413,12 @@ let rec step (c : config) : config =
422
413
423
414
| Switch (x , y ), Ref (ContRef ({contents = Some (n , ctxt )} as cont )) :: vs ->
424
415
let FuncT (ts, _) = func_type_of_cont_type c.frame.inst (cont_type c.frame.inst x) in
425
- let arity = switcher_contref_arity (Lib.List. last ts) in
416
+ let FuncT (ts', _) = as_cont_func_ref_type (Lib.List. last ts) in
417
+ let arity = Lib.List32. length ts' in
426
418
let tagt = tag c.frame.inst y in
427
419
let args, vs' = i32_split (Int32. sub n 1l ) vs e.at in
428
- (* NOTE(dhil): Slight hack here. We update the arity of given
429
- contref to be the arity of the current continuation
430
- generated by the handler for switch. *)
431
420
cont := Some (arity, ctxt);
432
- vs', [Suspending (tagt, args, Some (ContRef cont), fun code -> code) @@ e.at]
421
+ vs', [Suspending (tagt, args, Some (arity, ContRef cont), fun code -> code) @@ e.at]
433
422
434
423
| ReturnCall x , vs ->
435
424
(match (step {c with code = (vs, [Plain (Call x) @@ e.at])}).code with
@@ -1277,10 +1266,10 @@ let rec step (c : config) : config =
1277
1266
[Ref (ContRef (ref (Some (Lib.List32. length ts, ctxt'))))] @ vs1 @ vs,
1278
1267
[Plain (Br (List. assq tagt hs)) @@ e.at]
1279
1268
1280
- | Handle ((_, hs) as hso, (vs', {it = Suspending (tagt, vs1, Some (ContRef ({contents = Some (n , ctxt)} as cont)), ctxt'); at} :: es')), vs
1269
+ | Handle ((_, hs) as hso, (vs', {it = Suspending (tagt, vs1, Some (ar, ContRef ({contents = Some (_ , ctxt)} as cont)), ctxt'); at} :: es')), vs
1281
1270
when List. memq tagt hs ->
1282
1271
let ctxt'' code = compose (ctxt' code) (vs', es') in
1283
- let cont' = Ref (ContRef (ref (Some (n , ctxt'')))) in
1272
+ let cont' = Ref (ContRef (ref (Some (ar , ctxt'')))) in
1284
1273
let args = cont' :: vs1 in
1285
1274
cont := None ;
1286
1275
vs' @ vs, [Handle (hso, ctxt (args, [] )) @@ e.at]
0 commit comments