Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1394)

Unified Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1519013003: [wasm] Change the return type of traps for tests, and added ftoi64 instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@f32toui64
Patch Set: Fixed nits. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm.cc
diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc
index 7db7cb740e6483f4a446fb81c23331df7c24886b..7570583320e3e97009588f221618765e086c0107 100644
--- a/test/cctest/wasm/test-run-wasm.cc
+++ b/test/cctest/wasm/test-run-wasm.cc
@@ -32,7 +32,12 @@
// Currently, in tests, we just return 0xdeadbeef from the function in which
// the trap occurs if the runtime context is not available to throw a JavaScript
// exception.
-#define CHECK_TRAP(x) CHECK_EQ(0xdeadbeef, (x)&0xFFFFFFFF)
+#define CHECK_TRAP32(x) \
+ CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF)
+#define CHECK_TRAP64(x) \
+ CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF)
+#define CHECK_TRAP(x) CHECK_TRAP32(x)
+
using namespace v8::base;
using namespace v8::internal;
@@ -214,7 +219,7 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
CallDescriptor* descriptor() { return descriptor_; }
void Build(const byte* start, const byte* end) {
- compiler::WasmGraphBuilder builder(main_zone(), &jsgraph);
+ compiler::WasmGraphBuilder builder(main_zone(), &jsgraph, env.sig);
TreeResult result = BuildTFGraph(&builder, &env, start, end);
if (result.failed()) {
ptrdiff_t pc = result.error_pc - result.start;
@@ -973,10 +978,10 @@ TEST(Run_WASM_Int64DivS_trap) {
WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(0, r.Call(as64(0), as64(100)));
- CHECK_TRAP(r.Call(as64(100), as64(0)));
- CHECK_TRAP(r.Call(as64(-1001), as64(0)));
- CHECK_TRAP(r.Call(std::numeric_limits<int64_t>::min(), as64(-1)));
- CHECK_TRAP(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
+ CHECK_TRAP64(r.Call(as64(100), as64(0)));
+ CHECK_TRAP64(r.Call(as64(-1001), as64(0)));
+ CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), as64(-1)));
+ CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
}
@@ -985,9 +990,9 @@ TEST(Run_WASM_Int64RemS_trap) {
BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(33, r.Call(as64(133), as64(100)));
CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), as64(-1)));
- CHECK_TRAP(r.Call(as64(100), as64(0)));
- CHECK_TRAP(r.Call(as64(-1001), as64(0)));
- CHECK_TRAP(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
+ CHECK_TRAP64(r.Call(as64(100), as64(0)));
+ CHECK_TRAP64(r.Call(as64(-1001), as64(0)));
+ CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
}
@@ -996,9 +1001,9 @@ TEST(Run_WASM_Int64DivU_trap) {
BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(0, r.Call(as64(0), as64(100)));
CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), as64(-1)));
- CHECK_TRAP(r.Call(as64(100), as64(0)));
- CHECK_TRAP(r.Call(as64(-1001), as64(0)));
- CHECK_TRAP(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
+ CHECK_TRAP64(r.Call(as64(100), as64(0)));
+ CHECK_TRAP64(r.Call(as64(-1001), as64(0)));
+ CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
}
@@ -1006,9 +1011,9 @@ TEST(Run_WASM_Int64RemU_trap) {
WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(17, r.Call(as64(217), as64(100)));
- CHECK_TRAP(r.Call(as64(100), as64(0)));
- CHECK_TRAP(r.Call(as64(-1001), as64(0)));
- CHECK_TRAP(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
+ CHECK_TRAP64(r.Call(as64(100), as64(0)));
+ CHECK_TRAP64(r.Call(as64(-1001), as64(0)));
+ CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), as64(0)));
CHECK_EQ(std::numeric_limits<int64_t>::min(),
r.Call(std::numeric_limits<int64_t>::min(), as64(-1)));
}
@@ -1020,7 +1025,7 @@ TEST(Run_WASM_Int64DivS_byzero_const) {
BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64(denom)));
for (int64_t val = -7; val < 8; val++) {
if (denom == 0) {
- CHECK_TRAP(r.Call(val));
+ CHECK_TRAP64(r.Call(val));
} else {
CHECK_EQ(val / denom, r.Call(val));
}
@@ -1036,7 +1041,7 @@ TEST(Run_WASM_Int64DivU_byzero_const) {
for (uint64_t val = 0xfffffffffffffff0; val < 8; val++) {
if (denom == 0) {
- CHECK_TRAP(r.Call(val));
+ CHECK_TRAP64(r.Call(val));
} else {
CHECK_EQ(val / denom, r.Call(val));
}
@@ -3243,6 +3248,60 @@ TEST(Run_Wasm_F64UConvertI64) {
}
+TEST(Run_Wasm_I64SConvertF32) {
+ WasmRunner<int64_t> r(MachineType::Float32());
+ BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT32_INPUTS(i) {
+ if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) {
+ CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP64(r.Call(*i));
+ }
+ }
+}
+
+
+TEST(Run_Wasm_I64SConvertF64) {
+ WasmRunner<int64_t> r(MachineType::Float64());
+ BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT64_INPUTS(i) {
+ if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) {
+ CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP64(r.Call(*i));
+ }
+ }
+}
+
+
+TEST(Run_Wasm_I64UConvertF32) {
+ WasmRunner<uint64_t> r(MachineType::Float32());
+ BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT32_INPUTS(i) {
+ if (*i < 18446744073709551616.0 && *i >= 0) {
+ CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP64(r.Call(*i));
+ }
+ }
+}
+
+
+TEST(Run_Wasm_I64UConvertF64) {
+ WasmRunner<uint64_t> r(MachineType::Float64());
+ BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT64_INPUTS(i) {
+ if (*i < 18446744073709551616.0 && *i >= 0) {
+ CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP64(r.Call(*i));
+ }
+ }
+}
#endif
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698