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