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