[wasm] Test and fix for module with no functions
Initialize the code table with a valid default (e.g. illegal builtin), otherwise we're invalidating assumptions when relocating. Bug: chromium:757217 Change-Id: I77890f1fe0e31534d9844d2e91694df1ec185110 Reviewed-on: https://chromium-review.googlesource.com/630097 Reviewed-by: Brad Nelson <bradnelson@chromium.org> Commit-Queue: Brad Nelson <bradnelson@chromium.org> Cr-Commit-Position: refs/heads/master@{#47560}
This commit is contained in:
parent
c5f675d022
commit
172d6f50e5
@ -2094,7 +2094,9 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
|
||||
int code_table_size = static_cast<int>(module_->functions.size() +
|
||||
module_->num_exported_functions);
|
||||
job_->code_table_ = factory->NewFixedArray(code_table_size, TENURED);
|
||||
|
||||
for (int i = 0, e = module_->num_imported_functions; i < e; ++i) {
|
||||
job_->code_table_->set(i, *illegal_builtin);
|
||||
}
|
||||
// Transfer ownership of the {WasmModule} to the {ModuleCompiler}, but
|
||||
// keep a pointer.
|
||||
WasmModule* module = module_.get();
|
||||
|
20
test/mjsunit/regress/wasm/regression-757217.js
Normal file
20
test/mjsunit/regress/wasm/regression-757217.js
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
load('test/mjsunit/wasm/wasm-constants.js');
|
||||
load('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
let builder = new WasmModuleBuilder();
|
||||
builder.addImport('','f', kSig_v_v);
|
||||
builder.addExport('a', 0);
|
||||
builder.addExport('b', 0);
|
||||
var bytes = builder.toBuffer();
|
||||
|
||||
var m = new WebAssembly.Module(bytes);
|
||||
assertTrue(m instanceof WebAssembly.Module);
|
||||
|
||||
assertPromiseResult(
|
||||
WebAssembly.compile(bytes)
|
||||
.then(async_result => assertTrue(async_result instanceof WebAssembly.Module),
|
||||
assertUnreachable));
|
Loading…
Reference in New Issue
Block a user