Commit f0d69fc9 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[test] Modernize value helpers

This CL changes the usage pattern from
FOR_XXX_VALUES(i) { Use(*i); }
to
FOR_XXX_VALUES(i) { Use(i); }
which is way more intuitive.

Note that the replacement in the uses was done via regular expression,
so it's purely mechanical. In two locations I removed unneeded braces
around the macro, because they confused clang-format.
I plan to do more cleanups (remove redundant assignments within the
FOR_XXX_VALUES body) in a follow-up CL.

R=mstarzinger@chromium.org

Bug: v8:8562
Change-Id: I4329bfcf34e5b077d19b50f4204ceb3b4340fe61
Reviewed-on: https://chromium-review.googlesource.com/c/1449615
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59287}
parent 7ab09b39
...@@ -22,27 +22,23 @@ TEST(CompareWrapper) { ...@@ -22,27 +22,23 @@ TEST(CompareWrapper) {
CompareWrapper wUint32LessThan(IrOpcode::kUint32LessThan); CompareWrapper wUint32LessThan(IrOpcode::kUint32LessThan);
CompareWrapper wUint32LessThanOrEqual(IrOpcode::kUint32LessThanOrEqual); CompareWrapper wUint32LessThanOrEqual(IrOpcode::kUint32LessThanOrEqual);
{ FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pr) {
FOR_INT32_INPUTS(pr) { int32_t a = pl;
int32_t a = *pl; int32_t b = pr;
int32_t b = *pr; CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b));
CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b)); CHECK_EQ(a < b, wInt32LessThan.Int32Compare(a, b));
CHECK_EQ(a < b, wInt32LessThan.Int32Compare(a, b)); CHECK_EQ(a <= b, wInt32LessThanOrEqual.Int32Compare(a, b));
CHECK_EQ(a <= b, wInt32LessThanOrEqual.Int32Compare(a, b));
}
} }
} }
{ FOR_UINT32_INPUTS(pl) {
FOR_UINT32_INPUTS(pl) { FOR_UINT32_INPUTS(pr) {
FOR_UINT32_INPUTS(pr) { uint32_t a = pl;
uint32_t a = *pl; uint32_t b = pr;
uint32_t b = *pr; CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b));
CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b)); CHECK_EQ(a < b, wUint32LessThan.Int32Compare(a, b));
CHECK_EQ(a < b, wUint32LessThan.Int32Compare(a, b)); CHECK_EQ(a <= b, wUint32LessThanOrEqual.Int32Compare(a, b));
CHECK_EQ(a <= b, wUint32LessThanOrEqual.Int32Compare(a, b));
}
} }
} }
...@@ -338,8 +334,8 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { ...@@ -338,8 +334,8 @@ void Int32BinopInputShapeTester::TestAllInputShapes() {
void Int32BinopInputShapeTester::Run(RawMachineAssemblerTester<int32_t>* m) { void Int32BinopInputShapeTester::Run(RawMachineAssemblerTester<int32_t>* m) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
input_a = *pl; input_a = pl;
input_b = *pr; input_b = pr;
int32_t expect = gen->expected(input_a, input_b); int32_t expect = gen->expected(input_a, input_b);
CHECK_EQ(expect, m->Call(input_a, input_b)); CHECK_EQ(expect, m->Call(input_a, input_b));
} }
...@@ -350,7 +346,7 @@ void Int32BinopInputShapeTester::Run(RawMachineAssemblerTester<int32_t>* m) { ...@@ -350,7 +346,7 @@ void Int32BinopInputShapeTester::Run(RawMachineAssemblerTester<int32_t>* m) {
void Int32BinopInputShapeTester::RunLeft( void Int32BinopInputShapeTester::RunLeft(
RawMachineAssemblerTester<int32_t>* m) { RawMachineAssemblerTester<int32_t>* m) {
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
input_a = *i; input_a = i;
int32_t expect = gen->expected(input_a, input_b); int32_t expect = gen->expected(input_a, input_b);
CHECK_EQ(expect, m->Call(input_a, input_b)); CHECK_EQ(expect, m->Call(input_a, input_b));
} }
...@@ -360,7 +356,7 @@ void Int32BinopInputShapeTester::RunLeft( ...@@ -360,7 +356,7 @@ void Int32BinopInputShapeTester::RunLeft(
void Int32BinopInputShapeTester::RunRight( void Int32BinopInputShapeTester::RunRight(
RawMachineAssemblerTester<int32_t>* m) { RawMachineAssemblerTester<int32_t>* m) {
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
input_b = *i; input_b = i;
int32_t expect = gen->expected(input_a, input_b); int32_t expect = gen->expected(input_a, input_b);
CHECK_EQ(expect, m->Call(input_a, input_b)); CHECK_EQ(expect, m->Call(input_a, input_b));
} }
...@@ -414,8 +410,8 @@ TEST(RunEmpty) { ...@@ -414,8 +410,8 @@ TEST(RunEmpty) {
TEST(RunInt32Constants) { TEST(RunInt32Constants) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
m.Return(m.Int32Constant(*i)); m.Return(m.Int32Constant(i));
CHECK_EQ(*i, m.Call()); CHECK_EQ(i, m.Call());
} }
} }
...@@ -435,17 +431,12 @@ TEST(RunSmiConstants) { ...@@ -435,17 +431,12 @@ TEST(RunSmiConstants) {
RunSmiConstant(Smi::kMinValue); RunSmiConstant(Smi::kMinValue);
RunSmiConstant(Smi::kMinValue + 1); RunSmiConstant(Smi::kMinValue + 1);
FOR_INT32_INPUTS(i) { RunSmiConstant(*i); } FOR_INT32_INPUTS(i) { RunSmiConstant(i); }
} }
TEST(RunNumberConstants) { TEST(RunNumberConstants) {
{ FOR_FLOAT64_INPUTS(i) { RunNumberConstant(i); }
FOR_FLOAT64_INPUTS(i) { RunNumberConstant(*i); } FOR_INT32_INPUTS(i) { RunNumberConstant(i); }
}
{
FOR_INT32_INPUTS(i) { RunNumberConstant(*i); }
}
for (int32_t i = 1; i < Smi::kMaxValue && i != 0; for (int32_t i = 1; i < Smi::kMaxValue && i != 0;
i = base::ShlWithWraparound(i, 1)) { i = base::ShlWithWraparound(i, 1)) {
...@@ -460,7 +451,6 @@ TEST(RunNumberConstants) { ...@@ -460,7 +451,6 @@ TEST(RunNumberConstants) {
RunNumberConstant(Smi::kMinValue + 1); RunNumberConstant(Smi::kMinValue + 1);
} }
TEST(RunEmptyString) { TEST(RunEmptyString) {
RawMachineAssemblerTester<Object> m; RawMachineAssemblerTester<Object> m;
m.Return(m.StringConstant("empty")); m.Return(m.StringConstant("empty"));
...@@ -490,8 +480,8 @@ TEST(RunParam1) { ...@@ -490,8 +480,8 @@ TEST(RunParam1) {
m.Return(m.Parameter(0)); m.Return(m.Parameter(0));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t result = m.Call(*i); int32_t result = m.Call(i);
CHECK_EQ(*i, result); CHECK_EQ(i, result);
} }
} }
...@@ -505,8 +495,8 @@ TEST(RunParam2_1) { ...@@ -505,8 +495,8 @@ TEST(RunParam2_1) {
USE(p1); USE(p1);
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t result = m.Call(*i, -9999); int32_t result = m.Call(i, -9999);
CHECK_EQ(*i, result); CHECK_EQ(i, result);
} }
} }
...@@ -520,8 +510,8 @@ TEST(RunParam2_2) { ...@@ -520,8 +510,8 @@ TEST(RunParam2_2) {
USE(p0); USE(p0);
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t result = m.Call(-7777, *i); int32_t result = m.Call(-7777, i);
CHECK_EQ(*i, result); CHECK_EQ(i, result);
} }
} }
...@@ -535,9 +525,9 @@ TEST(RunParam3) { ...@@ -535,9 +525,9 @@ TEST(RunParam3) {
int p[] = {-99, -77, -88}; int p[] = {-99, -77, -88};
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
p[i] = *j; p[i] = j;
int32_t result = m.Call(p[0], p[1], p[2]); int32_t result = m.Call(p[0], p[1], p[2]);
CHECK_EQ(*j, result); CHECK_EQ(j, result);
} }
} }
} }
...@@ -549,7 +539,7 @@ TEST(RunBinopTester) { ...@@ -549,7 +539,7 @@ TEST(RunBinopTester) {
Int32BinopTester bt(&m); Int32BinopTester bt(&m);
bt.AddReturn(bt.param0); bt.AddReturn(bt.param0);
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, bt.call(*i, 777)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, bt.call(i, 777)); }
} }
{ {
...@@ -557,7 +547,7 @@ TEST(RunBinopTester) { ...@@ -557,7 +547,7 @@ TEST(RunBinopTester) {
Int32BinopTester bt(&m); Int32BinopTester bt(&m);
bt.AddReturn(bt.param1); bt.AddReturn(bt.param1);
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, bt.call(666, *i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, bt.call(666, i)); }
} }
{ {
...@@ -565,7 +555,7 @@ TEST(RunBinopTester) { ...@@ -565,7 +555,7 @@ TEST(RunBinopTester) {
Float64BinopTester bt(&m); Float64BinopTester bt(&m);
bt.AddReturn(bt.param0); bt.AddReturn(bt.param0);
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, bt.call(*i, 9.0)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, bt.call(i, 9.0)); }
} }
{ {
...@@ -573,7 +563,7 @@ TEST(RunBinopTester) { ...@@ -573,7 +563,7 @@ TEST(RunBinopTester) {
Float64BinopTester bt(&m); Float64BinopTester bt(&m);
bt.AddReturn(bt.param1); bt.AddReturn(bt.param1);
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, bt.call(-11.25, *i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, bt.call(-11.25, i)); }
} }
} }
...@@ -603,7 +593,7 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -603,7 +593,7 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
{ {
BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
m.Return(m.Parameter(0)); m.Return(m.Parameter(0));
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, m.Call(*i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, m.Call(i)); }
} }
{ {
BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Int64(), BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Int64(),
...@@ -611,8 +601,8 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -611,8 +601,8 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
m.Return(m.Int64Add(m.Parameter(0), m.Parameter(1))); m.Return(m.Int64Add(m.Parameter(0), m.Parameter(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(base::AddWithWraparound(*i, *j), m.Call(*i, *j)); CHECK_EQ(base::AddWithWraparound(i, j), m.Call(i, j));
CHECK_EQ(base::AddWithWraparound(*j, *i), m.Call(*j, *i)); CHECK_EQ(base::AddWithWraparound(j, i), m.Call(j, i));
} }
} }
} }
...@@ -623,9 +613,9 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -623,9 +613,9 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); m.Int64Add(m.Int64Add(m.Parameter(0), m.Parameter(1)), m.Parameter(2)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(Add3(*i, *i, *j), m.Call(*i, *i, *j)); CHECK_EQ(Add3(i, i, j), m.Call(i, i, j));
CHECK_EQ(Add3(*i, *j, *i), m.Call(*i, *j, *i)); CHECK_EQ(Add3(i, j, i), m.Call(i, j, i));
CHECK_EQ(Add3(*j, *i, *i), m.Call(*j, *i, *i)); CHECK_EQ(Add3(j, i, i), m.Call(j, i, i));
} }
} }
} }
...@@ -638,10 +628,10 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -638,10 +628,10 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
m.Parameter(3))); m.Parameter(3)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(Add4(*i, *i, *i, *j), m.Call(*i, *i, *i, *j)); CHECK_EQ(Add4(i, i, i, j), m.Call(i, i, i, j));
CHECK_EQ(Add4(*i, *i, *j, *i), m.Call(*i, *i, *j, *i)); CHECK_EQ(Add4(i, i, j, i), m.Call(i, i, j, i));
CHECK_EQ(Add4(*i, *j, *i, *i), m.Call(*i, *j, *i, *i)); CHECK_EQ(Add4(i, j, i, i), m.Call(i, j, i, i));
CHECK_EQ(Add4(*j, *i, *i, *i), m.Call(*j, *i, *i, *i)); CHECK_EQ(Add4(j, i, i, i), m.Call(j, i, i, i));
} }
} }
} }
...@@ -662,8 +652,8 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -662,8 +652,8 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
m.PointerConstant(&result), m.Parameter(0), kNoWriteBarrier); m.PointerConstant(&result), m.Parameter(0), kNoWriteBarrier);
m.Return(m.Int32Constant(0)); m.Return(m.Int32Constant(0));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
m.Call(*i); m.Call(i);
CHECK_DOUBLE_EQ(*i, result); CHECK_DOUBLE_EQ(i, result);
} }
} }
{ {
...@@ -676,11 +666,11 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -676,11 +666,11 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
m.Return(m.Int32Constant(0)); m.Return(m.Int32Constant(0));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
m.Call(*i, *j); m.Call(i, j);
CHECK_EQ(base::AddWithWraparound(*i, *j), result); CHECK_EQ(base::AddWithWraparound(i, j), result);
m.Call(*j, *i); m.Call(j, i);
CHECK_EQ(base::AddWithWraparound(*j, *i), result); CHECK_EQ(base::AddWithWraparound(j, i), result);
} }
} }
} }
...@@ -695,14 +685,14 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -695,14 +685,14 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
m.Return(m.Int32Constant(0)); m.Return(m.Int32Constant(0));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
m.Call(*i, *i, *j); m.Call(i, i, j);
CHECK_EQ(Add3(*i, *i, *j), result); CHECK_EQ(Add3(i, i, j), result);
m.Call(*i, *j, *i); m.Call(i, j, i);
CHECK_EQ(Add3(*i, *j, *i), result); CHECK_EQ(Add3(i, j, i), result);
m.Call(*j, *i, *i); m.Call(j, i, i);
CHECK_EQ(Add3(*j, *i, *i), result); CHECK_EQ(Add3(j, i, i), result);
} }
} }
} }
...@@ -720,17 +710,17 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) { ...@@ -720,17 +710,17 @@ TEST(RunBufferedRawMachineAssemblerTesterTester) {
m.Return(m.Int32Constant(0)); m.Return(m.Int32Constant(0));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
m.Call(*i, *i, *i, *j); m.Call(i, i, i, j);
CHECK_EQ(Add4(*i, *i, *i, *j), result); CHECK_EQ(Add4(i, i, i, j), result);
m.Call(*i, *i, *j, *i); m.Call(i, i, j, i);
CHECK_EQ(Add4(*i, *i, *j, *i), result); CHECK_EQ(Add4(i, i, j, i), result);
m.Call(*i, *j, *i, *i); m.Call(i, j, i, i);
CHECK_EQ(Add4(*i, *j, *i, *i), result); CHECK_EQ(Add4(i, j, i, i), result);
m.Call(*j, *i, *i, *i); m.Call(j, i, i, i);
CHECK_EQ(Add4(*j, *i, *i, *i), result); CHECK_EQ(Add4(j, i, i, i), result);
} }
} }
} }
......
...@@ -33,7 +33,7 @@ TEST(BranchCombineWord32EqualZero_1) { ...@@ -33,7 +33,7 @@ TEST(BranchCombineWord32EqualZero_1) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t a = *i; int32_t a = i;
int32_t expect = a == 0 ? eq_constant : ne_constant; int32_t expect = a == 0 ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(a)); CHECK_EQ(expect, m.Call(a));
} }
...@@ -60,7 +60,7 @@ TEST(BranchCombineWord32EqualZero_chain) { ...@@ -60,7 +60,7 @@ TEST(BranchCombineWord32EqualZero_chain) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t a = *i; int32_t a = i;
int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant) int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant)
: (a == 0 ? ne_constant : eq_constant); : (a == 0 ? ne_constant : eq_constant);
CHECK_EQ(expect, m.Call(a)); CHECK_EQ(expect, m.Call(a));
...@@ -84,7 +84,7 @@ TEST(BranchCombineInt32LessThanZero_1) { ...@@ -84,7 +84,7 @@ TEST(BranchCombineInt32LessThanZero_1) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t a = *i; int32_t a = i;
int32_t expect = a < 0 ? eq_constant : ne_constant; int32_t expect = a < 0 ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(a)); CHECK_EQ(expect, m.Call(a));
} }
...@@ -106,7 +106,7 @@ TEST(BranchCombineUint32LessThan100_1) { ...@@ -106,7 +106,7 @@ TEST(BranchCombineUint32LessThan100_1) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t a = *i; uint32_t a = i;
int32_t expect = a < 100 ? eq_constant : ne_constant; int32_t expect = a < 100 ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(a)); CHECK_EQ(expect, m.Call(a));
} }
...@@ -128,7 +128,7 @@ TEST(BranchCombineUint32LessThanOrEqual100_1) { ...@@ -128,7 +128,7 @@ TEST(BranchCombineUint32LessThanOrEqual100_1) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t a = *i; uint32_t a = i;
int32_t expect = a <= 100 ? eq_constant : ne_constant; int32_t expect = a <= 100 ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(a)); CHECK_EQ(expect, m.Call(a));
} }
...@@ -150,7 +150,7 @@ TEST(BranchCombineZeroLessThanInt32_1) { ...@@ -150,7 +150,7 @@ TEST(BranchCombineZeroLessThanInt32_1) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t a = *i; int32_t a = i;
int32_t expect = 0 < a ? eq_constant : ne_constant; int32_t expect = 0 < a ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(a)); CHECK_EQ(expect, m.Call(a));
} }
...@@ -172,7 +172,7 @@ TEST(BranchCombineInt32GreaterThanZero_1) { ...@@ -172,7 +172,7 @@ TEST(BranchCombineInt32GreaterThanZero_1) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t a = *i; int32_t a = i;
int32_t expect = a > 0 ? eq_constant : ne_constant; int32_t expect = a > 0 ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(a)); CHECK_EQ(expect, m.Call(a));
} }
...@@ -197,8 +197,8 @@ TEST(BranchCombineWord32EqualP) { ...@@ -197,8 +197,8 @@ TEST(BranchCombineWord32EqualP) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = a == b ? eq_constant : ne_constant; int32_t expect = a == b ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -213,7 +213,7 @@ TEST(BranchCombineWord32EqualI) { ...@@ -213,7 +213,7 @@ TEST(BranchCombineWord32EqualI) {
for (int left = 0; left < 2; left++) { for (int left = 0; left < 2; left++) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
int32_t a = *i; int32_t a = i;
Node* p0 = m.Int32Constant(a); Node* p0 = m.Int32Constant(a);
Node* p1 = m.Parameter(0); Node* p1 = m.Parameter(0);
...@@ -227,7 +227,7 @@ TEST(BranchCombineWord32EqualI) { ...@@ -227,7 +227,7 @@ TEST(BranchCombineWord32EqualI) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t b = *j; int32_t b = j;
int32_t expect = a == b ? eq_constant : ne_constant; int32_t expect = a == b ? eq_constant : ne_constant;
CHECK_EQ(expect, m.Call(b)); CHECK_EQ(expect, m.Call(b));
} }
...@@ -256,8 +256,8 @@ TEST(BranchCombineInt32CmpP) { ...@@ -256,8 +256,8 @@ TEST(BranchCombineInt32CmpP) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = 0; int32_t expect = 0;
if (op == 0) expect = a < b ? eq_constant : ne_constant; if (op == 0) expect = a < b ? eq_constant : ne_constant;
if (op == 1) expect = a <= b ? eq_constant : ne_constant; if (op == 1) expect = a <= b ? eq_constant : ne_constant;
...@@ -275,7 +275,7 @@ TEST(BranchCombineInt32CmpI) { ...@@ -275,7 +275,7 @@ TEST(BranchCombineInt32CmpI) {
for (int op = 0; op < 2; op++) { for (int op = 0; op < 2; op++) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
int32_t a = *i; int32_t a = i;
Node* p0 = m.Int32Constant(a); Node* p0 = m.Int32Constant(a);
Node* p1 = m.Parameter(0); Node* p1 = m.Parameter(0);
...@@ -288,7 +288,7 @@ TEST(BranchCombineInt32CmpI) { ...@@ -288,7 +288,7 @@ TEST(BranchCombineInt32CmpI) {
m.Return(m.Int32Constant(ne_constant)); m.Return(m.Int32Constant(ne_constant));
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t b = *j; int32_t b = j;
int32_t expect = 0; int32_t expect = 0;
if (op == 0) expect = a < b ? eq_constant : ne_constant; if (op == 0) expect = a < b ? eq_constant : ne_constant;
if (op == 1) expect = a <= b ? eq_constant : ne_constant; if (op == 1) expect = a <= b ? eq_constant : ne_constant;
...@@ -500,8 +500,8 @@ TEST(BranchCombineInt32AddLessThanZero) { ...@@ -500,8 +500,8 @@ TEST(BranchCombineInt32AddLessThanZero) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = int32_t expect =
(base::AddWithWraparound(a, b) < 0) ? t_constant : f_constant; (base::AddWithWraparound(a, b) < 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
...@@ -529,8 +529,8 @@ TEST(BranchCombineInt32AddGreaterThanOrEqualZero) { ...@@ -529,8 +529,8 @@ TEST(BranchCombineInt32AddGreaterThanOrEqualZero) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = int32_t expect =
(base::AddWithWraparound(a, b) >= 0) ? t_constant : f_constant; (base::AddWithWraparound(a, b) >= 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
...@@ -558,8 +558,8 @@ TEST(BranchCombineInt32ZeroGreaterThanAdd) { ...@@ -558,8 +558,8 @@ TEST(BranchCombineInt32ZeroGreaterThanAdd) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = int32_t expect =
(0 > base::AddWithWraparound(a, b)) ? t_constant : f_constant; (0 > base::AddWithWraparound(a, b)) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
...@@ -587,8 +587,8 @@ TEST(BranchCombineInt32ZeroLessThanOrEqualAdd) { ...@@ -587,8 +587,8 @@ TEST(BranchCombineInt32ZeroLessThanOrEqualAdd) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = int32_t expect =
(0 <= base::AddWithWraparound(a, b)) ? t_constant : f_constant; (0 <= base::AddWithWraparound(a, b)) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
...@@ -616,8 +616,8 @@ TEST(BranchCombineUint32AddLessThanOrEqualZero) { ...@@ -616,8 +616,8 @@ TEST(BranchCombineUint32AddLessThanOrEqualZero) {
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = (a + b <= 0) ? t_constant : f_constant; int32_t expect = (a + b <= 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -644,8 +644,8 @@ TEST(BranchCombineUint32AddGreaterThanZero) { ...@@ -644,8 +644,8 @@ TEST(BranchCombineUint32AddGreaterThanZero) {
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = (a + b > 0) ? t_constant : f_constant; int32_t expect = (a + b > 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -672,8 +672,8 @@ TEST(BranchCombineUint32ZeroGreaterThanOrEqualAdd) { ...@@ -672,8 +672,8 @@ TEST(BranchCombineUint32ZeroGreaterThanOrEqualAdd) {
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = (0 >= a + b) ? t_constant : f_constant; int32_t expect = (0 >= a + b) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -700,8 +700,8 @@ TEST(BranchCombineUint32ZeroLessThanAdd) { ...@@ -700,8 +700,8 @@ TEST(BranchCombineUint32ZeroLessThanAdd) {
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = (0 < a + b) ? t_constant : f_constant; int32_t expect = (0 < a + b) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -728,8 +728,8 @@ TEST(BranchCombineWord32AndLessThanZero) { ...@@ -728,8 +728,8 @@ TEST(BranchCombineWord32AndLessThanZero) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = ((a & b) < 0) ? t_constant : f_constant; int32_t expect = ((a & b) < 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -756,8 +756,8 @@ TEST(BranchCombineWord32AndGreaterThanOrEqualZero) { ...@@ -756,8 +756,8 @@ TEST(BranchCombineWord32AndGreaterThanOrEqualZero) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = ((a & b) >= 0) ? t_constant : f_constant; int32_t expect = ((a & b) >= 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -784,8 +784,8 @@ TEST(BranchCombineInt32ZeroGreaterThanAnd) { ...@@ -784,8 +784,8 @@ TEST(BranchCombineInt32ZeroGreaterThanAnd) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = (0 > (a & b)) ? t_constant : f_constant; int32_t expect = (0 > (a & b)) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -812,8 +812,8 @@ TEST(BranchCombineInt32ZeroLessThanOrEqualAnd) { ...@@ -812,8 +812,8 @@ TEST(BranchCombineInt32ZeroLessThanOrEqualAnd) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t a = *i; int32_t a = i;
int32_t b = *j; int32_t b = j;
int32_t expect = (0 <= (a & b)) ? t_constant : f_constant; int32_t expect = (0 <= (a & b)) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -840,8 +840,8 @@ TEST(BranchCombineUint32AndLessThanOrEqualZero) { ...@@ -840,8 +840,8 @@ TEST(BranchCombineUint32AndLessThanOrEqualZero) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = ((a & b) <= 0) ? t_constant : f_constant; int32_t expect = ((a & b) <= 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -868,8 +868,8 @@ TEST(BranchCombineUint32AndGreaterThanZero) { ...@@ -868,8 +868,8 @@ TEST(BranchCombineUint32AndGreaterThanZero) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = ((a & b) > 0) ? t_constant : f_constant; int32_t expect = ((a & b) > 0) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -896,8 +896,8 @@ TEST(BranchCombineUint32ZeroGreaterThanOrEqualAnd) { ...@@ -896,8 +896,8 @@ TEST(BranchCombineUint32ZeroGreaterThanOrEqualAnd) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = (0 >= (a & b)) ? t_constant : f_constant; int32_t expect = (0 >= (a & b)) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
...@@ -924,8 +924,8 @@ TEST(BranchCombineUint32ZeroLessThanAnd) { ...@@ -924,8 +924,8 @@ TEST(BranchCombineUint32ZeroLessThanAnd) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
uint32_t a = *i; uint32_t a = i;
uint32_t b = *j; uint32_t b = j;
int32_t expect = (0 < (a & b)) ? t_constant : f_constant; int32_t expect = (0 < (a & b)) ? t_constant : f_constant;
CHECK_EQ(expect, m.Call(a, b)); CHECK_EQ(expect, m.Call(a, b));
} }
......
...@@ -167,9 +167,9 @@ TEST(CanonicalizingNumbers) { ...@@ -167,9 +167,9 @@ TEST(CanonicalizingNumbers) {
JSConstantCacheTester T; JSConstantCacheTester T;
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
Node* node = T.Constant(*i); Node* node = T.Constant(i);
for (int j = 0; j < 5; j++) { for (int j = 0; j < 5; j++) {
CHECK_EQ(node, T.Constant(*i)); CHECK_EQ(node, T.Constant(i));
} }
} }
} }
...@@ -179,7 +179,7 @@ TEST(HeapNumbers) { ...@@ -179,7 +179,7 @@ TEST(HeapNumbers) {
JSConstantCacheTester T; JSConstantCacheTester T;
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
double value = *i; double value = i;
Handle<Object> num = T.factory()->NewNumber(value); Handle<Object> num = T.factory()->NewNumber(value);
Handle<HeapNumber> heap = T.factory()->NewHeapNumber(value); Handle<HeapNumber> heap = T.factory()->NewHeapNumber(value);
Node* node1 = T.Constant(value); Node* node1 = T.Constant(value);
......
...@@ -258,7 +258,7 @@ TEST(ReduceWord32And) { ...@@ -258,7 +258,7 @@ TEST(ReduceWord32And) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x & y, x, y); R.CheckFoldBinop<int32_t>(x & y, x, y);
} }
} }
...@@ -284,7 +284,7 @@ TEST(ReduceWord32Or) { ...@@ -284,7 +284,7 @@ TEST(ReduceWord32Or) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x | y, x, y); R.CheckFoldBinop<int32_t>(x | y, x, y);
} }
} }
...@@ -310,7 +310,7 @@ TEST(ReduceWord32Xor) { ...@@ -310,7 +310,7 @@ TEST(ReduceWord32Xor) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x ^ y, x, y); R.CheckFoldBinop<int32_t>(x ^ y, x, y);
} }
} }
...@@ -334,7 +334,7 @@ TEST(ReduceWord32Shl) { ...@@ -334,7 +334,7 @@ TEST(ReduceWord32Shl) {
// TODO(titzer): out of range shifts // TODO(titzer): out of range shifts
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
for (int y = 0; y < 32; y++) { for (int y = 0; y < 32; y++) {
int32_t x = *i; int32_t x = i;
R.CheckFoldBinop<int32_t>(base::ShlWithWraparound(x, y), x, y); R.CheckFoldBinop<int32_t>(base::ShlWithWraparound(x, y), x, y);
} }
} }
...@@ -353,7 +353,7 @@ TEST(ReduceWord64Shl) { ...@@ -353,7 +353,7 @@ TEST(ReduceWord64Shl) {
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
for (int64_t y = 0; y < 64; y++) { for (int64_t y = 0; y < 64; y++) {
int64_t x = *i; int64_t x = i;
R.CheckFoldBinop<int64_t>(base::ShlWithWraparound(x, y), x, y); R.CheckFoldBinop<int64_t>(base::ShlWithWraparound(x, y), x, y);
} }
} }
...@@ -373,7 +373,7 @@ TEST(ReduceWord32Shr) { ...@@ -373,7 +373,7 @@ TEST(ReduceWord32Shr) {
// TODO(titzer): test out of range shifts // TODO(titzer): test out of range shifts
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
for (uint32_t y = 0; y < 32; y++) { for (uint32_t y = 0; y < 32; y++) {
uint32_t x = *i; uint32_t x = i;
R.CheckFoldBinop<int32_t>(x >> y, x, y); R.CheckFoldBinop<int32_t>(x >> y, x, y);
} }
} }
...@@ -392,7 +392,7 @@ TEST(ReduceWord64Shr) { ...@@ -392,7 +392,7 @@ TEST(ReduceWord64Shr) {
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
for (uint64_t y = 0; y < 64; y++) { for (uint64_t y = 0; y < 64; y++) {
uint64_t x = *i; uint64_t x = i;
R.CheckFoldBinop<int64_t>(x >> y, x, y); R.CheckFoldBinop<int64_t>(x >> y, x, y);
} }
} }
...@@ -412,7 +412,7 @@ TEST(ReduceWord32Sar) { ...@@ -412,7 +412,7 @@ TEST(ReduceWord32Sar) {
// TODO(titzer): test out of range shifts // TODO(titzer): test out of range shifts
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
for (int32_t y = 0; y < 32; y++) { for (int32_t y = 0; y < 32; y++) {
int32_t x = *i; int32_t x = i;
R.CheckFoldBinop<int32_t>(x >> y, x, y); R.CheckFoldBinop<int32_t>(x >> y, x, y);
} }
} }
...@@ -431,7 +431,7 @@ TEST(ReduceWord64Sar) { ...@@ -431,7 +431,7 @@ TEST(ReduceWord64Sar) {
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
for (int64_t y = 0; y < 64; y++) { for (int64_t y = 0; y < 64; y++) {
int64_t x = *i; int64_t x = i;
R.CheckFoldBinop<int64_t>(x >> y, x, y); R.CheckFoldBinop<int64_t>(x >> y, x, y);
} }
} }
...@@ -479,7 +479,7 @@ TEST(Word32Equal) { ...@@ -479,7 +479,7 @@ TEST(Word32Equal) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x == y ? 1 : 0, x, y); R.CheckFoldBinop<int32_t>(x == y ? 1 : 0, x, y);
} }
} }
...@@ -504,7 +504,7 @@ TEST(ReduceInt32Add) { ...@@ -504,7 +504,7 @@ TEST(ReduceInt32Add) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(base::AddWithWraparound(x, y), x, y); R.CheckFoldBinop<int32_t>(base::AddWithWraparound(x, y), x, y);
} }
} }
...@@ -525,7 +525,7 @@ TEST(ReduceInt64Add) { ...@@ -525,7 +525,7 @@ TEST(ReduceInt64Add) {
FOR_INT64_INPUTS(pl) { FOR_INT64_INPUTS(pl) {
FOR_INT64_INPUTS(pr) { FOR_INT64_INPUTS(pr) {
int64_t x = *pl, y = *pr; int64_t x = pl, y = pr;
R.CheckFoldBinop<int64_t>(base::AddWithWraparound(x, y), x, y); R.CheckFoldBinop<int64_t>(base::AddWithWraparound(x, y), x, y);
} }
} }
...@@ -544,7 +544,7 @@ TEST(ReduceInt32Sub) { ...@@ -544,7 +544,7 @@ TEST(ReduceInt32Sub) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(base::SubWithWraparound(x, y), x, y); R.CheckFoldBinop<int32_t>(base::SubWithWraparound(x, y), x, y);
} }
} }
...@@ -563,7 +563,7 @@ TEST(ReduceInt64Sub) { ...@@ -563,7 +563,7 @@ TEST(ReduceInt64Sub) {
FOR_INT64_INPUTS(pl) { FOR_INT64_INPUTS(pl) {
FOR_INT64_INPUTS(pr) { FOR_INT64_INPUTS(pr) {
int64_t x = *pl, y = *pr; int64_t x = pl, y = pr;
R.CheckFoldBinop<int64_t>(base::SubWithWraparound(x, y), x, y); R.CheckFoldBinop<int64_t>(base::SubWithWraparound(x, y), x, y);
} }
} }
...@@ -588,7 +588,7 @@ TEST(ReduceInt32Mul) { ...@@ -588,7 +588,7 @@ TEST(ReduceInt32Mul) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(base::MulWithWraparound(x, y), x, y); R.CheckFoldBinop<int32_t>(base::MulWithWraparound(x, y), x, y);
} }
} }
...@@ -626,7 +626,7 @@ TEST(ReduceInt32Div) { ...@@ -626,7 +626,7 @@ TEST(ReduceInt32Div) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
if (y == 0) continue; // TODO(titzer): test / 0 if (y == 0) continue; // TODO(titzer): test / 0
int32_t r = y == -1 ? base::NegateWithWraparound(x) int32_t r = y == -1 ? base::NegateWithWraparound(x)
: x / y; // INT_MIN / -1 may explode in C : x / y; // INT_MIN / -1 may explode in C
...@@ -655,7 +655,7 @@ TEST(ReduceUint32Div) { ...@@ -655,7 +655,7 @@ TEST(ReduceUint32Div) {
FOR_UINT32_INPUTS(pl) { FOR_UINT32_INPUTS(pl) {
FOR_UINT32_INPUTS(pr) { FOR_UINT32_INPUTS(pr) {
uint32_t x = *pl, y = *pr; uint32_t x = pl, y = pr;
if (y == 0) continue; // TODO(titzer): test / 0 if (y == 0) continue; // TODO(titzer): test / 0
R.CheckFoldBinop<int32_t>(x / y, x, y); R.CheckFoldBinop<int32_t>(x / y, x, y);
} }
...@@ -684,7 +684,7 @@ TEST(ReduceInt32Mod) { ...@@ -684,7 +684,7 @@ TEST(ReduceInt32Mod) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
if (y == 0) continue; // TODO(titzer): test % 0 if (y == 0) continue; // TODO(titzer): test % 0
int32_t r = y == -1 ? 0 : x % y; // INT_MIN % -1 may explode in C int32_t r = y == -1 ? 0 : x % y; // INT_MIN % -1 may explode in C
R.CheckFoldBinop<int32_t>(r, x, y); R.CheckFoldBinop<int32_t>(r, x, y);
...@@ -708,7 +708,7 @@ TEST(ReduceUint32Mod) { ...@@ -708,7 +708,7 @@ TEST(ReduceUint32Mod) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
uint32_t x = *pl, y = *pr; uint32_t x = pl, y = pr;
if (y == 0) continue; // TODO(titzer): test x % 0 if (y == 0) continue; // TODO(titzer): test x % 0
R.CheckFoldBinop<int32_t>(x % y, x, y); R.CheckFoldBinop<int32_t>(x % y, x, y);
} }
...@@ -736,7 +736,7 @@ TEST(ReduceInt32LessThan) { ...@@ -736,7 +736,7 @@ TEST(ReduceInt32LessThan) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x < y ? 1 : 0, x, y); R.CheckFoldBinop<int32_t>(x < y ? 1 : 0, x, y);
} }
} }
...@@ -756,12 +756,12 @@ TEST(ReduceInt32LessThanOrEqual) { ...@@ -756,12 +756,12 @@ TEST(ReduceInt32LessThanOrEqual) {
FOR_INT32_INPUTS(pl) { FOR_INT32_INPUTS(pl) {
FOR_INT32_INPUTS(pr) { FOR_INT32_INPUTS(pr) {
int32_t x = *pl, y = *pr; int32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x <= y ? 1 : 0, x, y); R.CheckFoldBinop<int32_t>(x <= y ? 1 : 0, x, y);
} }
} }
FOR_INT32_INPUTS(i) { R.CheckDontPutConstantOnRight<int32_t>(*i); } FOR_INT32_INPUTS(i) { R.CheckDontPutConstantOnRight<int32_t>(i); }
Node* x = R.Parameter(0); Node* x = R.Parameter(0);
...@@ -775,7 +775,7 @@ TEST(ReduceUint32LessThan) { ...@@ -775,7 +775,7 @@ TEST(ReduceUint32LessThan) {
FOR_UINT32_INPUTS(pl) { FOR_UINT32_INPUTS(pl) {
FOR_UINT32_INPUTS(pr) { FOR_UINT32_INPUTS(pr) {
uint32_t x = *pl, y = *pr; uint32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x < y ? 1 : 0, x, y); R.CheckFoldBinop<int32_t>(x < y ? 1 : 0, x, y);
} }
} }
...@@ -799,7 +799,7 @@ TEST(ReduceUint32LessThanOrEqual) { ...@@ -799,7 +799,7 @@ TEST(ReduceUint32LessThanOrEqual) {
FOR_UINT32_INPUTS(pl) { FOR_UINT32_INPUTS(pl) {
FOR_UINT32_INPUTS(pr) { FOR_UINT32_INPUTS(pr) {
uint32_t x = *pl, y = *pr; uint32_t x = pl, y = pr;
R.CheckFoldBinop<int32_t>(x <= y ? 1 : 0, x, y); R.CheckFoldBinop<int32_t>(x <= y ? 1 : 0, x, y);
} }
} }
...@@ -848,7 +848,7 @@ TEST(ReduceFloat32Sub) { ...@@ -848,7 +848,7 @@ TEST(ReduceFloat32Sub) {
FOR_FLOAT32_INPUTS(pl) { FOR_FLOAT32_INPUTS(pl) {
FOR_FLOAT32_INPUTS(pr) { FOR_FLOAT32_INPUTS(pr) {
float x = *pl, y = *pr; float x = pl, y = pr;
R.CheckFoldBinop<float>(x - y, x, y); R.CheckFoldBinop<float>(x - y, x, y);
} }
} }
...@@ -868,7 +868,7 @@ TEST(ReduceFloat64Sub) { ...@@ -868,7 +868,7 @@ TEST(ReduceFloat64Sub) {
FOR_FLOAT64_INPUTS(pl) { FOR_FLOAT64_INPUTS(pl) {
FOR_FLOAT64_INPUTS(pr) { FOR_FLOAT64_INPUTS(pr) {
double x = *pl, y = *pr; double x = pl, y = pr;
R.CheckFoldBinop<double>(x - y, x, y); R.CheckFoldBinop<double>(x - y, x, y);
} }
} }
......
...@@ -261,12 +261,12 @@ TEST(ToInt32_constant) { ...@@ -261,12 +261,12 @@ TEST(ToInt32_constant) {
RepresentationChangerTester r; RepresentationChangerTester r;
{ {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
Node* n = r.jsgraph()->Constant(*i); Node* n = r.jsgraph()->Constant(i);
Node* use = r.Return(n); Node* use = r.Return(n);
Node* c = r.changer()->GetRepresentationFor( Node* c = r.changer()->GetRepresentationFor(
n, MachineRepresentation::kTagged, Type::Signed32(), use, n, MachineRepresentation::kTagged, Type::Signed32(), use,
UseInfo(MachineRepresentation::kWord32, Truncation::None())); UseInfo(MachineRepresentation::kWord32, Truncation::None()));
r.CheckInt32Constant(c, *i); r.CheckInt32Constant(c, i);
} }
} }
} }
...@@ -274,24 +274,24 @@ TEST(ToInt32_constant) { ...@@ -274,24 +274,24 @@ TEST(ToInt32_constant) {
TEST(ToUint32_constant) { TEST(ToUint32_constant) {
RepresentationChangerTester r; RepresentationChangerTester r;
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
Node* n = r.jsgraph()->Constant(static_cast<double>(*i)); Node* n = r.jsgraph()->Constant(static_cast<double>(i));
Node* use = r.Return(n); Node* use = r.Return(n);
Node* c = r.changer()->GetRepresentationFor( Node* c = r.changer()->GetRepresentationFor(
n, MachineRepresentation::kTagged, Type::Unsigned32(), use, n, MachineRepresentation::kTagged, Type::Unsigned32(), use,
UseInfo(MachineRepresentation::kWord32, Truncation::None())); UseInfo(MachineRepresentation::kWord32, Truncation::None()));
r.CheckUint32Constant(c, *i); r.CheckUint32Constant(c, i);
} }
} }
TEST(ToInt64_constant) { TEST(ToInt64_constant) {
RepresentationChangerTester r; RepresentationChangerTester r;
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
Node* n = r.jsgraph()->Constant(*i); Node* n = r.jsgraph()->Constant(i);
Node* use = r.Return(n); Node* use = r.Return(n);
Node* c = r.changer()->GetRepresentationFor( Node* c = r.changer()->GetRepresentationFor(
n, MachineRepresentation::kTagged, TypeCache::Get()->kSafeInteger, use, n, MachineRepresentation::kTagged, TypeCache::Get()->kSafeInteger, use,
UseInfo(MachineRepresentation::kWord64, Truncation::None())); UseInfo(MachineRepresentation::kWord64, Truncation::None()));
r.CheckInt64Constant(c, *i); r.CheckInt64Constant(c, i);
} }
} }
......
...@@ -52,7 +52,7 @@ void RunLoadInt32(const TestAlignment t) { ...@@ -52,7 +52,7 @@ void RunLoadInt32(const TestAlignment t) {
} }
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
p1 = *i; p1 = i;
CHECK_EQ(p1, m.Call()); CHECK_EQ(p1, m.Call());
} }
} }
...@@ -79,7 +79,7 @@ void RunLoadInt32Offset(TestAlignment t) { ...@@ -79,7 +79,7 @@ void RunLoadInt32Offset(TestAlignment t) {
} }
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
p1 = *j; p1 = j;
CHECK_EQ(p1, m.Call()); CHECK_EQ(p1, m.Call());
} }
} }
...@@ -91,9 +91,9 @@ void RunLoadStoreFloat32Offset(TestAlignment t) { ...@@ -91,9 +91,9 @@ void RunLoadStoreFloat32Offset(TestAlignment t) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t magic = int32_t magic =
base::AddWithWraparound(0x2342AABB, base::MulWithWraparound(*i, 3)); base::AddWithWraparound(0x2342AABB, base::MulWithWraparound(i, 3));
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
int32_t offset = *i; int32_t offset = i;
byte* from = reinterpret_cast<byte*>(&p1) - offset; byte* from = reinterpret_cast<byte*>(&p1) - offset;
byte* to = reinterpret_cast<byte*>(&p2) - offset; byte* to = reinterpret_cast<byte*>(&p2) - offset;
// generate load [#base + #index] // generate load [#base + #index]
...@@ -115,8 +115,8 @@ void RunLoadStoreFloat32Offset(TestAlignment t) { ...@@ -115,8 +115,8 @@ void RunLoadStoreFloat32Offset(TestAlignment t) {
m.Return(m.Int32Constant(magic)); m.Return(m.Int32Constant(magic));
FOR_FLOAT32_INPUTS(j) { FOR_FLOAT32_INPUTS(j) {
p1 = *j; p1 = j;
p2 = *j - 5; p2 = j - 5;
CHECK_EQ(magic, m.Call()); CHECK_EQ(magic, m.Call());
CHECK_DOUBLE_EQ(p1, p2); CHECK_DOUBLE_EQ(p1, p2);
} }
...@@ -129,9 +129,9 @@ void RunLoadStoreFloat64Offset(TestAlignment t) { ...@@ -129,9 +129,9 @@ void RunLoadStoreFloat64Offset(TestAlignment t) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t magic = int32_t magic =
base::AddWithWraparound(0x2342AABB, base::MulWithWraparound(*i, 3)); base::AddWithWraparound(0x2342AABB, base::MulWithWraparound(i, 3));
RawMachineAssemblerTester<int32_t> m; RawMachineAssemblerTester<int32_t> m;
int32_t offset = *i; int32_t offset = i;
byte* from = reinterpret_cast<byte*>(&p1) - offset; byte* from = reinterpret_cast<byte*>(&p1) - offset;
byte* to = reinterpret_cast<byte*>(&p2) - offset; byte* to = reinterpret_cast<byte*>(&p2) - offset;
// generate load [#base + #index] // generate load [#base + #index]
...@@ -152,8 +152,8 @@ void RunLoadStoreFloat64Offset(TestAlignment t) { ...@@ -152,8 +152,8 @@ void RunLoadStoreFloat64Offset(TestAlignment t) {
m.Return(m.Int32Constant(magic)); m.Return(m.Int32Constant(magic));
FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(j) {
p1 = *j; p1 = j;
p2 = *j - 5; p2 = j - 5;
CHECK_EQ(magic, m.Call()); CHECK_EQ(magic, m.Call());
CHECK_DOUBLE_EQ(p1, p2); CHECK_DOUBLE_EQ(p1, p2);
} }
...@@ -458,12 +458,12 @@ void RunLoadStoreSignExtend32(TestAlignment t) { ...@@ -458,12 +458,12 @@ void RunLoadStoreSignExtend32(TestAlignment t) {
m.Return(load8); m.Return(load8);
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
buffer[0] = *i; buffer[0] = i;
CHECK_EQ(static_cast<int8_t>(*i & 0xFF), m.Call()); CHECK_EQ(static_cast<int8_t>(i & 0xFF), m.Call());
CHECK_EQ(static_cast<int8_t>(*i & 0xFF), buffer[1]); CHECK_EQ(static_cast<int8_t>(i & 0xFF), buffer[1]);
CHECK_EQ(static_cast<int16_t>(*i & 0xFFFF), buffer[2]); CHECK_EQ(static_cast<int16_t>(i & 0xFFFF), buffer[2]);
CHECK_EQ(*i, buffer[3]); CHECK_EQ(i, buffer[3]);
} }
} }
...@@ -491,12 +491,12 @@ void RunLoadStoreZeroExtend32(TestAlignment t) { ...@@ -491,12 +491,12 @@ void RunLoadStoreZeroExtend32(TestAlignment t) {
m.Return(load8); m.Return(load8);
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
buffer[0] = *i; buffer[0] = i;
CHECK_EQ((*i & 0xFF), m.Call()); CHECK_EQ((i & 0xFF), m.Call());
CHECK_EQ((*i & 0xFF), buffer[1]); CHECK_EQ((i & 0xFF), buffer[1]);
CHECK_EQ((*i & 0xFFFF), buffer[2]); CHECK_EQ((i & 0xFFFF), buffer[2]);
CHECK_EQ(*i, buffer[3]); CHECK_EQ(i, buffer[3]);
} }
} }
} // namespace } // namespace
...@@ -552,13 +552,13 @@ void RunLoadStoreSignExtend64(TestAlignment t) { ...@@ -552,13 +552,13 @@ void RunLoadStoreSignExtend64(TestAlignment t) {
m.Return(load8); m.Return(load8);
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
buffer[0] = *i; buffer[0] = i;
CHECK_EQ(static_cast<int8_t>(*i & 0xFF), m.Call()); CHECK_EQ(static_cast<int8_t>(i & 0xFF), m.Call());
CHECK_EQ(static_cast<int8_t>(*i & 0xFF), buffer[1]); CHECK_EQ(static_cast<int8_t>(i & 0xFF), buffer[1]);
CHECK_EQ(static_cast<int16_t>(*i & 0xFFFF), buffer[2]); CHECK_EQ(static_cast<int16_t>(i & 0xFFFF), buffer[2]);
CHECK_EQ(static_cast<int32_t>(*i & 0xFFFFFFFF), buffer[3]); CHECK_EQ(static_cast<int32_t>(i & 0xFFFFFFFF), buffer[3]);
CHECK_EQ(*i, buffer[4]); CHECK_EQ(i, buffer[4]);
} }
} }
...@@ -595,13 +595,13 @@ void RunLoadStoreZeroExtend64(TestAlignment t) { ...@@ -595,13 +595,13 @@ void RunLoadStoreZeroExtend64(TestAlignment t) {
m.Return(load8); m.Return(load8);
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
buffer[0] = *i; buffer[0] = i;
CHECK_EQ((*i & 0xFF), m.Call()); CHECK_EQ((i & 0xFF), m.Call());
CHECK_EQ((*i & 0xFF), buffer[1]); CHECK_EQ((i & 0xFF), buffer[1]);
CHECK_EQ((*i & 0xFFFF), buffer[2]); CHECK_EQ((i & 0xFFFF), buffer[2]);
CHECK_EQ((*i & 0xFFFFFFFF), buffer[3]); CHECK_EQ((i & 0xFFFFFFFF), buffer[3]);
CHECK_EQ(*i, buffer[4]); CHECK_EQ(i, buffer[4]);
} }
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -542,9 +542,9 @@ static void TestInt32Sub(CallDescriptor* desc) { ...@@ -542,9 +542,9 @@ static void TestInt32Sub(CallDescriptor* desc) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) - int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(i) -
static_cast<uint32_t>(*j)); static_cast<uint32_t>(j));
int32_t result = runnable.Call(*i, *j); int32_t result = runnable.Call(i, j);
CHECK_EQ(expected, result); CHECK_EQ(expected, result);
} }
} }
......
...@@ -317,14 +317,9 @@ class ValueHelper { ...@@ -317,14 +317,9 @@ class ValueHelper {
} }
}; };
// Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... } // Helper macros that can be used in FOR_INT32_INPUTS(i) { ... i ... }
// Watch out, these macros aren't hygenic; they pollute your scope. Thanks STL. #define FOR_INPUTS(ctype, itype, var) \
#define FOR_INPUTS(ctype, itype, var) \ for (ctype var : ::v8::internal::compiler::ValueHelper::itype##_vector())
Vector<const ctype> var##_vec = \
::v8::internal::compiler::ValueHelper::itype##_vector(); \
for (Vector<const ctype>::iterator var = var##_vec.begin(), \
var##_end = var##_vec.end(); \
var != var##_end; ++var)
#define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var) #define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var)
#define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var) #define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var)
......
...@@ -4094,18 +4094,18 @@ namespace { ...@@ -4094,18 +4094,18 @@ namespace {
std::vector<Float32> Float32Inputs() { std::vector<Float32> Float32Inputs() {
std::vector<Float32> inputs; std::vector<Float32> inputs;
FOR_FLOAT32_INPUTS(f) { FOR_FLOAT32_INPUTS(f) {
inputs.push_back(Float32::FromBits(bit_cast<uint32_t>(*f))); inputs.push_back(Float32::FromBits(bit_cast<uint32_t>(f)));
} }
FOR_UINT32_INPUTS(bits) { inputs.push_back(Float32::FromBits(*bits)); } FOR_UINT32_INPUTS(bits) { inputs.push_back(Float32::FromBits(bits)); }
return inputs; return inputs;
} }
std::vector<Float64> Float64Inputs() { std::vector<Float64> Float64Inputs() {
std::vector<Float64> inputs; std::vector<Float64> inputs;
FOR_FLOAT64_INPUTS(f) { FOR_FLOAT64_INPUTS(f) {
inputs.push_back(Float64::FromBits(bit_cast<uint64_t>(*f))); inputs.push_back(Float64::FromBits(bit_cast<uint64_t>(f)));
} }
FOR_UINT64_INPUTS(bits) { inputs.push_back(Float64::FromBits(*bits)); } FOR_UINT64_INPUTS(bits) { inputs.push_back(Float64::FromBits(bits)); }
return inputs; return inputs;
} }
......
...@@ -109,7 +109,7 @@ TEST(TestCWasmEntryArgPassing_int32) { ...@@ -109,7 +109,7 @@ TEST(TestCWasmEntryArgPassing_int32) {
return base::AddWithWraparound(base::MulWithWraparound(2, a), 1); return base::AddWithWraparound(base::MulWithWraparound(2, a), 1);
}); });
FOR_INT32_INPUTS(v) { tester.CheckCall(*v); } FOR_INT32_INPUTS(v) { tester.CheckCall(v); }
} }
// Pass int64_t, return double. // Pass int64_t, return double.
...@@ -119,7 +119,7 @@ TEST(TestCWasmEntryArgPassing_double_int64) { ...@@ -119,7 +119,7 @@ TEST(TestCWasmEntryArgPassing_double_int64) {
WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))}, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))},
[](int64_t a) { return static_cast<double>(a); }); [](int64_t a) { return static_cast<double>(a); });
FOR_INT64_INPUTS(v) { tester.CheckCall(*v); } FOR_INT64_INPUTS(v) { tester.CheckCall(v); }
} }
// Pass double, return int64_t. // Pass double, return int64_t.
...@@ -129,7 +129,7 @@ TEST(TestCWasmEntryArgPassing_int64_double) { ...@@ -129,7 +129,7 @@ TEST(TestCWasmEntryArgPassing_int64_double) {
WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))}, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))},
[](double d) { return static_cast<int64_t>(d); }); [](double d) { return static_cast<int64_t>(d); });
FOR_INT64_INPUTS(i) { tester.CheckCall(*i); } FOR_INT64_INPUTS(i) { tester.CheckCall(i); }
} }
// Pass float, return double. // Pass float, return double.
...@@ -141,7 +141,7 @@ TEST(TestCWasmEntryArgPassing_float_double) { ...@@ -141,7 +141,7 @@ TEST(TestCWasmEntryArgPassing_float_double) {
WASM_F64(1))}, WASM_F64(1))},
[](float f) { return 2. * static_cast<double>(f) + 1.; }); [](float f) { return 2. * static_cast<double>(f) + 1.; });
FOR_FLOAT32_INPUTS(f) { tester.CheckCall(*f); } FOR_FLOAT32_INPUTS(f) { tester.CheckCall(f); }
} }
// Pass two doubles, return double. // Pass two doubles, return double.
...@@ -152,7 +152,7 @@ TEST(TestCWasmEntryArgPassing_double_double) { ...@@ -152,7 +152,7 @@ TEST(TestCWasmEntryArgPassing_double_double) {
[](double a, double b) { return a + b; }); [](double a, double b) { return a + b; });
FOR_FLOAT64_INPUTS(d1) { FOR_FLOAT64_INPUTS(d1) {
FOR_FLOAT64_INPUTS(d2) { tester.CheckCall(*d1, *d2); } FOR_FLOAT64_INPUTS(d2) { tester.CheckCall(d1, d2); }
} }
} }
......
...@@ -34,7 +34,7 @@ WASM_EXEC_TEST(I64Const_many) { ...@@ -34,7 +34,7 @@ WASM_EXEC_TEST(I64Const_many) {
int cntr = 0; int cntr = 0;
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
WasmRunner<int64_t> r(execution_tier); WasmRunner<int64_t> r(execution_tier);
const int64_t kExpectedValue = (static_cast<uint64_t>(*i) << 32) | cntr; const int64_t kExpectedValue = (static_cast<uint64_t>(i) << 32) | cntr;
// return(kExpectedValue) // return(kExpectedValue)
BUILD(r, WASM_I64V(kExpectedValue)); BUILD(r, WASM_I64V(kExpectedValue));
CHECK_EQ(kExpectedValue, r.Call()); CHECK_EQ(kExpectedValue, r.Call());
...@@ -47,7 +47,7 @@ WASM_EXEC_TEST(Return_I64) { ...@@ -47,7 +47,7 @@ WASM_EXEC_TEST(Return_I64) {
BUILD(r, WASM_RETURN1(WASM_GET_LOCAL(0))); BUILD(r, WASM_RETURN1(WASM_GET_LOCAL(0)));
FOR_INT64_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT64_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(I64Add) { WASM_EXEC_TEST(I64Add) {
...@@ -55,7 +55,7 @@ WASM_EXEC_TEST(I64Add) { ...@@ -55,7 +55,7 @@ WASM_EXEC_TEST(I64Add) {
BUILD(r, WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(base::AddWithWraparound(*i, *j), r.Call(*i, *j)); CHECK_EQ(base::AddWithWraparound(i, j), r.Call(i, j));
} }
} }
} }
...@@ -79,7 +79,7 @@ WASM_EXEC_TEST(I64Sub) { ...@@ -79,7 +79,7 @@ WASM_EXEC_TEST(I64Sub) {
BUILD(r, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(base::SubWithWraparound(*i, *j), r.Call(*i, *j)); CHECK_EQ(base::SubWithWraparound(i, j), r.Call(i, j));
} }
} }
} }
...@@ -99,8 +99,8 @@ WASM_EXEC_TEST(I64AddUseOnlyLowWord) { ...@@ -99,8 +99,8 @@ WASM_EXEC_TEST(I64AddUseOnlyLowWord) {
WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(static_cast<int32_t>(base::AddWithWraparound(*i, *j)), CHECK_EQ(static_cast<int32_t>(base::AddWithWraparound(i, j)),
r.Call(*i, *j)); r.Call(i, j));
} }
} }
} }
...@@ -111,8 +111,8 @@ WASM_EXEC_TEST(I64SubUseOnlyLowWord) { ...@@ -111,8 +111,8 @@ WASM_EXEC_TEST(I64SubUseOnlyLowWord) {
WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(static_cast<int32_t>(base::SubWithWraparound(*i, *j)), CHECK_EQ(static_cast<int32_t>(base::SubWithWraparound(i, j)),
r.Call(*i, *j)); r.Call(i, j));
} }
} }
} }
...@@ -123,8 +123,8 @@ WASM_EXEC_TEST(I64MulUseOnlyLowWord) { ...@@ -123,8 +123,8 @@ WASM_EXEC_TEST(I64MulUseOnlyLowWord) {
WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(static_cast<int32_t>(base::MulWithWraparound(*i, *j)), CHECK_EQ(static_cast<int32_t>(base::MulWithWraparound(i, j)),
r.Call(*i, *j)); r.Call(i, j));
} }
} }
} }
...@@ -135,8 +135,8 @@ WASM_EXEC_TEST(I64ShlUseOnlyLowWord) { ...@@ -135,8 +135,8 @@ WASM_EXEC_TEST(I64ShlUseOnlyLowWord) {
WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
int32_t expected = static_cast<int32_t>(base::ShlWithWraparound(*i, *j)); int32_t expected = static_cast<int32_t>(base::ShlWithWraparound(i, j));
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
...@@ -147,8 +147,8 @@ WASM_EXEC_TEST(I64ShrUseOnlyLowWord) { ...@@ -147,8 +147,8 @@ WASM_EXEC_TEST(I64ShrUseOnlyLowWord) {
WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
int32_t expected = static_cast<int32_t>((*i) >> (*j & 0x3F)); int32_t expected = static_cast<int32_t>((i) >> (j & 0x3F));
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
...@@ -159,8 +159,8 @@ WASM_EXEC_TEST(I64SarUseOnlyLowWord) { ...@@ -159,8 +159,8 @@ WASM_EXEC_TEST(I64SarUseOnlyLowWord) {
WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
int32_t expected = static_cast<int32_t>((*i) >> (*j & 0x3F)); int32_t expected = static_cast<int32_t>((i) >> (j & 0x3F));
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
...@@ -170,12 +170,12 @@ WASM_EXEC_TEST(I64DivS) { ...@@ -170,12 +170,12 @@ WASM_EXEC_TEST(I64DivS) {
BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
if (*j == 0) { if (j == 0) {
CHECK_TRAP64(r.Call(*i, *j)); CHECK_TRAP64(r.Call(i, j));
} else if (*j == -1 && *i == std::numeric_limits<int64_t>::min()) { } else if (j == -1 && i == std::numeric_limits<int64_t>::min()) {
CHECK_TRAP64(r.Call(*i, *j)); CHECK_TRAP64(r.Call(i, j));
} else { } else {
CHECK_EQ(*i / *j, r.Call(*i, *j)); CHECK_EQ(i / j, r.Call(i, j));
} }
} }
} }
...@@ -210,10 +210,10 @@ WASM_EXEC_TEST(I64DivU) { ...@@ -210,10 +210,10 @@ WASM_EXEC_TEST(I64DivU) {
BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
if (*j == 0) { if (j == 0) {
CHECK_TRAP64(r.Call(*i, *j)); CHECK_TRAP64(r.Call(i, j));
} else { } else {
CHECK_EQ(*i / *j, r.Call(*i, *j)); CHECK_EQ(i / j, r.Call(i, j));
} }
} }
} }
...@@ -248,10 +248,10 @@ WASM_EXEC_TEST(I64RemS) { ...@@ -248,10 +248,10 @@ WASM_EXEC_TEST(I64RemS) {
BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
if (*j == 0) { if (j == 0) {
CHECK_TRAP64(r.Call(*i, *j)); CHECK_TRAP64(r.Call(i, j));
} else { } else {
CHECK_EQ(*i % *j, r.Call(*i, *j)); CHECK_EQ(i % j, r.Call(i, j));
} }
} }
} }
...@@ -272,10 +272,10 @@ WASM_EXEC_TEST(I64RemU) { ...@@ -272,10 +272,10 @@ WASM_EXEC_TEST(I64RemU) {
BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
if (*j == 0) { if (j == 0) {
CHECK_TRAP64(r.Call(*i, *j)); CHECK_TRAP64(r.Call(i, j));
} else { } else {
CHECK_EQ(*i % *j, r.Call(*i, *j)); CHECK_EQ(i % j, r.Call(i, j));
} }
} }
} }
...@@ -294,7 +294,7 @@ WASM_EXEC_TEST(I64And) { ...@@ -294,7 +294,7 @@ WASM_EXEC_TEST(I64And) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ((*i) & (*j), r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ((i) & (j), r.Call(i, j)); }
} }
} }
...@@ -302,7 +302,7 @@ WASM_EXEC_TEST(I64Ior) { ...@@ -302,7 +302,7 @@ WASM_EXEC_TEST(I64Ior) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ((*i) | (*j), r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ((i) | (j), r.Call(i, j)); }
} }
} }
...@@ -310,7 +310,7 @@ WASM_EXEC_TEST(I64Xor) { ...@@ -310,7 +310,7 @@ WASM_EXEC_TEST(I64Xor) {
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ((i) ^ (j), r.Call(i, j)); }
} }
} }
...@@ -321,30 +321,30 @@ WASM_EXEC_TEST(I64Shl) { ...@@ -321,30 +321,30 @@ WASM_EXEC_TEST(I64Shl) {
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
uint64_t expected = (*i) << (*j & 0x3F); uint64_t expected = (i) << (j & 0x3F);
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(0))); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(0)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 0, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 0, r.Call(i)); }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(32))); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(32)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 32, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 32, r.Call(i)); }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(20))); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(20)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 20, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 20, r.Call(i)); }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(40))); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(40)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 40, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i << 40, r.Call(i)); }
} }
} }
...@@ -355,30 +355,30 @@ WASM_EXEC_TEST(I64ShrU) { ...@@ -355,30 +355,30 @@ WASM_EXEC_TEST(I64ShrU) {
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
uint64_t expected = (*i) >> (*j & 0x3F); uint64_t expected = (i) >> (j & 0x3F);
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(0))); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(0)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 0, r.Call(i)); }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(32))); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(32)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 32, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 32, r.Call(i)); }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(20)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 20, r.Call(i)); }
} }
{ {
WasmRunner<uint64_t, int64_t> r(execution_tier); WasmRunner<uint64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(40)));
FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } FOR_UINT64_INPUTS(i) { CHECK_EQ(i >> 40, r.Call(i)); }
} }
} }
...@@ -389,30 +389,30 @@ WASM_EXEC_TEST(I64ShrS) { ...@@ -389,30 +389,30 @@ WASM_EXEC_TEST(I64ShrS) {
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
int64_t expected = (*i) >> (*j & 0x3F); int64_t expected = (i) >> (j & 0x3F);
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
{ {
WasmRunner<int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(0))); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(0)));
FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); } FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 0, r.Call(i)); }
} }
{ {
WasmRunner<int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(32))); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(32)));
FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 32, r.Call(*i)); } FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 32, r.Call(i)); }
} }
{ {
WasmRunner<int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(20)));
FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 20, r.Call(i)); }
} }
{ {
WasmRunner<int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(40)));
FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } FOR_INT64_INPUTS(i) { CHECK_EQ(i >> 40, r.Call(i)); }
} }
} }
...@@ -420,7 +420,7 @@ WASM_EXEC_TEST(I64Eq) { ...@@ -420,7 +420,7 @@ WASM_EXEC_TEST(I64Eq) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i == *j ? 1 : 0, r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ(i == j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -428,7 +428,7 @@ WASM_EXEC_TEST(I64Ne) { ...@@ -428,7 +428,7 @@ WASM_EXEC_TEST(I64Ne) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_NE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_NE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i != *j ? 1 : 0, r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ(i != j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -436,7 +436,7 @@ WASM_EXEC_TEST(I64LtS) { ...@@ -436,7 +436,7 @@ WASM_EXEC_TEST(I64LtS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ(i < j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -444,7 +444,7 @@ WASM_EXEC_TEST(I64LeS) { ...@@ -444,7 +444,7 @@ WASM_EXEC_TEST(I64LeS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_LES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ(i <= j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -452,7 +452,7 @@ WASM_EXEC_TEST(I64LtU) { ...@@ -452,7 +452,7 @@ WASM_EXEC_TEST(I64LtU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } FOR_UINT64_INPUTS(j) { CHECK_EQ(i < j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -460,7 +460,7 @@ WASM_EXEC_TEST(I64LeU) { ...@@ -460,7 +460,7 @@ WASM_EXEC_TEST(I64LeU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } FOR_UINT64_INPUTS(j) { CHECK_EQ(i <= j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -468,7 +468,7 @@ WASM_EXEC_TEST(I64GtS) { ...@@ -468,7 +468,7 @@ WASM_EXEC_TEST(I64GtS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ(i > j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -476,7 +476,7 @@ WASM_EXEC_TEST(I64GeS) { ...@@ -476,7 +476,7 @@ WASM_EXEC_TEST(I64GeS) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_GES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } FOR_INT64_INPUTS(j) { CHECK_EQ(i >= j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -484,7 +484,7 @@ WASM_EXEC_TEST(I64GtU) { ...@@ -484,7 +484,7 @@ WASM_EXEC_TEST(I64GtU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } FOR_UINT64_INPUTS(j) { CHECK_EQ(i > j ? 1 : 0, r.Call(i, j)); }
} }
} }
...@@ -492,28 +492,28 @@ WASM_EXEC_TEST(I64GeU) { ...@@ -492,28 +492,28 @@ WASM_EXEC_TEST(I64GeU) {
WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); WasmRunner<int32_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } FOR_UINT64_INPUTS(j) { CHECK_EQ(i >= j ? 1 : 0, r.Call(i, j)); }
} }
} }
WASM_EXEC_TEST(I32ConvertI64) { WASM_EXEC_TEST(I32ConvertI64) {
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
BUILD(r, WASM_I32_CONVERT_I64(WASM_I64V(*i))); BUILD(r, WASM_I32_CONVERT_I64(WASM_I64V(i)));
CHECK_EQ(static_cast<int32_t>(*i), r.Call()); CHECK_EQ(static_cast<int32_t>(i), r.Call());
} }
} }
WASM_EXEC_TEST(I64SConvertI32) { WASM_EXEC_TEST(I64SConvertI32) {
WasmRunner<int64_t, int32_t> r(execution_tier); WasmRunner<int64_t, int32_t> r(execution_tier);
BUILD(r, WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(i), r.Call(i)); }
} }
WASM_EXEC_TEST(I64UConvertI32) { WASM_EXEC_TEST(I64UConvertI32) {
WasmRunner<int64_t, uint32_t> r(execution_tier); WasmRunner<int64_t, uint32_t> r(execution_tier);
BUILD(r, WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(0)));
FOR_UINT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(i), r.Call(i)); }
} }
WASM_EXEC_TEST(I64Popcnt) { WASM_EXEC_TEST(I64Popcnt) {
...@@ -536,7 +536,7 @@ WASM_EXEC_TEST(I64Popcnt) { ...@@ -536,7 +536,7 @@ WASM_EXEC_TEST(I64Popcnt) {
WASM_EXEC_TEST(F32SConvertI64) { WASM_EXEC_TEST(F32SConvertI64) {
WasmRunner<float, int64_t> r(execution_tier); WasmRunner<float, int64_t> r(execution_tier);
BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0)));
FOR_INT64_INPUTS(i) { CHECK_FLOAT_EQ(static_cast<float>(*i), r.Call(*i)); } FOR_INT64_INPUTS(i) { CHECK_FLOAT_EQ(static_cast<float>(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F32UConvertI64) { WASM_EXEC_TEST(F32UConvertI64) {
...@@ -629,7 +629,7 @@ WASM_EXEC_TEST(F32UConvertI64) { ...@@ -629,7 +629,7 @@ WASM_EXEC_TEST(F32UConvertI64) {
WASM_EXEC_TEST(F64SConvertI64) { WASM_EXEC_TEST(F64SConvertI64) {
WasmRunner<double, int64_t> r(execution_tier); WasmRunner<double, int64_t> r(execution_tier);
BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))); BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0)));
FOR_INT64_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), r.Call(*i)); } FOR_INT64_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F64UConvertI64) { WASM_EXEC_TEST(F64UConvertI64) {
...@@ -723,11 +723,11 @@ WASM_EXEC_TEST(I64SConvertF32) { ...@@ -723,11 +723,11 @@ WASM_EXEC_TEST(I64SConvertF32) {
BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (*i < static_cast<float>(std::numeric_limits<int64_t>::max()) && if (i < static_cast<float>(std::numeric_limits<int64_t>::max()) &&
*i >= static_cast<float>(std::numeric_limits<int64_t>::min())) { i >= static_cast<float>(std::numeric_limits<int64_t>::min())) {
CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<int64_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP64(r.Call(*i)); CHECK_TRAP64(r.Call(i));
} }
} }
} }
...@@ -738,17 +738,17 @@ WASM_EXEC_TEST(I64SConvertSatF32) { ...@@ -738,17 +738,17 @@ WASM_EXEC_TEST(I64SConvertSatF32) {
BUILD(r, WASM_I64_SCONVERT_SAT_F32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_SCONVERT_SAT_F32(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
int64_t expected; int64_t expected;
if (*i < static_cast<float>(std::numeric_limits<int64_t>::max()) && if (i < static_cast<float>(std::numeric_limits<int64_t>::max()) &&
*i >= static_cast<float>(std::numeric_limits<int64_t>::min())) { i >= static_cast<float>(std::numeric_limits<int64_t>::min())) {
expected = static_cast<int64_t>(*i); expected = static_cast<int64_t>(i);
} else if (std::isnan(*i)) { } else if (std::isnan(i)) {
expected = static_cast<int64_t>(0); expected = static_cast<int64_t>(0);
} else if (*i < 0.0) { } else if (i < 0.0) {
expected = std::numeric_limits<int64_t>::min(); expected = std::numeric_limits<int64_t>::min();
} else { } else {
expected = std::numeric_limits<int64_t>::max(); expected = std::numeric_limits<int64_t>::max();
} }
int64_t found = r.Call(*i); int64_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -758,11 +758,11 @@ WASM_EXEC_TEST(I64SConvertF64) { ...@@ -758,11 +758,11 @@ WASM_EXEC_TEST(I64SConvertF64) {
BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
if (*i < static_cast<double>(std::numeric_limits<int64_t>::max()) && if (i < static_cast<double>(std::numeric_limits<int64_t>::max()) &&
*i >= static_cast<double>(std::numeric_limits<int64_t>::min())) { i >= static_cast<double>(std::numeric_limits<int64_t>::min())) {
CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<int64_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP64(r.Call(*i)); CHECK_TRAP64(r.Call(i));
} }
} }
} }
...@@ -773,17 +773,17 @@ WASM_EXEC_TEST(I64SConvertSatF64) { ...@@ -773,17 +773,17 @@ WASM_EXEC_TEST(I64SConvertSatF64) {
BUILD(r, WASM_I64_SCONVERT_SAT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_SCONVERT_SAT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
int64_t expected; int64_t expected;
if (*i < static_cast<double>(std::numeric_limits<int64_t>::max()) && if (i < static_cast<double>(std::numeric_limits<int64_t>::max()) &&
*i >= static_cast<double>(std::numeric_limits<int64_t>::min())) { i >= static_cast<double>(std::numeric_limits<int64_t>::min())) {
expected = static_cast<int64_t>(*i); expected = static_cast<int64_t>(i);
} else if (std::isnan(*i)) { } else if (std::isnan(i)) {
expected = static_cast<int64_t>(0); expected = static_cast<int64_t>(0);
} else if (*i < 0.0) { } else if (i < 0.0) {
expected = std::numeric_limits<int64_t>::min(); expected = std::numeric_limits<int64_t>::min();
} else { } else {
expected = std::numeric_limits<int64_t>::max(); expected = std::numeric_limits<int64_t>::max();
} }
int64_t found = r.Call(*i); int64_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -793,11 +793,11 @@ WASM_EXEC_TEST(I64UConvertF32) { ...@@ -793,11 +793,11 @@ WASM_EXEC_TEST(I64UConvertF32) {
BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
*i > -1) { i > -1) {
CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<uint64_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP64(r.Call(*i)); CHECK_TRAP64(r.Call(i));
} }
} }
} }
...@@ -808,17 +808,17 @@ WASM_EXEC_TEST(I64UConvertSatF32) { ...@@ -808,17 +808,17 @@ WASM_EXEC_TEST(I64UConvertSatF32) {
BUILD(r, WASM_I64_UCONVERT_SAT_F32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_UCONVERT_SAT_F32(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
uint64_t expected; uint64_t expected;
if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
*i > -1) { i > -1) {
expected = static_cast<uint64_t>(*i); expected = static_cast<uint64_t>(i);
} else if (std::isnan(*i)) { } else if (std::isnan(i)) {
expected = static_cast<uint64_t>(0); expected = static_cast<uint64_t>(0);
} else if (*i < 0.0) { } else if (i < 0.0) {
expected = std::numeric_limits<uint64_t>::min(); expected = std::numeric_limits<uint64_t>::min();
} else { } else {
expected = std::numeric_limits<uint64_t>::max(); expected = std::numeric_limits<uint64_t>::max();
} }
uint64_t found = r.Call(*i); uint64_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -828,11 +828,11 @@ WASM_EXEC_TEST(I64UConvertF64) { ...@@ -828,11 +828,11 @@ WASM_EXEC_TEST(I64UConvertF64) {
BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
*i > -1) { i > -1) {
CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<uint64_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP64(r.Call(*i)); CHECK_TRAP64(r.Call(i));
} }
} }
} }
...@@ -843,17 +843,17 @@ WASM_EXEC_TEST(I64UConvertSatF64) { ...@@ -843,17 +843,17 @@ WASM_EXEC_TEST(I64UConvertSatF64) {
BUILD(r, WASM_I64_UCONVERT_SAT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_UCONVERT_SAT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
int64_t expected; int64_t expected;
if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && if (i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
*i > -1) { i > -1) {
expected = static_cast<uint64_t>(*i); expected = static_cast<uint64_t>(i);
} else if (std::isnan(*i)) { } else if (std::isnan(i)) {
expected = static_cast<uint64_t>(0); expected = static_cast<uint64_t>(0);
} else if (*i < 0.0) { } else if (i < 0.0) {
expected = std::numeric_limits<uint64_t>::min(); expected = std::numeric_limits<uint64_t>::min();
} else { } else {
expected = std::numeric_limits<uint64_t>::max(); expected = std::numeric_limits<uint64_t>::max();
} }
int64_t found = r.Call(*i); int64_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -1115,50 +1115,50 @@ WASM_EXEC_TEST(I64Popcnt2) { ...@@ -1115,50 +1115,50 @@ WASM_EXEC_TEST(I64Popcnt2) {
// Test the WasmRunner with an Int64 return value and different numbers of // Test the WasmRunner with an Int64 return value and different numbers of
// Int64 parameters. // Int64 parameters.
WASM_EXEC_TEST(I64WasmRunner) { WASM_EXEC_TEST(I64WasmRunner) {
{FOR_INT64_INPUTS(i){WasmRunner<int64_t> r(execution_tier);
BUILD(r, WASM_I64V(*i));
CHECK_EQ(*i, r.Call());
}
}
{
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0));
FOR_INT64_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
}
{
WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ(*i ^ *j, r.Call(*i, *j)); } WasmRunner<int64_t> r(execution_tier);
BUILD(r, WASM_I64V(i));
CHECK_EQ(i, r.Call());
} }
} {
{ WasmRunner<int64_t, int64_t> r(execution_tier);
WasmRunner<int64_t, int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_GET_LOCAL(0));
BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), FOR_INT64_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
WASM_I64_XOR(WASM_GET_LOCAL(1), WASM_GET_LOCAL(2)))); }
FOR_INT64_INPUTS(i) { {
FOR_INT64_INPUTS(j) { WasmRunner<int64_t, int64_t, int64_t> r(execution_tier);
CHECK_EQ(*i ^ *j ^ *j, r.Call(*i, *j, *j)); BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(*j ^ *i ^ *j, r.Call(*j, *i, *j)); FOR_INT64_INPUTS(i) {
CHECK_EQ(*j ^ *j ^ *i, r.Call(*j, *j, *i)); FOR_INT64_INPUTS(j) { CHECK_EQ(i ^ j, r.Call(i, j)); }
} }
} }
} {
{ WasmRunner<int64_t, int64_t, int64_t, int64_t> r(execution_tier);
WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0),
BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64_XOR(WASM_GET_LOCAL(1), WASM_GET_LOCAL(2))));
WASM_I64_XOR(WASM_GET_LOCAL(1), FOR_INT64_INPUTS(i) {
WASM_I64_XOR(WASM_GET_LOCAL(2), FOR_INT64_INPUTS(j) {
WASM_GET_LOCAL(3))))); CHECK_EQ(i ^ j ^ j, r.Call(i, j, j));
FOR_INT64_INPUTS(i) { CHECK_EQ(j ^ i ^ j, r.Call(j, i, j));
FOR_INT64_INPUTS(j) { CHECK_EQ(j ^ j ^ i, r.Call(j, j, i));
CHECK_EQ(*i ^ *j ^ *j ^ *j, r.Call(*i, *j, *j, *j)); }
CHECK_EQ(*j ^ *i ^ *j ^ *j, r.Call(*j, *i, *j, *j)); }
CHECK_EQ(*j ^ *j ^ *i ^ *j, r.Call(*j, *j, *i, *j)); }
CHECK_EQ(*j ^ *j ^ *j ^ *i, r.Call(*j, *j, *j, *i)); {
WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0),
WASM_I64_XOR(WASM_GET_LOCAL(1),
WASM_I64_XOR(WASM_GET_LOCAL(2),
WASM_GET_LOCAL(3)))));
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) {
CHECK_EQ(i ^ j ^ j ^ j, r.Call(i, j, j, j));
CHECK_EQ(j ^ i ^ j ^ j, r.Call(j, i, j, j));
CHECK_EQ(j ^ j ^ i ^ j, r.Call(j, j, i, j));
CHECK_EQ(j ^ j ^ j ^ i, r.Call(j, j, j, i));
}
} }
} }
}
} }
WASM_EXEC_TEST(Call_Int64Sub) { WASM_EXEC_TEST(Call_Int64Sub) {
...@@ -1174,7 +1174,7 @@ WASM_EXEC_TEST(Call_Int64Sub) { ...@@ -1174,7 +1174,7 @@ WASM_EXEC_TEST(Call_Int64Sub) {
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { FOR_INT64_INPUTS(j) {
CHECK_EQ(base::SubWithWraparound(*i, *j), r.Call(*i, *j)); CHECK_EQ(base::SubWithWraparound(i, j), r.Call(i, j));
} }
} }
} }
...@@ -1232,8 +1232,8 @@ WASM_EXEC_TEST(I64ReinterpretF64) { ...@@ -1232,8 +1232,8 @@ WASM_EXEC_TEST(I64ReinterpretF64) {
WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO))); WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int64_t expected = base::MulWithWraparound(static_cast<int64_t>(*i), int64_t expected =
int64_t{0x300010001L}); base::MulWithWraparound(static_cast<int64_t>(i), int64_t{0x300010001L});
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -1258,8 +1258,8 @@ WASM_EXEC_TEST(F64ReinterpretI64) { ...@@ -1258,8 +1258,8 @@ WASM_EXEC_TEST(F64ReinterpretI64) {
WASM_GET_LOCAL(0)); WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int64_t expected = base::MulWithWraparound(static_cast<int64_t>(*i), int64_t expected =
int64_t{0x300010001L}); base::MulWithWraparound(static_cast<int64_t>(i), int64_t{0x300010001L});
CHECK_EQ(expected, r.Call(expected)); CHECK_EQ(expected, r.Call(expected));
CHECK_EQ(expected, r.builder().ReadMemory<int64_t>(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory<int64_t>(&memory[0]));
} }
...@@ -1374,8 +1374,8 @@ WASM_EXEC_TEST(I64Eqz) { ...@@ -1374,8 +1374,8 @@ WASM_EXEC_TEST(I64Eqz) {
BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0))); BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0)));
FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(i) {
int32_t result = *i == 0 ? 1 : 0; int32_t result = i == 0 ? 1 : 0;
CHECK_EQ(result, r.Call(*i)); CHECK_EQ(result, r.Call(i));
} }
} }
...@@ -1385,8 +1385,8 @@ WASM_EXEC_TEST(I64Ror) { ...@@ -1385,8 +1385,8 @@ WASM_EXEC_TEST(I64Ror) {
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
int64_t expected = base::bits::RotateRight64(*i, *j & 0x3F); int64_t expected = base::bits::RotateRight64(i, j & 0x3F);
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
...@@ -1397,8 +1397,8 @@ WASM_EXEC_TEST(I64Rol) { ...@@ -1397,8 +1397,8 @@ WASM_EXEC_TEST(I64Rol) {
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
int64_t expected = base::bits::RotateLeft64(*i, *j & 0x3F); int64_t expected = base::bits::RotateLeft64(i, j & 0x3F);
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
......
...@@ -73,8 +73,8 @@ WASM_EXEC_TEST(I32AsmjsSConvertF32) { ...@@ -73,8 +73,8 @@ WASM_EXEC_TEST(I32AsmjsSConvertF32) {
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
int32_t expected = DoubleToInt32(*i); int32_t expected = DoubleToInt32(i);
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -84,8 +84,8 @@ WASM_EXEC_TEST(I32AsmjsSConvertF64) { ...@@ -84,8 +84,8 @@ WASM_EXEC_TEST(I32AsmjsSConvertF64) {
BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
int32_t expected = DoubleToInt32(*i); int32_t expected = DoubleToInt32(i);
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -95,8 +95,8 @@ WASM_EXEC_TEST(I32AsmjsUConvertF32) { ...@@ -95,8 +95,8 @@ WASM_EXEC_TEST(I32AsmjsUConvertF32) {
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
uint32_t expected = DoubleToUint32(*i); uint32_t expected = DoubleToUint32(i);
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -106,8 +106,8 @@ WASM_EXEC_TEST(I32AsmjsUConvertF64) { ...@@ -106,8 +106,8 @@ WASM_EXEC_TEST(I32AsmjsUConvertF64) {
BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
uint32_t expected = DoubleToUint32(*i); uint32_t expected = DoubleToUint32(i);
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
......
...@@ -22,11 +22,11 @@ void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, ...@@ -22,11 +22,11 @@ void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
MachineRepresentation::kWord32)); MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t initial = *i; uint32_t initial = i;
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(j));
uint32_t expected = expected_op(*i, *j); uint32_t expected = expected_op(i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -51,11 +51,11 @@ void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, ...@@ -51,11 +51,11 @@ void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op,
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t initial = *i; uint16_t initial = i;
FOR_UINT16_INPUTS(j) { FOR_UINT16_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(j));
uint16_t expected = expected_op(*i, *j); uint16_t expected = expected_op(i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -79,11 +79,11 @@ void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, ...@@ -79,11 +79,11 @@ void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t initial = *i; uint8_t initial = i;
FOR_UINT8_INPUTS(j) { FOR_UINT8_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(j));
uint8_t expected = expected_op(*i, *j); uint8_t expected = expected_op(i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -107,11 +107,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange) { ...@@ -107,11 +107,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange) {
WASM_GET_LOCAL(1), MachineRepresentation::kWord32)); WASM_GET_LOCAL(1), MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t initial = *i; uint32_t initial = i;
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*i, *j)); CHECK_EQ(initial, r.Call(i, j));
uint32_t expected = CompareExchange(initial, *i, *j); uint32_t expected = CompareExchange(initial, i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -129,11 +129,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange16U) { ...@@ -129,11 +129,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange16U) {
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t initial = *i; uint16_t initial = i;
FOR_UINT16_INPUTS(j) { FOR_UINT16_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*i, *j)); CHECK_EQ(initial, r.Call(i, j));
uint16_t expected = CompareExchange(initial, *i, *j); uint16_t expected = CompareExchange(initial, i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -150,11 +150,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) { ...@@ -150,11 +150,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) {
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t initial = *i; uint8_t initial = i;
FOR_UINT8_INPUTS(j) { FOR_UINT8_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*i, *j)); CHECK_EQ(initial, r.Call(i, j));
uint8_t expected = CompareExchange(initial, *i, *j); uint8_t expected = CompareExchange(initial, i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -192,7 +192,7 @@ WASM_EXEC_TEST(I32AtomicLoad) { ...@@ -192,7 +192,7 @@ WASM_EXEC_TEST(I32AtomicLoad) {
MachineRepresentation::kWord32)); MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t expected = *i; uint32_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -208,7 +208,7 @@ WASM_EXEC_TEST(I32AtomicLoad16U) { ...@@ -208,7 +208,7 @@ WASM_EXEC_TEST(I32AtomicLoad16U) {
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t expected = *i; uint16_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -223,7 +223,7 @@ WASM_EXEC_TEST(I32AtomicLoad8U) { ...@@ -223,7 +223,7 @@ WASM_EXEC_TEST(I32AtomicLoad8U) {
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t expected = *i; uint8_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -243,8 +243,8 @@ WASM_EXEC_TEST(I32AtomicStoreLoad) { ...@@ -243,8 +243,8 @@ WASM_EXEC_TEST(I32AtomicStoreLoad) {
MachineRepresentation::kWord32)); MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t expected = *i; uint32_t expected = i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -264,8 +264,8 @@ WASM_EXEC_TEST(I32AtomicStoreLoad16U) { ...@@ -264,8 +264,8 @@ WASM_EXEC_TEST(I32AtomicStoreLoad16U) {
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t expected = *i; uint16_t expected = i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -283,9 +283,9 @@ WASM_EXEC_TEST(I32AtomicStoreLoad8U) { ...@@ -283,9 +283,9 @@ WASM_EXEC_TEST(I32AtomicStoreLoad8U) {
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t expected = *i; uint8_t expected = i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
CHECK_EQ(*i, r.builder().ReadMemory(&memory[0])); CHECK_EQ(i, r.builder().ReadMemory(&memory[0]));
} }
} }
......
...@@ -22,11 +22,11 @@ void RunU64BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, ...@@ -22,11 +22,11 @@ void RunU64BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
MachineRepresentation::kWord64)); MachineRepresentation::kWord64));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
uint64_t initial = *i; uint64_t initial = i;
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(j));
uint64_t expected = expected_op(*i, *j); uint64_t expected = expected_op(i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -51,11 +51,11 @@ void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, ...@@ -51,11 +51,11 @@ void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
MachineRepresentation::kWord32)); MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t initial = *i; uint32_t initial = i;
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(j));
uint32_t expected = expected_op(*i, *j); uint32_t expected = expected_op(i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -80,11 +80,11 @@ void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, ...@@ -80,11 +80,11 @@ void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op,
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t initial = *i; uint16_t initial = i;
FOR_UINT16_INPUTS(j) { FOR_UINT16_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(j));
uint16_t expected = expected_op(*i, *j); uint16_t expected = expected_op(i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -108,11 +108,11 @@ void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, ...@@ -108,11 +108,11 @@ void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op,
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t initial = *i; uint8_t initial = i;
FOR_UINT8_INPUTS(j) { FOR_UINT8_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*j)); CHECK_EQ(initial, r.Call(j));
uint8_t expected = expected_op(*i, *j); uint8_t expected = expected_op(i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -136,11 +136,11 @@ WASM_EXEC_TEST(I64AtomicCompareExchange) { ...@@ -136,11 +136,11 @@ WASM_EXEC_TEST(I64AtomicCompareExchange) {
WASM_GET_LOCAL(1), MachineRepresentation::kWord64)); WASM_GET_LOCAL(1), MachineRepresentation::kWord64));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
uint64_t initial = *i; uint64_t initial = i;
FOR_UINT64_INPUTS(j) { FOR_UINT64_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*i, *j)); CHECK_EQ(initial, r.Call(i, j));
uint64_t expected = CompareExchange(initial, *i, *j); uint64_t expected = CompareExchange(initial, i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -158,11 +158,11 @@ WASM_EXEC_TEST(I64AtomicCompareExchange32U) { ...@@ -158,11 +158,11 @@ WASM_EXEC_TEST(I64AtomicCompareExchange32U) {
MachineRepresentation::kWord32)); MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t initial = *i; uint32_t initial = i;
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*i, *j)); CHECK_EQ(initial, r.Call(i, j));
uint32_t expected = CompareExchange(initial, *i, *j); uint32_t expected = CompareExchange(initial, i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -180,11 +180,11 @@ WASM_EXEC_TEST(I64AtomicCompareExchange16U) { ...@@ -180,11 +180,11 @@ WASM_EXEC_TEST(I64AtomicCompareExchange16U) {
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t initial = *i; uint16_t initial = i;
FOR_UINT16_INPUTS(j) { FOR_UINT16_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*i, *j)); CHECK_EQ(initial, r.Call(i, j));
uint16_t expected = CompareExchange(initial, *i, *j); uint16_t expected = CompareExchange(initial, i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -200,11 +200,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) { ...@@ -200,11 +200,11 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) {
WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t initial = *i; uint8_t initial = i;
FOR_UINT8_INPUTS(j) { FOR_UINT8_INPUTS(j) {
r.builder().WriteMemory(&memory[0], initial); r.builder().WriteMemory(&memory[0], initial);
CHECK_EQ(initial, r.Call(*i, *j)); CHECK_EQ(initial, r.Call(i, j));
uint8_t expected = CompareExchange(initial, *i, *j); uint8_t expected = CompareExchange(initial, i, j);
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -220,7 +220,7 @@ WASM_EXEC_TEST(I64AtomicLoad) { ...@@ -220,7 +220,7 @@ WASM_EXEC_TEST(I64AtomicLoad) {
MachineRepresentation::kWord64)); MachineRepresentation::kWord64));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
uint64_t expected = *i; uint64_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -236,7 +236,7 @@ WASM_EXEC_TEST(I64AtomicLoad32U) { ...@@ -236,7 +236,7 @@ WASM_EXEC_TEST(I64AtomicLoad32U) {
MachineRepresentation::kWord32)); MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t expected = *i; uint32_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -252,7 +252,7 @@ WASM_EXEC_TEST(I64AtomicLoad16U) { ...@@ -252,7 +252,7 @@ WASM_EXEC_TEST(I64AtomicLoad16U) {
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t expected = *i; uint16_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -267,7 +267,7 @@ WASM_EXEC_TEST(I64AtomicLoad8U) { ...@@ -267,7 +267,7 @@ WASM_EXEC_TEST(I64AtomicLoad8U) {
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t expected = *i; uint8_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -287,8 +287,8 @@ WASM_EXEC_TEST(I64AtomicStoreLoad) { ...@@ -287,8 +287,8 @@ WASM_EXEC_TEST(I64AtomicStoreLoad) {
MachineRepresentation::kWord64)); MachineRepresentation::kWord64));
FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(i) {
uint64_t expected = *i; uint64_t expected = i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -308,8 +308,8 @@ WASM_EXEC_TEST(I64AtomicStoreLoad32U) { ...@@ -308,8 +308,8 @@ WASM_EXEC_TEST(I64AtomicStoreLoad32U) {
MachineRepresentation::kWord32)); MachineRepresentation::kWord32));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
uint32_t expected = *i; uint32_t expected = i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -329,8 +329,8 @@ WASM_EXEC_TEST(I64AtomicStoreLoad16U) { ...@@ -329,8 +329,8 @@ WASM_EXEC_TEST(I64AtomicStoreLoad16U) {
MachineRepresentation::kWord16)); MachineRepresentation::kWord16));
FOR_UINT16_INPUTS(i) { FOR_UINT16_INPUTS(i) {
uint16_t expected = *i; uint16_t expected = i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
} }
...@@ -348,9 +348,9 @@ WASM_EXEC_TEST(I64AtomicStoreLoad8U) { ...@@ -348,9 +348,9 @@ WASM_EXEC_TEST(I64AtomicStoreLoad8U) {
MachineRepresentation::kWord8)); MachineRepresentation::kWord8));
FOR_UINT8_INPUTS(i) { FOR_UINT8_INPUTS(i) {
uint8_t expected = *i; uint8_t expected = i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
CHECK_EQ(*i, r.builder().ReadMemory(&memory[0])); CHECK_EQ(i, r.builder().ReadMemory(&memory[0]));
} }
} }
......
...@@ -192,7 +192,7 @@ TEST(Breakpoint_I32Add) { ...@@ -192,7 +192,7 @@ TEST(Breakpoint_I32Add) {
FOR_UINT32_INPUTS(a) { FOR_UINT32_INPUTS(a) {
for (uint32_t b = 11; b < 3000000000u; b += 1000000000u) { for (uint32_t b = 11; b < 3000000000u; b += 1000000000u) {
thread->Reset(); thread->Reset();
WasmValue args[] = {WasmValue(*a), WasmValue(b)}; WasmValue args[] = {WasmValue(a), WasmValue(b)};
thread->InitFrame(r.function(), args); thread->InitFrame(r.function(), args);
for (int i = 0; i < kNumBreakpoints; i++) { for (int i = 0; i < kNumBreakpoints; i++) {
...@@ -207,7 +207,7 @@ TEST(Breakpoint_I32Add) { ...@@ -207,7 +207,7 @@ TEST(Breakpoint_I32Add) {
// Check the thread finished with the right value. // Check the thread finished with the right value.
CHECK_EQ(WasmInterpreter::FINISHED, thread->state()); CHECK_EQ(WasmInterpreter::FINISHED, thread->state());
uint32_t expected = (*a) + (b); uint32_t expected = (a) + (b);
CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>()); CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>());
} }
} }
...@@ -227,7 +227,7 @@ TEST(Step_I32Mul) { ...@@ -227,7 +227,7 @@ TEST(Step_I32Mul) {
FOR_UINT32_INPUTS(a) { FOR_UINT32_INPUTS(a) {
for (uint32_t b = 33; b < 3000000000u; b += 1000000000u) { for (uint32_t b = 33; b < 3000000000u; b += 1000000000u) {
thread->Reset(); thread->Reset();
WasmValue args[] = {WasmValue(*a), WasmValue(b)}; WasmValue args[] = {WasmValue(a), WasmValue(b)};
thread->InitFrame(r.function(), args); thread->InitFrame(r.function(), args);
// Run instructions one by one. // Run instructions one by one.
...@@ -242,7 +242,7 @@ TEST(Step_I32Mul) { ...@@ -242,7 +242,7 @@ TEST(Step_I32Mul) {
// Check the thread finished with the right value. // Check the thread finished with the right value.
CHECK_EQ(WasmInterpreter::FINISHED, thread->state()); CHECK_EQ(WasmInterpreter::FINISHED, thread->state());
uint32_t expected = (*a) * (b); uint32_t expected = (a) * (b);
CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>()); CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>());
} }
} }
...@@ -269,7 +269,7 @@ TEST(Breakpoint_I32And_disable) { ...@@ -269,7 +269,7 @@ TEST(Breakpoint_I32And_disable) {
interpreter->SetBreakpoint(r.function(), kLocalsDeclSize + offsets[0], interpreter->SetBreakpoint(r.function(), kLocalsDeclSize + offsets[0],
do_break); do_break);
thread->Reset(); thread->Reset();
WasmValue args[] = {WasmValue(*a), WasmValue(b)}; WasmValue args[] = {WasmValue(a), WasmValue(b)};
thread->InitFrame(r.function(), args); thread->InitFrame(r.function(), args);
if (do_break) { if (do_break) {
...@@ -284,7 +284,7 @@ TEST(Breakpoint_I32And_disable) { ...@@ -284,7 +284,7 @@ TEST(Breakpoint_I32And_disable) {
// Check the thread finished with the right value. // Check the thread finished with the right value.
CHECK_EQ(WasmInterpreter::FINISHED, thread->state()); CHECK_EQ(WasmInterpreter::FINISHED, thread->state());
uint32_t expected = (*a) & (b); uint32_t expected = (a) & (b);
CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>()); CHECK_EQ(expected, thread->GetReturnValue().to<uint32_t>());
} }
} }
......
...@@ -408,8 +408,8 @@ WASM_SIMD_TEST(F32x4Splat) { ...@@ -408,8 +408,8 @@ WASM_SIMD_TEST(F32x4Splat) {
WASM_SIMD_CHECK_SPLAT_F32x4(simd, lane_val), WASM_RETURN1(WASM_ONE)); WASM_SIMD_CHECK_SPLAT_F32x4(simd, lane_val), WASM_RETURN1(WASM_ONE));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (SkipFPExpectedValue(*i)) continue; if (SkipFPExpectedValue(i)) continue;
CHECK_EQ(1, r.Call(*i)); CHECK_EQ(1, r.Call(i));
} }
} }
...@@ -486,8 +486,8 @@ WASM_SIMD_COMPILED_TEST(F32x4ConvertI32x4) { ...@@ -486,8 +486,8 @@ WASM_SIMD_COMPILED_TEST(F32x4ConvertI32x4) {
WASM_RETURN1(WASM_ONE)); WASM_RETURN1(WASM_ONE));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), CHECK_EQ(1, r.Call(i, static_cast<float>(i),
static_cast<float>(static_cast<uint32_t>(*i)))); static_cast<float>(static_cast<uint32_t>(i))));
} }
} }
...@@ -505,11 +505,11 @@ void RunF32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -505,11 +505,11 @@ void RunF32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_RETURN1(WASM_ONE)); WASM_RETURN1(WASM_ONE));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (SkipFPValue(*i)) continue; if (SkipFPValue(i)) continue;
float expected = expected_op(*i); float expected = expected_op(i);
if (SkipFPExpectedValue(expected)) continue; if (SkipFPExpectedValue(expected)) continue;
float abs_error = std::abs(expected) * error; float abs_error = std::abs(expected) * error;
CHECK_EQ(1, r.Call(*i, expected - abs_error, expected + abs_error)); CHECK_EQ(1, r.Call(i, expected - abs_error, expected + abs_error));
} }
} }
...@@ -547,12 +547,12 @@ void RunF32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -547,12 +547,12 @@ void RunF32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT_F32x4(simd1, expected), WASM_RETURN1(WASM_ONE)); WASM_SIMD_CHECK_SPLAT_F32x4(simd1, expected), WASM_RETURN1(WASM_ONE));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (SkipFPValue(*i)) continue; if (SkipFPValue(i)) continue;
FOR_FLOAT32_INPUTS(j) { FOR_FLOAT32_INPUTS(j) {
if (SkipFPValue(*j)) continue; if (SkipFPValue(j)) continue;
float expected = expected_op(*i, *j); float expected = expected_op(i, j);
if (SkipFPExpectedValue(expected)) continue; if (SkipFPExpectedValue(expected)) continue;
CHECK_EQ(1, r.Call(*i, *j, expected)); CHECK_EQ(1, r.Call(i, j, expected));
} }
} }
} }
...@@ -588,12 +588,12 @@ void RunF32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -588,12 +588,12 @@ void RunF32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (SkipFPValue(*i)) continue; if (SkipFPValue(i)) continue;
FOR_FLOAT32_INPUTS(j) { FOR_FLOAT32_INPUTS(j) {
if (SkipFPValue(*j)) continue; if (SkipFPValue(j)) continue;
float diff = *i - *j; float diff = i - j;
if (SkipFPExpectedValue(diff)) continue; if (SkipFPExpectedValue(diff)) continue;
CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); CHECK_EQ(1, r.Call(i, j, expected_op(i, j)));
} }
} }
} }
...@@ -640,7 +640,7 @@ WASM_SIMD_TEST(I32x4Splat) { ...@@ -640,7 +640,7 @@ WASM_SIMD_TEST(I32x4Splat) {
WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(lane_val))), WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(lane_val))),
WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, lane_val), WASM_ONE); WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, lane_val), WASM_ONE);
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(i)); }
} }
WASM_SIMD_TEST(I32x4ReplaceLane) { WASM_SIMD_TEST(I32x4ReplaceLane) {
...@@ -677,7 +677,7 @@ WASM_SIMD_TEST(I16x8Splat) { ...@@ -677,7 +677,7 @@ WASM_SIMD_TEST(I16x8Splat) {
WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))), WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))),
WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE); WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE);
FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(i)); }
} }
WASM_SIMD_TEST(I16x8ReplaceLane) { WASM_SIMD_TEST(I16x8ReplaceLane) {
...@@ -737,7 +737,7 @@ WASM_SIMD_TEST(I8x16Splat) { ...@@ -737,7 +737,7 @@ WASM_SIMD_TEST(I8x16Splat) {
WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))),
WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE);
FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(i)); }
} }
WASM_SIMD_TEST(I8x16ReplaceLane) { WASM_SIMD_TEST(I8x16ReplaceLane) {
...@@ -875,10 +875,10 @@ WASM_SIMD_TEST(I32x4ConvertF32x4) { ...@@ -875,10 +875,10 @@ WASM_SIMD_TEST(I32x4ConvertF32x4) {
WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE); WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE);
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (SkipFPValue(*i)) continue; if (SkipFPValue(i)) continue;
int32_t signed_value = ConvertToInt(*i, false); int32_t signed_value = ConvertToInt(i, false);
int32_t unsigned_value = ConvertToInt(*i, true); int32_t unsigned_value = ConvertToInt(i, true);
CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); CHECK_EQ(1, r.Call(i, signed_value, unsigned_value));
} }
} }
...@@ -916,10 +916,9 @@ WASM_SIMD_TEST(I32x4ConvertI16x8) { ...@@ -916,10 +916,9 @@ WASM_SIMD_TEST(I32x4ConvertI16x8) {
WASM_ONE); WASM_ONE);
FOR_INT16_INPUTS(i) { FOR_INT16_INPUTS(i) {
int32_t unpacked_signed = static_cast<int32_t>(Widen<int16_t>(*i)); int32_t unpacked_signed = static_cast<int32_t>(Widen<int16_t>(i));
int32_t unpacked_unsigned = int32_t unpacked_unsigned = static_cast<int32_t>(UnsignedWiden<int16_t>(i));
static_cast<int32_t>(UnsignedWiden<int16_t>(*i)); CHECK_EQ(1, r.Call(i, unpacked_signed, unpacked_unsigned, 0));
CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned, 0));
} }
} }
...@@ -933,7 +932,7 @@ void RunI32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -933,7 +932,7 @@ void RunI32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(i, expected_op(i))); }
} }
WASM_SIMD_TEST(I32x4Neg) { WASM_SIMD_TEST(I32x4Neg) {
...@@ -960,7 +959,7 @@ void RunI32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -960,7 +959,7 @@ void RunI32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(i, j, expected_op(i, j))); }
} }
} }
...@@ -1024,7 +1023,7 @@ void RunI32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1024,7 +1023,7 @@ void RunI32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(i, j, expected_op(i, j))); }
} }
} }
...@@ -1085,7 +1084,7 @@ void RunI32x4ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1085,7 +1084,7 @@ void RunI32x4ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(i, expected_op(i, shift))); }
} }
} }
...@@ -1141,9 +1140,9 @@ WASM_SIMD_TEST(I16x8ConvertI8x16) { ...@@ -1141,9 +1140,9 @@ WASM_SIMD_TEST(I16x8ConvertI8x16) {
WASM_ONE); WASM_ONE);
FOR_INT8_INPUTS(i) { FOR_INT8_INPUTS(i) {
int32_t unpacked_signed = static_cast<int32_t>(Widen<int8_t>(*i)); int32_t unpacked_signed = static_cast<int32_t>(Widen<int8_t>(i));
int32_t unpacked_unsigned = static_cast<int32_t>(UnsignedWiden<int8_t>(*i)); int32_t unpacked_unsigned = static_cast<int32_t>(UnsignedWiden<int8_t>(i));
CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned, 0)); CHECK_EQ(1, r.Call(i, unpacked_signed, unpacked_unsigned, 0));
} }
} }
...@@ -1157,7 +1156,7 @@ void RunI16x8UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1157,7 +1156,7 @@ void RunI16x8UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(i, expected_op(i))); }
} }
WASM_SIMD_TEST(I16x8Neg) { WASM_SIMD_TEST(I16x8Neg) {
...@@ -1197,15 +1196,15 @@ WASM_SIMD_TEST(I16x8ConvertI32x4) { ...@@ -1197,15 +1196,15 @@ WASM_SIMD_TEST(I16x8ConvertI32x4) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
// packed signed values // packed signed values
int32_t ps_a = Narrow<int16_t>(*i); int32_t ps_a = Narrow<int16_t>(i);
int32_t ps_b = Narrow<int16_t>(*j); int32_t ps_b = Narrow<int16_t>(j);
// packed unsigned values // packed unsigned values
int32_t pu_a = UnsignedNarrow<int16_t>(*i); int32_t pu_a = UnsignedNarrow<int16_t>(i);
int32_t pu_b = UnsignedNarrow<int16_t>(*j); int32_t pu_b = UnsignedNarrow<int16_t>(j);
// Sign-extend here, since ExtractLane sign extends. // Sign-extend here, since ExtractLane sign extends.
if (pu_a & 0x8000) pu_a |= 0xFFFF0000; if (pu_a & 0x8000) pu_a |= 0xFFFF0000;
if (pu_b & 0x8000) pu_b |= 0xFFFF0000; if (pu_b & 0x8000) pu_b |= 0xFFFF0000;
CHECK_EQ(1, r.Call(*i, *j, ps_a, ps_b, pu_a, pu_b)); CHECK_EQ(1, r.Call(i, j, ps_a, ps_b, pu_a, pu_b));
} }
} }
} }
...@@ -1225,7 +1224,7 @@ void RunI16x8BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1225,7 +1224,7 @@ void RunI16x8BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE);
FOR_INT16_INPUTS(i) { FOR_INT16_INPUTS(i) {
FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(i, j, expected_op(i, j))); }
} }
} }
...@@ -1297,7 +1296,7 @@ void RunI16x8CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1297,7 +1296,7 @@ void RunI16x8CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE);
FOR_INT16_INPUTS(i) { FOR_INT16_INPUTS(i) {
FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(i, j, expected_op(i, j))); }
} }
} }
...@@ -1358,7 +1357,7 @@ void RunI16x8ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1358,7 +1357,7 @@ void RunI16x8ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(i, expected_op(i, shift))); }
} }
} }
...@@ -1387,7 +1386,7 @@ void RunI8x16UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1387,7 +1386,7 @@ void RunI8x16UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE);
FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(i, expected_op(i))); }
} }
WASM_SIMD_TEST(I8x16Neg) { WASM_SIMD_TEST(I8x16Neg) {
...@@ -1429,15 +1428,15 @@ WASM_SIMD_TEST(I8x16ConvertI16x8) { ...@@ -1429,15 +1428,15 @@ WASM_SIMD_TEST(I8x16ConvertI16x8) {
FOR_INT16_INPUTS(i) { FOR_INT16_INPUTS(i) {
FOR_INT16_INPUTS(j) { FOR_INT16_INPUTS(j) {
// packed signed values // packed signed values
int32_t ps_a = Narrow<int8_t>(*i); int32_t ps_a = Narrow<int8_t>(i);
int32_t ps_b = Narrow<int8_t>(*j); int32_t ps_b = Narrow<int8_t>(j);
// packed unsigned values // packed unsigned values
int32_t pu_a = UnsignedNarrow<int8_t>(*i); int32_t pu_a = UnsignedNarrow<int8_t>(i);
int32_t pu_b = UnsignedNarrow<int8_t>(*j); int32_t pu_b = UnsignedNarrow<int8_t>(j);
// Sign-extend here, since ExtractLane sign extends. // Sign-extend here, since ExtractLane sign extends.
if (pu_a & 0x80) pu_a |= 0xFFFFFF00; if (pu_a & 0x80) pu_a |= 0xFFFFFF00;
if (pu_b & 0x80) pu_b |= 0xFFFFFF00; if (pu_b & 0x80) pu_b |= 0xFFFFFF00;
CHECK_EQ(1, r.Call(*i, *j, ps_a, ps_b, pu_a, pu_b)); CHECK_EQ(1, r.Call(i, j, ps_a, ps_b, pu_a, pu_b));
} }
} }
} }
...@@ -1457,7 +1456,7 @@ void RunI8x16BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1457,7 +1456,7 @@ void RunI8x16BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE);
FOR_INT8_INPUTS(i) { FOR_INT8_INPUTS(i) {
FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(i, j, expected_op(i, j))); }
} }
} }
...@@ -1524,7 +1523,7 @@ void RunI8x16CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1524,7 +1523,7 @@ void RunI8x16CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE);
FOR_INT8_INPUTS(i) { FOR_INT8_INPUTS(i) {
FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(i, j, expected_op(i, j))); }
} }
} }
...@@ -1590,7 +1589,7 @@ void RunI8x16ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, ...@@ -1590,7 +1589,7 @@ void RunI8x16ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd,
simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE);
FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(i, expected_op(i, shift))); }
} }
} }
...@@ -2335,7 +2334,7 @@ WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) { ...@@ -2335,7 +2334,7 @@ WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) {
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_I32V(4)))); WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_I32V(4))));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i; int32_t expected = i;
r.builder().WriteMemory(&memory[1], expected); r.builder().WriteMemory(&memory[1], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
......
...@@ -38,7 +38,7 @@ WASM_EXEC_TEST(Int32Const) { ...@@ -38,7 +38,7 @@ WASM_EXEC_TEST(Int32Const) {
WASM_EXEC_TEST(Int32Const_many) { WASM_EXEC_TEST(Int32Const_many) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
const int32_t kExpectedValue = *i; const int32_t kExpectedValue = i;
// return(kExpectedValue) // return(kExpectedValue)
BUILD(r, WASM_I32V(kExpectedValue)); BUILD(r, WASM_I32V(kExpectedValue));
CHECK_EQ(kExpectedValue, r.Call()); CHECK_EQ(kExpectedValue, r.Call());
...@@ -57,21 +57,21 @@ WASM_EXEC_TEST(Int32Param0) { ...@@ -57,21 +57,21 @@ WASM_EXEC_TEST(Int32Param0) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
// return(local[0]) // return(local[0])
BUILD(r, WASM_GET_LOCAL(0)); BUILD(r, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Int32Param0_fallthru) { WASM_EXEC_TEST(Int32Param0_fallthru) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
// local[0] // local[0]
BUILD(r, WASM_GET_LOCAL(0)); BUILD(r, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Int32Param1) { WASM_EXEC_TEST(Int32Param1) {
WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t, int32_t> r(execution_tier);
// local[1] // local[1]
BUILD(r, WASM_GET_LOCAL(1)); BUILD(r, WASM_GET_LOCAL(1));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(-111, *i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(-111, i)); }
} }
WASM_EXEC_TEST(Int32Add) { WASM_EXEC_TEST(Int32Add) {
...@@ -85,14 +85,14 @@ WASM_EXEC_TEST(Int32Add_P) { ...@@ -85,14 +85,14 @@ WASM_EXEC_TEST(Int32Add_P) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
// p0 + 13 // p0 + 13
BUILD(r, WASM_I32_ADD(WASM_I32V_1(13), WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_ADD(WASM_I32V_1(13), WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(base::AddWithWraparound(*i, 13), r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(base::AddWithWraparound(i, 13), r.Call(i)); }
} }
WASM_EXEC_TEST(Int32Add_P_fallthru) { WASM_EXEC_TEST(Int32Add_P_fallthru) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
// p0 + 13 // p0 + 13
BUILD(r, WASM_I32_ADD(WASM_I32V_1(13), WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_ADD(WASM_I32V_1(13), WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(base::AddWithWraparound(*i, 13), r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(base::AddWithWraparound(i, 13), r.Call(i)); }
} }
static void RunInt32AddTest(ExecutionTier execution_tier, const byte* code, static void RunInt32AddTest(ExecutionTier execution_tier, const byte* code,
...@@ -104,9 +104,9 @@ static void RunInt32AddTest(ExecutionTier execution_tier, const byte* code, ...@@ -104,9 +104,9 @@ static void RunInt32AddTest(ExecutionTier execution_tier, const byte* code,
r.Build(code, code + size); r.Build(code, code + size);
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) + int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(i) +
static_cast<uint32_t>(*j)); static_cast<uint32_t>(j));
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
...@@ -168,8 +168,8 @@ static void TestInt32Binop(ExecutionTier execution_tier, WasmOpcode opcode, ...@@ -168,8 +168,8 @@ static void TestInt32Binop(ExecutionTier execution_tier, WasmOpcode opcode,
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
WasmRunner<ctype> r(execution_tier); WasmRunner<ctype> r(execution_tier);
// Apply {opcode} on two constants. // Apply {opcode} on two constants.
BUILD(r, WASM_BINOP(opcode, WASM_I32V(*i), WASM_I32V(*j))); BUILD(r, WASM_BINOP(opcode, WASM_I32V(i), WASM_I32V(j)));
CHECK_EQ(expected(*i, *j), r.Call()); CHECK_EQ(expected(i, j), r.Call());
} }
} }
{ {
...@@ -178,7 +178,7 @@ static void TestInt32Binop(ExecutionTier execution_tier, WasmOpcode opcode, ...@@ -178,7 +178,7 @@ static void TestInt32Binop(ExecutionTier execution_tier, WasmOpcode opcode,
BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
CHECK_EQ(expected(*i, *j), r.Call(*i, *j)); CHECK_EQ(expected(i, j), r.Call(i, j));
} }
} }
} }
...@@ -392,11 +392,11 @@ WASM_EXEC_TEST(Int32AsmjsDivS_byzero_const) { ...@@ -392,11 +392,11 @@ WASM_EXEC_TEST(Int32AsmjsDivS_byzero_const) {
BUILD(r, WASM_I32_ASMJS_DIVS(WASM_GET_LOCAL(0), WASM_I32V_1(denom))); BUILD(r, WASM_I32_ASMJS_DIVS(WASM_GET_LOCAL(0), WASM_I32V_1(denom)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
if (denom == 0) { if (denom == 0) {
CHECK_EQ(0, r.Call(*i)); CHECK_EQ(0, r.Call(i));
} else if (denom == -1 && *i == std::numeric_limits<int32_t>::min()) { } else if (denom == -1 && i == std::numeric_limits<int32_t>::min()) {
CHECK_EQ(std::numeric_limits<int32_t>::min(), r.Call(*i)); CHECK_EQ(std::numeric_limits<int32_t>::min(), r.Call(i));
} else { } else {
CHECK_EQ(*i / denom, r.Call(*i)); CHECK_EQ(i / denom, r.Call(i));
} }
} }
} }
...@@ -409,11 +409,11 @@ WASM_EXEC_TEST(Int32AsmjsRemS_byzero_const) { ...@@ -409,11 +409,11 @@ WASM_EXEC_TEST(Int32AsmjsRemS_byzero_const) {
BUILD(r, WASM_I32_ASMJS_REMS(WASM_GET_LOCAL(0), WASM_I32V_1(denom))); BUILD(r, WASM_I32_ASMJS_REMS(WASM_GET_LOCAL(0), WASM_I32V_1(denom)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
if (denom == 0) { if (denom == 0) {
CHECK_EQ(0, r.Call(*i)); CHECK_EQ(0, r.Call(i));
} else if (denom == -1 && *i == std::numeric_limits<int32_t>::min()) { } else if (denom == -1 && i == std::numeric_limits<int32_t>::min()) {
CHECK_EQ(0, r.Call(*i)); CHECK_EQ(0, r.Call(i));
} else { } else {
CHECK_EQ(*i % denom, r.Call(*i)); CHECK_EQ(i % denom, r.Call(i));
} }
} }
} }
...@@ -605,8 +605,7 @@ WASM_EXEC_TEST(Float32Neg) { ...@@ -605,8 +605,7 @@ WASM_EXEC_TEST(Float32Neg) {
BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0))); BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
CHECK_EQ(0x80000000, CHECK_EQ(0x80000000, bit_cast<uint32_t>(i) ^ bit_cast<uint32_t>(r.Call(i)));
bit_cast<uint32_t>(*i) ^ bit_cast<uint32_t>(r.Call(*i)));
} }
} }
...@@ -616,7 +615,7 @@ WASM_EXEC_TEST(Float64Neg) { ...@@ -616,7 +615,7 @@ WASM_EXEC_TEST(Float64Neg) {
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
CHECK_EQ(0x8000000000000000, CHECK_EQ(0x8000000000000000,
bit_cast<uint64_t>(*i) ^ bit_cast<uint64_t>(r.Call(*i))); bit_cast<uint64_t>(i) ^ bit_cast<uint64_t>(r.Call(i)));
} }
} }
...@@ -627,36 +626,36 @@ WASM_EXEC_TEST(IfElse_P) { ...@@ -627,36 +626,36 @@ WASM_EXEC_TEST(IfElse_P) {
WASM_I32V_1(11), // -- WASM_I32V_1(11), // --
WASM_I32V_1(22))); // -- WASM_I32V_1(22))); // --
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 11 : 22; int32_t expected = i ? 11 : 22;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
WASM_EXEC_TEST(If_empty1) { WASM_EXEC_TEST(If_empty1) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprEnd, WASM_GET_LOCAL(1)); BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprEnd, WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 9, *i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 9, i)); }
} }
WASM_EXEC_TEST(IfElse_empty1) { WASM_EXEC_TEST(IfElse_empty1) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, kExprEnd, BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, kExprEnd,
WASM_GET_LOCAL(1)); WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 8, *i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 8, i)); }
} }
WASM_EXEC_TEST(IfElse_empty2) { WASM_EXEC_TEST(IfElse_empty2) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, WASM_NOP, kExprElse, BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, WASM_NOP, kExprElse,
kExprEnd, WASM_GET_LOCAL(1)); kExprEnd, WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 7, *i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 7, i)); }
} }
WASM_EXEC_TEST(IfElse_empty3) { WASM_EXEC_TEST(IfElse_empty3) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, WASM_NOP, BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, WASM_NOP,
kExprEnd, WASM_GET_LOCAL(1)); kExprEnd, WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 6, *i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 6, i)); }
} }
WASM_EXEC_TEST(If_chain1) { WASM_EXEC_TEST(If_chain1) {
...@@ -664,7 +663,7 @@ WASM_EXEC_TEST(If_chain1) { ...@@ -664,7 +663,7 @@ WASM_EXEC_TEST(If_chain1) {
// if (p0) 13; if (p0) 14; 15 // if (p0) 13; if (p0) 14; 15
BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_NOP), BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_NOP),
WASM_IF(WASM_GET_LOCAL(0), WASM_NOP), WASM_I32V_1(15)); WASM_IF(WASM_GET_LOCAL(0), WASM_NOP), WASM_I32V_1(15));
FOR_INT32_INPUTS(i) { CHECK_EQ(15, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(15, r.Call(i)); }
} }
WASM_EXEC_TEST(If_chain_set) { WASM_EXEC_TEST(If_chain_set) {
...@@ -674,8 +673,8 @@ WASM_EXEC_TEST(If_chain_set) { ...@@ -674,8 +673,8 @@ WASM_EXEC_TEST(If_chain_set) {
WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(1, WASM_I32V_2(74))), WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(1, WASM_I32V_2(74))),
WASM_GET_LOCAL(1)); WASM_GET_LOCAL(1));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 74 : *i; int32_t expected = i ? 74 : i;
CHECK_EQ(expected, r.Call(*i, *i)); CHECK_EQ(expected, r.Call(i, i));
} }
} }
...@@ -716,7 +715,7 @@ WASM_EXEC_TEST(Return_I32) { ...@@ -716,7 +715,7 @@ WASM_EXEC_TEST(Return_I32) {
BUILD(r, RET(WASM_GET_LOCAL(0))); BUILD(r, RET(WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Return_F32) { WASM_EXEC_TEST(Return_F32) {
...@@ -725,7 +724,7 @@ WASM_EXEC_TEST(Return_F32) { ...@@ -725,7 +724,7 @@ WASM_EXEC_TEST(Return_F32) {
BUILD(r, RET(WASM_GET_LOCAL(0))); BUILD(r, RET(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
float expect = *i; float expect = i;
float result = r.Call(expect); float result = r.Call(expect);
if (std::isnan(expect)) { if (std::isnan(expect)) {
CHECK(std::isnan(result)); CHECK(std::isnan(result));
...@@ -741,7 +740,7 @@ WASM_EXEC_TEST(Return_F64) { ...@@ -741,7 +740,7 @@ WASM_EXEC_TEST(Return_F64) {
BUILD(r, RET(WASM_GET_LOCAL(0))); BUILD(r, RET(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
double expect = *i; double expect = i;
double result = r.Call(expect); double result = r.Call(expect);
if (std::isnan(expect)) { if (std::isnan(expect)) {
CHECK(std::isnan(result)); CHECK(std::isnan(result));
...@@ -764,8 +763,8 @@ WASM_EXEC_TEST(Select) { ...@@ -764,8 +763,8 @@ WASM_EXEC_TEST(Select) {
// return select(11, 22, a); // return select(11, 22, a);
BUILD(r, WASM_SELECT(WASM_I32V_1(11), WASM_I32V_1(22), WASM_GET_LOCAL(0))); BUILD(r, WASM_SELECT(WASM_I32V_1(11), WASM_I32V_1(22), WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 11 : 22; int32_t expected = i ? 11 : 22;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -776,7 +775,7 @@ WASM_EXEC_TEST(Select_strict1) { ...@@ -776,7 +775,7 @@ WASM_EXEC_TEST(Select_strict1) {
WASM_TEE_LOCAL(0, WASM_I32V_1(1)), WASM_TEE_LOCAL(0, WASM_I32V_1(1)),
WASM_TEE_LOCAL(0, WASM_I32V_1(2))), WASM_TEE_LOCAL(0, WASM_I32V_1(2))),
WASM_DROP, WASM_GET_LOCAL(0)); WASM_DROP, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(i)); }
} }
WASM_EXEC_TEST(Select_strict2) { WASM_EXEC_TEST(Select_strict2) {
...@@ -787,8 +786,8 @@ WASM_EXEC_TEST(Select_strict2) { ...@@ -787,8 +786,8 @@ WASM_EXEC_TEST(Select_strict2) {
BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(1, WASM_I32V_1(5)), BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(1, WASM_I32V_1(5)),
WASM_TEE_LOCAL(2, WASM_I32V_1(6)), WASM_GET_LOCAL(0))); WASM_TEE_LOCAL(2, WASM_I32V_1(6)), WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 5 : 6; int32_t expected = i ? 5 : 6;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -802,7 +801,7 @@ WASM_EXEC_TEST(Select_strict3) { ...@@ -802,7 +801,7 @@ WASM_EXEC_TEST(Select_strict3) {
WASM_TEE_LOCAL(0, WASM_GET_LOCAL(1)))); WASM_TEE_LOCAL(0, WASM_GET_LOCAL(1))));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = 5; int32_t expected = 5;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -811,7 +810,7 @@ WASM_EXEC_TEST(BrIf_strict) { ...@@ -811,7 +810,7 @@ WASM_EXEC_TEST(BrIf_strict) {
BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_GET_LOCAL(0), BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_GET_LOCAL(0),
WASM_TEE_LOCAL(0, WASM_I32V_2(99))))); WASM_TEE_LOCAL(0, WASM_I32V_2(99)))));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Br_height) { WASM_EXEC_TEST(Br_height) {
...@@ -839,7 +838,7 @@ WASM_EXEC_TEST(BrTable0a) { ...@@ -839,7 +838,7 @@ WASM_EXEC_TEST(BrTable0a) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0)))), BUILD(r, B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0)))),
WASM_I32V_2(91)); WASM_I32V_2(91));
FOR_INT32_INPUTS(i) { CHECK_EQ(91, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(91, r.Call(i)); }
} }
WASM_EXEC_TEST(BrTable0b) { WASM_EXEC_TEST(BrTable0b) {
...@@ -847,7 +846,7 @@ WASM_EXEC_TEST(BrTable0b) { ...@@ -847,7 +846,7 @@ WASM_EXEC_TEST(BrTable0b) {
BUILD(r, BUILD(r,
B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(0)))), B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(0)))),
WASM_I32V_2(92)); WASM_I32V_2(92));
FOR_INT32_INPUTS(i) { CHECK_EQ(92, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(92, r.Call(i)); }
} }
WASM_EXEC_TEST(BrTable0c) { WASM_EXEC_TEST(BrTable0c) {
...@@ -858,15 +857,15 @@ WASM_EXEC_TEST(BrTable0c) { ...@@ -858,15 +857,15 @@ WASM_EXEC_TEST(BrTable0c) {
RET_I8(76))), RET_I8(76))),
WASM_I32V_2(77)); WASM_I32V_2(77));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i == 0 ? 76 : 77; int32_t expected = i == 0 ? 76 : 77;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
WASM_EXEC_TEST(BrTable1) { WASM_EXEC_TEST(BrTable1) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0))), RET_I8(93)); BUILD(r, B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0))), RET_I8(93));
FOR_INT32_INPUTS(i) { CHECK_EQ(93, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(93, r.Call(i)); }
} }
WASM_EXEC_TEST(BrTable_loop) { WASM_EXEC_TEST(BrTable_loop) {
...@@ -1021,7 +1020,7 @@ WASM_EXEC_TEST(F32ReinterpretI32) { ...@@ -1021,7 +1020,7 @@ WASM_EXEC_TEST(F32ReinterpretI32) {
WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO))); WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i; int32_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -1037,7 +1036,7 @@ WASM_EXEC_TEST(I32ReinterpretF32) { ...@@ -1037,7 +1036,7 @@ WASM_EXEC_TEST(I32ReinterpretF32) {
WASM_I32V_2(107)); WASM_I32V_2(107));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i; int32_t expected = i;
CHECK_EQ(107, r.Call(expected)); CHECK_EQ(107, r.Call(expected));
CHECK_EQ(expected, r.builder().ReadMemory(&memory[0])); CHECK_EQ(expected, r.builder().ReadMemory(&memory[0]));
} }
...@@ -1079,7 +1078,7 @@ WASM_EXEC_TEST(LoadStoreLoad) { ...@@ -1079,7 +1078,7 @@ WASM_EXEC_TEST(LoadStoreLoad) {
WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)); WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i; int32_t expected = i;
r.builder().WriteMemory(&memory[0], expected); r.builder().WriteMemory(&memory[0], expected);
CHECK_EQ(expected, r.Call()); CHECK_EQ(expected, r.Call());
} }
...@@ -1170,61 +1169,61 @@ WASM_EXEC_TEST(VoidReturn2) { ...@@ -1170,61 +1169,61 @@ WASM_EXEC_TEST(VoidReturn2) {
WASM_EXEC_TEST(BrEmpty) { WASM_EXEC_TEST(BrEmpty) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_BRV(0, WASM_GET_LOCAL(0))); BUILD(r, WASM_BRV(0, WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(BrIfEmpty) { WASM_EXEC_TEST(BrIfEmpty) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); BUILD(r, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Block_empty) { WASM_EXEC_TEST(Block_empty) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, kExprBlock, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0)); BUILD(r, kExprBlock, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Block_empty_br1) { WASM_EXEC_TEST(Block_empty_br1) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, B1(WASM_BR(0)), WASM_GET_LOCAL(0)); BUILD(r, B1(WASM_BR(0)), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Block_empty_brif1) { WASM_EXEC_TEST(Block_empty_brif1) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0)); BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Block_empty_brif2) { WASM_EXEC_TEST(Block_empty_brif2) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0)); BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i, i + 1)); }
} }
WASM_EXEC_TEST(Block_i) { WASM_EXEC_TEST(Block_i) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_BLOCK_I(WASM_GET_LOCAL(0))); BUILD(r, WASM_BLOCK_I(WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Block_f) { WASM_EXEC_TEST(Block_f) {
WasmRunner<float, float> r(execution_tier); WasmRunner<float, float> r(execution_tier);
BUILD(r, WASM_BLOCK_F(WASM_GET_LOCAL(0))); BUILD(r, WASM_BLOCK_F(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Block_d) { WASM_EXEC_TEST(Block_d) {
WasmRunner<double, double> r(execution_tier); WasmRunner<double, double> r(execution_tier);
BUILD(r, WASM_BLOCK_D(WASM_GET_LOCAL(0))); BUILD(r, WASM_BLOCK_D(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, r.Call(*i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Block_br2) { WASM_EXEC_TEST(Block_br2) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)))); BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0))));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, static_cast<uint32_t>(r.Call(*i))); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, static_cast<uint32_t>(r.Call(i))); }
} }
WASM_EXEC_TEST(Block_If_P) { WASM_EXEC_TEST(Block_If_P) {
...@@ -1235,51 +1234,51 @@ WASM_EXEC_TEST(Block_If_P) { ...@@ -1235,51 +1234,51 @@ WASM_EXEC_TEST(Block_If_P) {
WASM_BRV(1, WASM_I32V_1(51))), // -- WASM_BRV(1, WASM_I32V_1(51))), // --
WASM_I32V_1(52))); // -- WASM_I32V_1(52))); // --
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 51 : 52; int32_t expected = i ? 51 : 52;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
WASM_EXEC_TEST(Loop_empty) { WASM_EXEC_TEST(Loop_empty) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, kExprLoop, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0)); BUILD(r, kExprLoop, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Loop_i) { WASM_EXEC_TEST(Loop_i) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_LOOP_I(WASM_GET_LOCAL(0))); BUILD(r, WASM_LOOP_I(WASM_GET_LOCAL(0)));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Loop_f) { WASM_EXEC_TEST(Loop_f) {
WasmRunner<float, float> r(execution_tier); WasmRunner<float, float> r(execution_tier);
BUILD(r, WASM_LOOP_F(WASM_GET_LOCAL(0))); BUILD(r, WASM_LOOP_F(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Loop_d) { WASM_EXEC_TEST(Loop_d) {
WasmRunner<double, double> r(execution_tier); WasmRunner<double, double> r(execution_tier);
BUILD(r, WASM_LOOP_D(WASM_GET_LOCAL(0))); BUILD(r, WASM_LOOP_D(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(*i, r.Call(*i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Loop_empty_br1) { WASM_EXEC_TEST(Loop_empty_br1) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, B1(WASM_LOOP(WASM_BR(1))), WASM_GET_LOCAL(0)); BUILD(r, B1(WASM_LOOP(WASM_BR(1))), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Loop_empty_brif1) { WASM_EXEC_TEST(Loop_empty_brif1) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, B1(WASM_LOOP(WASM_BR_IF(1, WASM_ZERO))), WASM_GET_LOCAL(0)); BUILD(r, B1(WASM_LOOP(WASM_BR_IF(1, WASM_ZERO))), WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
WASM_EXEC_TEST(Loop_empty_brif2) { WASM_EXEC_TEST(Loop_empty_brif2) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_LOOP_I(WASM_BRV_IF(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); BUILD(r, WASM_LOOP_I(WASM_BRV_IF(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i, i + 1)); }
} }
WASM_EXEC_TEST(Loop_empty_brif3) { WASM_EXEC_TEST(Loop_empty_brif3) {
...@@ -1288,8 +1287,8 @@ WASM_EXEC_TEST(Loop_empty_brif3) { ...@@ -1288,8 +1287,8 @@ WASM_EXEC_TEST(Loop_empty_brif3) {
WASM_GET_LOCAL(1)); WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) { FOR_UINT32_INPUTS(j) {
CHECK_EQ(*i, r.Call(0, *i, *j)); CHECK_EQ(i, r.Call(0, i, j));
CHECK_EQ(*j, r.Call(1, *i, *j)); CHECK_EQ(j, r.Call(1, i, j));
} }
} }
} }
...@@ -1299,8 +1298,8 @@ WASM_EXEC_TEST(Block_BrIf_P) { ...@@ -1299,8 +1298,8 @@ WASM_EXEC_TEST(Block_BrIf_P) {
BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I32V_1(51), WASM_GET_LOCAL(0)), BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I32V_1(51), WASM_GET_LOCAL(0)),
WASM_I32V_1(52))); WASM_I32V_1(52)));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 51 : 52; int32_t expected = i ? 51 : 52;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -1313,8 +1312,8 @@ WASM_EXEC_TEST(Block_IfElse_P_assign) { ...@@ -1313,8 +1312,8 @@ WASM_EXEC_TEST(Block_IfElse_P_assign) {
WASM_SET_LOCAL(0, WASM_I32V_2(72))), // -- WASM_SET_LOCAL(0, WASM_I32V_2(72))), // --
WASM_GET_LOCAL(0)); WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 71 : 72; int32_t expected = i ? 71 : 72;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -1327,8 +1326,8 @@ WASM_EXEC_TEST(Block_IfElse_P_return) { ...@@ -1327,8 +1326,8 @@ WASM_EXEC_TEST(Block_IfElse_P_return) {
RET_I8(82)), // -- RET_I8(82)), // --
WASM_ZERO); // -- WASM_ZERO); // --
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 81 : 82; int32_t expected = i ? 81 : 82;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -1338,8 +1337,8 @@ WASM_EXEC_TEST(Block_If_P_assign) { ...@@ -1338,8 +1337,8 @@ WASM_EXEC_TEST(Block_If_P_assign) {
BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I32V_1(61))), BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I32V_1(61))),
WASM_GET_LOCAL(0)); WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 61 : *i; int32_t expected = i ? 61 : i;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -1357,8 +1356,8 @@ WASM_EXEC_TEST(ExprIf_P) { ...@@ -1357,8 +1356,8 @@ WASM_EXEC_TEST(ExprIf_P) {
WASM_I32V_1(11), // -- WASM_I32V_1(11), // --
WASM_I32V_1(22))); // -- WASM_I32V_1(22))); // --
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
int32_t expected = *i ? 11 : 22; int32_t expected = i ? 11 : 22;
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(i));
} }
} }
...@@ -2275,9 +2274,9 @@ WASM_EXEC_TEST(Call_Int32Add) { ...@@ -2275,9 +2274,9 @@ WASM_EXEC_TEST(Call_Int32Add) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) + int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(i) +
static_cast<uint32_t>(*j)); static_cast<uint32_t>(j));
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
...@@ -2294,7 +2293,7 @@ WASM_EXEC_TEST(Call_Float32Sub) { ...@@ -2294,7 +2293,7 @@ WASM_EXEC_TEST(Call_Float32Sub) {
WASM_GET_LOCAL(1))); WASM_GET_LOCAL(1)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, r.Call(*i, *j)); } FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(i - j, r.Call(i, j)); }
} }
} }
...@@ -2312,9 +2311,9 @@ WASM_EXEC_TEST(Call_Float64Sub) { ...@@ -2312,9 +2311,9 @@ WASM_EXEC_TEST(Call_Float64Sub) {
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(j) {
r.builder().WriteMemory(&memory[0], *i); r.builder().WriteMemory(&memory[0], i);
r.builder().WriteMemory(&memory[1], *j); r.builder().WriteMemory(&memory[1], j);
double expected = *i - *j; double expected = i - j;
CHECK_EQ(107, r.Call()); CHECK_EQ(107, r.Call());
if (expected != expected) { if (expected != expected) {
...@@ -2445,9 +2444,9 @@ WASM_EXEC_TEST(MultiReturnSub) { ...@@ -2445,9 +2444,9 @@ WASM_EXEC_TEST(MultiReturnSub) {
FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) { FOR_INT32_INPUTS(j) {
int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*j) - int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(j) -
static_cast<uint32_t>(*i)); static_cast<uint32_t>(i));
CHECK_EQ(expected, r.Call(*i, *j)); CHECK_EQ(expected, r.Call(i, j));
} }
} }
} }
...@@ -2779,56 +2778,56 @@ WASM_EXEC_TEST(F32Floor) { ...@@ -2779,56 +2778,56 @@ WASM_EXEC_TEST(F32Floor) {
WasmRunner<float, float> r(execution_tier); WasmRunner<float, float> r(execution_tier);
BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0))); BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), r.Call(*i)); } FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F32Ceil) { WASM_EXEC_TEST(F32Ceil) {
WasmRunner<float, float> r(execution_tier); WasmRunner<float, float> r(execution_tier);
BUILD(r, WASM_F32_CEIL(WASM_GET_LOCAL(0))); BUILD(r, WASM_F32_CEIL(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(ceilf(*i), r.Call(*i)); } FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(ceilf(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F32Trunc) { WASM_EXEC_TEST(F32Trunc) {
WasmRunner<float, float> r(execution_tier); WasmRunner<float, float> r(execution_tier);
BUILD(r, WASM_F32_TRUNC(WASM_GET_LOCAL(0))); BUILD(r, WASM_F32_TRUNC(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(truncf(*i), r.Call(*i)); } FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(truncf(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F32NearestInt) { WASM_EXEC_TEST(F32NearestInt) {
WasmRunner<float, float> r(execution_tier); WasmRunner<float, float> r(execution_tier);
BUILD(r, WASM_F32_NEARESTINT(WASM_GET_LOCAL(0))); BUILD(r, WASM_F32_NEARESTINT(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(nearbyintf(*i), r.Call(*i)); } FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(nearbyintf(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F64Floor) { WASM_EXEC_TEST(F64Floor) {
WasmRunner<double, double> r(execution_tier); WasmRunner<double, double> r(execution_tier);
BUILD(r, WASM_F64_FLOOR(WASM_GET_LOCAL(0))); BUILD(r, WASM_F64_FLOOR(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(floor(*i), r.Call(*i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(floor(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F64Ceil) { WASM_EXEC_TEST(F64Ceil) {
WasmRunner<double, double> r(execution_tier); WasmRunner<double, double> r(execution_tier);
BUILD(r, WASM_F64_CEIL(WASM_GET_LOCAL(0))); BUILD(r, WASM_F64_CEIL(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ceil(*i), r.Call(*i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ceil(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F64Trunc) { WASM_EXEC_TEST(F64Trunc) {
WasmRunner<double, double> r(execution_tier); WasmRunner<double, double> r(execution_tier);
BUILD(r, WASM_F64_TRUNC(WASM_GET_LOCAL(0))); BUILD(r, WASM_F64_TRUNC(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(trunc(*i), r.Call(*i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(trunc(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F64NearestInt) { WASM_EXEC_TEST(F64NearestInt) {
WasmRunner<double, double> r(execution_tier); WasmRunner<double, double> r(execution_tier);
BUILD(r, WASM_F64_NEARESTINT(WASM_GET_LOCAL(0))); BUILD(r, WASM_F64_NEARESTINT(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(nearbyint(*i), r.Call(*i)); } FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(nearbyint(i), r.Call(i)); }
} }
WASM_EXEC_TEST(F32Min) { WASM_EXEC_TEST(F32Min) {
...@@ -2836,7 +2835,7 @@ WASM_EXEC_TEST(F32Min) { ...@@ -2836,7 +2835,7 @@ WASM_EXEC_TEST(F32Min) {
BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
FOR_FLOAT32_INPUTS(j) { CHECK_DOUBLE_EQ(JSMin(*i, *j), r.Call(*i, *j)); } FOR_FLOAT32_INPUTS(j) { CHECK_DOUBLE_EQ(JSMin(i, j), r.Call(i, j)); }
} }
} }
...@@ -2852,7 +2851,7 @@ WASM_EXEC_TEST(F64Min) { ...@@ -2852,7 +2851,7 @@ WASM_EXEC_TEST(F64Min) {
BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(JSMin(*i, *j), r.Call(*i, *j)); } FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(JSMin(i, j), r.Call(i, j)); }
} }
} }
...@@ -2868,7 +2867,7 @@ WASM_EXEC_TEST(F32Max) { ...@@ -2868,7 +2867,7 @@ WASM_EXEC_TEST(F32Max) {
BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(JSMax(*i, *j), r.Call(*i, *j)); } FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(JSMax(i, j), r.Call(i, j)); }
} }
} }
...@@ -2885,8 +2884,8 @@ WASM_EXEC_TEST(F64Max) { ...@@ -2885,8 +2884,8 @@ WASM_EXEC_TEST(F64Max) {
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) { FOR_FLOAT64_INPUTS(j) {
double result = r.Call(*i, *j); double result = r.Call(i, j);
CHECK_DOUBLE_EQ(JSMax(*i, *j), result); CHECK_DOUBLE_EQ(JSMax(i, j), result);
} }
} }
} }
...@@ -2903,10 +2902,10 @@ WASM_EXEC_TEST(I32SConvertF32) { ...@@ -2903,10 +2902,10 @@ WASM_EXEC_TEST(I32SConvertF32) {
BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (is_inbounds<int32_t>(*i)) { if (is_inbounds<int32_t>(i)) {
CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<int32_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP32(r.Call(*i)); CHECK_TRAP32(r.Call(i));
} }
} }
} }
...@@ -2918,12 +2917,12 @@ WASM_EXEC_TEST(I32SConvertSatF32) { ...@@ -2918,12 +2917,12 @@ WASM_EXEC_TEST(I32SConvertSatF32) {
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
int32_t expected = int32_t expected =
is_inbounds<int32_t>(*i) is_inbounds<int32_t>(i)
? static_cast<int32_t>(*i) ? static_cast<int32_t>(i)
: std::isnan(*i) ? 0 : std::isnan(i) ? 0
: *i < 0.0 ? std::numeric_limits<int32_t>::min() : i < 0.0 ? std::numeric_limits<int32_t>::min()
: std::numeric_limits<int32_t>::max(); : std::numeric_limits<int32_t>::max();
int32_t found = r.Call(*i); int32_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -2933,10 +2932,10 @@ WASM_EXEC_TEST(I32SConvertF64) { ...@@ -2933,10 +2932,10 @@ WASM_EXEC_TEST(I32SConvertF64) {
BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
if (is_inbounds<int32_t>(*i)) { if (is_inbounds<int32_t>(i)) {
CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<int32_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP32(r.Call(*i)); CHECK_TRAP32(r.Call(i));
} }
} }
} }
...@@ -2947,12 +2946,12 @@ WASM_EXEC_TEST(I32SConvertSatF64) { ...@@ -2947,12 +2946,12 @@ WASM_EXEC_TEST(I32SConvertSatF64) {
BUILD(r, WASM_I32_SCONVERT_SAT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_SCONVERT_SAT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
int32_t expected = int32_t expected =
is_inbounds<int32_t>(*i) is_inbounds<int32_t>(i)
? static_cast<int32_t>(*i) ? static_cast<int32_t>(i)
: std::isnan(*i) ? 0 : std::isnan(i) ? 0
: *i < 0.0 ? std::numeric_limits<int32_t>::min() : i < 0.0 ? std::numeric_limits<int32_t>::min()
: std::numeric_limits<int32_t>::max(); : std::numeric_limits<int32_t>::max();
int32_t found = r.Call(*i); int32_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -2961,10 +2960,10 @@ WASM_EXEC_TEST(I32UConvertF32) { ...@@ -2961,10 +2960,10 @@ WASM_EXEC_TEST(I32UConvertF32) {
WasmRunner<uint32_t, float> r(execution_tier); WasmRunner<uint32_t, float> r(execution_tier);
BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
if (is_inbounds<uint32_t>(*i)) { if (is_inbounds<uint32_t>(i)) {
CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<uint32_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP32(r.Call(*i)); CHECK_TRAP32(r.Call(i));
} }
} }
} }
...@@ -2975,12 +2974,12 @@ WASM_EXEC_TEST(I32UConvertSatF32) { ...@@ -2975,12 +2974,12 @@ WASM_EXEC_TEST(I32UConvertSatF32) {
BUILD(r, WASM_I32_UCONVERT_SAT_F32(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_UCONVERT_SAT_F32(WASM_GET_LOCAL(0)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
int32_t expected = int32_t expected =
is_inbounds<uint32_t>(*i) is_inbounds<uint32_t>(i)
? static_cast<uint32_t>(*i) ? static_cast<uint32_t>(i)
: std::isnan(*i) ? 0 : std::isnan(i) ? 0
: *i < 0.0 ? std::numeric_limits<uint32_t>::min() : i < 0.0 ? std::numeric_limits<uint32_t>::min()
: std::numeric_limits<uint32_t>::max(); : std::numeric_limits<uint32_t>::max();
int32_t found = r.Call(*i); int32_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -2989,10 +2988,10 @@ WASM_EXEC_TEST(I32UConvertF64) { ...@@ -2989,10 +2988,10 @@ WASM_EXEC_TEST(I32UConvertF64) {
WasmRunner<uint32_t, double> r(execution_tier); WasmRunner<uint32_t, double> r(execution_tier);
BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
if (is_inbounds<uint32_t>(*i)) { if (is_inbounds<uint32_t>(i)) {
CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); CHECK_EQ(static_cast<uint32_t>(i), r.Call(i));
} else { } else {
CHECK_TRAP32(r.Call(*i)); CHECK_TRAP32(r.Call(i));
} }
} }
} }
...@@ -3003,12 +3002,12 @@ WASM_EXEC_TEST(I32UConvertSatF64) { ...@@ -3003,12 +3002,12 @@ WASM_EXEC_TEST(I32UConvertSatF64) {
BUILD(r, WASM_I32_UCONVERT_SAT_F64(WASM_GET_LOCAL(0))); BUILD(r, WASM_I32_UCONVERT_SAT_F64(WASM_GET_LOCAL(0)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
int32_t expected = int32_t expected =
is_inbounds<uint32_t>(*i) is_inbounds<uint32_t>(i)
? static_cast<uint32_t>(*i) ? static_cast<uint32_t>(i)
: std::isnan(*i) ? 0 : std::isnan(i) ? 0
: *i < 0.0 ? std::numeric_limits<uint32_t>::min() : i < 0.0 ? std::numeric_limits<uint32_t>::min()
: std::numeric_limits<uint32_t>::max(); : std::numeric_limits<uint32_t>::max();
int32_t found = r.Call(*i); int32_t found = r.Call(i);
CHECK_EQ(expected, found); CHECK_EQ(expected, found);
} }
} }
...@@ -3018,7 +3017,7 @@ WASM_EXEC_TEST(F64CopySign) { ...@@ -3018,7 +3017,7 @@ WASM_EXEC_TEST(F64CopySign) {
BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT64_INPUTS(i) { FOR_FLOAT64_INPUTS(i) {
FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(copysign(*i, *j), r.Call(*i, *j)); } FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(copysign(i, j), r.Call(i, j)); }
} }
} }
...@@ -3027,7 +3026,7 @@ WASM_EXEC_TEST(F32CopySign) { ...@@ -3027,7 +3026,7 @@ WASM_EXEC_TEST(F32CopySign) {
BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_FLOAT32_INPUTS(i) { FOR_FLOAT32_INPUTS(i) {
FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysignf(*i, *j), r.Call(*i, *j)); } FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysignf(i, j), r.Call(i, j)); }
} }
} }
......
...@@ -105,7 +105,7 @@ TEST(TestArgumentPassing_int32) { ...@@ -105,7 +105,7 @@ TEST(TestArgumentPassing_int32) {
return base::AddWithWraparound(base::MulWithWraparound(2, a), 1); return base::AddWithWraparound(base::MulWithWraparound(2, a), 1);
}); });
FOR_INT32_INPUTS(v) { helper.CheckCall(*v); } FOR_INT32_INPUTS(v) { helper.CheckCall(v); }
} }
// Pass int64_t, return double. // Pass int64_t, return double.
...@@ -129,12 +129,12 @@ TEST(TestArgumentPassing_double_int64) { ...@@ -129,12 +129,12 @@ TEST(TestArgumentPassing_double_int64) {
}); });
FOR_INT32_INPUTS(v1) { FOR_INT32_INPUTS(v1) {
FOR_INT32_INPUTS(v2) { helper.CheckCall(*v1, *v2); } FOR_INT32_INPUTS(v2) { helper.CheckCall(v1, v2); }
} }
FOR_INT64_INPUTS(v) { FOR_INT64_INPUTS(v) {
int32_t v1 = static_cast<int32_t>(*v); int32_t v1 = static_cast<int32_t>(v);
int32_t v2 = static_cast<int32_t>(*v >> 32); int32_t v2 = static_cast<int32_t>(v >> 32);
helper.CheckCall(v1, v2); helper.CheckCall(v1, v2);
helper.CheckCall(v2, v1); helper.CheckCall(v2, v1);
} }
...@@ -175,7 +175,7 @@ TEST(TestArgumentPassing_float_double) { ...@@ -175,7 +175,7 @@ TEST(TestArgumentPassing_float_double) {
WASM_GET_LOCAL(0), WASM_CALL_FUNCTION0(f2.function_index())}, WASM_GET_LOCAL(0), WASM_CALL_FUNCTION0(f2.function_index())},
[](float f) { return 2. * static_cast<double>(f) + 1.; }); [](float f) { return 2. * static_cast<double>(f) + 1.; });
FOR_FLOAT32_INPUTS(f) { helper.CheckCall(*f); } FOR_FLOAT32_INPUTS(f) { helper.CheckCall(f); }
} }
// Pass two doubles, return double. // Pass two doubles, return double.
...@@ -192,7 +192,7 @@ TEST(TestArgumentPassing_double_double) { ...@@ -192,7 +192,7 @@ TEST(TestArgumentPassing_double_double) {
[](double a, double b) { return a + b; }); [](double a, double b) { return a + b; });
FOR_FLOAT64_INPUTS(d1) { FOR_FLOAT64_INPUTS(d1) {
FOR_FLOAT64_INPUTS(d2) { helper.CheckCall(*d1, *d2); } FOR_FLOAT64_INPUTS(d2) { helper.CheckCall(d1, d2); }
} }
} }
......
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