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 13 matching lines...) Expand all Loading... |
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 | 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. | 33 // the return address added by the ExitFrame in native calls. |
34 #ifdef MIPS_ABI_N64 | |
35 typedef int (*mips_regexp_matcher)(String* input, | 34 typedef int (*mips_regexp_matcher)(String* input, |
36 int64_t start_offset, | 35 int64_t start_offset, |
37 const byte* input_start, | 36 const byte* input_start, |
38 const byte* input_end, | 37 const byte* input_end, |
39 int* output, | 38 int* output, |
40 int64_t output_size, | 39 int64_t output_size, |
41 Address stack_base, | 40 Address stack_base, |
42 int64_t direct_call, | 41 int64_t direct_call, |
43 void* return_address, | 42 void* return_address, |
44 Isolate* isolate); | 43 Isolate* isolate); |
45 | 44 |
46 #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, \ |
47 p7, p8) \ | 46 p7, p8) \ |
48 (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, \ |
49 NULL, p8)) | 48 NULL, p8)) |
50 | 49 |
51 #else // O32 Abi. | |
52 | |
53 typedef int (*mips_regexp_matcher)(String* input, | |
54 int32_t start_offset, | |
55 const byte* input_start, | |
56 const byte* input_end, | |
57 void* return_address, | |
58 int* output, | |
59 int32_t output_size, | |
60 Address stack_base, | |
61 int32_t direct_call, | |
62 Isolate* isolate); | |
63 | |
64 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | |
65 p7, p8) \ | |
66 (FUNCTION_CAST<mips_regexp_matcher>(entry)(p0, p1, p2, p3, NULL, p4, p5, p6, \ | |
67 p7, p8)) | |
68 | |
69 #endif // MIPS_ABI_N64 | |
70 | |
71 | 50 |
72 // 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 |
73 // 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 |
74 // just use the C stack limit. | 53 // just use the C stack limit. |
75 class SimulatorStack : public v8::internal::AllStatic { | 54 class SimulatorStack : public v8::internal::AllStatic { |
76 public: | 55 public: |
77 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 56 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
78 uintptr_t c_limit) { | 57 uintptr_t c_limit) { |
79 return c_limit; | 58 return c_limit; |
80 } | 59 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 488 |
510 // When running with the simulator transition into simulated execution at this | 489 // When running with the simulator transition into simulated execution at this |
511 // point. | 490 // point. |
512 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 491 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
513 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 492 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
514 FUNCTION_ADDR(entry), 5, reinterpret_cast<int64_t*>(p0), \ | 493 FUNCTION_ADDR(entry), 5, reinterpret_cast<int64_t*>(p0), \ |
515 reinterpret_cast<int64_t*>(p1), reinterpret_cast<int64_t*>(p2), \ | 494 reinterpret_cast<int64_t*>(p1), reinterpret_cast<int64_t*>(p2), \ |
516 reinterpret_cast<int64_t*>(p3), reinterpret_cast<int64_t*>(p4))) | 495 reinterpret_cast<int64_t*>(p3), reinterpret_cast<int64_t*>(p4))) |
517 | 496 |
518 | 497 |
519 #ifdef MIPS_ABI_N64 | |
520 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 498 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
521 p7, p8) \ | 499 p7, p8) \ |
522 static_cast<int>(Simulator::current(isolate)->Call( \ | 500 static_cast<int>(Simulator::current(isolate)->Call( \ |
523 entry, 10, p0, p1, p2, p3, p4, reinterpret_cast<int64_t*>(p5), p6, p7, \ | 501 entry, 10, p0, p1, p2, p3, p4, reinterpret_cast<int64_t*>(p5), p6, p7, \ |
524 NULL, p8)) | 502 NULL, p8)) |
525 #else // Must be O32 Abi. | |
526 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | |
527 p7, p8) \ | |
528 static_cast<int>(Simulator::current(isolate)->Call( \ | |
529 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8)) | |
530 #endif // MIPS_ABI_N64 | |
531 | 503 |
532 | 504 |
533 // The simulator has its own stack. Thus it has a different stack limit from | 505 // The simulator has its own stack. Thus it has a different stack limit from |
534 // the C-based native code. The JS-based limit normally points near the end of | 506 // the C-based native code. The JS-based limit normally points near the end of |
535 // the simulator stack. When the C-based limit is exhausted we reflect that by | 507 // the simulator stack. When the C-based limit is exhausted we reflect that by |
536 // lowering the JS-based limit as well, to make stack checks trigger. | 508 // lowering the JS-based limit as well, to make stack checks trigger. |
537 class SimulatorStack : public v8::internal::AllStatic { | 509 class SimulatorStack : public v8::internal::AllStatic { |
538 public: | 510 public: |
539 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, | 511 static inline uintptr_t JsLimitFromCLimit(Isolate* isolate, |
540 uintptr_t c_limit) { | 512 uintptr_t c_limit) { |
541 return Simulator::current(isolate)->StackLimit(c_limit); | 513 return Simulator::current(isolate)->StackLimit(c_limit); |
542 } | 514 } |
543 | 515 |
544 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, | 516 static inline uintptr_t RegisterCTryCatch(Isolate* isolate, |
545 uintptr_t try_catch_address) { | 517 uintptr_t try_catch_address) { |
546 Simulator* sim = Simulator::current(isolate); | 518 Simulator* sim = Simulator::current(isolate); |
547 return sim->PushAddress(try_catch_address); | 519 return sim->PushAddress(try_catch_address); |
548 } | 520 } |
549 | 521 |
550 static inline void UnregisterCTryCatch(Isolate* isolate) { | 522 static inline void UnregisterCTryCatch(Isolate* isolate) { |
551 Simulator::current(isolate)->PopAddress(); | 523 Simulator::current(isolate)->PopAddress(); |
552 } | 524 } |
553 }; | 525 }; |
554 | 526 |
555 } // namespace internal | 527 } // namespace internal |
556 } // namespace v8 | 528 } // namespace v8 |
557 | 529 |
558 #endif // !defined(USE_SIMULATOR) | 530 #endif // !defined(USE_SIMULATOR) |
559 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 531 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
OLD | NEW |