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

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: Fix argument slots. 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
« no previous file with comments | « src/compiler/x64/linkage-x64.cc ('k') | test/unittests/compiler/raw-machine-assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
5158 int32_t foo8(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f,
5159 int32_t g, int32_t h) {
5160 return a + b + c + d + e + f + g + h;
Sven Panne 2015/06/25 08:35:09 Using a non-commutative and non-associative operat
5161 }
5162
5163 } // namespace
5164
5165
5166 TEST(RunCallCFunction0) {
5167 auto* foo0_ptr = &foo0;
5168 RawMachineAssemblerTester<int32_t> m;
5169 Node* function = m.LoadFromPointer(&foo0_ptr, kMachPtr);
5170 m.Return(m.CallCFunction0(kMachInt32, function));
5171 CHECK_EQ(kMagicFoo0, m.Call());
5172 }
5173
5174
5175 TEST(RunCallCFunction1) {
5176 auto* foo1_ptr = &foo1;
5177 RawMachineAssemblerTester<int32_t> m(kMachInt32);
5178 Node* function = m.LoadFromPointer(&foo1_ptr, kMachPtr);
5179 m.Return(m.CallCFunction1(kMachInt32, kMachInt32, function, m.Parameter(0)));
5180 FOR_INT32_INPUTS(i) {
5181 int32_t const expected = *i;
5182 CHECK_EQ(expected, m.Call(expected));
5183 }
5184 }
5185
5186
5187 TEST(RunCallCFunction2) {
5188 auto* foo2_ptr = &foo2;
5189 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
5190 Node* function = m.LoadFromPointer(&foo2_ptr, kMachPtr);
5191 m.Return(m.CallCFunction2(kMachInt32, kMachInt32, kMachInt32, function,
5192 m.Parameter(0), m.Parameter(1)));
5193 FOR_INT32_INPUTS(i) {
5194 int32_t const x = *i;
5195 FOR_INT32_INPUTS(j) {
5196 int32_t const y = *j;
5197 CHECK_EQ(x - y, m.Call(x, y));
5198 }
5199 }
5200 }
5201
5202
5203 TEST(RunCallCFunction8) {
5204 auto* foo8_ptr = &foo8;
5205 RawMachineAssemblerTester<int32_t> m(kMachInt32);
5206 Node* function = m.LoadFromPointer(&foo8_ptr, kMachPtr);
5207 Node* param = m.Parameter(0);
5208 m.Return(m.CallCFunction8(kMachInt32, kMachInt32, kMachInt32, kMachInt32,
5209 kMachInt32, kMachInt32, kMachInt32, kMachInt32,
5210 kMachInt32, function, param, param, param, param,
Sven Panne 2015/06/25 08:35:09 Using the same actual parameter for all formal par
5211 param, param, param, param));
5212 FOR_INT32_INPUTS(i) {
5213 int32_t const x = *i;
5214 CHECK_EQ(x * 8, m.Call(x));
5215 }
5216 }
5217
5218 #endif // USE_SIMULATOR
5219
5141 #endif // V8_TURBOFAN_TARGET 5220 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « src/compiler/x64/linkage-x64.cc ('k') | test/unittests/compiler/raw-machine-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698