-
Notifications
You must be signed in to change notification settings - Fork 786
[RT] Add type to tables and element segments #3763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7f4bc4c
bde8f94
fb2abda
a5da3d4
eb76258
2b07dc9
8c3e93e
900b176
af98cc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2619,7 +2619,8 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { | |
if (curr->hasMax()) { | ||
o << ' ' << curr->max; | ||
} | ||
o << " funcref)"; | ||
o << ' '; | ||
printType(o, curr->type, currModule) << ')'; | ||
} | ||
void visitTable(Table* curr) { | ||
if (curr->imported()) { | ||
|
@@ -2656,9 +2657,9 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { | |
}); | ||
auto printElemType = [&]() { | ||
if (allElementsRefFunc) { | ||
TypeNamePrinter(o, currModule).print(HeapType::func); | ||
o << "func"; | ||
} else { | ||
TypeNamePrinter(o, currModule).print(Type::funcref); | ||
printType(o, curr->type, currModule); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to print the value type (e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a value type. My understanding is that the only heap type allowed here is |
||
} | ||
}; | ||
|
||
|
@@ -2671,7 +2672,6 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { | |
} | ||
|
||
if (curr->table.is()) { | ||
// TODO(reference-types): check for old-style based on the complete spec | ||
if (!allElementsRefFunc || currModule->tables.size() > 1) { | ||
// tableuse | ||
o << " (table "; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,13 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { | |
wasm.memory.initial = 1; | ||
wasm.memory.max = 2; | ||
} | ||
|
||
ModuleUtils::iterImportedTables(wasm, [&](Table* table) { | ||
if (table->module == SPECTEST && table->base == TABLE) { | ||
table->initial = 10; | ||
table->max = 20; | ||
Comment on lines
+149
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do these numbers come from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the reference interpreter! This is an old mechanism for to link a few default global when running spec tests. More recent tests have I was trying to get more spec tests to pass, so I decided to dig into the differences between
that are a validation error in Again, to be clear, these difference haven't been fully addressed in this PR, so I may remove these from this PR as well if you think that's cleaner. |
||
} | ||
}); | ||
} | ||
|
||
Literals callImport(Function* import, LiteralList& arguments) override { | ||
|
@@ -234,8 +241,13 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { | |
memory.set<std::array<uint8_t, 16>>(addr, value); | ||
} | ||
|
||
void tableStore(Name tableName, Address addr, Literal entry) override { | ||
tables[tableName][addr] = entry; | ||
void tableStore(Name tableName, Address addr, const Literal& entry) override { | ||
auto& table = tables[tableName]; | ||
if (addr >= table.size()) { | ||
trap("out of bounds table access"); | ||
} else { | ||
table.emplace(table.begin() + addr, entry); | ||
} | ||
} | ||
|
||
bool growMemory(Address /*oldSize*/, Address newSize) override { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tlively is this enough for making sure table & elem types are counted correctly everywhere, or have I missed something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!