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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 // Accessor to the internal simulator stack area. | 243 // Accessor to the internal simulator stack area. |
244 uintptr_t StackLimit(uintptr_t c_limit) const; | 244 uintptr_t StackLimit(uintptr_t c_limit) const; |
245 | 245 |
246 // Executes MIPS instructions until the PC reaches end_sim_pc. | 246 // Executes MIPS instructions until the PC reaches end_sim_pc. |
247 void Execute(); | 247 void Execute(); |
248 | 248 |
249 // Call on program start. | 249 // Call on program start. |
250 static void Initialize(Isolate* isolate); | 250 static void Initialize(Isolate* isolate); |
251 | 251 |
252 static void TearDown(base::HashMap* i_cache, Redirection* first); | 252 static void TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first); |
253 | 253 |
254 // V8 generally calls into generated JS code with 5 parameters and into | 254 // V8 generally calls into generated JS code with 5 parameters and into |
255 // generated RegExp code with 7 parameters. This is a convenience function, | 255 // generated RegExp code with 7 parameters. This is a convenience function, |
256 // which sets up the simulator state and grabs the result on return. | 256 // which sets up the simulator state and grabs the result on return. |
257 int32_t Call(byte* entry, int argument_count, ...); | 257 int32_t Call(byte* entry, int argument_count, ...); |
258 // Alternative: call a 2-argument double function. | 258 // Alternative: call a 2-argument double function. |
259 double CallFP(byte* entry, double d0, double d1); | 259 double CallFP(byte* entry, double d0, double d1); |
260 | 260 |
261 // Push an address onto the JS stack. | 261 // Push an address onto the JS stack. |
262 uintptr_t PushAddress(uintptr_t address); | 262 uintptr_t PushAddress(uintptr_t address); |
263 | 263 |
264 // Pop an address from the JS stack. | 264 // Pop an address from the JS stack. |
265 uintptr_t PopAddress(); | 265 uintptr_t PopAddress(); |
266 | 266 |
267 // Debugger input. | 267 // Debugger input. |
268 void set_last_debugger_input(char* input); | 268 void set_last_debugger_input(char* input); |
269 char* last_debugger_input() { return last_debugger_input_; } | 269 char* last_debugger_input() { return last_debugger_input_; } |
270 | 270 |
271 // ICache checking. | 271 // ICache checking. |
272 static void FlushICache(base::HashMap* i_cache, void* start, size_t size); | 272 static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, |
| 273 size_t size); |
273 | 274 |
274 // Returns true if pc register contains one of the 'special_values' defined | 275 // Returns true if pc register contains one of the 'special_values' defined |
275 // below (bad_ra, end_sim_pc). | 276 // below (bad_ra, end_sim_pc). |
276 bool has_bad_pc() const; | 277 bool has_bad_pc() const; |
277 | 278 |
278 private: | 279 private: |
279 enum special_values { | 280 enum special_values { |
280 // Known bad pc value to ensure that the simulator does not execute | 281 // Known bad pc value to ensure that the simulator does not execute |
281 // without being properly setup. | 282 // without being properly setup. |
282 bad_ra = -1, | 283 bad_ra = -1, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (instr->IsForbiddenInBranchDelay()) { | 424 if (instr->IsForbiddenInBranchDelay()) { |
424 V8_Fatal(__FILE__, __LINE__, | 425 V8_Fatal(__FILE__, __LINE__, |
425 "Eror:Unexpected %i opcode in a branch delay slot.", | 426 "Eror:Unexpected %i opcode in a branch delay slot.", |
426 instr->OpcodeValue()); | 427 instr->OpcodeValue()); |
427 } | 428 } |
428 InstructionDecode(instr); | 429 InstructionDecode(instr); |
429 SNPrintF(trace_buf_, " "); | 430 SNPrintF(trace_buf_, " "); |
430 } | 431 } |
431 | 432 |
432 // ICache. | 433 // ICache. |
433 static void CheckICache(base::HashMap* i_cache, Instruction* instr); | 434 static void CheckICache(base::CustomMatcherHashMap* i_cache, |
434 static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size); | 435 Instruction* instr); |
435 static CachePage* GetCachePage(base::HashMap* i_cache, void* page); | 436 static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, |
| 437 int size); |
| 438 static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache, |
| 439 void* page); |
436 | 440 |
437 enum Exception { | 441 enum Exception { |
438 none, | 442 none, |
439 kIntegerOverflow, | 443 kIntegerOverflow, |
440 kIntegerUnderflow, | 444 kIntegerUnderflow, |
441 kDivideByZero, | 445 kDivideByZero, |
442 kNumExceptions | 446 kNumExceptions |
443 }; | 447 }; |
444 | 448 |
445 // Exceptions. | 449 // Exceptions. |
(...skipping 25 matching lines...) Expand all Loading... |
471 static const size_t stack_size_ = 1 * 1024*1024; | 475 static const size_t stack_size_ = 1 * 1024*1024; |
472 char* stack_; | 476 char* stack_; |
473 bool pc_modified_; | 477 bool pc_modified_; |
474 uint64_t icount_; | 478 uint64_t icount_; |
475 int break_count_; | 479 int break_count_; |
476 | 480 |
477 // Debugger input. | 481 // Debugger input. |
478 char* last_debugger_input_; | 482 char* last_debugger_input_; |
479 | 483 |
480 // Icache simulation. | 484 // Icache simulation. |
481 base::HashMap* i_cache_; | 485 base::CustomMatcherHashMap* i_cache_; |
482 | 486 |
483 v8::internal::Isolate* isolate_; | 487 v8::internal::Isolate* isolate_; |
484 | 488 |
485 // Registered breakpoints. | 489 // Registered breakpoints. |
486 Instruction* break_pc_; | 490 Instruction* break_pc_; |
487 Instr break_instr_; | 491 Instr break_instr_; |
488 | 492 |
489 // Stop is disabled if bit 31 is set. | 493 // Stop is disabled if bit 31 is set. |
490 static const uint32_t kStopDisabledBit = 1 << 31; | 494 static const uint32_t kStopDisabledBit = 1 << 31; |
491 | 495 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 static inline void UnregisterCTryCatch(Isolate* isolate) { | 537 static inline void UnregisterCTryCatch(Isolate* isolate) { |
534 Simulator::current(isolate)->PopAddress(); | 538 Simulator::current(isolate)->PopAddress(); |
535 } | 539 } |
536 }; | 540 }; |
537 | 541 |
538 } // namespace internal | 542 } // namespace internal |
539 } // namespace v8 | 543 } // namespace v8 |
540 | 544 |
541 #endif // !defined(USE_SIMULATOR) | 545 #endif // !defined(USE_SIMULATOR) |
542 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 546 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
OLD | NEW |