OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 MIPS instructions if we are not generating a native | 6 // Declares a Simulator for MIPS instructions if we are not generating a native |
7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation | 7 // MIPS binary. This Simulator allows us to run and debug MIPS code generation |
8 // on regular desktop machines. | 8 // on 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 // Accessor to the internal simulator stack area. | 210 // Accessor to the internal simulator stack area. |
211 uintptr_t StackLimit(uintptr_t c_limit) const; | 211 uintptr_t StackLimit(uintptr_t c_limit) const; |
212 | 212 |
213 // Executes MIPS instructions until the PC reaches end_sim_pc. | 213 // Executes MIPS instructions until the PC reaches end_sim_pc. |
214 void Execute(); | 214 void Execute(); |
215 | 215 |
216 // Call on program start. | 216 // Call on program start. |
217 static void Initialize(Isolate* isolate); | 217 static void Initialize(Isolate* isolate); |
218 | 218 |
219 static void TearDown(HashMap* i_cache, Redirection* first); | 219 static void TearDown(base::HashMap* i_cache, Redirection* first); |
220 | 220 |
221 // V8 generally calls into generated JS code with 5 parameters and into | 221 // V8 generally calls into generated JS code with 5 parameters and into |
222 // generated RegExp code with 7 parameters. This is a convenience function, | 222 // generated RegExp code with 7 parameters. This is a convenience function, |
223 // which sets up the simulator state and grabs the result on return. | 223 // which sets up the simulator state and grabs the result on return. |
224 int32_t Call(byte* entry, int argument_count, ...); | 224 int32_t Call(byte* entry, int argument_count, ...); |
225 // Alternative: call a 2-argument double function. | 225 // Alternative: call a 2-argument double function. |
226 double CallFP(byte* entry, double d0, double d1); | 226 double CallFP(byte* entry, double d0, double d1); |
227 | 227 |
228 // Push an address onto the JS stack. | 228 // Push an address onto the JS stack. |
229 uintptr_t PushAddress(uintptr_t address); | 229 uintptr_t PushAddress(uintptr_t address); |
230 | 230 |
231 // Pop an address from the JS stack. | 231 // Pop an address from the JS stack. |
232 uintptr_t PopAddress(); | 232 uintptr_t PopAddress(); |
233 | 233 |
234 // Debugger input. | 234 // Debugger input. |
235 void set_last_debugger_input(char* input); | 235 void set_last_debugger_input(char* input); |
236 char* last_debugger_input() { return last_debugger_input_; } | 236 char* last_debugger_input() { return last_debugger_input_; } |
237 | 237 |
238 // ICache checking. | 238 // ICache checking. |
239 static void FlushICache(v8::internal::HashMap* i_cache, void* start, | 239 static void FlushICache(base::HashMap* i_cache, void* start, |
240 size_t size); | 240 size_t size); |
241 | 241 |
242 // Returns true if pc register contains one of the 'special_values' defined | 242 // Returns true if pc register contains one of the 'special_values' defined |
243 // below (bad_ra, end_sim_pc). | 243 // below (bad_ra, end_sim_pc). |
244 bool has_bad_pc() const; | 244 bool has_bad_pc() const; |
245 | 245 |
246 private: | 246 private: |
247 enum special_values { | 247 enum special_values { |
248 // Known bad pc value to ensure that the simulator does not execute | 248 // Known bad pc value to ensure that the simulator does not execute |
249 // without being properly setup. | 249 // without being properly setup. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 if (instr->IsForbiddenInBranchDelay()) { | 394 if (instr->IsForbiddenInBranchDelay()) { |
395 V8_Fatal(__FILE__, __LINE__, | 395 V8_Fatal(__FILE__, __LINE__, |
396 "Eror:Unexpected %i opcode in a branch delay slot.", | 396 "Eror:Unexpected %i opcode in a branch delay slot.", |
397 instr->OpcodeValue()); | 397 instr->OpcodeValue()); |
398 } | 398 } |
399 InstructionDecode(instr); | 399 InstructionDecode(instr); |
400 SNPrintF(trace_buf_, " "); | 400 SNPrintF(trace_buf_, " "); |
401 } | 401 } |
402 | 402 |
403 // ICache. | 403 // ICache. |
404 static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr); | 404 static void CheckICache(base::HashMap* i_cache, Instruction* instr); |
405 static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, | 405 static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size); |
406 int size); | 406 static CachePage* GetCachePage(base::HashMap* i_cache, void* page); |
407 static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page); | |
408 | 407 |
409 enum Exception { | 408 enum Exception { |
410 none, | 409 none, |
411 kIntegerOverflow, | 410 kIntegerOverflow, |
412 kIntegerUnderflow, | 411 kIntegerUnderflow, |
413 kDivideByZero, | 412 kDivideByZero, |
414 kNumExceptions | 413 kNumExceptions |
415 }; | 414 }; |
416 | 415 |
417 // Exceptions. | 416 // Exceptions. |
(...skipping 25 matching lines...) Expand all Loading... |
443 static const size_t stack_size_ = 1 * 1024*1024; | 442 static const size_t stack_size_ = 1 * 1024*1024; |
444 char* stack_; | 443 char* stack_; |
445 bool pc_modified_; | 444 bool pc_modified_; |
446 uint64_t icount_; | 445 uint64_t icount_; |
447 int break_count_; | 446 int break_count_; |
448 | 447 |
449 // Debugger input. | 448 // Debugger input. |
450 char* last_debugger_input_; | 449 char* last_debugger_input_; |
451 | 450 |
452 // Icache simulation. | 451 // Icache simulation. |
453 v8::internal::HashMap* i_cache_; | 452 base::HashMap* i_cache_; |
454 | 453 |
455 v8::internal::Isolate* isolate_; | 454 v8::internal::Isolate* isolate_; |
456 | 455 |
457 // Registered breakpoints. | 456 // Registered breakpoints. |
458 Instruction* break_pc_; | 457 Instruction* break_pc_; |
459 Instr break_instr_; | 458 Instr break_instr_; |
460 | 459 |
461 // Stop is disabled if bit 31 is set. | 460 // Stop is disabled if bit 31 is set. |
462 static const uint32_t kStopDisabledBit = 1 << 31; | 461 static const uint32_t kStopDisabledBit = 1 << 31; |
463 | 462 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 static inline void UnregisterCTryCatch(Isolate* isolate) { | 504 static inline void UnregisterCTryCatch(Isolate* isolate) { |
506 Simulator::current(isolate)->PopAddress(); | 505 Simulator::current(isolate)->PopAddress(); |
507 } | 506 } |
508 }; | 507 }; |
509 | 508 |
510 } // namespace internal | 509 } // namespace internal |
511 } // namespace v8 | 510 } // namespace v8 |
512 | 511 |
513 #endif // !defined(USE_SIMULATOR) | 512 #endif // !defined(USE_SIMULATOR) |
514 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 513 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
OLD | NEW |