@@ -64,9 +64,8 @@ and admin_instr' =
64
64
| Plain of instr'
65
65
| Refer of ref_
66
66
| Invoke of func_inst
67
- | Label of int * instr list * code
68
- | Frame of int * frame * code
69
- | Local of int32 * value list * code
67
+ | Label of int32 * instr list * code
68
+ | Frame of int32 * frame * code
70
69
| Handle of (tag_inst * idx) list option * code
71
70
| Trapping of string
72
71
| Throwing of tag_inst * value stack
@@ -88,7 +87,7 @@ type ref_ += ContRef of cont option ref
88
87
let () =
89
88
let type_of_ref' = ! Value. type_of_ref' in
90
89
Value. type_of_ref' := function
91
- | ContRef _ -> BotHeapType (* TODO *)
90
+ | ContRef _ -> BotHT (* TODO *)
92
91
| r -> type_of_ref' r
93
92
94
93
let () =
@@ -199,22 +198,22 @@ let rec step (c : config) : config =
199
198
match e.it, vs with
200
199
| Plain e' , vs ->
201
200
(match e', vs with
202
- | Unreachable , vs ->
201
+ | Unreachable , vs ->
203
202
vs, [Trapping " unreachable executed" @@ e.at]
204
203
205
204
| Nop , vs ->
206
205
vs, []
207
206
208
207
| Block (bt , es' ), vs ->
209
208
let InstrT (ts1, ts2, _xs) = block_type c.frame.inst bt e.at in
210
- let n1 = List . length ts1 in
211
- let n2 = List . length ts2 in
209
+ let n1 = Lib.List32 . length ts1 in
210
+ let n2 = Lib.List32 . length ts2 in
212
211
let args, vs' = take n1 vs e.at, drop n1 vs e.at in
213
212
vs', [Label (n2, [] , (args, List. map plain es')) @@ e.at]
214
213
215
214
| Loop (bt , es' ), vs ->
216
215
let InstrT (ts1, ts2, _xs) = block_type c.frame.inst bt e.at in
217
- let n1 = List . length ts1 in
216
+ let n1 = Lib.List32 . length ts1 in
218
217
let args, vs' = take n1 vs e.at, drop n1 vs e.at in
219
218
vs', [Label (n1, [e' @@ e.at], (args, List. map plain es')) @@ e.at]
220
219
@@ -227,23 +226,23 @@ let rec step (c : config) : config =
227
226
| Throw x , vs ->
228
227
let tagt = tag c.frame.inst x in
229
228
let TagT x' = Tag. type_of tagt in
230
- let FuncT (ts, _) = as_func_def_type (def_of (as_sem_var x')) in
229
+ let FuncT (ts, _) = as_func_def_type (def_of (as_dyn_var x')) in
231
230
let vs0, vs' = split (Lib.List32. length ts) vs e.at in
232
231
vs', [Throwing (tagt, vs0) @@ e.at]
233
232
234
233
| Rethrow x , vs ->
235
234
vs, [Rethrowing (x.it, fun e -> e) @@ e.at]
236
235
237
236
| TryCatch (bt , es' , cts , ca ), vs ->
238
- let FuncType (ts1, ts2) = block_type c.frame.inst bt e.at in
237
+ let InstrT (ts1, ts2, _xs ) = block_type c.frame.inst bt e.at in
239
238
let n1 = Lib.List32. length ts1 in
240
239
let n2 = Lib.List32. length ts2 in
241
240
let args, vs' = take n1 vs e.at, drop n1 vs e.at in
242
241
let cts' = List. map (fun (x , es'' ) -> ((tag c.frame.inst x), es'')) cts in
243
242
vs', [Label (n2, [] , ([] , [Catch (n2, cts', ca, (args, List. map plain es')) @@ e.at])) @@ e.at]
244
243
245
244
| TryDelegate (bt , es' , x ), vs ->
246
- let FuncType (ts1, ts2) = block_type c.frame.inst bt e.at in
245
+ let InstrT (ts1, ts2, _xs ) = block_type c.frame.inst bt e.at in
247
246
let n1 = Lib.List32. length ts1 in
248
247
let n2 = Lib.List32. length ts2 in
249
248
let args, vs' = take n1 vs e.at, drop n1 vs e.at in
@@ -315,7 +314,7 @@ let rec step (c : config) : config =
315
314
vs, [Trapping " null function reference" @@ e.at]
316
315
317
316
| ContNew x , Ref (FuncRef f ) :: vs ->
318
- let FuncType (ts, _) = Func. type_of f in
317
+ let FuncT (ts, _) = Func. type_of f in
319
318
let ctxt code = compose code ([] , [Invoke f @@ e.at]) in
320
319
Ref (ContRef (ref (Some (Lib.List32. length ts, ctxt)))) :: vs, []
321
320
@@ -326,8 +325,8 @@ let rec step (c : config) : config =
326
325
vs, [Trapping " continuation already consumed" @@ e.at]
327
326
328
327
| ContBind x , Ref (ContRef ({contents = Some (n , ctxt )} as cont )) :: vs ->
329
- let ContType z = cont_type c.frame.inst x in
330
- let FuncType (ts', _) = as_func_def_type (def_of (as_sem_var z)) in
328
+ let ContT z = cont_type c.frame.inst x in
329
+ let FuncT (ts', _) = as_func_def_type (def_of (as_dyn_var z)) in
331
330
let args, vs' =
332
331
try split (Int32. sub n (Lib.List32. length ts')) vs e.at
333
332
with Failure _ -> Crash. error e.at " type mismatch at continuation bind"
@@ -339,7 +338,7 @@ let rec step (c : config) : config =
339
338
| Suspend x , vs ->
340
339
let tagt = tag c.frame.inst x in
341
340
let TagT x' = Tag. type_of tagt in
342
- let FuncT (ts, _) = as_func_def_type (def_of (as_sem_var x')) in
341
+ let FuncT (ts, _) = as_func_def_type (def_of (as_dyn_var x')) in
343
342
let args, vs' = split (Lib.List32. length ts) vs e.at in
344
343
vs', [Suspending (tagt, args, fun code -> code) @@ e.at]
345
344
@@ -364,14 +363,14 @@ let rec step (c : config) : config =
364
363
| ResumeThrow x , Ref (ContRef ({contents = Some (n , ctxt )} as cont )) :: vs ->
365
364
let tagt = tag c.frame.inst x in
366
365
let TagT x' = Tag. type_of tagt in
367
- let FuncType (ts, _) = as_func_def_type (def_of (as_sem_var x')) in
366
+ let FuncT (ts, _) = as_func_def_type (def_of (as_dyn_var x')) in
368
367
let args, vs' = split (Lib.List32. length ts) vs e.at in
369
368
let vs1', es1' = ctxt (args, [Plain (Throw x) @@ e.at]) in
370
369
cont := None ;
371
370
vs1' @ vs', es1'
372
371
373
372
| Barrier (bt , es' ), vs ->
374
- let FuncType (ts1, _) = block_type c.frame.inst bt e.at in
373
+ let InstrT (ts1, _, _xs ) = block_type c.frame.inst bt e.at in
375
374
let args, vs' = split (Lib.List32. length ts1) vs e.at in
376
375
vs', [
377
376
Handle (None ,
@@ -821,6 +820,12 @@ let rec step (c : config) : config =
821
820
| Frame (n , frame' , (vs' , [] )), vs ->
822
821
vs' @ vs, []
823
822
823
+ | Frame (n , frame' , (vs' , {it = Trapping msg ; at} :: es' )), vs ->
824
+ vs, [Trapping msg @@ at]
825
+
826
+ | Frame (n , frame' , (vs' , {it = Throwing (a , vs0 ); at} :: es' )), vs ->
827
+ vs, [Throwing (a, vs0) @@ at]
828
+
824
829
| Frame (n , frame' , (vs' , {it = Suspending (tagt , vs1 , ctxt ); at} :: es' )), vs ->
825
830
let ctxt' code = [], [Frame (n, frame', compose (ctxt code) (vs', es')) @@ e.at] in
826
831
vs, [Suspending (tagt, vs1, ctxt') @@ at]
@@ -830,7 +835,7 @@ let rec step (c : config) : config =
830
835
831
836
| Frame (n , frame' , (vs' , {it = ReturningInvoke (vs0 , f ); at} :: es' )), vs ->
832
837
let FuncT (ts1, _ts2) = Func. type_of f in
833
- take (List . length ts1) vs0 e.at @ vs, [Invoke f @@ at]
838
+ take (Lib.List32 . length ts1) vs0 e.at @ vs, [Invoke f @@ at]
834
839
835
840
| Frame (n , frame' , code' ), vs ->
836
841
let c' = step {frame = frame'; code = code'; budget = c.budget - 1 } in
@@ -895,10 +900,10 @@ let rec step (c : config) : config =
895
900
896
901
| Invoke f , vs ->
897
902
let FuncT (ts1, ts2) = Func. type_of f in
898
- let n1, n2 = List. length ts1, List . length ts2 in
903
+ let n1, n2 = Lib.List32. length ts1, Lib.List32 . length ts2 in
899
904
let args, vs' = split n1 vs e.at in
900
905
(match f with
901
- | Func. AstFunc (_ , inst' , func ) ->
906
+ | Func. AstFunc (_ , inst' , func ) ->
902
907
let {locals; body; _} = func.it in
903
908
let m = Lib.Promise. value inst' in
904
909
let ts = List. map (fun loc -> Types. dyn_val_type m.types loc.it.ltype) locals in
@@ -921,7 +926,7 @@ let rec step (c : config) : config =
921
926
| Handle (Some hs, (vs', {it = Suspending (tagt, vs1, ctxt); at} :: es')), vs
922
927
when List. mem_assq tagt hs ->
923
928
let TagT x' = Tag. type_of tagt in
924
- let FuncT (_, ts) = as_func_def_type (def_of (as_sem_var x')) in
929
+ let FuncT (_, ts) = as_func_def_type (def_of (as_dyn_var x')) in
925
930
let ctxt' code = compose (ctxt code) (vs', es') in
926
931
[Ref (ContRef (ref (Some (Lib.List32. length ts, ctxt'))))] @ vs1 @ vs,
927
932
[Plain (Br (List. assq tagt hs)) @@ e.at]
@@ -1025,7 +1030,7 @@ let create_global (inst : module_inst) (glob : global) : global_inst =
1025
1030
1026
1031
let create_tag (inst : module_inst ) (tag : tag ) : tag_inst =
1027
1032
let {tagtype} = tag.it in
1028
- Tag. alloc (Types. sem_tag_type inst.types tagtype)
1033
+ Tag. alloc (Types. dyn_tag_type inst.types tagtype)
1029
1034
1030
1035
let create_export (inst : module_inst ) (ex : export ) : export_inst =
1031
1036
let {name; edesc} = ex.it in
0 commit comments