Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/tools/wasm-ctor-eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ class EvallingModuleRunner : public ModuleRunnerBase<EvallingModuleRunner> {
throw FailToEvalException("TODO: table.get");
}

Flow visitTableSet(TableSet* curr) {
// When changes occur to the table, give up.
throw FailToEvalException("TODO: table.set");
}

Flow visitTableGrow(TableGrow* curr) {
// When changes occur to the table, give up.
throw FailToEvalException("TODO: table.grow");
}

bool allowContNew = true;

Flow visitContNew(ContNew* curr) {
Expand Down
102 changes: 102 additions & 0 deletions test/lit/ctor-eval/start-table.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --quiet -all -S -o - | filecheck %s

;; The table.set in the start alters what is called indirectly later. We do not
;; handle this yet, but at least do not misoptimize. TODO
(module
;; CHECK: (type $func (func))
(type $func (func))

;; CHECK: (table $t 48 48 funcref)
(table $t 48 48 funcref)

;; CHECK: (elem $e (i32.const 0) $target)
(elem $e (i32.const 0) $target)

;; CHECK: (export "test" (func $test))

;; CHECK: (start $start)
(start $start)

;; CHECK: (func $start (type $func)
;; CHECK-NEXT: (table.set $t
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (ref.null nofunc)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $start
(table.set $t
(i32.const 0)
(ref.null nofunc)
)
)

;; CHECK: (func $test (type $func)
;; CHECK-NEXT: (call_indirect $t (type $func)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test (export "test")
(call_indirect (type $func)
(i32.const 0)
)
)

;; CHECK: (func $target (type $func)
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
(func $target
)
)

;; Similar, but with grow. We also do not optimize TODO
(module
;; CHECK: (type $func (func))
(type $func (func))

;; CHECK: (table $t 48 48 funcref)
(table $t 48 48 funcref)

;; CHECK: (elem $e (i32.const 0) $target)
(elem $e (i32.const 0) $target)

;; CHECK: (export "test" (func $test))

;; CHECK: (start $start)
(start $start)

;; CHECK: (func $start (type $func)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (table.grow $t
;; CHECK-NEXT: (ref.null nofunc)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $start
(drop
(table.grow $t
(ref.null nofunc)
(i32.const 0)
)
)
)

;; CHECK: (func $test (type $func)
;; CHECK-NEXT: (call_indirect $t (type $func)
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test (export "test")
(call_indirect (type $func)
(i32.const 0)
)
)

;; CHECK: (func $target (type $func)
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
(func $target
)
)

Loading