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