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, void*, Isolate*); | 29 int, Address, int, Isolate*); |
30 | |
31 | 30 |
32 // Call the generated regexp code directly. The code at the entry address | 31 // Call the generated regexp code directly. The code at the entry address |
33 // should act as a function matching the type ppc_regexp_matcher. | 32 // 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. | |
36 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 33 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
37 p7, p8) \ | 34 p7, p8) \ |
38 (FUNCTION_CAST<ppc_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, \ | 35 (FUNCTION_CAST<ppc_regexp_matcher>(entry)(p0, p1, p2, p3, p4, p5, p6, p7, p8)) |
39 NULL, p8)) | |
40 | 36 |
41 // The stack limit beyond which we will throw stack overflow errors in | 37 // The stack limit beyond which we will throw stack overflow errors in |
42 // generated code. Because generated code on ppc uses the C stack, we | 38 // generated code. Because generated code on ppc uses the C stack, we |
43 // just use the C stack limit. | 39 // just use the C stack limit. |
44 class SimulatorStack : public v8::internal::AllStatic { | 40 class SimulatorStack : public v8::internal::AllStatic { |
45 public: | 41 public: |
46 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 42 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
47 uintptr_t c_limit) { | 43 uintptr_t c_limit) { |
48 USE(isolate); | 44 USE(isolate); |
49 return c_limit; | 45 return c_limit; |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 484 |
489 // When running with the simulator transition into simulated execution at this | 485 // When running with the simulator transition into simulated execution at this |
490 // point. | 486 // point. |
491 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ | 487 #define CALL_GENERATED_CODE(isolate, entry, p0, p1, p2, p3, p4) \ |
492 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ | 488 reinterpret_cast<Object*>(Simulator::current(isolate)->Call( \ |
493 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ | 489 FUNCTION_ADDR(entry), 5, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ |
494 (intptr_t)p3, (intptr_t)p4)) | 490 (intptr_t)p3, (intptr_t)p4)) |
495 | 491 |
496 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ | 492 #define CALL_GENERATED_REGEXP_CODE(isolate, entry, p0, p1, p2, p3, p4, p5, p6, \ |
497 p7, p8) \ | 493 p7, p8) \ |
498 Simulator::current(isolate)->Call(entry, 10, (intptr_t)p0, (intptr_t)p1, \ | 494 Simulator::current(isolate)->Call( \ |
499 (intptr_t)p2, (intptr_t)p3, (intptr_t)p4, \ | 495 entry, 9, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, (intptr_t)p3, \ |
500 (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, \ | 496 (intptr_t)p4, (intptr_t)p5, (intptr_t)p6, (intptr_t)p7, (intptr_t)p8) |
501 (intptr_t)NULL, (intptr_t)p8) | |
502 | |
503 | 497 |
504 // The simulator has its own stack. Thus it has a different stack limit from | 498 // The simulator has its own stack. Thus it has a different stack limit from |
505 // the C-based native code. The JS-based limit normally points near the end of | 499 // the C-based native code. The JS-based limit normally points near the end of |
506 // the simulator stack. When the C-based limit is exhausted we reflect that by | 500 // the simulator stack. When the C-based limit is exhausted we reflect that by |
507 // lowering the JS-based limit as well, to make stack checks trigger. | 501 // lowering the JS-based limit as well, to make stack checks trigger. |
508 class SimulatorStack : public v8::internal::AllStatic { | 502 class SimulatorStack : public v8::internal::AllStatic { |
509 public: | 503 public: |
510 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 504 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
511 uintptr_t c_limit) { | 505 uintptr_t c_limit) { |
512 return Simulator::current(isolate)->StackLimit(c_limit); | 506 return Simulator::current(isolate)->StackLimit(c_limit); |
513 } | 507 } |
514 | 508 |
515 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, | 509 static inline uintptr_t RegisterCTryCatch(v8::internal::Isolate* isolate, |
516 uintptr_t try_catch_address) { | 510 uintptr_t try_catch_address) { |
517 Simulator* sim = Simulator::current(isolate); | 511 Simulator* sim = Simulator::current(isolate); |
518 return sim->PushAddress(try_catch_address); | 512 return sim->PushAddress(try_catch_address); |
519 } | 513 } |
520 | 514 |
521 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { | 515 static inline void UnregisterCTryCatch(v8::internal::Isolate* isolate) { |
522 Simulator::current(isolate)->PopAddress(); | 516 Simulator::current(isolate)->PopAddress(); |
523 } | 517 } |
524 }; | 518 }; |
525 } // namespace internal | 519 } // namespace internal |
526 } // namespace v8 | 520 } // namespace v8 |
527 | 521 |
528 #endif // !defined(USE_SIMULATOR) | 522 #endif // !defined(USE_SIMULATOR) |
529 #endif // V8_PPC_SIMULATOR_PPC_H_ | 523 #endif // V8_PPC_SIMULATOR_PPC_H_ |
OLD | NEW |