| 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 |
| 11 // on a ARM HW platform. | 11 // on a ARM HW platform. |
| 12 | 12 |
| 13 #ifndef V8_ARM_SIMULATOR_ARM_H_ | 13 #ifndef V8_ARM_SIMULATOR_ARM_H_ |
| 14 #define V8_ARM_SIMULATOR_ARM_H_ | 14 #define V8_ARM_SIMULATOR_ARM_H_ |
| 15 | 15 |
| 16 #include "src/allocation.h" | 16 #include "src/allocation.h" |
| 17 #include "src/base/lazy-instance.h" | 17 #include "src/base/lazy-instance.h" |
| 18 #include "src/base/platform/mutex.h" | 18 #include "src/base/platform/mutex.h" |
| 19 | 19 |
| 20 #if !defined(USE_SIMULATOR) | 20 #if !defined(USE_SIMULATOR) |
| 21 // Running without a simulator on a native arm platform. | 21 // Running without a simulator on a native arm platform. |
| 22 | 22 |
| 23 namespace v8 { | 23 namespace v8 { |
| 24 namespace internal { | 24 namespace internal { |
| 25 | 25 |
| 26 // When running without a simulator we call the entry directly. | 26 // When running without a simulator we call the entry directly. |
| 27 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 27 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
| 28 (entry(p0, p1, p2, p3, p4)) | 28 (entry(p0, p1, p2, p3, p4)) |
| 29 | 29 |
| 30 typedef int (*arm_regexp_matcher)(String*, int, const byte*, const byte*, int*, | 30 typedef int (*arm_regexp_matcher)(String*, int, const byte*, const byte*, |
| 31 int, Address, int, Isolate*); | 31 void*, int*, int, Address, int, Isolate*); |
| 32 |
| 32 | 33 |
| 33 // Call the generated regexp code directly. The code at the entry address | 34 // Call the generated regexp code directly. The code at the entry address |
| 34 // should act as a function matching the type arm_regexp_matcher. | 35 // should act as a function matching the type arm_regexp_matcher. |
| 36 // The fifth argument is a dummy that reserves the space used for |
| 37 // the return address added by the ExitFrame in native calls. |
| 35 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 38 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
| 36 p7, p8) \ | 39 p7, p8) \ |
| 37 (FUNCTION_CAST<arm_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, p8)) | 40 (FUNCTION_CAST<arm_regexp_matcher>(entry)(p0, p1, p2, p3, NULL, p4, p5, p6, \ |
| 41 p7, p8)) |
| 38 | 42 |
| 39 // The stack limit beyond which we will throw stack overflow errors in | 43 // The stack limit beyond which we will throw stack overflow errors in |
| 40 // generated code. Because generated code on arm uses the C stack, we | 44 // generated code. Because generated code on arm uses the C stack, we |
| 41 // just use the C stack limit. | 45 // just use the C stack limit. |
| 42 class SimulatorStack : public v8::internal::AllStatic { | 46 class SimulatorStack : public v8::internal::AllStatic { |
| 43 public: | 47 public: |
| 44 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 48 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
| 45 uintptr_t c_limit) { | 49 uintptr_t c_limit) { |
| 46 USE(isolate); | 50 USE(isolate); |
| 47 return c_limit; | 51 return c_limit; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 // point. | 542 // point. |
| 539 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 543 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
| 540 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 544 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
| 541 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) | 545 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) |
| 542 | 546 |
| 543 #define CALL_GENERATED_FP_INT(isolate, entry, p0, p1) \ | 547 #define CALL_GENERATED_FP_INT(isolate, entry, p0, p1) \ |
| 544 Simulator::current(isolate)->CallFPReturnsInt(FUNCTION_ADDR(entry), p0, p1) | 548 Simulator::current(isolate)->CallFPReturnsInt(FUNCTION_ADDR(entry), p0, p1) |
| 545 | 549 |
| 546 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 550 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
| 547 p7, p8) \ | 551 p7, p8) \ |
| 548 Simulator::current(isolate)->Call(entry, 9, p0, p1, p2, p3, p4, p5, p6, p7, \ | 552 Simulator::current(isolate) \ |
| 549 p8) | 553 ->Call(entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) |
| 554 |
| 550 | 555 |
| 551 // The simulator has its own stack. Thus it has a different stack limit from | 556 // The simulator has its own stack. Thus it has a different stack limit from |
| 552 // the C-based native code. The JS-based limit normally points near the end of | 557 // the C-based native code. The JS-based limit normally points near the end of |
| 553 // the simulator stack. When the C-based limit is exhausted we reflect that by | 558 // the simulator stack. When the C-based limit is exhausted we reflect that by |
| 554 // lowering the JS-based limit as well, to make stack checks trigger. | 559 // lowering the JS-based limit as well, to make stack checks trigger. |
| 555 class SimulatorStack : public v8::internal::AllStatic { | 560 class SimulatorStack : public v8::internal::AllStatic { |
| 556 public: | 561 public: |
| 557 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 562 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
| 558 uintptr_t c_limit) { | 563 uintptr_t c_limit) { |
| 559 return Simulator::current(isolate)->StackLimit(c_limit); | 564 return Simulator::current(isolate)->StackLimit(c_limit); |
| 560 } | 565 } |
| 561 | 566 |
| 562 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, | 567 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, |
| 563 uintptr_t try_catch_address) { | 568 uintptr_t try_catch_address) { |
| 564 Simulator* sim = Simulator::current(isolate); | 569 Simulator* sim = Simulator::current(isolate); |
| 565 return sim->PushAddress(try_catch_address); | 570 return sim->PushAddress(try_catch_address); |
| 566 } | 571 } |
| 567 | 572 |
| 568 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 573 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
| 569 Simulator::current(isolate)->PopAddress(); | 574 Simulator::current(isolate)->PopAddress(); |
| 570 } | 575 } |
| 571 }; | 576 }; |
| 572 | 577 |
| 573 } // namespace internal | 578 } // namespace internal |
| 574 } // namespace v8 | 579 } // namespace v8 |
| 575 | 580 |
| 576 #endif // !defined(USE_SIMULATOR) | 581 #endif // !defined(USE_SIMULATOR) |
| 577 #endif // V8_ARM_SIMULATOR_ARM_H_ | 582 #endif // V8_ARM_SIMULATOR_ARM_H_ |
| OLD | NEW |