Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 9aef0c5

Browse files
authoredOct 7, 2019
[interpreter/test] Update table.init semantics as well (#120)
1 parent 4f9ae30 commit 9aef0c5

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed
 

‎interpreter/exec/eval.ml

+6
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,18 @@ let rec step (c : config) : config =
202202
with Global.NotMutable -> Crash.error e.at "write to immutable global"
203203
| Global.Type -> Crash.error e.at "type mismatch at global write")
204204

205+
| TableCopy, I32 0l :: I32 s :: I32 d :: vs' ->
206+
vs', []
207+
205208
(* TODO: turn into small-step, but needs reference values *)
206209
| TableCopy, I32 n :: I32 s :: I32 d :: vs' ->
207210
let tab = table frame.inst (0l @@ e.at) in
208211
(try Table.copy tab d s n; vs', []
209212
with exn -> vs', [Trapping (table_error e.at exn) @@ e.at])
210213

214+
| TableInit x, I32 0l :: I32 s :: I32 d :: vs' ->
215+
vs', []
216+
211217
(* TODO: turn into small-step, but needs reference values *)
212218
| TableInit x, I32 n :: I32 s :: I32 d :: vs' ->
213219
let tab = table frame.inst (0l @@ e.at) in

‎test/core/bulk.wast

+11-7
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,24 @@
220220
(elem $a (table 0) (i32.const 0) func $f)
221221

222222
(func (export "drop_passive") (elem.drop $p))
223-
(func (export "init_passive")
224-
(table.init $p (i32.const 0) (i32.const 0) (i32.const 0)))
223+
(func (export "init_passive") (param $len i32)
224+
(table.init $p (i32.const 0) (i32.const 0) (local.get $len))
225+
)
225226

226227
(func (export "drop_active") (elem.drop $a))
227-
(func (export "init_active")
228-
(table.init $a (i32.const 0) (i32.const 0) (i32.const 0)))
228+
(func (export "init_active") (param $len i32)
229+
(table.init $a (i32.const 0) (i32.const 0) (local.get $len))
230+
)
229231
)
230232

231-
(invoke "init_passive")
233+
(invoke "init_passive" (i32.const 1))
232234
(invoke "drop_passive")
233235
(assert_trap (invoke "drop_passive") "element segment dropped")
234-
(assert_trap (invoke "init_passive") "element segment dropped")
236+
(assert_return (invoke "init_passive" (i32.const 0)))
237+
(assert_trap (invoke "init_passive" (i32.const 1)) "element segment dropped")
235238
(assert_trap (invoke "drop_active") "element segment dropped")
236-
(assert_trap (invoke "init_active") "element segment dropped")
239+
(assert_return (invoke "init_active" (i32.const 0)))
240+
(assert_trap (invoke "init_active" (i32.const 1)) "element segment dropped")
237241

238242

239243
;; table.copy

0 commit comments

Comments
 (0)