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

Unified Diff: test/cctest/compiler/test-run-machops.cc

Issue 1205023002: [turbofan] Add basic support for calling to (a subset of) C functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
Index: test/cctest/compiler/test-run-machops.cc
diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc
index 251afdfb70f070c580bff952aa83b2fa40e66a86..f945887ce7e361cb406119105acc6dadbde90a79 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -5138,4 +5138,61 @@ TEST(RunFloat64RoundTiesAway) {
}
}
+
+#if !USE_SIMULATOR
+
+namespace {
+
+int32_t const kMagicFoo0 = 0xdeadbeef;
+
+
+int32_t foo0() { return kMagicFoo0; }
+
+
+int32_t foo1(int32_t x) { return x; }
+
+
+int32_t foo2(int32_t x, int32_t y) { return x - y; }
+
+} // namespace
+
+
+TEST(RunCallCFunction0) {
+ auto* foo0_ptr = &foo0;
+ RawMachineAssemblerTester<int32_t> m;
+ Node* function = m.LoadFromPointer(&foo0_ptr, kMachPtr);
+ m.Return(m.CallCFunction0(kMachInt32, function));
+ CHECK_EQ(kMagicFoo0, m.Call());
+}
+
+
+TEST(RunCallCFunction1) {
+ auto* foo1_ptr = &foo1;
+ RawMachineAssemblerTester<int32_t> m(kMachInt32);
+ Node* function = m.LoadFromPointer(&foo1_ptr, kMachPtr);
+ m.Return(m.CallCFunction1(kMachInt32, kMachInt32, function, m.Parameter(0)));
+ FOR_INT32_INPUTS(i) {
+ int32_t const expected = *i;
+ CHECK_EQ(expected, m.Call(expected));
+ }
+}
+
+
+TEST(RunCallCFunction2) {
+ auto* foo2_ptr = &foo2;
+ RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
+ Node* function = m.LoadFromPointer(&foo2_ptr, kMachPtr);
+ m.Return(m.CallCFunction2(kMachInt32, kMachInt32, kMachInt32, function,
+ m.Parameter(0), m.Parameter(1)));
+ FOR_INT32_INPUTS(i) {
+ int32_t const x = *i;
+ FOR_INT32_INPUTS(j) {
+ int32_t const y = *j;
+ CHECK_EQ(x - y, m.Call(x, y));
+ }
+ }
+}
+
Sven Panne 2015/06/25 07:15:59 What about float/double/int64_t/... arguments/retu
Benedikt Meurer 2015/06/25 07:31:10 Acknowledged.
+#endif // USE_SIMULATOR
+
#endif // V8_TURBOFAN_TARGET

Powered by Google App Engine
This is Rietveld 408576698