diff options
-rw-r--r-- | src/ir/global-utils.h | 3 | ||||
-rw-r--r-- | test/heap-types.wast | 6 | ||||
-rw-r--r-- | test/heap-types.wast.from-wast | 3 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary | 3 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary.noDebugInfo | 3 |
5 files changed, 17 insertions, 1 deletions
diff --git a/src/ir/global-utils.h b/src/ir/global-utils.h index 053eb0456..0d91dcbb5 100644 --- a/src/ir/global-utils.h +++ b/src/ir/global-utils.h @@ -63,7 +63,8 @@ inline bool canInitializeGlobal(const Expression* curr) { return true; } return Properties::isSingleConstantExpression(curr) || - curr->is<GlobalGet>() || curr->is<RttCanon>() || curr->is<RttSub>(); + curr->is<GlobalGet>() || curr->is<RttCanon>() || curr->is<RttSub>() || + curr->is<StructNew>(); } } // namespace GlobalUtils diff --git a/test/heap-types.wast b/test/heap-types.wast index 0445c97d5..06ceceb3b 100644 --- a/test/heap-types.wast +++ b/test/heap-types.wast @@ -40,6 +40,12 @@ (type $nested-child-struct (struct (field (mut (ref $child))))) (type $nested-child-array (array (mut (ref $child)))) + (global $struct.new-in-global (ref $struct.A) + (struct.new_default_with_rtt $struct.A + (rtt.canon $struct.A) + ) + ) + (func $structs (param $x (ref $struct.A)) (result (ref $struct.B)) (local $tA (ref null $struct.A)) (local $tB (ref null $struct.B)) diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast index dfb8b622a..6c4b837e8 100644 --- a/test/heap-types.wast.from-wast +++ b/test/heap-types.wast.from-wast @@ -25,6 +25,9 @@ (global $rttgrandchild (rtt 2 $grandchild) (rtt.sub $grandchild (global.get $rttchild) )) + (global $struct.new-in-global (ref $struct.A) (struct.new_default_with_rtt $struct.A + (rtt.canon $struct.A) + )) (func $structs (param $x (ref $struct.A)) (result (ref $struct.B)) (local $tA (ref null $struct.A)) (local $tB (ref null $struct.B)) diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary index 314b3c29e..1e3cc9527 100644 --- a/test/heap-types.wast.fromBinary +++ b/test/heap-types.wast.fromBinary @@ -25,6 +25,9 @@ (global $rttgrandchild (rtt 2 $grandchild) (rtt.sub $grandchild (global.get $rttchild) )) + (global $struct.new-in-global (ref $struct.A) (struct.new_default_with_rtt $struct.A + (rtt.canon $struct.A) + )) (func $structs (param $x (ref $struct.A)) (result (ref $struct.B)) (local $tA (ref null $struct.A)) (local $tB (ref null $struct.B)) diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo index bb6ff9165..30bfd1064 100644 --- a/test/heap-types.wast.fromBinary.noDebugInfo +++ b/test/heap-types.wast.fromBinary.noDebugInfo @@ -25,6 +25,9 @@ (global $global$2 (rtt 2 ${i32_i64}) (rtt.sub ${i32_i64} (global.get $global$1) )) + (global $global$3 (ref ${i32_f32_f64}) (struct.new_default_with_rtt ${i32_f32_f64} + (rtt.canon ${i32_f32_f64}) + )) (func $0 (param $0 (ref ${i32_f32_f64})) (result (ref ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|})) (local $1 (ref null ${i32_f32_f64})) (local $2 (ref null ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|})) |