[wasm] Fix partial deserialization for lazy compilation
The function index encoded into the serialized module is already offset by num_imported_functions. For lazy compilation, however, we added the number of imported functions another time, which was incorrect. R=clemensb@chromium.org Change-Id: I56380e21e74b4d1935ebdbab6ef8cc388de49f2c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3172761 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#76965}
This commit is contained in:
parent
c437489250
commit
9380e55ec4
@ -3046,13 +3046,13 @@ void CompilationStateImpl::InitializeCompilationProgressAfterDeserialization(
|
||||
}
|
||||
compilation_progress_.assign(module->num_declared_functions,
|
||||
kProgressAfterDeserialization);
|
||||
uint32_t num_imported_functions = module->num_imported_functions;
|
||||
for (auto func_index : missing_functions) {
|
||||
if (FLAG_wasm_lazy_compilation) {
|
||||
native_module_->UseLazyStub(num_imported_functions + func_index);
|
||||
native_module_->UseLazyStub(func_index);
|
||||
}
|
||||
compilation_progress_[func_index] = SetupCompilationProgressForFunction(
|
||||
lazy_module, module, enabled_features, func_index);
|
||||
compilation_progress_[declared_function_index(module, func_index)] =
|
||||
SetupCompilationProgressForFunction(lazy_module, module,
|
||||
enabled_features, func_index);
|
||||
}
|
||||
}
|
||||
auto builder = std::make_unique<CompilationUnitBuilder>(native_module_);
|
||||
|
@ -10,6 +10,7 @@ const num_functions = 2;
|
||||
|
||||
function create_builder() {
|
||||
const builder = new WasmModuleBuilder();
|
||||
builder.addImport("foo", "bar", kSig_i_v);
|
||||
for (let i = 0; i < num_functions; ++i) {
|
||||
builder.addFunction('f' + i, kSig_i_v)
|
||||
.addBody(wasmI32Const(i))
|
||||
@ -37,7 +38,7 @@ gc();
|
||||
print(arguments.callee.name);
|
||||
const module = %DeserializeWasmModule(serialized_module, wire_bytes);
|
||||
|
||||
const instance = new WebAssembly.Instance(module);
|
||||
const instance = new WebAssembly.Instance(module, {foo: {bar: () => 1}});
|
||||
assertEquals(0, instance.exports.f0());
|
||||
assertEquals(1, instance.exports.f1());
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user