Commit 9d6f96c1 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Prepare tests for flipping the wasm-bigint flag

We want to enable the wasm-bigint implementation by default. However,
at the moment there exist several tests which fail when wasm-bigint
gets enabled. With this CL we adjust or delete these tests so that they
pass once wasm-bigint gets enabled. At the same time we disable these
tests for now, and re-enable them in the CL that flips the flag.

R=jkummerow@chromium.org

Bug: v8:7741
Change-Id: I733bfe7ff19e403913b143e6ea86ab13602ab993
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2243212
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68328}
parent 3c0ca766
......@@ -127,37 +127,6 @@ WASM_COMPILED_EXEC_TEST(TryCatchCallExternal) {
r.CheckCallViaJS(kResult1, 1);
}
WASM_COMPILED_EXEC_TEST(TryCatchTrapTypeError) {
TestSignatures sigs;
EXPERIMENTAL_FLAG_SCOPE(eh);
HandleScope scope(CcTest::InitIsolateOnce());
const char* source = "(function() { return 0; })";
Handle<JSFunction> js_function =
Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(source))));
// Make sure to use a signature incompatible with JS below.
ManuallyImportedJSFunction import = {sigs.i_ll(), js_function};
WasmRunner<uint32_t, uint32_t> r(execution_tier, &import);
constexpr uint32_t kResult0 = 23;
constexpr uint32_t kResult1 = 42;
constexpr uint32_t kJSFunc = 0;
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(
WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_GET_LOCAL(0)),
WASM_STMTS(WASM_CALL_FUNCTION(kJSFunc, WASM_I64V(7),
WASM_I64V(9)),
WASM_DROP))),
WASM_STMTS(WASM_DROP, WASM_I32V(kResult0))));
// Need to call through JS to allow for creation of stack traces.
r.CheckCallViaJS(kResult0, 0);
r.CheckCallViaJS(kResult1, 1);
}
namespace {
void TestTrapNotCaught(byte* code, size_t code_size,
......
......@@ -73,6 +73,14 @@
# Enable once multi-byte prefixed opcodes are correctly handled
'regress/wasm/regress-1065599': [SKIP],
# https://crbug.com/v8/7741
# These tests fail at the moment because we already prepared them to switch
# the wasm-bigint flag. Once we flip the flag, we can enable them again.
'wasm/ffi-error': [FAIL],
'wasm/type-reflection': [FAIL],
'wasm/globals': [FAIL],
##############################################################################
# Tests where variants make no sense.
'd8/enable-tracing': [PASS, NO_VARIANTS],
......
......@@ -155,27 +155,6 @@ function import_error(index, module, func, msg) {
assertTraps(kTrapUnreachable, () => b.instantiate());
})();
(function TestConversionError() {
print(arguments.callee.name);
let b = builder();
b.addImport('foo', 'bar', kSig_v_l);
let buffer = b.addFunction('run', kSig_v_v)
.addBody([kExprI64Const, 0, kExprCallFunction, 0])
.exportFunc()
.end()
.toBuffer();
assertConversionError(
buffer, {foo: {bar: (l) => {}}}, kTrapMsgs[kTrapTypeError]);
buffer = builder()
.addFunction('run', kSig_l_v)
.addBody([kExprI64Const, 0])
.exportFunc()
.end()
.toBuffer();
assertConversionError(buffer, {}, kTrapMsgs[kTrapTypeError]);
})();
(function InternalDebugTrace() {
print(arguments.callee.name);
var builder = new WasmModuleBuilder();
......
......@@ -119,7 +119,7 @@ function checkFailingInstantiation(
instance => assertEquals(33, instance.exports.main()));
})();
(function I64InSignatureThrows() {
(function I64InSignature() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
......@@ -133,12 +133,11 @@ function checkFailingInstantiation(
checkSuccessfulInstantiation(
builder, undefined,
instance => assertThrows(function() {
instance.exports.function_with_invalid_signature(33, 88);
}, TypeError, 'wasm function signature contains illegal type'));
instance => assertEquals(
instance.exports.function_with_invalid_signature(33n, 88n), -55n));
})();
(function I64ParamsInSignatureThrows() {
(function I64ParamsInSignature() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
......@@ -149,13 +148,12 @@ function checkFailingInstantiation(
checkSuccessfulInstantiation(
builder, undefined,
instance => assertThrows(
_ => instance.exports.function_with_invalid_signature(12), TypeError,
'wasm function signature contains illegal type'));
instance => assertEquals(12,
instance.exports.function_with_invalid_signature(12n)));
})();
(function I64JSImportThrows() {
(function I64JSImport() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let sig_index = builder.addType(kSig_i_i);
......@@ -169,13 +167,11 @@ function checkFailingInstantiation(
checkSuccessfulInstantiation(
builder, {'': {func: _ => {}}},
instance => assertThrows(
instance.exports.main, TypeError,
'wasm function signature contains illegal type'));
instance => assertEquals(0, instance.exports.main(1)));
})();
(function ImportI64ParamWithF64ReturnThrows() {
(function ImportI64ParamWithF64Return() {
print(arguments.callee.name);
// This tests that we generate correct code by using the correct return
// register. See bug 6096.
......@@ -186,11 +182,8 @@ function checkFailingInstantiation(
.exportFunc();
checkSuccessfulInstantiation(
builder, {'': {f: i => i}},
instance => assertThrows(
instance.exports.main, TypeError,
'wasm function signature contains illegal type'));
builder, {'': {f: i => Number(i)}},
instance => assertDoesNotThrow(instance.exports.main));
})();
(function ImportI64Return() {
......@@ -204,11 +197,8 @@ function checkFailingInstantiation(
.exportFunc();
checkSuccessfulInstantiation(
builder, {'': {f: _ => 1}},
instance => assertThrows(
instance.exports.main, TypeError,
'wasm function signature contains illegal type'));
builder, {'': {f: _ => 1n}},
instance => assertDoesNotThrow(instance.exports.main));
})();
(function ImportSymbolToNumberThrows() {
......
......@@ -119,7 +119,7 @@ TestExported(kWasmF64, 87347.66666, 87347.66666);
var instance = builder.instantiate();
assertTrue(instance.exports.foo instanceof WebAssembly.Global);
assertThrows(() => {instance.exports.foo.value}, TypeError);
assertEquals(instance.exports.foo.value, 1234n);
})();
function TestImportedExported(type, val, expected) {
......
......@@ -943,13 +943,6 @@ assertInstantiateSuccess(
assertTrue(instance instanceof Instance);
})();
(function TestPassBigIntInGlobalWhenNotEnabled() {
assertThrows(() => new WebAssembly.Global({ value: "i64" }, 1), TypeError,
/Can't set the value/);
assertThrows(() => new WebAssembly.Global({ value: "i64" }, 1n), TypeError,
/Can't set the value/);
})();
(function TestAccessorFunctions() {
function testAccessorFunction(obj, prop, accessor) {
var desc = Object.getOwnPropertyDescriptor(obj, prop);
......
......@@ -549,12 +549,6 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
});
})();
(function TestFunctionConstructedIncompatibleSig() {
let fun = new WebAssembly.Function({parameters:["i64"], results:[]}, _ => 0);
assertThrows(() => fun(), TypeError,
/wasm function signature contains illegal type/);
})();
(function TestFunctionTableSetAndCall() {
let builder = new WasmModuleBuilder();
let fun1 = new WebAssembly.Function({parameters:[], results:["i32"]}, _ => 7);
......@@ -578,9 +572,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
assertTraps(kTrapFuncSigMismatch, () => instance.exports.main(1));
})();
(function TestFunctionTableSetIncompatibleSig() {
(function TestFunctionTableSetI64() {
let builder = new WasmModuleBuilder();
let fun = new WebAssembly.Function({parameters:[], results:["i64"]}, _ => 0);
let fun = new WebAssembly.Function({parameters:[], results:["i64"]}, _ => 0n);
let table = new WebAssembly.Table({element: "anyfunc", initial: 2});
let table_index = builder.addImportedTable("m", "table", 2);
let sig_index = builder.addType(kSig_l_v);
......@@ -593,14 +587,10 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
])
.exportFunc();
let instance = builder.instantiate({ m: { table: table }});
assertThrows(
() => instance.exports.main(0), TypeError,
/wasm function signature contains illegal type/);
assertDoesNotThrow(() => instance.exports.main(0));
assertTraps(kTrapFuncSigMismatch, () => instance.exports.main(1));
table.set(1, fun);
assertThrows(
() => instance.exports.main(1), TypeError,
/wasm function signature contains illegal type/);
assertDoesNotThrow(() => instance.exports.main(1));
})();
(function TestFunctionModuleImportMatchingSig() {
......
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