Commit 172d6f50 authored by Mircea Trofin's avatar Mircea Trofin Committed by Commit Bot

[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/630097Reviewed-by: 's avatarBrad Nelson <bradnelson@chromium.org>
Commit-Queue: Brad Nelson <bradnelson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47560}
parent c5f675d0
......@@ -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();
......
// 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));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment