OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 ARM instructions if we are not generating a native | 6 // Declares a Simulator for ARM instructions if we are not generating a native |
7 // ARM binary. This Simulator allows us to run and debug ARM code generation on | 7 // ARM binary. This Simulator allows us to run and debug ARM 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 } | 174 } |
175 | 175 |
176 int get_sinteger_from_s_register(int sreg) { | 176 int get_sinteger_from_s_register(int sreg) { |
177 return GetFromVFPRegister<int, 1>(sreg); | 177 return GetFromVFPRegister<int, 1>(sreg); |
178 } | 178 } |
179 | 179 |
180 // Special case of set_register and get_register to access the raw PC value. | 180 // Special case of set_register and get_register to access the raw PC value. |
181 void set_pc(int32_t value); | 181 void set_pc(int32_t value); |
182 int32_t get_pc() const; | 182 int32_t get_pc() const; |
183 | 183 |
184 Address get_sp() { | 184 Address get_sp() const { |
185 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp))); | 185 return reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp))); |
186 } | 186 } |
187 | 187 |
188 // Accessor to the internal simulator stack area. | 188 // Accessor to the internal simulator stack area. |
189 uintptr_t StackLimit() const; | 189 uintptr_t StackLimit(uintptr_t c_limit) const; |
190 | 190 |
191 // Executes ARM instructions until the PC reaches end_sim_pc. | 191 // Executes ARM instructions until the PC reaches end_sim_pc. |
192 void Execute(); | 192 void Execute(); |
193 | 193 |
194 // Call on program start. | 194 // Call on program start. |
195 static void Initialize(Isolate* isolate); | 195 static void Initialize(Isolate* isolate); |
196 | 196 |
197 static void TearDown(HashMap* i_cache, Redirection* first); | 197 static void TearDown(HashMap* i_cache, Redirection* first); |
198 | 198 |
199 // V8 generally calls into generated JS code with 5 parameters and into | 199 // V8 generally calls into generated JS code with 5 parameters and into |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 #define CALL_GENERATED_FP_INT(entry, p0, p1) \ | 432 #define CALL_GENERATED_FP_INT(entry, p0, p1) \ |
433 Simulator::current(Isolate::Current())->CallFPReturnsInt( \ | 433 Simulator::current(Isolate::Current())->CallFPReturnsInt( \ |
434 FUNCTION_ADDR(entry), p0, p1) | 434 FUNCTION_ADDR(entry), p0, p1) |
435 | 435 |
436 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ | 436 #define CALL_GENERATED_REGEXP_CODE(entry, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ |
437 Simulator::current(Isolate::Current())->Call( \ | 437 Simulator::current(Isolate::Current())->Call( \ |
438 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) | 438 entry, 10, p0, p1, p2, p3, NULL, p4, p5, p6, p7, p8) |
439 | 439 |
440 | 440 |
441 // The simulator has its own stack. Thus it has a different stack limit from | 441 // The simulator has its own stack. Thus it has a different stack limit from |
442 // the C-based native code. Setting the c_limit to indicate a very small | 442 // the C-based native code. The JS-based limit normally points near the end of |
443 // stack cause stack overflow errors, since the simulator ignores the input. | 443 // the simulator stack. When the C-based limit is exhausted we reflect that by |
444 // This is unlikely to be an issue in practice, though it might cause testing | 444 // lowering the JS-based limit as well, to make stack checks trigger. |
Michael Starzinger
2015/08/24 13:46:31
You claim this to unlikely be an issue in practice
| |
445 // trouble down the line. | |
446 class SimulatorStack : public v8::internal::AllStatic { | 445 class SimulatorStack : public v8::internal::AllStatic { |
447 public: | 446 public: |
448 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, | 447 static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate, |
449 uintptr_t c_limit) { | 448 uintptr_t c_limit) { |
450 return Simulator::current(isolate)->StackLimit(); | 449 return Simulator::current(isolate)->StackLimit(c_limit); |
451 } | 450 } |
452 | 451 |
453 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { | 452 static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) { |
454 Simulator* sim = Simulator::current(Isolate::Current()); | 453 Simulator* sim = Simulator::current(Isolate::Current()); |
455 return sim->PushAddress(try_catch_address); | 454 return sim->PushAddress(try_catch_address); |
456 } | 455 } |
457 | 456 |
458 static inline void UnregisterCTryCatch() { | 457 static inline void UnregisterCTryCatch() { |
459 Simulator::current(Isolate::Current())->PopAddress(); | 458 Simulator::current(Isolate::Current())->PopAddress(); |
460 } | 459 } |
461 }; | 460 }; |
462 | 461 |
463 } } // namespace v8::internal | 462 } } // namespace v8::internal |
464 | 463 |
465 #endif // !defined(USE_SIMULATOR) | 464 #endif // !defined(USE_SIMULATOR) |
466 #endif // V8_ARM_SIMULATOR_ARM_H_ | 465 #endif // V8_ARM_SIMULATOR_ARM_H_ |
OLD | NEW |