summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-12-09 11:17:28 -0800
committerGitHub <noreply@github.com>2020-12-09 11:17:28 -0800
commit823222ff566b38495327bc28b4726871b0a86b26 (patch)
treed0425f0c40d61e9085bc3a9880faa08eafd70276 /src/passes/Print.cpp
parent63a042e3a94df7ba3a5c9dde03990a9813fdc366 (diff)
downloadbinaryen-823222ff566b38495327bc28b4726871b0a86b26.tar.gz
binaryen-823222ff566b38495327bc28b4726871b0a86b26.tar.bz2
binaryen-823222ff566b38495327bc28b4726871b0a86b26.zip
[GC] Add struct.new and start to test interesting execution (#3433)
With struct.new read/write support, we can start to do interesting things! This adds a test of creating a struct and seeing that references behave like references, that is, if we write to the value X refers to, and if Y refers to the same thing, when reading from Y's value we see the change as well. The test is run through all of -O1, which uncovered a minor issue in Precompute: We can't try to precompute a reference type, as we can't replace a reference with a value. Note btw that the test shows the optimizer properly running CoalesceLocals on reference types, merging two locals.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 2edd069d9..5c2acf3f0 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1702,7 +1702,12 @@ struct PrintExpressionContents
printHeapTypeName(o, curr->type.getRtt().heapType);
}
void visitStructNew(StructNew* curr) {
- WASM_UNREACHABLE("TODO (gc): struct.new");
+ printMedium(o, "struct.new_");
+ if (curr->isWithDefault()) {
+ o << "default_";
+ }
+ o << "with_rtt ";
+ printHeapTypeName(o, curr->rtt->type.getRtt().heapType);
}
void visitStructGet(StructGet* curr) {
const auto& field =
@@ -2391,7 +2396,12 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
void visitStructNew(StructNew* curr) {
o << '(';
PrintExpressionContents(currFunction, o).visit(curr);
- WASM_UNREACHABLE("TODO (gc): struct.new");
+ incIndent();
+ printFullLine(curr->rtt);
+ for (auto& operand : curr->operands) {
+ printFullLine(operand);
+ }
+ decIndent();
}
void visitStructGet(StructGet* curr) {
o << '(';