OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // 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/ieee754.h" | 10 #include "src/base/ieee754.h" |
(...skipping 6145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6156 | 6156 |
6157 | 6157 |
6158 int32_t foo2(int32_t x, int32_t y) { return x - y; } | 6158 int32_t foo2(int32_t x, int32_t y) { return x - y; } |
6159 | 6159 |
6160 | 6160 |
6161 int32_t foo8(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, | 6161 int32_t foo8(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, |
6162 int32_t g, int32_t h) { | 6162 int32_t g, int32_t h) { |
6163 return a + b + c + d + e + f + g + h; | 6163 return a + b + c + d + e + f + g + h; |
6164 } | 6164 } |
6165 | 6165 |
| 6166 int32_t foo9(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, int32_t f, |
| 6167 int32_t g, int32_t h, int32_t i) { |
| 6168 return a + b + c + d + e + f + g + h + i; |
| 6169 } |
| 6170 |
6166 } // namespace | 6171 } // namespace |
6167 | 6172 |
6168 | 6173 |
6169 TEST(RunCallCFunction0) { | 6174 TEST(RunCallCFunction0) { |
6170 auto* foo0_ptr = &foo0; | 6175 auto* foo0_ptr = &foo0; |
6171 RawMachineAssemblerTester<int32_t> m; | 6176 RawMachineAssemblerTester<int32_t> m; |
6172 Node* function = m.LoadFromPointer(&foo0_ptr, MachineType::Pointer()); | 6177 Node* function = m.LoadFromPointer(&foo0_ptr, MachineType::Pointer()); |
6173 m.Return(m.CallCFunction0(MachineType::Int32(), function)); | 6178 m.Return(m.CallCFunction0(MachineType::Int32(), function)); |
6174 CHECK_EQ(kMagicFoo0, m.Call()); | 6179 CHECK_EQ(kMagicFoo0, m.Call()); |
6175 } | 6180 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6214 m.Return(m.CallCFunction8( | 6219 m.Return(m.CallCFunction8( |
6215 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), | 6220 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), |
6216 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), | 6221 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), |
6217 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), | 6222 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), |
6218 function, param, param, param, param, param, param, param, param)); | 6223 function, param, param, param, param, param, param, param, param)); |
6219 FOR_INT32_INPUTS(i) { | 6224 FOR_INT32_INPUTS(i) { |
6220 int32_t const x = *i; | 6225 int32_t const x = *i; |
6221 CHECK_EQ(x * 8, m.Call(x)); | 6226 CHECK_EQ(x * 8, m.Call(x)); |
6222 } | 6227 } |
6223 } | 6228 } |
| 6229 |
| 6230 TEST(RunCallCFunction9) { |
| 6231 auto* foo9_ptr = &foo9; |
| 6232 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 6233 Node* function = m.LoadFromPointer(&foo9_ptr, MachineType::Pointer()); |
| 6234 Node* param = m.Parameter(0); |
| 6235 m.Return(m.CallCFunction9( |
| 6236 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), |
| 6237 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), |
| 6238 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), |
| 6239 MachineType::Int32(), function, param, |
| 6240 m.Int32Add(param, m.Int32Constant(1)), |
| 6241 m.Int32Add(param, m.Int32Constant(2)), |
| 6242 m.Int32Add(param, m.Int32Constant(3)), |
| 6243 m.Int32Add(param, m.Int32Constant(4)), |
| 6244 m.Int32Add(param, m.Int32Constant(5)), |
| 6245 m.Int32Add(param, m.Int32Constant(6)), |
| 6246 m.Int32Add(param, m.Int32Constant(7)), |
| 6247 m.Int32Add(param, m.Int32Constant(8)))); |
| 6248 FOR_INT32_INPUTS(i) { |
| 6249 int32_t const x = *i; |
| 6250 CHECK_EQ(x * 9 + 36, m.Call(x)); |
| 6251 } |
| 6252 } |
6224 #endif // USE_SIMULATOR | 6253 #endif // USE_SIMULATOR |
6225 | 6254 |
6226 #if V8_TARGET_ARCH_64_BIT | 6255 #if V8_TARGET_ARCH_64_BIT |
6227 // TODO(titzer): run int64 tests on all platforms when supported. | 6256 // TODO(titzer): run int64 tests on all platforms when supported. |
6228 | 6257 |
6229 TEST(RunBitcastInt64ToFloat64) { | 6258 TEST(RunBitcastInt64ToFloat64) { |
6230 int64_t input = 1; | 6259 int64_t input = 1; |
6231 double output = 0.0; | 6260 double output = 0.0; |
6232 RawMachineAssemblerTester<int32_t> m; | 6261 RawMachineAssemblerTester<int32_t> m; |
6233 m.StoreToPointer( | 6262 m.StoreToPointer( |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6782 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Int32()); | 6811 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
6783 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(0)), | 6812 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(0)), |
6784 m.Int32Constant(0xffffffff))); | 6813 m.Int32Constant(0xffffffff))); |
6785 int32_t input = 1234; | 6814 int32_t input = 1234; |
6786 CHECK_EQ(input, m.Call(input)); | 6815 CHECK_EQ(input, m.Call(input)); |
6787 } | 6816 } |
6788 | 6817 |
6789 } // namespace compiler | 6818 } // namespace compiler |
6790 } // namespace internal | 6819 } // namespace internal |
6791 } // namespace v8 | 6820 } // namespace v8 |
OLD | NEW |