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

Unified Diff: test/cctest/compiler/test-run-calls-to-external-references.cc

Issue 1804513002: [wasm] Int64Lowering of I64Div and I64Rem. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 9 months 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/wasm/wasm-external-refs.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-calls-to-external-references.cc
diff --git a/test/cctest/compiler/test-run-calls-to-external-references.cc b/test/cctest/compiler/test-run-calls-to-external-references.cc
index 2444045e9a49aa8c67f58ecee91e1a47aa9c9a92..3b79cd8a4495a9721dbf4970e580ee5d0d8b26ea 100644
--- a/test/cctest/compiler/test-run-calls-to-external-references.cc
+++ b/test/cctest/compiler/test-run-calls-to-external-references.cc
@@ -424,6 +424,108 @@ TEST(RunCallFloat64ToUint64) {
}
}
}
+
+TEST(RunCallInt64Div) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_int64_div(m.isolate());
+
+ int64_t dst;
+ int64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_INT64_INPUTS(i) {
+ FOR_INT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else if (src == -1 && dst == std::numeric_limits<int64_t>::min()) {
+ CHECK_EQ(-1, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i / *j, dst);
+ }
+ }
+ }
+}
+
+TEST(RunCallInt64Mod) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_int64_mod(m.isolate());
+
+ int64_t dst;
+ int64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_INT64_INPUTS(i) {
+ FOR_INT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i % *j, dst);
+ }
+ }
+ }
+}
+
+TEST(RunCallUint64Div) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_uint64_div(m.isolate());
+
+ uint64_t dst;
+ uint64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i / *j, dst);
+ }
+ }
+ }
+}
+
+TEST(RunCallUint64Mod) {
+ BufferedRawMachineAssemblerTester<int32_t> m;
+ ExternalReference ref = ExternalReference::wasm_uint64_mod(m.isolate());
+
+ uint64_t dst;
+ uint64_t src;
+
+ Node* function = m.ExternalConstant(ref);
+ m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Pointer(), function,
+ m.PointerConstant(&dst), m.PointerConstant(&src)));
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ dst = *i;
+ src = *j;
+ if (src == 0) {
+ CHECK_EQ(0, m.Call());
+ } else {
+ CHECK_EQ(1, m.Call());
+ CHECK_EQ(*i % *j, dst);
+ }
+ }
+ }
+}
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/wasm-external-refs.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698