| 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 18 matching lines...) Expand all Loading... |
| 29 typedef int (*mips_regexp_matcher)(String*, int, const byte*, const byte*, | 29 typedef int (*mips_regexp_matcher)(String*, int, const byte*, const byte*, |
| 30 void*, int*, int, Address, int, Isolate*); | 30 void*, int*, int, Address, int, Isolate*); |
| 31 | 31 |
| 32 | 32 |
| 33 // 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 |
| 34 // should act as a function matching the type arm_regexp_matcher. | 34 // should act as a function matching the type arm_regexp_matcher. |
| 35 // 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 |
| 36 // the return address added by the ExitFrame in native calls. | 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, \ | 37 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
| 38 p7, p8) \ | 38 p7, p8) \ |
| 39 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, NULL, p4, p5, p6, \ | 39 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ |
| 40 p7, p8)) | 40 p8)) |
| 41 | 41 |
| 42 // The stack limit beyond which we will throw stack overflow errors in | 42 // 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 | 43 // generated code. Because generated code on mips uses the C stack, we |
| 44 // just use the C stack limit. | 44 // just use the C stack limit. |
| 45 class SimulatorStack : public v8::internal::AllStatic { | 45 class SimulatorStack : public v8::internal::AllStatic { |
| 46 public: | 46 public: |
| 47 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 47 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
| 48 uintptr_t c_limit) { | 48 uintptr_t c_limit) { |
| 49 return c_limit; | 49 return c_limit; |
| 50 } | 50 } |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 523 |
| 524 | 524 |
| 525 // When running with the simulator transition into simulated execution at this | 525 // When running with the simulator transition into simulated execution at this |
| 526 // point. | 526 // point. |
| 527 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 527 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
| 528 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 528 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
| 529 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) | 529 FUNCTION_ADDR(entry), 5, p0, p1, p2, p3, p4)) |
| 530 | 530 |
| 531 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 531 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
| 532 p7, p8) \ | 532 p7, p8) \ |
| 533 Simulator::current(isolate) \ | 533 Simulator::current(isolate)->Call(entry, 10, p0, p1, p2, p3, p4, p5, p6, p7, \ |
| 534 ->Call(entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) | 534 p8) |
| 535 | |
| 536 | 535 |
| 537 // The simulator has its own stack. Thus it has a different stack limit from | 536 // 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 | 537 // 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 | 538 // 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. | 539 // lowering the JS-based limit as well, to make stack checks trigger. |
| 541 class SimulatorStack : public v8::internal::AllStatic { | 540 class SimulatorStack : public v8::internal::AllStatic { |
| 542 public: | 541 public: |
| 543 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 542 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
| 544 uintptr_t c_limit) { | 543 uintptr_t c_limit) { |
| 545 return Simulator::current(isolate)->StackLimit(c_limit); | 544 return Simulator::current(isolate)->StackLimit(c_limit); |
| 546 } | 545 } |
| 547 | 546 |
| 548 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, | 547 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, |
| 549 uintptr_t try_catch_address) { | 548 uintptr_t try_catch_address) { |
| 550 Simulator* sim = Simulator::current(isolate); | 549 Simulator* sim = Simulator::current(isolate); |
| 551 return sim->PushAddress(try_catch_address); | 550 return sim->PushAddress(try_catch_address); |
| 552 } | 551 } |
| 553 | 552 |
| 554 static inline void UnregisterCTryCatch(Isolate* isolate) { | 553 static inline void UnregisterCTryCatch(Isolate* isolate) { |
| 555 Simulator::current(isolate)->PopAddress(); | 554 Simulator::current(isolate)->PopAddress(); |
| 556 } | 555 } |
| 557 }; | 556 }; |
| 558 | 557 |
| 559 } // namespace internal | 558 } // namespace internal |
| 560 } // namespace v8 | 559 } // namespace v8 |
| 561 | 560 |
| 562 #endif // !defined(USE_SIMULATOR) | 561 #endif // !defined(USE_SIMULATOR) |
| 563 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 562 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
| OLD | NEW |