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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 5120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5131 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); 5131 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64)));
5132 m.Return(m.Int32Constant(0)); 5132 m.Return(m.Int32Constant(0));
5133 for (size_t i = 0; i < arraysize(kValues); ++i) { 5133 for (size_t i = 0; i < arraysize(kValues); ++i) {
5134 input = kValues[i]; 5134 input = kValues[i];
5135 CHECK_EQ(0, m.Call()); 5135 CHECK_EQ(0, m.Call());
5136 double expected = round(kValues[i]); 5136 double expected = round(kValues[i]);
5137 CHECK_EQ(expected, result); 5137 CHECK_EQ(expected, result);
5138 } 5138 }
5139 } 5139 }
5140 5140
5141
5142 #if !USE_SIMULATOR
5143
5144 namespace {
5145
5146 int32_t const kMagicFoo0 = 0xdeadbeef;
5147
5148
5149 int32_t foo0() { return kMagicFoo0; }
5150
5151
5152 int32_t foo1(int32_t x) { return x; }
5153
5154
5155 int32_t foo2(int32_t x, int32_t y) { return x - y; }
5156
5157 } // namespace
5158
5159
5160 TEST(RunCallCFunction0) {
5161 auto* foo0_ptr = &foo0;
5162 RawMachineAssemblerTester<int32_t> m;
5163 Node* function = m.LoadFromPointer(&foo0_ptr, kMachPtr);
5164 m.Return(m.CallCFunction0(kMachInt32, function));
5165 CHECK_EQ(kMagicFoo0, m.Call());
5166 }
5167
5168
5169 TEST(RunCallCFunction1) {
5170 auto* foo1_ptr = &foo1;
5171 RawMachineAssemblerTester<int32_t> m(kMachInt32);
5172 Node* function = m.LoadFromPointer(&foo1_ptr, kMachPtr);
5173 m.Return(m.CallCFunction1(kMachInt32, kMachInt32, function, m.Parameter(0)));
5174 FOR_INT32_INPUTS(i) {
5175 int32_t const expected = *i;
5176 CHECK_EQ(expected, m.Call(expected));
5177 }
5178 }
5179
5180
5181 TEST(RunCallCFunction2) {
5182 auto* foo2_ptr = &foo2;
5183 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
5184 Node* function = m.LoadFromPointer(&foo2_ptr, kMachPtr);
5185 m.Return(m.CallCFunction2(kMachInt32, kMachInt32, kMachInt32, function,
5186 m.Parameter(0), m.Parameter(1)));
5187 FOR_INT32_INPUTS(i) {
5188 int32_t const x = *i;
5189 FOR_INT32_INPUTS(j) {
5190 int32_t const y = *j;
5191 CHECK_EQ(x - y, m.Call(x, y));
5192 }
5193 }
5194 }
5195
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.
5196 #endif // USE_SIMULATOR
5197
5141 #endif // V8_TURBOFAN_TARGET 5198 #endif // V8_TURBOFAN_TARGET
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698