OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 PPC instructions if we are not generating a native | 6 // Declares a Simulator for PPC instructions if we are not generating a native |
7 // PPC binary. This Simulator allows us to run and debug PPC code generation on | 7 // PPC binary. This Simulator allows us to run and debug PPC code generation on |
8 // regular desktop machines. | 8 // 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 |
11 // on a PPC HW platform. | 11 // on a PPC HW platform. |
12 | 12 |
13 #ifndef V8_PPC_SIMULATOR_PPC_H_ | 13 #ifndef V8_PPC_SIMULATOR_PPC_H_ |
14 #define V8_PPC_SIMULATOR_PPC_H_ | 14 #define V8_PPC_SIMULATOR_PPC_H_ |
15 | 15 |
16 #include "src/allocation.h" | 16 #include "src/allocation.h" |
17 | 17 |
18 #if !defined(USE_SIMULATOR) | 18 #if !defined(USE_SIMULATOR) |
19 // Running without a simulator on a native ppc platform. | 19 // Running without a simulator on a native ppc platform. |
20 | 20 |
21 namespace v8 { | 21 namespace v8 { |
22 namespace internal { | 22 namespace internal { |
23 | 23 |
24 // When running without a simulator we call the entry directly. | 24 // When running without a simulator we call the entry directly. |
25 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 25 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
26 (entry(p0, p1, p2, p3, p4)) | 26 (entry(p0, p1, p2, p3, p4)) |
27 | 27 |
28 typedef int (*ppc_regexp_matcher)(String*, int, const byte*, const byte*, int*, | 28 typedef int (*ppc_regexp_matcher)(String*, int, const byte*, const byte*, int*, |
29 int, Address, int, Isolate*); | 29 int, Address, int, void*, Isolate*); |
| 30 |
30 | 31 |
31 // Call the generated regexp code directly. The code at the entry address | 32 // Call the generated regexp code directly. The code at the entry address |
32 // should act as a function matching the type ppc_regexp_matcher. | 33 // should act as a function matching the type ppc_regexp_matcher. |
| 34 // The ninth argument is a dummy that reserves the space used for |
| 35 // the return address added by the ExitFrame in native calls. |
33 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 36 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
34 p7, p8) \ | 37 p7, p8) \ |
35 (FUNCTION_CAST<ppc_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, p8)) | 38 (FUNCTION_CAST<ppc_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ |
| 39 NULL, p8)) |
36 | 40 |
37 // The stack limit beyond which we will throw stack overflow errors in | 41 // The stack limit beyond which we will throw stack overflow errors in |
38 // generated code. Because generated code on ppc uses the C stack, we | 42 // generated code. Because generated code on ppc uses the C stack, we |
39 // just use the C stack limit. | 43 // just use the C stack limit. |
40 class SimulatorStack : public v8::internal::AllStatic { | 44 class SimulatorStack : public v8::internal::AllStatic { |
41 public: | 45 public: |
42 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 46 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
43 uintptr_t c_limit) { | 47 uintptr_t c_limit) { |
44 USE(isolate); | 48 USE(isolate); |
45 return c_limit; | 49 return c_limit; |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 488 |
485 // When running with the simulator transition into simulated execution at this | 489 // When running with the simulator transition into simulated execution at this |
486 // point. | 490 // point. |
487 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 491 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
488 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 492 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
489 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ | 493 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ |
490 (intptr_t)p3, (intptr_t)p4)) | 494 (intptr_t)p3, (intptr_t)p4)) |
491 | 495 |
492 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 496 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
493 p7, p8) \ | 497 p7, p8) \ |
494 Simulator::current(isolate)->Call( \ | 498 Simulator::current(isolate)->Call(entry, 10, (intptr_t)p0, (intptr_t)p1, \ |
495 entry, 9, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, (intptr_t)p3, \ | 499 (intptr_t)p2, (intptr_t)p3, (intptr_t)p4, \ |
496 (intptr_t)p4, (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, (intptr_t)p8) | 500 (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, \ |
| 501 (intptr_t)NULL, (intptr_t)p8) |
| 502 |
497 | 503 |
498 // The simulator has its own stack. Thus it has a different stack limit from | 504 // The simulator has its own stack. Thus it has a different stack limit from |
499 // the C-based native code. The JS-based limit normally points near the end of | 505 // the C-based native code. The JS-based limit normally points near the end of |
500 // the simulator stack. When the C-based limit is exhausted we reflect that by | 506 // the simulator stack. When the C-based limit is exhausted we reflect that by |
501 // lowering the JS-based limit as well, to make stack checks trigger. | 507 // lowering the JS-based limit as well, to make stack checks trigger. |
502 class SimulatorStack : public v8::internal::AllStatic { | 508 class SimulatorStack : public v8::internal::AllStatic { |
503 public: | 509 public: |
504 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 510 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
505 uintptr_t c_limit) { | 511 uintptr_t c_limit) { |
506 return Simulator::current(isolate)->StackLimit(c_limit); | 512 return Simulator::current(isolate)->StackLimit(c_limit); |
507 } | 513 } |
508 | 514 |
509 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, | 515 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, |
510 uintptr_t try_catch_address) { | 516 uintptr_t try_catch_address) { |
511 Simulator* sim = Simulator::current(isolate); | 517 Simulator* sim = Simulator::current(isolate); |
512 return sim->PushAddress(try_catch_address); | 518 return sim->PushAddress(try_catch_address); |
513 } | 519 } |
514 | 520 |
515 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 521 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
516 Simulator::current(isolate)->PopAddress(); | 522 Simulator::current(isolate)->PopAddress(); |
517 } | 523 } |
518 }; | 524 }; |
519 } // namespace internal | 525 } // namespace internal |
520 } // namespace v8 | 526 } // namespace v8 |
521 | 527 |
522 #endif // !defined(USE_SIMULATOR) | 528 #endif // !defined(USE_SIMULATOR) |
523 #endif // V8_PPC_SIMULATOR_PPC_H_ | 529 #endif // V8_PPC_SIMULATOR_PPC_H_ |
OLD | NEW |