6b650574fc
This CL just adds a parameter to addElementSegment and adjusts all existing tests. Note that addElementSegment contains some convenience code to construct one initial table if it does not exist yet. I did not extend that code to multiple tables. If you want to use multiple tables, you have to create them first before calling addElementSegment. R=clemensh@chromium.org Bug: v8:7581 Change-Id: Ie131fd5dc19856703ab5cfb2fa8f7d576f70a18b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1520709 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#60211}
25 lines
918 B
JavaScript
25 lines
918 B
JavaScript
// 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-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.addElementSegment(0, glob_import, true, [mul_import]);
|
|
builder2.instantiate(
|
|
{q: {glob: 0, js_div: i => i, wasm_mul: mul, table: table}});
|