diff options
author | Alon Zakai <azakai@google.com> | 2024-10-18 16:14:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-18 16:14:01 -0700 |
commit | bc36c02d1a54c91d9fc4bdbffe00608929ec3169 (patch) | |
tree | f6a1276d57df68a34f0626ee7290b832ff6d6c8a /src/wasm | |
parent | 679c26faec1a714eb220033254f7147ec12b8282 (diff) | |
download | binaryen-bc36c02d1a54c91d9fc4bdbffe00608929ec3169.tar.gz binaryen-bc36c02d1a54c91d9fc4bdbffe00608929ec3169.tar.bz2 binaryen-bc36c02d1a54c91d9fc4bdbffe00608929ec3169.zip |
Remove closed world validation checks (#7019)
These were added to avoid common problems with closed world mode, but
in practice they are causing more harm than good, forcing users to work
around them. In the meantime (until #6965), remove this validation to unblock
current toolchain makers.
Fix GlobalTypeOptimization and AbstractTypeRefining on issues that this
uncovers: without this validation, it is possible to run them on more wasm
files than before, hence these were not previously detected. They are
bundled in this PR because their tests cannot validate before this PR.
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 51 |
1 files changed, 1 insertions, 50 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 0184e3284..d1ca5220c 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -63,7 +63,6 @@ struct ValidationInfo { bool validateWeb; bool validateGlobally; bool quiet; - bool closedWorld; std::atomic<bool> valid; @@ -4135,46 +4134,6 @@ static void validateFeatures(Module& module, ValidationInfo& info) { } } -static void validateClosedWorldInterface(Module& module, ValidationInfo& info) { - // Error if there are any publicly exposed heap types beyond the types of - // publicly exposed functions. Note that we must include all types in the rec - // groups that are used, as if a type if public then all types in its rec - // group are as well. - std::unordered_set<RecGroup> publicRecGroups; - ModuleUtils::iterImportedFunctions(module, [&](Function* func) { - publicRecGroups.insert(func->type.getRecGroup()); - }); - for (auto& ex : module.exports) { - if (ex->kind == ExternalKind::Function) { - publicRecGroups.insert(module.getFunction(ex->value)->type.getRecGroup()); - } - } - - std::unordered_set<HeapType> publicTypes; - for (auto& group : publicRecGroups) { - for (auto type : group) { - publicTypes.insert(type); - } - } - - // Ignorable public types are public, but we can ignore them for purposes of - // erroring here: It is always ok that they are public. - auto ignorable = getIgnorablePublicTypes(); - - for (auto type : ModuleUtils::getPublicHeapTypes(module)) { - if (!publicTypes.count(type) && !ignorable.count(type)) { - auto name = type.toString(); - if (auto it = module.typeNames.find(type); it != module.typeNames.end()) { - name = it->second.name.toString(); - } - info.fail("publicly exposed type disallowed with a closed world: $" + - name, - type, - nullptr); - } - } -} - // TODO: If we want the validator to be part of libwasm rather than libpasses, // then Using PassRunner::getPassDebug causes a circular dependence. We should // fix that, perhaps by moving some of the pass infrastructure into libsupport. @@ -4183,7 +4142,6 @@ bool WasmValidator::validate(Module& module, Flags flags) { info.validateWeb = (flags & Web) != 0; info.validateGlobally = (flags & Globally) != 0; info.quiet = (flags & Quiet) != 0; - info.closedWorld = (flags & ClosedWorld) != 0; // Parallel function validation. PassRunner runner(&module); @@ -4210,9 +4168,6 @@ bool WasmValidator::validate(Module& module, Flags flags) { validateStart(module, info); validateModuleMaps(module, info); validateFeatures(module, info); - if (info.closedWorld) { - validateClosedWorldInterface(module, info); - } } // Validate additional internal IR details when in pass-debug mode. @@ -4231,11 +4186,7 @@ bool WasmValidator::validate(Module& module, Flags flags) { } bool WasmValidator::validate(Module& module, const PassOptions& options) { - Flags flags = options.validateGlobally ? Globally : Minimal; - if (options.closedWorld) { - flags |= ClosedWorld; - } - return validate(module, flags); + return validate(module, options.validateGlobally ? Globally : Minimal); } bool WasmValidator::validate(Function* func, Module& module, Flags flags) { |