Commit 08e0ea38 authored by titzer's avatar titzer Committed by Commit bot

[wasm] Fix and enable more tests.

R=ahaas@chromium.org, bradnelson@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1846613002

Cr-Commit-Position: refs/heads/master@{#35156}
parent 454ab5dd
......@@ -869,26 +869,35 @@ void TestI64Cmp(WasmOpcode opcode, int64_t expected, int64_t a, int64_t b) {
} while (false)
TEST(Run_Wasm_I64Binops) {
// TODO(titzer): real 64-bit numbers
TEST_I64_BINOP(I64Add, 8888888888888LL, 3333333333333LL, 5555555555555LL);
TEST_I64_BINOP(I64Sub, -111111111111LL, 777777777777LL, 888888888888LL);
TEST_I64_BINOP(I64Mul, 65130756, 88734, 734);
TEST_I64_BINOP(I64Mul, 65130756, -88734, -734);
TEST_I64_BINOP(I64Mul, -65130756, -88734, 734);
TEST_I64_BINOP(I64DivS, -66, -4777344, 72384);
TEST_I64_BINOP(I64DivU, 805306368, 0xF0000000, 5);
TEST_I64_BINOP(I64RemS, -3, -3003, 1000);
TEST_I64_BINOP(I64RemU, 4, 4004, 1000);
TEST_I64_BINOP(I64And, 0xEE, 0xFFEE, 0xFF0000FF);
TEST_I64_BINOP(I64Ior, 0xF0FF00FF, 0xF0F000EE, 0x000F0011);
TEST_I64_BINOP(I64Xor, 0xABCDEF01, 0xABCDEFFF, 0xFE);
TEST_I64_BINOP(I64Shl, 0xA0000000, 0xA, 28);
TEST_I64_BINOP(I64ShrU, 0x0700001000123456LL, 0x7000010001234567LL, 4);
TEST_I64_BINOP(I64ShrS, 0xFF00000000000000LL, 0x8000000000000000LL, 7);
TEST_I64_BINOP(I64Ror, 0x0100000000000000LL, 0x8000000000000000LL, 7);
TEST_I64_BINOP(I64Ror, 0x0100000000000000LL, 0x8000000000000000LL, 71);
TEST_I64_BINOP(I64Rol, 0x0000000000000040LL, 0x8000000000000000LL, 7);
TEST_I64_BINOP(I64Rol, 0x0000000000000040LL, 0x8000000000000000LL, 71);
TEST_I64_BINOP(I64Add, -5586332274295447011, 0x501b72ebabc26847,
0x625de9793d8f79d6);
TEST_I64_BINOP(I64Sub, 9001903251710731490, 0xf24fe6474640002e,
0x7562b6f711991b4c);
TEST_I64_BINOP(I64Mul, -4569547818546064176, 0x231a263c2cbc6451,
0xead44de6bd3e23d0);
TEST_I64_BINOP(I64Mul, -25963122347507043, 0x4da1fa47c9352b73,
0x91fe82317aa035af);
TEST_I64_BINOP(I64Mul, 7640290486138131960, 0x185731abe8eea47c,
0x714ec59f1380d4c2);
TEST_I64_BINOP(I64DivS, -91517, 0x93b1190a34de56a0, 0x00004d8f68863948);
TEST_I64_BINOP(I64DivU, 149016, 0xe15b3727e8a2080a, 0x0000631bfa72db8b);
TEST_I64_BINOP(I64RemS, -664128064149968, 0x9a78b4e4fe708692,
0x0003e0b6b3be7609);
TEST_I64_BINOP(I64RemU, 1742040017332765, 0x0ce84708c6258c81,
0x000a6fde82016697);
TEST_I64_BINOP(I64And, 2531040582801836054, 0xaf257d1602644a16,
0x33b290a91a10d997);
TEST_I64_BINOP(I64Ior, 8556201506536114940, 0x169d9be7bd3f0a5c,
0x66bca28d77af40e8);
TEST_I64_BINOP(I64Xor, -4605655183785456377, 0xb6ea20a5d48e85b8,
0x76ff4da6c80688bf);
TEST_I64_BINOP(I64Shl, -7240704056088331264, 0xef4dc1ed030e8ffe, 9);
TEST_I64_BINOP(I64ShrU, 12500673744059159, 0xb1a52fa7deec5d14, 10);
TEST_I64_BINOP(I64ShrS, 1725103446999874, 0x3107c791461a112b, 11);
TEST_I64_BINOP(I64Ror, -8960135652432576946, 0x73418d1717e4e83a, 12);
TEST_I64_BINOP(I64Ror, 7617662827409989779, 0xebff67cf0c126d36, 13);
TEST_I64_BINOP(I64Rol, -2097714064174346012, 0x43938b8db0b0f230, 14);
TEST_I64_BINOP(I64Rol, 8728493013947314237, 0xe07af243ac4d219d, 15);
}
#define TEST_I64_CMP(name, expected, a, b) \
......@@ -897,17 +906,16 @@ TEST(Run_Wasm_I64Binops) {
} while (false)
TEST(Run_Wasm_I64Compare) {
// TODO(titzer): real 64-bit numbers
TEST_I64_CMP(I64Eq, 1, -9999, -9999);
TEST_I64_CMP(I64Ne, 1, -9199, -9999);
TEST_I64_CMP(I64LtS, 1, -4, 4);
TEST_I64_CMP(I64LeS, 0, -2, -3);
TEST_I64_CMP(I64LtU, 1, 0, -6);
TEST_I64_CMP(I64LeU, 1, 98978, 0xF0000000);
TEST_I64_CMP(I64GtS, 1, 4, -4);
TEST_I64_CMP(I64GeS, 0, -3, -2);
TEST_I64_CMP(I64GtU, 1, -6, 0);
TEST_I64_CMP(I64GeU, 1, 0xF0000000, 98978);
TEST_I64_CMP(I64Eq, 0, 0xB915D8FA494064F0, 0x04D700B2536019A3);
TEST_I64_CMP(I64Ne, 1, 0xC2FAFAAAB0446CDC, 0x52A3328F780C97A3);
TEST_I64_CMP(I64LtS, 0, 0x673636E6306B0578, 0x028EC9ECA78F7227);
TEST_I64_CMP(I64LeS, 1, 0xAE5214114B86A0FA, 0x7C1D21DA3DFD0CCF);
TEST_I64_CMP(I64LtU, 0, 0x7D52166381EC1CE0, 0x59F4A6A9E78CD3D8);
TEST_I64_CMP(I64LeU, 1, 0xE4169A385C7EA0E0, 0xFBDBED2C8781E5BC);
TEST_I64_CMP(I64GtS, 0, 0x9D08FF8FB5F42E81, 0xD4E5C9D7FE09F621);
TEST_I64_CMP(I64GeS, 1, 0x78DA3B2F73264E0F, 0x6FE5E2A67C501CBE);
TEST_I64_CMP(I64GtU, 0, 0x8F691284E44F7DA9, 0xD5EA9BC1EE149192);
TEST_I64_CMP(I64GeU, 0, 0x0886A0C58C7AA224, 0x5DDBE5A81FD7EE47);
}
TEST(Run_Wasm_I64Clz) {
......@@ -1102,7 +1110,7 @@ TEST(Run_WasmCall_Int64Sub) {
TEST(Run_Wasm_LoadStoreI64_sx) {
REQUIRE(I64LoadStore);
REQUIRE(DepthFirst); // TODO(titzer): temporary hack
REQUIRE(DepthFirst);
byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S,
kExprI64LoadMem};
......@@ -1288,7 +1296,7 @@ TEST(Run_Wasm_I64Global) {
REQUIRE(I64LoadStore);
REQUIRE(I64SConvertI32);
REQUIRE(I64And);
REQUIRE(DepthFirst); // TODO(titzer): temporary hack
REQUIRE(DepthFirst);
TestingModule module;
int64_t* global = module.AddGlobal<int64_t>(MachineType::Int64());
WasmRunner<int32_t> r(&module, MachineType::Int32());
......
......@@ -122,16 +122,6 @@ TEST(Run_WasmModule_ReadLoadedDataSegment) {
TestModule(writer->WriteTo(&zone), 0xddccbbaa);
}
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
#define V8_WITH_ASAN 1
#endif
#endif
#if !defined(V8_WITH_ASAN)
// TODO(bradnelson): Figure out why this crashes under asan.
TEST(Run_WasmModule_CheckMemoryIsZero) {
static const int kCheckSize = 16 * 1024;
Zone zone;
......@@ -153,11 +143,7 @@ TEST(Run_WasmModule_CheckMemoryIsZero) {
WasmModuleWriter* writer = builder->Build(&zone);
TestModule(writer->WriteTo(&zone), 11);
}
#endif
#if !defined(V8_WITH_ASAN)
// TODO(bradnelson): Figure out why this crashes under asan.
TEST(Run_WasmModule_CallMain_recursive) {
Zone zone;
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
......@@ -178,11 +164,7 @@ TEST(Run_WasmModule_CallMain_recursive) {
WasmModuleWriter* writer = builder->Build(&zone);
TestModule(writer->WriteTo(&zone), 55);
}
#endif
#if !defined(V8_WITH_ASAN)
// TODO(bradnelson): Figure out why this crashes under asan.
TEST(Run_WasmModule_Global) {
Zone zone;
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
......@@ -205,4 +187,3 @@ TEST(Run_WasmModule_Global) {
WasmModuleWriter* writer = builder->Build(&zone);
TestModule(writer->WriteTo(&zone), 97);
}
#endif
......@@ -2089,7 +2089,6 @@ TEST(Run_WasmCall_Float64Sub) {
double* memory = module.AddMemoryElems<double>(16);
WasmRunner<int32_t> r(&module);
// TODO(titzer): convert to a binop test.
BUILD(r, WASM_BLOCK(
2, WASM_STORE_MEM(
MachineType::Float64(), WASM_ZERO,
......
......@@ -443,7 +443,6 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
return result;
}
// TODO(titzer): remove me.
Handle<Code> Compile() {
InitializeDescriptor();
CallDescriptor* desc = descriptor_;
......@@ -463,7 +462,6 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
return result;
}
// TODO(titzer): remove me.
uint32_t CompileAndAdd(uint16_t sig_index = 0) {
CHECK(testing_module_);
function()->sig_index = sig_index;
......
......@@ -459,7 +459,6 @@ function TestFloatHeapAccess(stdlib, foreign, buffer) {
var j = 8;
var v = 6.0;
// TODO(bradnelson): Add float32 when asm-wasm supports it.
f64[2] = v + 1.0;
f64[i >> 3] = +f64[2] + 1.0;
f64[j >> 3] = +f64[j >> 3] + 1.0;
......@@ -587,9 +586,6 @@ function TestModDouble() {
assertWasm(28, TestModDouble);
/*
TODO: Fix parsing of negative doubles
Fix code to use trunc instead of casts
function TestModDoubleNegative() {
"use asm";
......@@ -606,8 +602,6 @@ function TestModDoubleNegative() {
}
assertWasm(28, TestModDoubleNegative);
*/
(function () {
function TestNamedFunctions() {
......@@ -1325,7 +1319,7 @@ assertWasm(1, TestXor);
var m = Wasm.instantiateModuleFromAsm(Module.toString());
assertEquals(3, m.func());
}); // TODO(bradnelson): Enable when Math.fround implementation lands.
})();
(function TestDoubleToFloatAssignment() {
......
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