OLD | NEW |
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 #ifndef V8_CCTEST_COMPILER_CALL_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_CALL_TESTER_H_ |
6 #define V8_CCTEST_COMPILER_CALL_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_CALL_TESTER_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/simulator.h" | 10 #include "src/simulator.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 template <typename R, typename F, typename P1, typename P2, typename P3, | 201 template <typename R, typename F, typename P1, typename P2, typename P3, |
202 typename P4> | 202 typename P4> |
203 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { | 203 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { |
204 Simulator::CallArgument args[] = { | 204 Simulator::CallArgument args[] = { |
205 Simulator::CallArgument(p1), Simulator::CallArgument(p2), | 205 Simulator::CallArgument(p1), Simulator::CallArgument(p2), |
206 Simulator::CallArgument(p3), Simulator::CallArgument(p4), | 206 Simulator::CallArgument(p3), Simulator::CallArgument(p4), |
207 Simulator::CallArgument::End()}; | 207 Simulator::CallArgument::End()}; |
208 return ReturnValueTraits<R>::Cast(CallSimulator(FUNCTION_ADDR(f), args)); | 208 return ReturnValueTraits<R>::Cast(CallSimulator(FUNCTION_ADDR(f), args)); |
209 } | 209 } |
| 210 #elif USE_SIMULATOR && V8_TARGET_ARCH_MIPS64 |
| 211 uintptr_t CallSimulator(byte* f, int64_t p1 = 0, int64_t p2 = 0, |
| 212 int64_t p3 = 0, int64_t p4 = 0) { |
| 213 Simulator* simulator = Simulator::current(isolate_); |
| 214 return static_cast<uintptr_t>(simulator->Call(f, 4, p1, p2, p3, p4)); |
| 215 } |
| 216 |
| 217 template <typename R, typename F> |
| 218 R DoCall(F* f) { |
| 219 return ReturnValueTraits<R>::Cast(CallSimulator(FUNCTION_ADDR(f))); |
| 220 } |
| 221 template <typename R, typename F, typename P1> |
| 222 R DoCall(F* f, P1 p1) { |
| 223 return ReturnValueTraits<R>::Cast( |
| 224 CallSimulator(FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1))); |
| 225 } |
| 226 template <typename R, typename F, typename P1, typename P2> |
| 227 R DoCall(F* f, P1 p1, P2 p2) { |
| 228 return ReturnValueTraits<R>::Cast( |
| 229 CallSimulator(FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), |
| 230 ParameterTraits<P2>::Cast(p2))); |
| 231 } |
| 232 template <typename R, typename F, typename P1, typename P2, typename P3> |
| 233 R DoCall(F* f, P1 p1, P2 p2, P3 p3) { |
| 234 return ReturnValueTraits<R>::Cast(CallSimulator( |
| 235 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), |
| 236 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3))); |
| 237 } |
| 238 template <typename R, typename F, typename P1, typename P2, typename P3, |
| 239 typename P4> |
| 240 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { |
| 241 return ReturnValueTraits<R>::Cast(CallSimulator( |
| 242 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), |
| 243 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3), |
| 244 ParameterTraits<P4>::Cast(p4))); |
| 245 } |
210 #elif USE_SIMULATOR && (V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS) | 246 #elif USE_SIMULATOR && (V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS) |
211 uintptr_t CallSimulator(byte* f, int32_t p1 = 0, int32_t p2 = 0, | 247 uintptr_t CallSimulator(byte* f, int32_t p1 = 0, int32_t p2 = 0, |
212 int32_t p3 = 0, int32_t p4 = 0) { | 248 int32_t p3 = 0, int32_t p4 = 0) { |
213 Simulator* simulator = Simulator::current(isolate_); | 249 Simulator* simulator = Simulator::current(isolate_); |
214 return static_cast<uintptr_t>(simulator->Call(f, 4, p1, p2, p3, p4)); | 250 return static_cast<uintptr_t>(simulator->Call(f, 4, p1, p2, p3, p4)); |
215 } | 251 } |
216 template <typename R, typename F> | 252 template <typename R, typename F> |
217 R DoCall(F* f) { | 253 R DoCall(F* f) { |
218 return ReturnValueTraits<R>::Cast(CallSimulator(FUNCTION_ADDR(f))); | 254 return ReturnValueTraits<R>::Cast(CallSimulator(FUNCTION_ADDR(f))); |
219 } | 255 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 420 |
385 private: | 421 private: |
386 CallHelper* helper() { return static_cast<C*>(this); } | 422 CallHelper* helper() { return static_cast<C*>(this); } |
387 }; | 423 }; |
388 | 424 |
389 } // namespace compiler | 425 } // namespace compiler |
390 } // namespace internal | 426 } // namespace internal |
391 } // namespace v8 | 427 } // namespace v8 |
392 | 428 |
393 #endif // V8_CCTEST_COMPILER_CALL_TESTER_H_ | 429 #endif // V8_CCTEST_COMPILER_CALL_TESTER_H_ |
OLD | NEW |