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