| ;; 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=ok,trap,s --kept-exports=s,trap --quiet -all -S -o - | filecheck %s |
| |
| ;; Similar to start-rerun.wast, but rather than $s executing twice, the second |
| ;; time fails to eval, so only the usage in the start function ends up baked in. |
| ;; Specifically, the start function evals fine, as does $ok, but $trap stops us |
| ;; before we get to $s. The start function's increment of the global will leave |
| ;; it as 1, and $ok adds 1000, so it ends up at 1001 but not 1002. |
| |
| (module |
| (rec |
| ;; CHECK: (rec |
| ;; CHECK-NEXT: (type $A (sub (shared (struct (field (mut (ref null $B))))))) |
| (type $A (sub (shared (struct (field (mut (ref null $B))))))) |
| ;; CHECK: (type $B (sub (shared (struct (field (mut (ref null (shared any)))))))) |
| (type $B (sub (shared (struct (field (mut (ref null (shared any)))))))) |
| ) |
| |
| (global $global (ref $A) (struct.new $A |
| (struct.new_default $B) |
| )) |
| |
| ;; A counter to show how $s executes twice (each time adding 1), and $t once |
| ;; (adding 1000). |
| ;; CHECK: (type $2 (func)) |
| |
| ;; CHECK: (global $ctor-eval$global (ref (exact $A)) (struct.new $A |
| ;; CHECK-NEXT: (ref.null (shared none)) |
| ;; CHECK-NEXT: )) |
| |
| ;; CHECK: (global $ctor-eval$global_3 (ref (exact $B)) (struct.new $B |
| ;; CHECK-NEXT: (ref.null (shared none)) |
| ;; CHECK-NEXT: )) |
| |
| ;; CHECK: (global $counter (mut i32) (i32.const 1001)) |
| (global $counter (mut i32) (i32.const 0)) |
| |
| ;; CHECK: (export "s" (func $s)) |
| (export "s" (func $s)) |
| |
| (export "ok" (func $ok)) |
| |
| ;; CHECK: (export "trap" (func $trap)) |
| (export "trap" (func $trap)) |
| |
| (start $s) |
| |
| ;; CHECK: (start $start) |
| |
| ;; CHECK: (func $s (type $2) |
| ;; CHECK-NEXT: (global.set $counter |
| ;; CHECK-NEXT: (i32.add |
| ;; CHECK-NEXT: (global.get $counter) |
| ;; CHECK-NEXT: (i32.const 1) |
| ;; CHECK-NEXT: ) |
| ;; CHECK-NEXT: ) |
| ;; CHECK-NEXT: ) |
| (func $s |
| (global.set $counter |
| (i32.add |
| (global.get $counter) |
| (i32.const 1) |
| ) |
| ) |
| ) |
| |
| (func $ok |
| (global.set $counter |
| (i32.add |
| (global.get $counter) |
| (i32.const 1000) |
| ) |
| ) |
| ) |
| |
| ;; CHECK: (func $trap (type $2) |
| ;; CHECK-NEXT: (unreachable) |
| ;; CHECK-NEXT: ) |
| (func $trap |
| (unreachable) |
| ) |
| ) |
| |
| ;; CHECK: (func $start (type $2) |
| ;; CHECK-NEXT: (struct.set $A 0 |
| ;; CHECK-NEXT: (global.get $ctor-eval$global) |
| ;; CHECK-NEXT: (global.get $ctor-eval$global_3) |
| ;; CHECK-NEXT: ) |
| ;; CHECK-NEXT: ) |