From e5be9ac2e2f22545ae02db43e9f94dd7d3dbceef Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 7 Apr 2023 08:12:10 -0700 Subject: [Wasm GC] Fix GUFA on ArrayInit (#5638) --- src/ir/possible-contents.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/ir/possible-contents.cpp') diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 8ed2118fe..b2a0b417a 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -618,6 +618,7 @@ struct InfoCollector addRoot(curr); } void visitTableGet(TableGet* curr) { + // TODO: be more precise addRoot(curr); } void visitTableSet(TableSet* curr) {} @@ -992,6 +993,7 @@ struct InfoCollector if (curr->type == Type::unreachable) { return; } + // See ArrayCopy, above. Builder builder(*getModule()); auto* set = builder.makeArraySet(curr->ref, curr->index, curr->value); visitArraySet(set); @@ -1000,9 +1002,18 @@ struct InfoCollector if (curr->type == Type::unreachable) { return; } - // TODO: Modeling the write to the array can be similar to the above, but - // how should the read from the segment be modeled? - WASM_UNREACHABLE("unimplemented"); + // See ArrayCopy, above. Here an additional complexity is that we need to + // model the read from the segment. As in TableGet, for now we just assume + // any value is possible there (a root in the graph), which we set up + // manually here as a fake unknown value, using a fake local.get that we + // root. + // TODO: be more precise about what is in the table + auto valueType = curr->ref->type.getHeapType().getArray().element.type; + Builder builder(*getModule()); + auto* get = builder.makeLocalGet(-1, valueType); + addRoot(get); + auto* set = builder.makeArraySet(curr->ref, curr->index, get); + visitArraySet(set); } void visitStringNew(StringNew* curr) { if (curr->type == Type::unreachable) { -- cgit v1.2.3