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