Commit 6195ebe1 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Fix DCHECK for lazy compilation

Table inits can contain imported functions, hence their code will be a
wasm-to-wasm wrapper.
Fix a DCHECK and add a regression test.

R=ahaas@chromium.org

Bug: chromium:817380
Change-Id: I836be589e1ae66839ccd470154c8dea488e6bc1f
Reviewed-on: https://chromium-review.googlesource.com/943107
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51685}
parent 1525374f
......@@ -3289,7 +3289,8 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table,
// needed otherwise).
if (code->builtin_index() != Builtins::kWasmCompileLazy) {
DCHECK(code->kind() == Code::WASM_FUNCTION ||
code->kind() == Code::WASM_TO_JS_FUNCTION);
code->kind() == Code::WASM_TO_JS_FUNCTION ||
code->kind() == Code::WASM_TO_WASM_FUNCTION);
continue;
}
} else {
......@@ -3298,7 +3299,8 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table,
// needed otherwise).
if (code->kind() != wasm::WasmCode::kLazyStub) {
DCHECK(code->kind() == wasm::WasmCode::kFunction ||
code->kind() == wasm::WasmCode::kWasmToJsWrapper);
code->kind() == wasm::WasmCode::kWasmToJsWrapper ||
code->kind() == wasm::WasmCode::kWasmToWasmWrapper);
continue;
}
}
......
// Copyright 2018 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.
// Flags: --wasm-lazy-compilation
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
const builder1 = new WasmModuleBuilder();
builder1.addFunction('mul', kSig_i_ii)
.addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Mul])
.exportFunc();
const mul = builder1.instantiate().exports.mul;
const table = new WebAssembly.Table({
element: 'anyfunc',
initial: 10,
});
const builder2 = new WasmModuleBuilder();
const mul_import = builder2.addImport('q', 'wasm_mul', kSig_i_ii);
builder2.addImportedTable('q', 'table');
const glob_import = builder2.addImportedGlobal('q', 'glob', kWasmI32);
builder2.addFunctionTableInit(glob_import, true, [mul_import]);
builder2.instantiate(
{q: {glob: 0, js_div: i => i, wasm_mul: mul, table: table}});
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