OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 | 5 |
6 // Declares a Simulator for ARM instructions if we are not generating a native | 6 // Declares a Simulator for ARM instructions if we are not generating a native |
7 // ARM binary. This Simulator allows us to run and debug ARM code generation on | 7 // ARM binary. This Simulator allows us to run and debug ARM code generation on |
8 // regular desktop machines. | 8 // regular desktop machines. |
9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, | 9 // V8 calls into generated code by "calling" the CALL_GENERATED_CODE macro, |
10 // which will start execution in the Simulator or forwards to the real entry | 10 // which will start execution in the Simulator or forwards to the real entry |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 | 31 |
32 // Call the generated regexp code directly. The code at the entry address | 32 // Call the generated regexp code directly. The code at the entry address |
33 // should act as a function matching the type arm_regexp_matcher. | 33 // should act as a function matching the type arm_regexp_matcher. |
34 // The fifth argument is a dummy that reserves the space used for | 34 // The fifth argument is a dummy that reserves the space used for |
35 // the return address added by the ExitFrame in native calls. | 35 // the return address added by the ExitFrame in native calls. |
36 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ | 36 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ |
37 (FUNCTION_CAST<arm_regexp_matcher>(entry)( \ | 37 (FUNCTION_CAST<arm_regexp_matcher>(entry)( \ |
38 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)) | 38 p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)) |
39 | 39 |
40 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ | |
41 reinterpret_cast<TryCatch*>(try_catch_address) | |
42 | |
43 // The stack limit beyond which we will throw stack overflow errors in | 40 // The stack limit beyond which we will throw stack overflow errors in |
44 // generated code. Because generated code on arm uses the C stack, we | 41 // generated code. Because generated code on arm uses the C stack, we |
45 // just use the C stack limit. | 42 // just use the C stack limit. |
46 class SimulatorStack : public v8::internal::AllStatic { | 43 class SimulatorStack : public v8::internal::AllStatic { |
47 public: | 44 public: |
48 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 45 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
49 uintptr_t c_limit) { | 46 uintptr_t c_limit) { |
50 USE(isolate); | 47 USE(isolate); |
51 return c_limit; | 48 return c_limit; |
52 } | 49 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) | 426 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) |
430 | 427 |
431 #define CALL_GENERATED_FP_INT(entry, p0, p1) \ | 428 #define CALL_GENERATED_FP_INT(entry, p0, p1) \ |
432 Simulator::current(Isolate::Current())->CallFPReturnsInt( \ | 429 Simulator::current(Isolate::Current())->CallFPReturnsInt( \ |
433 FUNCTION_ADDR(entry), p0, p1) | 430 FUNCTION_ADDR(entry), p0, p1) |
434 | 431 |
435 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ | 432 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ |
436 Simulator::current(Isolate::Current())->Call( \ | 433 Simulator::current(Isolate::Current())->Call( \ |
437 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) | 434 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) |
438 | 435 |
439 #define TRY_CATCH_FROM_ADDRESS(try_catch_address) \ | |
440 try_catch_address == NULL ? \ | |
441 NULL : *(reinterpret_cast<TryCatch**>(try_catch_address)) | |
442 | |
443 | 436 |
444 // The simulator has its own stack. Thus it has a different stack limit from | 437 // The simulator has its own stack. Thus it has a different stack limit from |
445 // the C-based native code. Setting the c_limit to indicate a very small | 438 // the C-based native code. Setting the c_limit to indicate a very small |
446 // stack cause stack overflow errors, since the simulator ignores the input. | 439 // stack cause stack overflow errors, since the simulator ignores the input. |
447 // This is unlikely to be an issue in practice, though it might cause testing | 440 // This is unlikely to be an issue in practice, though it might cause testing |
448 // trouble down the line. | 441 // trouble down the line. |
449 class SimulatorStack : public v8::internal::AllStatic { | 442 class SimulatorStack : public v8::internal::AllStatic { |
450 public: | 443 public: |
451 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 444 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
452 uintptr_t c_limit) { | 445 uintptr_t c_limit) { |
453 return Simulator::current(isolate)->StackLimit(); | 446 return Simulator::current(isolate)->StackLimit(); |
454 } | 447 } |
455 | 448 |
456 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 449 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
457 Simulator* sim = Simulator::current(Isolate::Current()); | 450 Simulator* sim = Simulator::current(Isolate::Current()); |
458 return sim->PushAddress(try_catch_address); | 451 return sim->PushAddress(try_catch_address); |
459 } | 452 } |
460 | 453 |
461 static inline void UnregisterCTryCatch() { | 454 static inline void UnregisterCTryCatch() { |
462 Simulator::current(Isolate::Current())->PopAddress(); | 455 Simulator::current(Isolate::Current())->PopAddress(); |
463 } | 456 } |
464 }; | 457 }; |
465 | 458 |
466 } } // namespace v8::internal | 459 } } // namespace v8::internal |
467 | 460 |
468 #endif // !defined(USE_SIMULATOR) | 461 #endif // !defined(USE_SIMULATOR) |
469 #endif // V8_ARM_SIMULATOR_ARM_H_ | 462 #endif // V8_ARM_SIMULATOR_ARM_H_ |
OLD | NEW |