OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 MIPS instructions if we are not generating a native | 6 // Declares a Simulator for MIPS instructions if we are not generating a native |
7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation | 7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation |
8 // on regular desktop machines. | 8 // on 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 MIPS HW platform. | 11 // on a MIPS HW platform. |
12 | 12 |
13 #ifndef V8_MIPS_SIMULATOR_MIPS_H_ | 13 #ifndef V8_MIPS_SIMULATOR_MIPS_H_ |
14 #define V8_MIPS_SIMULATOR_MIPS_H_ | 14 #define V8_MIPS_SIMULATOR_MIPS_H_ |
15 | 15 |
16 #include "src/allocation.h" | 16 #include "src/allocation.h" |
17 #include "src/mips/constants-mips.h" | 17 #include "src/mips/constants-mips.h" |
18 | 18 |
19 #if !defined(USE_SIMULATOR) | 19 #if !defined(USE_SIMULATOR) |
20 // Running without a simulator on a native mips platform. | 20 // Running without a simulator on a native mips platform. |
21 | 21 |
22 namespace v8 { | 22 namespace v8 { |
23 namespace internal { | 23 namespace internal { |
24 | 24 |
25 // When running without a simulator we call the entry directly. | 25 // When running without a simulator we call the entry directly. |
26 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 26 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
27 entry(p0, p1, p2, p3, p4) | 27 entry(p0, p1, p2, p3, p4) |
28 | 28 |
29 typedef int (*mips_regexp_matcher)(String*, int, const byte*, const byte*, | 29 typedef int (*mips_regexp_matcher)(String*, int, const byte*, const byte*, int*, |
30 void*, int*, int, Address, int, Isolate*); | 30 int, Address, int, Isolate*); |
31 | |
32 | 31 |
33 // 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 |
34 // should act as a function matching the type arm_regexp_matcher. | 33 // should act as a function matching the type arm_regexp_matcher. |
35 // The fifth argument is a dummy that reserves the space used for | |
36 // the return address added by the ExitFrame in native calls. | |
37 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 34 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
38 p7, p8) \ | 35 p7, p8) \ |
39 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, NULL, p4, p5, p6, \ | 36 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ |
40 p7, p8)) | 37 p8)) |
41 | 38 |
42 // The stack limit beyond which we will throw stack overflow errors in | 39 // The stack limit beyond which we will throw stack overflow errors in |
43 // generated code. Because generated code on mips uses the C stack, we | 40 // generated code. Because generated code on mips uses the C stack, we |
44 // just use the C stack limit. | 41 // just use the C stack limit. |
45 class SimulatorStack : public v8::internal::AllStatic { | 42 class SimulatorStack : public v8::internal::AllStatic { |
46 public: | 43 public: |
47 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 44 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
48 uintptr_t c_limit) { | 45 uintptr_t c_limit) { |
49 return c_limit; | 46 return c_limit; |
50 } | 47 } |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 520 |
524 | 521 |
525 // When running with the simulator transition into simulated execution at this | 522 // When running with the simulator transition into simulated execution at this |
526 // point. | 523 // point. |
527 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 524 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
528 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 525 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
529 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) | 526 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) |
530 | 527 |
531 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 528 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
532 p7, p8) \ | 529 p7, p8) \ |
533 Simulator::current(isolate) \ | 530 Simulator::current(isolate)->Call(entry, 9, p0, p1, p2, p3, p4, p5, p6, p7, \ |
534 ->Call(entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) | 531 p8) |
535 | |
536 | 532 |
537 // The simulator has its own stack. Thus it has a different stack limit from | 533 // The simulator has its own stack. Thus it has a different stack limit from |
538 // the C-based native code. The JS-based limit normally points near the end of | 534 // the C-based native code. The JS-based limit normally points near the end of |
539 // the simulator stack. When the C-based limit is exhausted we reflect that by | 535 // the simulator stack. When the C-based limit is exhausted we reflect that by |
540 // lowering the JS-based limit as well, to make stack checks trigger. | 536 // lowering the JS-based limit as well, to make stack checks trigger. |
541 class SimulatorStack : public v8::internal::AllStatic { | 537 class SimulatorStack : public v8::internal::AllStatic { |
542 public: | 538 public: |
543 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 539 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
544 uintptr_t c_limit) { | 540 uintptr_t c_limit) { |
545 return Simulator::current(isolate)->StackLimit(c_limit); | 541 return Simulator::current(isolate)->StackLimit(c_limit); |
546 } | 542 } |
547 | 543 |
548 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, | 544 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, |
549 uintptr_t try_catch_address) { | 545 uintptr_t try_catch_address) { |
550 Simulator* sim = Simulator::current(isolate); | 546 Simulator* sim = Simulator::current(isolate); |
551 return sim->PushAddress(try_catch_address); | 547 return sim->PushAddress(try_catch_address); |
552 } | 548 } |
553 | 549 |
554 static inline void UnregisterCTryCatch(Isolate* isolate) { | 550 static inline void UnregisterCTryCatch(Isolate* isolate) { |
555 Simulator::current(isolate)->PopAddress(); | 551 Simulator::current(isolate)->PopAddress(); |
556 } | 552 } |
557 }; | 553 }; |
558 | 554 |
559 } // namespace internal | 555 } // namespace internal |
560 } // namespace v8 | 556 } // namespace v8 |
561 | 557 |
562 #endif // !defined(USE_SIMULATOR) | 558 #endif // !defined(USE_SIMULATOR) |
563 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 559 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
OLD | NEW |