diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ctor-eval/gc.wast.out | 8 | ||||
-rw-r--r-- | test/lit/ctor-eval/ctor_after_serialization.wat | 78 |
2 files changed, 82 insertions, 4 deletions
diff --git a/test/ctor-eval/gc.wast.out b/test/ctor-eval/gc.wast.out index 6ca1f50d9..4a30752e0 100644 --- a/test/ctor-eval/gc.wast.out +++ b/test/ctor-eval/gc.wast.out @@ -7,11 +7,11 @@ (global $global1 (ref $struct) (struct.new $struct (i32.const 1337) )) - (global $ctor-eval$global (ref $struct) (struct.new $struct + (global $ctor-eval$global_1 (ref $struct) (struct.new $struct (i32.const 42) )) - (global $global2 (mut (ref null $struct)) (global.get $ctor-eval$global)) - (global $ctor-eval$global_0 (ref $struct) (struct.new $struct + (global $global2 (mut (ref null $struct)) (global.get $ctor-eval$global_1)) + (global $ctor-eval$global_2 (ref $struct) (struct.new $struct (i32.const 99) )) (export "test1" (func $0_0)) @@ -29,7 +29,7 @@ (func $0_0 (type $none_=>_none) (local $0 (ref $struct)) (local.set $0 - (global.get $ctor-eval$global_0) + (global.get $ctor-eval$global_2) ) (call $import (ref.null none) diff --git a/test/lit/ctor-eval/ctor_after_serialization.wat b/test/lit/ctor-eval/ctor_after_serialization.wat new file mode 100644 index 000000000..7a4871398 --- /dev/null +++ b/test/lit/ctor-eval/ctor_after_serialization.wat @@ -0,0 +1,78 @@ +;; 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=new,nop --kept-exports=new,nop --quiet -all -S -o - | filecheck %s + +;; We can eval $new, and afterwards also eval $nop as well. When doing the +;; latter we should not undo or break the previous work in any way. In +;; particular, we should have a valid global for $new to refer to (which +;; contains the serialization of the struct.new instruction). + +(module + ;; CHECK: (type $A (struct )) + (type $A (struct)) + + ;; CHECK: (type $none_=>_ref|any| (func (result (ref any)))) + + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (global $ctor-eval$global (ref $A) (struct.new_default $A)) + + ;; CHECK: (export "new" (func $new_0)) + (export "new" (func $new)) + ;; CHECK: (export "nop" (func $nop_0)) + (export "nop" (func $nop)) + + (func $new (result (ref any)) + (struct.new $A) + ) + + (func $nop + (nop) + ) +) + +;; CHECK: (func $new_0 (type $none_=>_ref|any|) (result (ref any)) +;; CHECK-NEXT: (global.get $ctor-eval$global) +;; CHECK-NEXT: ) + +;; CHECK: (func $nop_0 (type $none_=>_none) +;; CHECK-NEXT: (nop) +;; CHECK-NEXT: ) +(module + ;; As above, but now there is an existing global with the name that we want to + ;; use. We should not collide. + + ;; CHECK: (type $A (struct )) + (type $A (struct)) + + ;; CHECK: (type $none_=>_ref|any| (func (result (ref any)))) + + ;; CHECK: (type $none_=>_anyref (func (result anyref))) + + ;; CHECK: (global $ctor-eval$global (ref $A) (struct.new_default $A)) + (global $ctor-eval$global (ref $A) + (struct.new_default $A) + ) + + ;; CHECK: (global $ctor-eval$global_0 (ref $A) (struct.new_default $A)) + + ;; CHECK: (export "new" (func $new_0)) + (export "new" (func $new)) + ;; CHECK: (export "nop" (func $nop_0)) + (export "nop" (func $nop)) + + (func $new (result (ref any)) + (struct.new $A) + ) + + (func $nop (result anyref) + ;; Use the existing global to keep it alive. + (global.get $ctor-eval$global) + ) +) +;; CHECK: (func $new_0 (type $none_=>_ref|any|) (result (ref any)) +;; CHECK-NEXT: (global.get $ctor-eval$global_0) +;; CHECK-NEXT: ) + +;; CHECK: (func $nop_0 (type $none_=>_anyref) (result anyref) +;; CHECK-NEXT: (global.get $ctor-eval$global) +;; CHECK-NEXT: ) |