From 675295888609a688ee81dc9ad2024169da5aa7ed Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 23 Sep 2021 12:36:17 -0700 Subject: [Wasm GC] Implement static (rtt-free) StructNew, ArrayNew, ArrayInit (#4172) See #4149 This modifies the test added in #4163 which used static casts on dynamically-created structs and arrays. That was technically not valid (as we won't want users to "mix" the two forms). This makes that test 100% static, which both fixes the test and gives test coverage to the new instructions added here. --- src/passes/Print.cpp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/passes/Print.cpp') diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 6198218d8..6a41961a2 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1985,15 +1985,18 @@ struct PrintExpressionContents } void visitStructNew(StructNew* curr) { - if (printUnreachableReplacement(curr->rtt)) { + if (printUnreachableReplacement(curr)) { return; } - printMedium(o, "struct.new_"); + printMedium(o, "struct.new"); if (curr->isWithDefault()) { - o << "default_"; + printMedium(o, "_default"); } - o << "with_rtt "; - TypeNamePrinter(o, wasm).print(curr->rtt->type.getHeapType()); + if (curr->rtt) { + printMedium(o, "_with_rtt"); + } + o << ' '; + TypeNamePrinter(o, wasm).print(curr->type.getHeapType()); } void printFieldName(HeapType type, Index index) { @@ -2035,16 +2038,29 @@ struct PrintExpressionContents printFieldName(heapType, curr->index); } void visitArrayNew(ArrayNew* curr) { - printMedium(o, "array.new_"); + if (printUnreachableReplacement(curr)) { + return; + } + printMedium(o, "array.new"); if (curr->isWithDefault()) { - o << "default_"; + printMedium(o, "_default"); + } + if (curr->rtt) { + printMedium(o, "_with_rtt"); } - o << "with_rtt "; - TypeNamePrinter(o, wasm).print(curr->rtt->type.getHeapType()); + o << ' '; + TypeNamePrinter(o, wasm).print(curr->type.getHeapType()); } void visitArrayInit(ArrayInit* curr) { - printMedium(o, "array.init "); - TypeNamePrinter(o, wasm).print(curr->rtt->type.getHeapType()); + if (printUnreachableReplacement(curr)) { + return; + } + printMedium(o, "array.init"); + if (!curr->rtt) { + printMedium(o, "_static"); + } + o << ' '; + TypeNamePrinter(o, wasm).print(curr->type.getHeapType()); } void visitArrayGet(ArrayGet* curr) { if (printUnreachableReplacement(curr->ref)) { -- cgit v1.2.3