Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def check_expected(actual, expected, stdout=None):

UNSPLITTABLE_TESTS = [Path(x) for x in [
"spec/testsuite/instance.wast",
"spec/instance.wast"]]
"spec/instance.wast",
"spec/testsuite/tag.wast",
"spec/tag.wast"]]


def is_splittable(wast: Path):
Expand Down Expand Up @@ -377,7 +379,6 @@ def run_example_tests():
subprocess.check_call(cmd)
print('run...', output_file)
actual = subprocess.check_output([os.path.abspath(output_file)]).decode('utf-8')
os.remove(output_file)
shared.fail_if_not_identical_to_file(actual, expected)


Expand Down
1 change: 0 additions & 1 deletion scripts/test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ def get_tests(test_dir, extensions=[], recursive=False):
'id.wast', # Empty IDs should be disallowed
'instance.wast', # Requires support for table default elements
'table64.wast', # Requires validations for table size
'tag.wast', # Non-empty tag results allowed by stack switching
'local_init.wast', # Requires local validation to respect unnamed blocks
'ref_func.wast', # Requires rejecting undeclared functions references
'ref_is_null.wast', # Requires support for non-nullable reference types in tables
Expand Down
10 changes: 7 additions & 3 deletions src/ir/import-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ImportResolver {
virtual RuntimeTable* getTableOrNull(ImportNames name,
const Table& type) const = 0;

virtual Tag* getTagOrNull(ImportNames name, const Signature& type) const = 0;
virtual Tag* getTagOrNull(ImportNames name, HeapType type) const = 0;
};

// Looks up imports from the given `linkedInstances`.
Expand Down Expand Up @@ -170,14 +170,18 @@ class LinkedInstancesImportResolver : public ImportResolver {
return instance->getExportedTableOrNull(name.name);
}

Tag* getTagOrNull(ImportNames name, const Signature& type) const override {
Tag* getTagOrNull(ImportNames name, HeapType type) const override {
auto it = linkedInstances.find(name.module);
if (it == linkedInstances.end()) {
return nullptr;
}

ModuleRunnerType* instance = it->second.get();
return instance->getExportedTagOrNull(name.name);
auto* tag = instance->getExportedTagOrNull(name.name);
if (tag && tag->type != type) {
return nullptr;
}
return tag;
}

private:
Expand Down
11 changes: 9 additions & 2 deletions src/parser/contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -1533,12 +1533,19 @@ struct ParseModuleTypesCtx : TypeParserCtx<ParseModuleTypesCtx>,

Result<> addDeclareElem(Name, ElemListT&&, Index) { return Ok{}; }

Result<>
addTag(Name, const std::vector<Name>&, ImportNames*, TypeUse use, Index pos) {
Result<> addTag(Name name,
const std::vector<Name>& exports,
ImportNames* import,
TypeUse use,
Index pos) {
auto& t = wasm.tags[index];
if (!use.type.isSignature()) {
return in.err(pos, "tag type must be a signature");
}
if (use.type.getSignature().results != Type::none &&
!wasm.features.hasStackSwitching()) {
return in.err(pos, "non-empty tag result type");
}
t->type = use.type;
return Ok{};
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/execution-results.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ struct LoggingExternalInterface : public ShellExternalInterface {
class FuzzerImportResolver
: public LinkedInstancesImportResolver<ModuleRunner> {
using LinkedInstancesImportResolver::LinkedInstancesImportResolver;
Tag* getTagOrNull(ImportNames name, const Signature& type) const override {
Tag* getTagOrNull(ImportNames name, HeapType type) const override {
if (name.module == "fuzzing-support") {
if (name.name == "wasmtag") {
return &wasmTag;
Expand Down
7 changes: 2 additions & 5 deletions src/tools/wasm-ctor-eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,11 @@ class EvallingImportResolver : public ImportResolver {
throw FailToEvalException{"Imported table access."};
}

// We assume that each tag import is distinct. This is wrong if the same tag
// instantiation is imported twice with different import names.
Tag* getTagOrNull(ImportNames name,
const Signature& signature) const override {
Tag* getTagOrNull(ImportNames name, HeapType type) const override {
auto [it, inserted] = importedTags.try_emplace(name, Tag{});
if (inserted) {
auto& tag = it->second;
tag.type = HeapType(signature);
tag.type = type;
}

return &it->second;
Expand Down
3 changes: 1 addition & 2 deletions src/wasm-interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3478,8 +3478,7 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
for (auto& tag : wasm.tags) {
if (tag->imported()) {
auto importNames = tag->importNames();
auto importedTag =
importResolver->getTagOrNull(importNames, tag->type.getSignature());
auto importedTag = importResolver->getTagOrNull(importNames, tag->type);
if (!importedTag) {
externalInterface->trap((std::stringstream()
<< "Imported tag " << importNames
Expand Down
Loading