1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
;; 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))
(export "new" (func $new))
(export "nop" (func $nop))
(func $new (result (ref any))
(struct.new $A)
)
(func $nop
(nop)
)
)
;; CHECK: (type $1 (func (result (ref any))))
;; CHECK: (type $2 (func))
;; CHECK: (global $ctor-eval$global (ref $A) (struct.new_default $A))
;; CHECK: (export "new" (func $new_2))
;; CHECK: (export "nop" (func $nop_3))
;; CHECK: (func $new_2 (type $1) (result (ref any))
;; CHECK-NEXT: (global.get $ctor-eval$global)
;; CHECK-NEXT: )
;; CHECK: (func $nop_3 (type $2)
;; 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 $1 (func (result (ref any))))
;; CHECK: (type $2 (func (result anyref)))
;; CHECK: (global $ctor-eval$global (ref $A) (struct.new_default $A))
(global $ctor-eval$global (ref $A)
(struct.new_default $A)
)
(export "new" (func $new))
(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: (global $ctor-eval$global_1 (ref $A) (struct.new_default $A))
;; CHECK: (export "new" (func $new_2))
;; CHECK: (export "nop" (func $nop_3))
;; CHECK: (func $new_2 (type $1) (result (ref any))
;; CHECK-NEXT: (global.get $ctor-eval$global_1)
;; CHECK-NEXT: )
;; CHECK: (func $nop_3 (type $2) (result anyref)
;; CHECK-NEXT: (global.get $ctor-eval$global)
;; CHECK-NEXT: )
|