[wasm] Remove the --wasm-interpret-all flag
The interpreter will be moved to be test-only, hence --wasm-interpret-all also needs to be removed. Since we don't have any non-compiling tier any more, we also remove the implication from --jitless to --wasm-lazy-compilation. Instead, we add another CHECK that we can't be in jitless mode if we trigger any wasm compilation. All tests that just ran other tests and additionally passed --wasm-interpret-all become redundant and are deleted. Also all regression tests that explicitly specify --wasm-interpret-all are not needed any more. R=thibaudm@chromium.org Bug: v8:10389 Change-Id: I5ddf20a842117a6c05e277a5308f5cfe42e6bfa5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2164792 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Thibaud Michaud <thibaudm@chromium.org> Cr-Commit-Position: refs/heads/master@{#67419}
This commit is contained in:
parent
e34425a2e5
commit
6f4991fada
@ -433,11 +433,6 @@ DEFINE_NEG_IMPLICATION(jitless, track_heap_object_fields)
|
||||
DEFINE_IMPLICATION(jitless, regexp_interpret_all)
|
||||
// asm.js validation is disabled since it triggers wasm code generation.
|
||||
DEFINE_NEG_IMPLICATION(jitless, validate_asm)
|
||||
// Wasm is put into interpreter-only mode. We repeat flag implications down
|
||||
// here to ensure they're applied correctly by setting the --jitless flag.
|
||||
DEFINE_IMPLICATION(jitless, wasm_interpret_all)
|
||||
DEFINE_NEG_IMPLICATION(jitless, asm_wasm_lazy_compilation)
|
||||
DEFINE_NEG_IMPLICATION(jitless, wasm_lazy_compilation)
|
||||
// --jitless also implies --no-expose-wasm, see InitializeOncePerProcessImpl.
|
||||
|
||||
// Flags for inline caching and feedback vectors.
|
||||
@ -769,8 +764,6 @@ DEFINE_BOOL(wasm_fuzzer_gen_test, false,
|
||||
DEFINE_IMPLICATION(wasm_fuzzer_gen_test, single_threaded)
|
||||
DEFINE_BOOL(print_wasm_code, false, "Print WebAssembly code")
|
||||
DEFINE_BOOL(print_wasm_stub_code, false, "Print WebAssembly stub code")
|
||||
DEFINE_BOOL(wasm_interpret_all, false,
|
||||
"execute all wasm code in the wasm interpreter")
|
||||
DEFINE_BOOL(asm_wasm_lazy_compilation, false,
|
||||
"enable lazy compilation for asm-wasm modules")
|
||||
DEFINE_IMPLICATION(validate_asm, asm_wasm_lazy_compilation)
|
||||
@ -792,10 +785,6 @@ DEFINE_BOOL(wasm_simd_post_mvp, false,
|
||||
"included in the current proposal")
|
||||
DEFINE_IMPLICATION(wasm_simd_post_mvp, experimental_wasm_simd)
|
||||
|
||||
// wasm-interpret-all resets {asm-,}wasm-lazy-compilation.
|
||||
DEFINE_NEG_IMPLICATION(wasm_interpret_all, asm_wasm_lazy_compilation)
|
||||
DEFINE_NEG_IMPLICATION(wasm_interpret_all, wasm_lazy_compilation)
|
||||
DEFINE_NEG_IMPLICATION(wasm_interpret_all, wasm_tier_up)
|
||||
DEFINE_BOOL(wasm_code_gc, true, "enable garbage collection of wasm code")
|
||||
DEFINE_BOOL(trace_wasm_code_gc, false, "trace garbage collection of wasm code")
|
||||
DEFINE_BOOL(stress_wasm_code_gc, false,
|
||||
|
@ -115,7 +115,6 @@ ExecutionTier WasmCompilationUnit::GetBaselineExecutionTier(
|
||||
// Liftoff does not support the special asm.js opcodes, thus always compile
|
||||
// asm.js modules with TurboFan.
|
||||
if (is_asmjs_module(module)) return ExecutionTier::kTurbofan;
|
||||
if (FLAG_wasm_interpret_all) return ExecutionTier::kInterpreter;
|
||||
return FLAG_liftoff ? ExecutionTier::kLiftoff : ExecutionTier::kTurbofan;
|
||||
}
|
||||
|
||||
|
@ -1328,6 +1328,7 @@ class CompilationTimeCallback {
|
||||
void CompileNativeModule(Isolate* isolate, ErrorThrower* thrower,
|
||||
const WasmModule* wasm_module,
|
||||
NativeModule* native_module) {
|
||||
CHECK(!FLAG_jitless);
|
||||
ModuleWireBytes wire_bytes(native_module->wire_bytes());
|
||||
const bool lazy_module = IsLazyModule(wasm_module);
|
||||
if (!FLAG_wasm_lazy_validation && wasm_module->origin == kWasmOrigin &&
|
||||
|
@ -203,7 +203,6 @@ TEST(FlagsJitlessImplications) {
|
||||
// definition order in flag-definitions.h.
|
||||
CHECK(!FLAG_opt);
|
||||
CHECK(!FLAG_validate_asm);
|
||||
CHECK(FLAG_wasm_interpret_all);
|
||||
CHECK(!FLAG_asm_wasm_lazy_compilation);
|
||||
CHECK(!FLAG_wasm_lazy_compilation);
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --no-stress-opt --expose-wasm --trace-wasm-memory --wasm-interpret-all
|
||||
// Flags: --experimental-wasm-simd
|
||||
|
||||
load("test/message/wasm-trace-memory.js");
|
@ -1,14 +0,0 @@
|
||||
interpreter func: 0+0x3 load from 00000004 val: i32:0 / 00000000
|
||||
interpreter func: 1+0x3 load from 00000001 val: i8:0 / 00
|
||||
interpreter func: 3+0x5 store to 00000004 val: i32:305419896 / 12345678
|
||||
interpreter func: 0+0x3 load from 00000002 val: i32:1450704896 / 56780000
|
||||
interpreter func: 1+0x3 load from 00000006 val: i8:52 / 34
|
||||
interpreter func: 2+0x3 load from 00000002 val: f32:68169720922112.000000 / 56780000
|
||||
interpreter func: 4+0x5 store to 00000004 val: i8:171 / ab
|
||||
interpreter func: 0+0x3 load from 00000002 val: i32:1454047232 / 56ab0000
|
||||
interpreter func: 2+0x3 load from 00000002 val: f32:94008244174848.000000 / 56ab0000
|
||||
interpreter func: 6+0x7 store to 00000004 val: s128:48879 48879 48879 48879 / 0000beef 0000beef 0000beef 0000beef
|
||||
interpreter func: 5+0x3 load from 00000002 val: s128:-1091633152 -1091633152 -1091633152 -1091633152 / beef0000 beef0000 beef0000 beef0000
|
||||
interpreter func: 7+0x3 load from 00000004 val: i16:48879 / beef
|
||||
interpreter func: 8+0x3 load from 00000002 val: i64:-4688528683866062848 / beef0000beef0000
|
||||
interpreter func: 9+0x3 load from 00000002 val: f64:-0.000015 / beef0000beef0000
|
@ -1,35 +0,0 @@
|
||||
// Copyright 2020 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-staging --wasm-interpret-all --experimental-wasm-simd
|
||||
|
||||
load('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
const builder = new WasmModuleBuilder();
|
||||
builder.addMemory(16, 32, false);
|
||||
builder.addType(makeSig([kWasmI32, kWasmI32, kWasmI32], [kWasmI32]));
|
||||
// Generate function 1 (out of 1).
|
||||
builder.addFunction(undefined, 0 /* sig */)
|
||||
.addBodyWithEnd([
|
||||
// signature: i_iii
|
||||
// body:
|
||||
kExprI32Const, 0x75, // i32.const
|
||||
kExprI32Const, 0x74, // i32.const
|
||||
kExprI32Const, 0x18, // i32.const
|
||||
kSimdPrefix, ...kExprS8x16LoadSplat, // s8x16.load_splat
|
||||
kExprUnreachable, // unreachable
|
||||
kExprUnreachable, // unreachable
|
||||
kExprI32Const, 0x6f, // i32.const
|
||||
kExprI32Const, 0x7f, // i32.const
|
||||
kExprI32Const, 0x6f, // i32.const
|
||||
kExprDrop,
|
||||
kExprDrop,
|
||||
kExprDrop,
|
||||
kExprDrop,
|
||||
kExprDrop,
|
||||
kExprEnd, // end @18
|
||||
]);
|
||||
builder.addExport('main', 0);
|
||||
const instance = builder.instantiate();
|
||||
print(instance.exports.main(1, 2, 3));
|
@ -1,12 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --wasm-interpret-all --validate-asm
|
||||
|
||||
function asm() {
|
||||
"use asm";
|
||||
function f() {}
|
||||
return {};
|
||||
}
|
||||
asm();
|
@ -1,12 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --wasm-interpret-all --wasm-lazy-compilation
|
||||
|
||||
load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
var builder = new WasmModuleBuilder();
|
||||
builder.addFunction('f', kSig_v_v).addBody([]);
|
||||
builder.addFunction('g', kSig_v_v).addBody([]);
|
||||
builder.instantiate();
|
@ -1,16 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --validate-asm --wasm-interpret-all
|
||||
|
||||
function asm() {
|
||||
'use asm';
|
||||
function f() {
|
||||
if (1.0 % 2.5 == -0.75) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return {f: f};
|
||||
}
|
||||
asm().f();
|
@ -1,16 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --expose-wasm --wasm-interpret-all
|
||||
|
||||
load('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
__v_6 = new WasmModuleBuilder();
|
||||
__v_6.addFunction('exp1', kSig_i_i).addBody([kExprUnreachable]).exportFunc();
|
||||
__v_7 = new WasmModuleBuilder();
|
||||
__v_7.addImport('__v_11', '__v_11', kSig_i_i);
|
||||
try {
|
||||
; } catch(e) {; }
|
||||
__v_8 = __v_6.instantiate().exports.exp1;
|
||||
__v_9 = __v_7.instantiate({__v_11: {__v_11: __v_8}}).exports.call_imp;
|
@ -1,38 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --expose-wasm --wasm-interpret-all
|
||||
|
||||
load('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
assertThrows(() => {
|
||||
__v_29 = 0;
|
||||
function __f_1() {
|
||||
__v_19 = new WasmModuleBuilder();
|
||||
if (__v_25) {
|
||||
__v_23 = __v_19.addImport('__v_24', '__v_30', __v_25);
|
||||
}
|
||||
if (__v_18) {
|
||||
__v_19.addMemory();
|
||||
__v_19.addFunction('load', kSig_i_i)
|
||||
.addBody([ 0])
|
||||
.exportFunc();
|
||||
}
|
||||
return __v_19;
|
||||
}
|
||||
(function TestExternalCallBetweenTwoWasmModulesWithoutAndWithMemory() {
|
||||
__v_21 = __f_1(__v_18 = false, __v_25 = kSig_i_i);
|
||||
__v_21.addFunction('plus_one', kSig_i_i)
|
||||
.addBody([
|
||||
kExprLocalGet, 0, // -
|
||||
kExprCallFunction, __v_29 ])
|
||||
.exportFunc();
|
||||
__v_32 =
|
||||
__f_1(__v_18 = true, __v_25 = undefined);
|
||||
__v_31 = __v_32.instantiate(); try { __v_32[__getRandomProperty()] = __v_0; delete __v_18[__getRandomProperty()]; delete __v_34[__getRandomProperty()]; } catch(e) {; };
|
||||
__v_20 = __v_21.instantiate(
|
||||
{__v_24: {__v_30: __v_31.exports.load}});
|
||||
__v_20.exports.plus_one(); __v_33 = __v_43;
|
||||
})();
|
||||
});
|
@ -1,32 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --expose-wasm --wasm-interpret-all
|
||||
|
||||
load('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
assertThrows(() => {
|
||||
let __v_50315 = 0;
|
||||
function __f_15356(__v_50316, __v_50317) {
|
||||
let __v_50318 = new WasmModuleBuilder();
|
||||
if (__v_50317) {
|
||||
let __v_50319 = __v_50318.addImport('import_module', 'other_module_fn', kSig_i_i);
|
||||
}
|
||||
__v_50318.addMemory();
|
||||
__v_50318.addFunction('load', kSig_i_i).addBody([ 0, 0, 0]).exportFunc();
|
||||
return __v_50318;
|
||||
}
|
||||
(function __f_15357() {
|
||||
let __v_50320 = __f_15356(__v_50350 = false, __v_50351 = kSig_i_i);
|
||||
__v_50320.addFunction('plus_one', kSig_i_i).addBody([kExprLocalGet, 0, kExprCallFunction, __v_50315, kExprI32Const, kExprI32Add, kExprReturn]).exportFunc();
|
||||
let __v_50321 = __f_15356();
|
||||
let __v_50324 = __v_50321.instantiate();
|
||||
let __v_50325 = __v_50320.instantiate({
|
||||
import_module: {
|
||||
other_module_fn: __v_50324.exports.load
|
||||
}
|
||||
});
|
||||
__v_50325.exports.plus_one();
|
||||
})();
|
||||
});
|
@ -1,19 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --expose-wasm --wasm-interpret-all
|
||||
|
||||
load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
|
||||
const builder = new WasmModuleBuilder();
|
||||
|
||||
const index = builder.addFunction("huge_frame", kSig_v_v)
|
||||
.addBody([kExprCallFunction, 0])
|
||||
.addLocals({f64_count: 49555}).exportFunc().index;
|
||||
// We assume above that the function we added has index 0.
|
||||
assertEquals(0, index);
|
||||
|
||||
const module = builder.instantiate();
|
||||
assertThrows(module.exports.huge_frame, RangeError);
|
@ -1,21 +0,0 @@
|
||||
// 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-interpret-all
|
||||
|
||||
load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
const builder = new WasmModuleBuilder();
|
||||
const sig = builder.addType(kSig_i_i);
|
||||
builder.addFunction('call', kSig_i_v)
|
||||
.addBody([
|
||||
kExprI32Const, 0, kExprI32Const, 0, kExprCallIndirect, sig, kTableZero
|
||||
])
|
||||
.exportAs('call');
|
||||
builder.addImportedTable('imp', 'table');
|
||||
const table = new WebAssembly.Table({element: 'anyfunc', initial: 1});
|
||||
const instance = builder.instantiate({imp: {table: table}});
|
||||
assertThrows(
|
||||
() => instance.exports.call(), WebAssembly.RuntimeError,
|
||||
/function signature mismatch/);
|
@ -1,29 +0,0 @@
|
||||
// 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-interpret-all
|
||||
|
||||
load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
let instance;
|
||||
(function DoTest() {
|
||||
function call_main() {
|
||||
instance.exports.main();
|
||||
}
|
||||
let module = new WasmModuleBuilder();
|
||||
module.addImport('mod', 'func', kSig_v_i);
|
||||
module.addFunction('main', kSig_v_i)
|
||||
.addBody([kExprLocalGet, 0, kExprCallFunction, 0])
|
||||
.exportFunc();
|
||||
instance = module.instantiate({
|
||||
mod: {
|
||||
func: call_main
|
||||
}
|
||||
});
|
||||
try {
|
||||
instance.exports.main();
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
})();
|
@ -1,26 +0,0 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
// Bug is in the C-to-Wasm entry, used e.g. by the Wasm interpreter.
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
let argc = 7;
|
||||
let builder = new WasmModuleBuilder();
|
||||
let types = new Array(argc).fill(kWasmI32);
|
||||
let sig = makeSig(types, []);
|
||||
let body = [];
|
||||
for (let i = 0; i < argc; ++i) {
|
||||
body.push(kExprLocalGet, i);
|
||||
}
|
||||
body.push(kExprCallFunction, 0);
|
||||
builder.addImport('', 'f', sig);
|
||||
builder.addFunction("main", sig).addBody(body).exportAs('main');
|
||||
let instance = builder.instantiate({
|
||||
'': {
|
||||
'f': function() { throw "don't crash"; }
|
||||
}
|
||||
});
|
||||
assertThrows(instance.exports.main);
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-anyref --expose-gc
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/anyfunc.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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-anyref --expose-gc
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/anyref-globals.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-anyref --expose-gc
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/anyref.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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-eh --experimental-wasm-anyref --allow-natives-syntax
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for existing exception handling test cases that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/exceptions-anyref.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-eh --allow-natives-syntax
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for existing exception handling test cases that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/exceptions-global.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-eh --allow-natives-syntax
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for existing exception handling test cases that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/exceptions.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-eh --allow-natives-syntax
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for existing exception handling test cases that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/exceptions-rethrow.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-eh --experimental-wasm-simd --allow-natives-syntax
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for existing exception handling test cases that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/exceptions-simd.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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-threads --allow-natives-syntax
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is a wrapper for existing futex tests with the --wasm-interpret-all
|
||||
// flag added. If we ever decide to add a test variant for this, this file can
|
||||
// be removed.
|
||||
|
||||
load("test/mjsunit/wasm/futex.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-anyref --experimental-wasm-return-call
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/indirect-call-non-zero-table.js");
|
@ -1,569 +0,0 @@
|
||||
// Copyright 2016 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-interpret-all --allow-natives-syntax --expose-gc
|
||||
|
||||
load('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
// The stack trace contains file path, only keep "interpreter.js".
|
||||
let stripPath = s => s.replace(/[^ (]*interpreter\.js/g, 'interpreter.js');
|
||||
|
||||
function checkStack(stack, expected_lines) {
|
||||
print('stack: ' + stack);
|
||||
var lines = stack.split('\n');
|
||||
assertEquals(expected_lines.length, lines.length);
|
||||
for (var i = 0; i < lines.length; ++i) {
|
||||
let test =
|
||||
typeof expected_lines[i] == 'string' ? assertEquals : assertMatches;
|
||||
test(expected_lines[i], lines[i], 'line ' + i);
|
||||
}
|
||||
}
|
||||
|
||||
(function testCallImported() {
|
||||
print(arguments.callee.name);
|
||||
var stack;
|
||||
let func = () => stack = new Error('test imported stack').stack;
|
||||
|
||||
var builder = new WasmModuleBuilder();
|
||||
builder.addImport('mod', 'func', kSig_v_v);
|
||||
builder.addFunction('main', kSig_v_v)
|
||||
.addBody([kExprCallFunction, 0])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate({mod: {func: func}});
|
||||
// Test that this does not mess up internal state by executing it three times.
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
var interpreted_before = %WasmNumInterpretedCalls(instance);
|
||||
instance.exports.main();
|
||||
assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance));
|
||||
checkStack(stripPath(stack), [
|
||||
'Error: test imported stack', // -
|
||||
/^ at func \(interpreter.js:\d+:28\)$/, // -
|
||||
' at main (<anonymous>:wasm-function[1]:0x32)', // -
|
||||
/^ at testCallImported \(interpreter.js:\d+:22\)$/, // -
|
||||
/^ at interpreter.js:\d+:3$/
|
||||
]);
|
||||
}
|
||||
})();
|
||||
|
||||
(function testCallImportedWithParameters() {
|
||||
print(arguments.callee.name);
|
||||
var stack;
|
||||
var passed_args = [];
|
||||
let func1 = (i, j) => (passed_args.push(i, j), 2 * i + j);
|
||||
let func2 = (f) => (passed_args.push(f), 8 * f);
|
||||
|
||||
var builder = new WasmModuleBuilder();
|
||||
builder.addImport('mod', 'func1', makeSig([kWasmI32, kWasmI32], [kWasmF32]));
|
||||
builder.addImport('mod', 'func2', makeSig([kWasmF64], [kWasmI32]));
|
||||
builder.addFunction('main', makeSig([kWasmI32, kWasmF64], [kWasmF32]))
|
||||
.addBody([
|
||||
// call #0 with arg 0 and arg 0 + 1
|
||||
kExprLocalGet, 0, kExprLocalGet, 0, kExprI32Const, 1, kExprI32Add,
|
||||
kExprCallFunction, 0,
|
||||
// call #1 with arg 1
|
||||
kExprLocalGet, 1, kExprCallFunction, 1,
|
||||
// convert returned value to f32
|
||||
kExprF32UConvertI32,
|
||||
// add the two values
|
||||
kExprF32Add
|
||||
])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate({mod: {func1: func1, func2: func2}});
|
||||
var interpreted_before = %WasmNumInterpretedCalls(instance);
|
||||
var args = [11, 0.3];
|
||||
var ret = instance.exports.main(...args);
|
||||
assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance));
|
||||
var passed_test_args = [...passed_args];
|
||||
var expected = func1(args[0], args[0] + 1) + func2(args[1]) | 0;
|
||||
assertEquals(expected, ret);
|
||||
assertArrayEquals([args[0], args[0] + 1, args[1]], passed_test_args);
|
||||
})();
|
||||
|
||||
(function testTrap() {
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
var foo_idx = builder.addFunction('foo', kSig_v_v)
|
||||
.addBody([kExprNop, kExprNop, kExprUnreachable])
|
||||
.index;
|
||||
builder.addFunction('main', kSig_v_v)
|
||||
.addBody([kExprNop, kExprCallFunction, foo_idx])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate();
|
||||
// Test that this does not mess up internal state by executing it three times.
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
var interpreted_before = %WasmNumInterpretedCalls(instance);
|
||||
var stack;
|
||||
try {
|
||||
instance.exports.main();
|
||||
assertUnreachable();
|
||||
} catch (e) {
|
||||
stack = e.stack;
|
||||
}
|
||||
assertEquals(interpreted_before + 2, %WasmNumInterpretedCalls(instance));
|
||||
checkStack(stripPath(stack), [
|
||||
'RuntimeError: unreachable', // -
|
||||
' at foo (<anonymous>:wasm-function[0]:0x27)', // -
|
||||
' at main (<anonymous>:wasm-function[1]:0x2c)', // -
|
||||
/^ at testTrap \(interpreter.js:\d+:24\)$/, // -
|
||||
/^ at interpreter.js:\d+:3$/
|
||||
]);
|
||||
}
|
||||
})();
|
||||
|
||||
(function testThrowFromImport() {
|
||||
print(arguments.callee.name);
|
||||
function func() {
|
||||
throw new Error('thrown from imported function');
|
||||
}
|
||||
var builder = new WasmModuleBuilder();
|
||||
builder.addImport("mod", "func", kSig_v_v);
|
||||
builder.addFunction('main', kSig_v_v)
|
||||
.addBody([kExprCallFunction, 0])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate({mod: {func: func}});
|
||||
// Test that this does not mess up internal state by executing it three times.
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
var interpreted_before = %WasmNumInterpretedCalls(instance);
|
||||
var stack;
|
||||
try {
|
||||
instance.exports.main();
|
||||
assertUnreachable();
|
||||
} catch (e) {
|
||||
stack = e.stack;
|
||||
}
|
||||
assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance));
|
||||
checkStack(stripPath(stack), [
|
||||
'Error: thrown from imported function', // -
|
||||
/^ at func \(interpreter.js:\d+:11\)$/, // -
|
||||
' at main (<anonymous>:wasm-function[1]:0x32)', // -
|
||||
/^ at testThrowFromImport \(interpreter.js:\d+:24\)$/, // -
|
||||
/^ at interpreter.js:\d+:3$/
|
||||
]);
|
||||
}
|
||||
})();
|
||||
|
||||
(function testGlobals() {
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
builder.addGlobal(kWasmI32, true); // 0
|
||||
builder.addGlobal(kWasmI64, true); // 1
|
||||
builder.addGlobal(kWasmF32, true); // 2
|
||||
builder.addGlobal(kWasmF64, true); // 3
|
||||
builder.addFunction('get_i32', kSig_i_v)
|
||||
.addBody([kExprGlobalGet, 0])
|
||||
.exportFunc();
|
||||
builder.addFunction('get_i64', kSig_d_v)
|
||||
.addBody([kExprGlobalGet, 1, kExprF64SConvertI64])
|
||||
.exportFunc();
|
||||
builder.addFunction('get_f32', kSig_d_v)
|
||||
.addBody([kExprGlobalGet, 2, kExprF64ConvertF32])
|
||||
.exportFunc();
|
||||
builder.addFunction('get_f64', kSig_d_v)
|
||||
.addBody([kExprGlobalGet, 3])
|
||||
.exportFunc();
|
||||
builder.addFunction('set_i32', kSig_v_i)
|
||||
.addBody([kExprLocalGet, 0, kExprGlobalSet, 0])
|
||||
.exportFunc();
|
||||
builder.addFunction('set_i64', kSig_v_d)
|
||||
.addBody([kExprLocalGet, 0, kExprI64SConvertF64, kExprGlobalSet, 1])
|
||||
.exportFunc();
|
||||
builder.addFunction('set_f32', kSig_v_d)
|
||||
.addBody([kExprLocalGet, 0, kExprF32ConvertF64, kExprGlobalSet, 2])
|
||||
.exportFunc();
|
||||
builder.addFunction('set_f64', kSig_v_d)
|
||||
.addBody([kExprLocalGet, 0, kExprGlobalSet, 3])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate();
|
||||
// Initially, all should be zero.
|
||||
assertEquals(0, instance.exports.get_i32());
|
||||
assertEquals(0, instance.exports.get_i64());
|
||||
assertEquals(0, instance.exports.get_f32());
|
||||
assertEquals(0, instance.exports.get_f64());
|
||||
// Assign values to all variables.
|
||||
var values = [4711, 1<<40 + 1 << 33, 0.3, 12.34567];
|
||||
instance.exports.set_i32(values[0]);
|
||||
instance.exports.set_i64(values[1]);
|
||||
instance.exports.set_f32(values[2]);
|
||||
instance.exports.set_f64(values[3]);
|
||||
// Now check the values.
|
||||
assertEquals(values[0], instance.exports.get_i32());
|
||||
assertEquals(values[1], instance.exports.get_i64());
|
||||
assertEqualsDelta(values[2], instance.exports.get_f32(), 2**-23);
|
||||
assertEquals(values[3], instance.exports.get_f64());
|
||||
})();
|
||||
|
||||
(function testReentrantInterpreter() {
|
||||
print(arguments.callee.name);
|
||||
var stacks;
|
||||
var instance;
|
||||
function func(i) {
|
||||
stacks.push(new Error('reentrant interpreter test #' + i).stack);
|
||||
if (i < 2) instance.exports.main(i + 1);
|
||||
}
|
||||
|
||||
var builder = new WasmModuleBuilder();
|
||||
builder.addImport('mod', 'func', kSig_v_i);
|
||||
builder.addFunction('main', kSig_v_i)
|
||||
.addBody([kExprLocalGet, 0, kExprCallFunction, 0])
|
||||
.exportFunc();
|
||||
instance = builder.instantiate({mod: {func: func}});
|
||||
// Test that this does not mess up internal state by executing it three times.
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
var interpreted_before = %WasmNumInterpretedCalls(instance);
|
||||
stacks = [];
|
||||
instance.exports.main(0);
|
||||
assertEquals(interpreted_before + 3, %WasmNumInterpretedCalls(instance));
|
||||
assertEquals(3, stacks.length);
|
||||
for (var e = 0; e < stacks.length; ++e) {
|
||||
expected = ['Error: reentrant interpreter test #' + e];
|
||||
expected.push(/^ at func \(interpreter.js:\d+:17\)$/);
|
||||
expected.push(' at main (<anonymous>:wasm-function[1]:0x36)');
|
||||
for (var k = e; k > 0; --k) {
|
||||
expected.push(/^ at func \(interpreter.js:\d+:33\)$/);
|
||||
expected.push(' at main (<anonymous>:wasm-function[1]:0x36)');
|
||||
}
|
||||
expected.push(
|
||||
/^ at testReentrantInterpreter \(interpreter.js:\d+:22\)$/);
|
||||
expected.push(/ at interpreter.js:\d+:3$/);
|
||||
checkStack(stripPath(stacks[e]), expected);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
(function testIndirectImports() {
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
|
||||
var sig_i_ii = builder.addType(kSig_i_ii);
|
||||
var sig_i_i = builder.addType(kSig_i_i);
|
||||
var mul = builder.addImport('q', 'mul', sig_i_ii);
|
||||
var add = builder.addFunction('add', sig_i_ii).addBody([
|
||||
kExprLocalGet, 0, kExprLocalGet, 1, kExprI32Add
|
||||
]);
|
||||
var mismatch =
|
||||
builder.addFunction('sig_mismatch', sig_i_i).addBody([kExprLocalGet, 0]);
|
||||
var main = builder.addFunction('main', kSig_i_iii)
|
||||
.addBody([
|
||||
// Call indirect #0 with args <#1, #2>.
|
||||
kExprLocalGet, 1, kExprLocalGet, 2, kExprLocalGet, 0,
|
||||
kExprCallIndirect, sig_i_ii, kTableZero
|
||||
])
|
||||
.exportFunc();
|
||||
builder.appendToTable([mul, add.index, mismatch.index, main.index]);
|
||||
|
||||
var instance = builder.instantiate({q: {mul: (a, b) => a * b}});
|
||||
|
||||
// Call mul.
|
||||
assertEquals(-6, instance.exports.main(0, -2, 3));
|
||||
// Call add.
|
||||
assertEquals(99, instance.exports.main(1, 22, 77));
|
||||
// main and sig_mismatch have another signature.
|
||||
assertTraps(kTrapFuncSigMismatch, () => instance.exports.main(2, 12, 33));
|
||||
assertTraps(kTrapFuncSigMismatch, () => instance.exports.main(3, 12, 33));
|
||||
// Function index 4 does not exist.
|
||||
assertTraps(kTrapFuncInvalid, () => instance.exports.main(4, 12, 33));
|
||||
})();
|
||||
|
||||
(function testIllegalImports() {
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
|
||||
var sig_l_v = builder.addType(kSig_l_v);
|
||||
var imp = builder.addImport('q', 'imp', sig_l_v);
|
||||
var direct = builder.addFunction('direct', kSig_l_v)
|
||||
.addBody([kExprCallFunction, imp])
|
||||
.exportFunc();
|
||||
var indirect = builder.addFunction('indirect', kSig_l_v).addBody([
|
||||
kExprI32Const, 0, kExprCallIndirect, sig_l_v, kTableZero
|
||||
]);
|
||||
var main =
|
||||
builder.addFunction('main', kSig_v_i)
|
||||
.addBody([
|
||||
// Call indirect #0 with arg #0, drop result.
|
||||
kExprLocalGet, 0, kExprCallIndirect, sig_l_v, kTableZero, kExprDrop
|
||||
])
|
||||
.exportFunc();
|
||||
builder.appendToTable([imp, direct.index, indirect.index]);
|
||||
|
||||
var instance = builder.instantiate({q: {imp: () => 1}});
|
||||
|
||||
// Calling imported functions with i64 in signature should fail.
|
||||
try {
|
||||
// Via direct call.
|
||||
instance.exports.main(1);
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError)) throw e;
|
||||
checkStack(stripPath(e.stack), [
|
||||
'TypeError: ' + kTrapMsgs[kTrapTypeError], // -
|
||||
' at direct (<anonymous>:wasm-function[1]:0x55)', // -
|
||||
' at main (<anonymous>:wasm-function[3]:0x64)', // -
|
||||
/^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // -
|
||||
/^ at interpreter.js:\d+:3$/
|
||||
]);
|
||||
}
|
||||
try {
|
||||
// Via indirect call.
|
||||
instance.exports.main(2);
|
||||
} catch (e) {
|
||||
if (!(e instanceof TypeError)) throw e;
|
||||
checkStack(stripPath(e.stack), [
|
||||
'TypeError: ' + kTrapMsgs[kTrapTypeError], // -
|
||||
' at indirect (<anonymous>:wasm-function[2]:0x5c)', // -
|
||||
' at main (<anonymous>:wasm-function[3]:0x64)', // -
|
||||
/^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // -
|
||||
/^ at interpreter.js:\d+:3$/
|
||||
]);
|
||||
}
|
||||
})();
|
||||
|
||||
(function testImportExportedFunction() {
|
||||
// See https://crbug.com/860392.
|
||||
print(arguments.callee.name);
|
||||
let instance0 = (() => {
|
||||
let builder = new WasmModuleBuilder();
|
||||
builder.addFunction('f11', kSig_i_v).addBody(wasmI32Const(11)).exportFunc();
|
||||
builder.addFunction('f17', kSig_i_v).addBody(wasmI32Const(17)).exportFunc();
|
||||
return builder.instantiate();
|
||||
})();
|
||||
|
||||
let builder = new WasmModuleBuilder();
|
||||
let sig_i_v = builder.addType(kSig_i_v);
|
||||
let f11_imp = builder.addImport('q', 'f11', sig_i_v);
|
||||
let f17_imp = builder.addImport('q', 'f17', sig_i_v);
|
||||
let add = builder.addFunction('add', sig_i_v).addBody([
|
||||
kExprCallFunction, f11_imp, // call f11
|
||||
kExprCallFunction, f17_imp, // call f17
|
||||
kExprI32Add // i32.add
|
||||
]).exportFunc();
|
||||
let instance = builder.instantiate(
|
||||
{q: {f11: instance0.exports.f11, f17: instance0.exports.f17}});
|
||||
|
||||
assertEquals(28, instance.exports.add());
|
||||
})();
|
||||
|
||||
(function testInfiniteRecursion() {
|
||||
print(arguments.callee.name);
|
||||
var builder = new WasmModuleBuilder();
|
||||
|
||||
var direct = builder.addFunction('main', kSig_v_v)
|
||||
.addBody([kExprNop, kExprCallFunction, 0])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate();
|
||||
|
||||
try {
|
||||
instance.exports.main();
|
||||
assertUnreachable("should throw");
|
||||
} catch (e) {
|
||||
if (!(e instanceof RangeError)) throw e;
|
||||
checkStack(stripPath(e.stack), [
|
||||
'RangeError: Maximum call stack size exceeded',
|
||||
' at main (<anonymous>:wasm-function[0]:0x20)'
|
||||
].concat(Array(9).fill(' at main (<anonymous>:wasm-function[0]:0x22)')));
|
||||
}
|
||||
})();
|
||||
|
||||
(function testUnwindSingleActivation() {
|
||||
print(arguments.callee.name);
|
||||
// Create two activations and unwind just the top one.
|
||||
var builder = new WasmModuleBuilder();
|
||||
|
||||
function MyError(i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
// We call wasm -> func 1 -> wasm -> func2.
|
||||
// func2 throws, func 1 catches.
|
||||
function func1() {
|
||||
try {
|
||||
return instance.exports.foo();
|
||||
} catch (e) {
|
||||
if (!(e instanceof MyError)) throw e;
|
||||
return e.i + 2;
|
||||
}
|
||||
}
|
||||
function func2() {
|
||||
throw new MyError(11);
|
||||
}
|
||||
var imp1 = builder.addImport('mod', 'func1', kSig_i_v);
|
||||
var imp2 = builder.addImport('mod', 'func2', kSig_v_v);
|
||||
builder.addFunction('main', kSig_i_v)
|
||||
.addBody([kExprCallFunction, imp1, kExprI32Const, 2, kExprI32Mul])
|
||||
.exportFunc();
|
||||
builder.addFunction('foo', kSig_v_v)
|
||||
.addBody([kExprCallFunction, imp2])
|
||||
.exportFunc();
|
||||
var instance = builder.instantiate({mod: {func1: func1, func2: func2}});
|
||||
|
||||
var interpreted_before = %WasmNumInterpretedCalls(instance);
|
||||
assertEquals(2 * (11 + 2), instance.exports.main());
|
||||
assertEquals(interpreted_before + 2, %WasmNumInterpretedCalls(instance));
|
||||
})();
|
||||
|
||||
(function testInterpreterGC() {
|
||||
print(arguments.callee.name);
|
||||
function run(f) {
|
||||
// wrap the creation in a closure so that the only thing returned is
|
||||
// the module (i.e. the underlying array buffer of wasm wire bytes dies).
|
||||
var module = (() => {
|
||||
var builder = new WasmModuleBuilder();
|
||||
var imp = builder.addImport('mod', 'the_name_of_my_import', kSig_i_i);
|
||||
builder.addFunction('main', kSig_i_i)
|
||||
.addBody([kExprLocalGet, 0, kExprCallFunction, imp])
|
||||
.exportAs('main');
|
||||
print('module');
|
||||
return new WebAssembly.Module(builder.toBuffer());
|
||||
})();
|
||||
|
||||
gc();
|
||||
for (var i = 0; i < 10; i++) {
|
||||
print(' instance ' + i);
|
||||
var instance =
|
||||
new WebAssembly.Instance(module, {'mod': {the_name_of_my_import: f}});
|
||||
var g = instance.exports.main;
|
||||
assertEquals('function', typeof g);
|
||||
for (var j = 0; j < 10; j++) {
|
||||
assertEquals(f(j), g(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < 3; i++) {
|
||||
run(x => (x + 19));
|
||||
run(x => (x - 18));
|
||||
}
|
||||
})();
|
||||
|
||||
(function testImportThrowsOnToNumber() {
|
||||
print(arguments.callee.name);
|
||||
const builder = new WasmModuleBuilder();
|
||||
const imp_idx = builder.addImport('mod', 'func', kSig_i_v);
|
||||
builder.addFunction('main', kSig_i_v)
|
||||
.addBody([kExprCallFunction, imp_idx])
|
||||
.exportFunc();
|
||||
var num_callback_calls = 0;
|
||||
const callback = () => {
|
||||
++num_callback_calls;
|
||||
return Symbol()
|
||||
};
|
||||
var instance = builder.instantiate({mod: {func: callback}});
|
||||
// Test that this does not mess up internal state by executing it three times.
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
var interpreted_before = %WasmNumInterpretedCalls(instance);
|
||||
assertThrows(
|
||||
() => instance.exports.main(), TypeError,
|
||||
'Cannot convert a Symbol value to a number');
|
||||
assertEquals(interpreted_before + 1, %WasmNumInterpretedCalls(instance));
|
||||
assertEquals(i + 1, num_callback_calls);
|
||||
}
|
||||
})();
|
||||
|
||||
(function testCallWithMoreReturnsThenParams() {
|
||||
print(arguments.callee.name);
|
||||
const builder1 = new WasmModuleBuilder();
|
||||
builder1.addFunction('exp', kSig_l_v)
|
||||
.addBody([kExprI64Const, 23])
|
||||
.exportFunc();
|
||||
const exp = builder1.instantiate().exports.exp;
|
||||
const builder2 = new WasmModuleBuilder();
|
||||
const imp_idx = builder2.addImport('imp', 'func', kSig_l_v);
|
||||
builder2.addFunction('main', kSig_i_v)
|
||||
.addBody([kExprCallFunction, imp_idx, kExprI32ConvertI64])
|
||||
.exportFunc();
|
||||
const instance = builder2.instantiate({imp: {func: exp}});
|
||||
assertEquals(23, instance.exports.main());
|
||||
})();
|
||||
|
||||
(function testTableCall() {
|
||||
print(arguments.callee.name);
|
||||
const builder1 = new WasmModuleBuilder();
|
||||
builder1.addFunction('func', kSig_v_v).addBody([]).exportFunc();
|
||||
const instance1 = builder1.instantiate();
|
||||
const table = new WebAssembly.Table({element: 'anyfunc', initial: 2});
|
||||
|
||||
const builder2 = new WasmModuleBuilder()
|
||||
builder2.addImportedTable('m', 'table');
|
||||
const sig = builder2.addType(kSig_v_v);
|
||||
builder2.addFunction('call_func', kSig_v_v)
|
||||
.addBody([kExprI32Const, 0, kExprCallIndirect, sig, kTableZero])
|
||||
.exportFunc();
|
||||
const instance2 = builder2.instantiate({m: {table: table}});
|
||||
table.set(0, instance1.exports.func);
|
||||
instance2.exports.call_func();
|
||||
})();
|
||||
|
||||
(function testTableCall2() {
|
||||
// See crbug.com/787910.
|
||||
print(arguments.callee.name);
|
||||
const builder1 = new WasmModuleBuilder();
|
||||
builder1.addFunction('exp', kSig_i_i)
|
||||
.addBody([kExprI32Const, 0])
|
||||
.exportFunc();
|
||||
const instance1 = builder1.instantiate();
|
||||
const builder2 = new WasmModuleBuilder();
|
||||
const sig1 = builder2.addType(kSig_i_v);
|
||||
const sig2 = builder2.addType(kSig_i_i);
|
||||
builder2.addFunction('call2', kSig_i_v)
|
||||
.addBody([
|
||||
kExprI32Const, 0, kExprI32Const, 0, kExprCallIndirect, sig2, kTableZero
|
||||
])
|
||||
.exportAs('call2');
|
||||
builder2.addImportedTable('imp', 'table');
|
||||
const tab = new WebAssembly.Table({
|
||||
element: 'anyfunc',
|
||||
initial: 3,
|
||||
});
|
||||
const instance2 = builder2.instantiate({imp: {table: tab}});
|
||||
tab.set(0, instance1.exports.exp);
|
||||
instance2.exports.call2();
|
||||
})();
|
||||
|
||||
(function testTableCall3() {
|
||||
// See crbug.com/814562.
|
||||
print(arguments.callee.name);
|
||||
const builder0 = new WasmModuleBuilder();
|
||||
const sig_index = builder0.addType(kSig_i_v);
|
||||
builder0.addFunction('main', kSig_i_i)
|
||||
.addBody([
|
||||
kExprLocalGet, 0, // --
|
||||
kExprCallIndirect, sig_index, kTableZero
|
||||
]) // --
|
||||
.exportAs('main');
|
||||
builder0.setTableBounds(3, 3);
|
||||
builder0.addExportOfKind('table', kExternalTable);
|
||||
const module0 = new WebAssembly.Module(builder0.toBuffer());
|
||||
const instance0 = new WebAssembly.Instance(module0);
|
||||
|
||||
const builder1 = new WasmModuleBuilder();
|
||||
builder1.addFunction('main', kSig_i_v).addBody([kExprUnreachable]);
|
||||
builder1.addImportedTable('z', 'table');
|
||||
builder1.addElementSegment(0, 0, false, [0]);
|
||||
const module1 = new WebAssembly.Module(builder1.toBuffer());
|
||||
const instance1 =
|
||||
new WebAssembly.Instance(module1, {z: {table: instance0.exports.table}});
|
||||
assertThrows(
|
||||
() => instance0.exports.main(0), WebAssembly.RuntimeError, 'unreachable');
|
||||
})();
|
||||
|
||||
(function testSerializeInterpreted() {
|
||||
print(arguments.callee.name);
|
||||
const builder = new WasmModuleBuilder();
|
||||
builder.addFunction('main', kSig_i_i)
|
||||
.addBody([kExprLocalGet, 0, kExprI32Const, 7, kExprI32Add])
|
||||
.exportFunc();
|
||||
|
||||
const wire_bytes = builder.toBuffer();
|
||||
var module = new WebAssembly.Module(wire_bytes);
|
||||
const i1 = new WebAssembly.Instance(module);
|
||||
|
||||
assertEquals(11, i1.exports.main(4));
|
||||
|
||||
const buff = %SerializeWasmModule(module);
|
||||
module = null;
|
||||
gc();
|
||||
|
||||
module = %DeserializeWasmModule(buff, wire_bytes);
|
||||
const i2 = new WebAssembly.Instance(module);
|
||||
|
||||
assertEquals(11, i2.exports.main(4));
|
||||
})();
|
@ -1,7 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Flags: --experimental-wasm-mv --wasm-interpret-all
|
||||
|
||||
load("test/mjsunit/wasm/multi-value.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2020 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-anyref -experimental-wasm-eh
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/nullref.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-anyref
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/table-access.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-anyref
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/table-fill.js");
|
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 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: --expose-wasm --experimental-wasm-anyref
|
||||
// Flags: --wasm-interpret-all
|
||||
|
||||
// This is just a wrapper for an existing reference types test case that runs
|
||||
// with the --wasm-interpret-all flag added. If we ever decide to add a test
|
||||
// variant for this, then we can remove this file.
|
||||
|
||||
load("test/mjsunit/wasm/table-grow-from-wasm.js");
|
Loading…
Reference in New Issue
Block a user