Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

[interpreter/test] Update table.init semantics as well #120

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions interpreter/exec/eval.ml
Original file line number Diff line number Diff line change
@@ -202,12 +202,18 @@ let rec step (c : config) : config =
with Global.NotMutable -> Crash.error e.at "write to immutable global"
| Global.Type -> Crash.error e.at "type mismatch at global write")

| TableCopy, I32 0l :: I32 s :: I32 d :: vs' ->
vs', []

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

| TableInit x, I32 0l :: I32 s :: I32 d :: vs' ->
vs', []

(* TODO: turn into small-step, but needs reference values *)
| TableInit x, I32 n :: I32 s :: I32 d :: vs' ->
let tab = table frame.inst (0l @@ e.at) in
18 changes: 11 additions & 7 deletions test/core/bulk.wast
Original file line number Diff line number Diff line change
@@ -220,20 +220,24 @@
(elem $a (table 0) (i32.const 0) func $f)

(func (export "drop_passive") (elem.drop $p))
(func (export "init_passive")
(table.init $p (i32.const 0) (i32.const 0) (i32.const 0)))
(func (export "init_passive") (param $len i32)
(table.init $p (i32.const 0) (i32.const 0) (local.get $len))
)

(func (export "drop_active") (elem.drop $a))
(func (export "init_active")
(table.init $a (i32.const 0) (i32.const 0) (i32.const 0)))
(func (export "init_active") (param $len i32)
(table.init $a (i32.const 0) (i32.const 0) (local.get $len))
)
)

(invoke "init_passive")
(invoke "init_passive" (i32.const 1))
(invoke "drop_passive")
(assert_trap (invoke "drop_passive") "element segment dropped")
(assert_trap (invoke "init_passive") "element segment dropped")
(assert_return (invoke "init_passive" (i32.const 0)))
(assert_trap (invoke "init_passive" (i32.const 1)) "element segment dropped")
(assert_trap (invoke "drop_active") "element segment dropped")
(assert_trap (invoke "init_active") "element segment dropped")
(assert_return (invoke "init_active" (i32.const 0)))
(assert_trap (invoke "init_active" (i32.const 1)) "element segment dropped")


;; table.copy