mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:51:35 +00:00

PR-URL: https://github.com/nodejs/node/pull/54077 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
// Copyright 2024 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: --experimental-wasm-memory64
|
|
|
|
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
(function TestImportTable64AsTable64() {
|
|
print(arguments.callee.name);
|
|
const builder1 = new WasmModuleBuilder();
|
|
builder1.addTable64(kWasmAnyFunc, 10, 10).exportAs('table64');
|
|
const {table64} = builder1.instantiate().exports;
|
|
|
|
let builder2 = new WasmModuleBuilder();
|
|
builder2.addImportedTable(
|
|
'imports', 'table', 10, 10, kWasmAnyFunc, /* table64 */ true);
|
|
builder2.instantiate({imports: {table: table64}});
|
|
})();
|
|
|
|
(function TestImportTable32AsTable32() {
|
|
print(arguments.callee.name);
|
|
const builder1 = new WasmModuleBuilder();
|
|
builder1.addTable(kWasmAnyFunc, 10, 10).exportAs('table32');
|
|
const {table32} = builder1.instantiate().exports;
|
|
|
|
let builder2 = new WasmModuleBuilder();
|
|
builder2.addImportedTable(
|
|
'imports', 'table', 10, 10, kWasmAnyFunc, /* table64 */ false);
|
|
builder2.instantiate({imports: {table: table32}});
|
|
})();
|
|
|
|
(function TestImportTable64AsTable32() {
|
|
print(arguments.callee.name);
|
|
const builder1 = new WasmModuleBuilder();
|
|
builder1.addTable64(kWasmAnyFunc, 10, 10).exportAs('table64');
|
|
const {table64} = builder1.instantiate().exports;
|
|
|
|
let builder2 = new WasmModuleBuilder();
|
|
builder2.addImportedTable(
|
|
'imports', 'table', 10, 10, kWasmAnyFunc, /* table64 */ false);
|
|
assertThrows(
|
|
() => builder2.instantiate({imports: {table: table64}}),
|
|
WebAssembly.LinkError,
|
|
'WebAssembly.Instance(): cannot import table64 as table32');
|
|
})();
|
|
|
|
(function TestImportTable32AsTable64() {
|
|
print(arguments.callee.name);
|
|
const builder1 = new WasmModuleBuilder();
|
|
builder1.addTable(kWasmAnyFunc, 10, 10).exportAs('table32');
|
|
const {table32} = builder1.instantiate().exports;
|
|
|
|
let builder2 = new WasmModuleBuilder();
|
|
builder2.addImportedTable(
|
|
'imports', 'table', 10, 10, kWasmAnyFunc, /* table64 */ true);
|
|
assertThrows(
|
|
() => builder2.instantiate({imports: {table: table32}}),
|
|
WebAssembly.LinkError,
|
|
'WebAssembly.Instance(): cannot import table32 as table64');
|
|
})();
|