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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 int64_t get_d_register(int dreg) { | 193 int64_t get_d_register(int dreg) { |
194 DCHECK(dreg >= 0 && dreg < kNumFPRs); | 194 DCHECK(dreg >= 0 && dreg < kNumFPRs); |
195 return fp_registers_[dreg]; | 195 return fp_registers_[dreg]; |
196 } | 196 } |
197 | 197 |
198 // Special case of set_register and get_register to access the raw PC value. | 198 // Special case of set_register and get_register to access the raw PC value. |
199 void set_pc(intptr_t value); | 199 void set_pc(intptr_t value); |
200 intptr_t get_pc() const; | 200 intptr_t get_pc() const; |
201 | 201 |
202 Address get_sp() { | 202 Address get_sp() const { |
203 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp))); | 203 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp))); |
204 } | 204 } |
205 | 205 |
206 // Accessor to the internal simulator stack area. | 206 // Accessor to the internal simulator stack area. |
207 uintptr_t StackLimit() const; | 207 uintptr_t StackLimit(uintptr_t c_limit) const; |
208 | 208 |
209 // Executes PPC instructions until the PC reaches end_sim_pc. | 209 // Executes PPC instructions until the PC reaches end_sim_pc. |
210 void Execute(); | 210 void Execute(); |
211 | 211 |
212 // Call on program start. | 212 // Call on program start. |
213 static void Initialize(Isolate* isolate); | 213 static void Initialize(Isolate* isolate); |
214 | 214 |
215 static void TearDown(HashMap* i_cache, Redirection* first); | 215 static void TearDown(HashMap* i_cache, Redirection* first); |
216 | 216 |
217 // V8 generally calls into generated JS code with 5 parameters and into | 217 // V8 generally calls into generated JS code with 5 parameters and into |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 (intptr_t)p3, (intptr_t)p4)) | 396 (intptr_t)p3, (intptr_t)p4)) |
397 | 397 |
398 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ | 398 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ |
399 Simulator::current(Isolate::Current()) \ | 399 Simulator::current(Isolate::Current()) \ |
400 ->Call(entry, 10, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ | 400 ->Call(entry, 10, (intptr_t)p0, (intptr_t)p1, (intptr_t)p2, \ |
401 (intptr_t)p3, (intptr_t)p4, (intptr_t)p5, (intptr_t)p6, \ | 401 (intptr_t)p3, (intptr_t)p4, (intptr_t)p5, (intptr_t)p6, \ |
402 (intptr_t)p7, (intptr_t)NULL, (intptr_t)p8) | 402 (intptr_t)p7, (intptr_t)NULL, (intptr_t)p8) |
403 | 403 |
404 | 404 |
405 // The simulator has its own stack. Thus it has a different stack limit from | 405 // The simulator has its own stack. Thus it has a different stack limit from |
406 // the C-based native code. Setting the c_limit to indicate a very small | 406 // the C-based native code. The JS-based limit normally points near the end of |
407 // stack cause stack overflow errors, since the simulator ignores the input. | 407 // the simulator stack. When the C-based limit is exhausted we reflect that by |
408 // This is unlikely to be an issue in practice, though it might cause testing | 408 // lowering the JS-based limit as well, to make stack checks trigger. |
409 // trouble down the line. | |
410 class SimulatorStack : public v8::internal::AllStatic { | 409 class SimulatorStack : public v8::internal::AllStatic { |
411 public: | 410 public: |
412 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 411 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
413 uintptr_t c_limit) { | 412 uintptr_t c_limit) { |
414 return Simulator::current(isolate)->StackLimit(); | 413 return Simulator::current(isolate)->StackLimit(c_limit); |
415 } | 414 } |
416 | 415 |
417 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 416 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
418 Simulator* sim = Simulator::current(Isolate::Current()); | 417 Simulator* sim = Simulator::current(Isolate::Current()); |
419 return sim->PushAddress(try_catch_address); | 418 return sim->PushAddress(try_catch_address); |
420 } | 419 } |
421 | 420 |
422 static inline void UnregisterCTryCatch() { | 421 static inline void UnregisterCTryCatch() { |
423 Simulator::current(Isolate::Current())->PopAddress(); | 422 Simulator::current(Isolate::Current())->PopAddress(); |
424 } | 423 } |
425 }; | 424 }; |
426 } | 425 } |
427 } // namespace v8::internal | 426 } // namespace v8::internal |
428 | 427 |
429 #endif // !defined(USE_SIMULATOR) | 428 #endif // !defined(USE_SIMULATOR) |
430 #endif // V8_PPC_SIMULATOR_PPC_H_ | 429 #endif // V8_PPC_SIMULATOR_PPC_H_ |
OLD | NEW |