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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 int* output, | 38 int* output, |
39 int64_t output_size, | 39 int64_t output_size, |
40 Address stack_base, | 40 Address stack_base, |
41 int64_t direct_call, | 41 int64_t direct_call, |
42 void* return_address, | 42 void* return_address, |
43 Isolate* isolate); | 43 Isolate* isolate); |
44 | 44 |
45 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 45 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
46 p7, p8) \ | 46 p7, p8) \ |
47 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ | 47 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ |
48 NULL, p8)) | 48 p8)) |
49 | |
50 | 49 |
51 // The stack limit beyond which we will throw stack overflow errors in | 50 // The stack limit beyond which we will throw stack overflow errors in |
52 // generated code. Because generated code on mips uses the C stack, we | 51 // generated code. Because generated code on mips uses the C stack, we |
53 // just use the C stack limit. | 52 // just use the C stack limit. |
54 class SimulatorStack : public v8::internal::AllStatic { | 53 class SimulatorStack : public v8::internal::AllStatic { |
55 public: | 54 public: |
56 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 55 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
57 uintptr_t c_limit) { | 56 uintptr_t c_limit) { |
58 return c_limit; | 57 return c_limit; |
59 } | 58 } |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 552 |
554 | 553 |
555 // When running with the simulator transition into simulated execution at this | 554 // When running with the simulator transition into simulated execution at this |
556 // point. | 555 // point. |
557 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 556 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
558 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 557 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
559 FUNCTION_ADDR(entry), 5, reinterpret_cast<int64_t*>(p0), \ | 558 FUNCTION_ADDR(entry), 5, reinterpret_cast<int64_t*>(p0), \ |
560 reinterpret_cast<int64_t*>(p1), reinterpret_cast<int64_t*>(p2), \ | 559 reinterpret_cast<int64_t*>(p1), reinterpret_cast<int64_t*>(p2), \ |
561 reinterpret_cast<int64_t*>(p3), reinterpret_cast<int64_t*>(p4))) | 560 reinterpret_cast<int64_t*>(p3), reinterpret_cast<int64_t*>(p4))) |
562 | 561 |
563 | |
564 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 562 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
565 p7, p8) \ | 563 p7, p8) \ |
566 static_cast<int>(Simulator::current(isolate)->Call( \ | 564 static_cast<int>(Simulator::current(isolate)->Call( \ |
567 entry, 10, p0, p1, p2, p3, p4, reinterpret_cast<int64_t*>(p5), p6, p7, \ | 565 entry, 10, p0, p1, p2, p3, p4, reinterpret_cast<int64_t*>(p5), p6, p7, \ |
568 NULL, p8)) | 566 p8)) |
569 | |
570 | 567 |
571 // The simulator has its own stack. Thus it has a different stack limit from | 568 // The simulator has its own stack. Thus it has a different stack limit from |
572 // the C-based native code. The JS-based limit normally points near the end of | 569 // the C-based native code. The JS-based limit normally points near the end of |
573 // the simulator stack. When the C-based limit is exhausted we reflect that by | 570 // the simulator stack. When the C-based limit is exhausted we reflect that by |
574 // lowering the JS-based limit as well, to make stack checks trigger. | 571 // lowering the JS-based limit as well, to make stack checks trigger. |
575 class SimulatorStack : public v8::internal::AllStatic { | 572 class SimulatorStack : public v8::internal::AllStatic { |
576 public: | 573 public: |
577 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 574 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
578 uintptr_t c_limit) { | 575 uintptr_t c_limit) { |
579 return Simulator::current(isolate)->StackLimit(c_limit); | 576 return Simulator::current(isolate)->StackLimit(c_limit); |
580 } | 577 } |
581 | 578 |
582 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, | 579 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, |
583 uintptr_t try_catch_address) { | 580 uintptr_t try_catch_address) { |
584 Simulator* sim = Simulator::current(isolate); | 581 Simulator* sim = Simulator::current(isolate); |
585 return sim->PushAddress(try_catch_address); | 582 return sim->PushAddress(try_catch_address); |
586 } | 583 } |
587 | 584 |
588 static inline void UnregisterCTryCatch(Isolate* isolate) { | 585 static inline void UnregisterCTryCatch(Isolate* isolate) { |
589 Simulator::current(isolate)->PopAddress(); | 586 Simulator::current(isolate)->PopAddress(); |
590 } | 587 } |
591 }; | 588 }; |
592 | 589 |
593 } // namespace internal | 590 } // namespace internal |
594 } // namespace v8 | 591 } // namespace v8 |
595 | 592 |
596 #endif // !defined(USE_SIMULATOR) | 593 #endif // !defined(USE_SIMULATOR) |
597 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 594 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
OLD | NEW |