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