| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 // Accessor to the internal simulator stack area. | 253 // Accessor to the internal simulator stack area. |
| 254 uintptr_t StackLimit(uintptr_t c_limit) const; | 254 uintptr_t StackLimit(uintptr_t c_limit) const; |
| 255 | 255 |
| 256 // Executes MIPS instructions until the PC reaches end_sim_pc. | 256 // Executes MIPS instructions until the PC reaches end_sim_pc. |
| 257 void Execute(); | 257 void Execute(); |
| 258 | 258 |
| 259 // Call on program start. | 259 // Call on program start. |
| 260 static void Initialize(Isolate* isolate); | 260 static void Initialize(Isolate* isolate); |
| 261 | 261 |
| 262 static void TearDown(base::HashMap* i_cache, Redirection* first); | 262 static void TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first); |
| 263 | 263 |
| 264 // V8 generally calls into generated JS code with 5 parameters and into | 264 // V8 generally calls into generated JS code with 5 parameters and into |
| 265 // generated RegExp code with 7 parameters. This is a convenience function, | 265 // generated RegExp code with 7 parameters. This is a convenience function, |
| 266 // which sets up the simulator state and grabs the result on return. | 266 // which sets up the simulator state and grabs the result on return. |
| 267 int64_t Call(byte* entry, int argument_count, ...); | 267 int64_t Call(byte* entry, int argument_count, ...); |
| 268 // Alternative: call a 2-argument double function. | 268 // Alternative: call a 2-argument double function. |
| 269 double CallFP(byte* entry, double d0, double d1); | 269 double CallFP(byte* entry, double d0, double d1); |
| 270 | 270 |
| 271 // Push an address onto the JS stack. | 271 // Push an address onto the JS stack. |
| 272 uintptr_t PushAddress(uintptr_t address); | 272 uintptr_t PushAddress(uintptr_t address); |
| 273 | 273 |
| 274 // Pop an address from the JS stack. | 274 // Pop an address from the JS stack. |
| 275 uintptr_t PopAddress(); | 275 uintptr_t PopAddress(); |
| 276 | 276 |
| 277 // Debugger input. | 277 // Debugger input. |
| 278 void set_last_debugger_input(char* input); | 278 void set_last_debugger_input(char* input); |
| 279 char* last_debugger_input() { return last_debugger_input_; } | 279 char* last_debugger_input() { return last_debugger_input_; } |
| 280 | 280 |
| 281 // ICache checking. | 281 // ICache checking. |
| 282 static void FlushICache(base::HashMap* i_cache, void* start, size_t size); | 282 static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, |
| 283 size_t size); |
| 283 | 284 |
| 284 // Returns true if pc register contains one of the 'special_values' defined | 285 // Returns true if pc register contains one of the 'special_values' defined |
| 285 // below (bad_ra, end_sim_pc). | 286 // below (bad_ra, end_sim_pc). |
| 286 bool has_bad_pc() const; | 287 bool has_bad_pc() const; |
| 287 | 288 |
| 288 private: | 289 private: |
| 289 enum special_values { | 290 enum special_values { |
| 290 // Known bad pc value to ensure that the simulator does not execute | 291 // Known bad pc value to ensure that the simulator does not execute |
| 291 // without being properly setup. | 292 // without being properly setup. |
| 292 bad_ra = -1, | 293 bad_ra = -1, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 if (instr->IsForbiddenAfterBranch()) { | 439 if (instr->IsForbiddenAfterBranch()) { |
| 439 V8_Fatal(__FILE__, __LINE__, | 440 V8_Fatal(__FILE__, __LINE__, |
| 440 "Eror:Unexpected %i opcode in a branch delay slot.", | 441 "Eror:Unexpected %i opcode in a branch delay slot.", |
| 441 instr->OpcodeValue()); | 442 instr->OpcodeValue()); |
| 442 } | 443 } |
| 443 InstructionDecode(instr); | 444 InstructionDecode(instr); |
| 444 SNPrintF(trace_buf_, " "); | 445 SNPrintF(trace_buf_, " "); |
| 445 } | 446 } |
| 446 | 447 |
| 447 // ICache. | 448 // ICache. |
| 448 static void CheckICache(base::HashMap* i_cache, Instruction* instr); | 449 static void CheckICache(base::CustomMatcherHashMap* i_cache, |
| 449 static void FlushOnePage(base::HashMap* i_cache, intptr_t start, size_t size); | 450 Instruction* instr); |
| 450 static CachePage* GetCachePage(base::HashMap* i_cache, void* page); | 451 static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, |
| 452 size_t size); |
| 453 static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache, |
| 454 void* page); |
| 451 | 455 |
| 452 enum Exception { | 456 enum Exception { |
| 453 none, | 457 none, |
| 454 kIntegerOverflow, | 458 kIntegerOverflow, |
| 455 kIntegerUnderflow, | 459 kIntegerUnderflow, |
| 456 kDivideByZero, | 460 kDivideByZero, |
| 457 kNumExceptions | 461 kNumExceptions |
| 458 }; | 462 }; |
| 459 | 463 |
| 460 // Exceptions. | 464 // Exceptions. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 485 char* stack_; | 489 char* stack_; |
| 486 bool pc_modified_; | 490 bool pc_modified_; |
| 487 int64_t icount_; | 491 int64_t icount_; |
| 488 int break_count_; | 492 int break_count_; |
| 489 EmbeddedVector<char, 128> trace_buf_; | 493 EmbeddedVector<char, 128> trace_buf_; |
| 490 | 494 |
| 491 // Debugger input. | 495 // Debugger input. |
| 492 char* last_debugger_input_; | 496 char* last_debugger_input_; |
| 493 | 497 |
| 494 // Icache simulation. | 498 // Icache simulation. |
| 495 base::HashMap* i_cache_; | 499 base::CustomMatcherHashMap* i_cache_; |
| 496 | 500 |
| 497 v8::internal::Isolate* isolate_; | 501 v8::internal::Isolate* isolate_; |
| 498 | 502 |
| 499 // Registered breakpoints. | 503 // Registered breakpoints. |
| 500 Instruction* break_pc_; | 504 Instruction* break_pc_; |
| 501 Instr break_instr_; | 505 Instr break_instr_; |
| 502 | 506 |
| 503 // Stop is disabled if bit 31 is set. | 507 // Stop is disabled if bit 31 is set. |
| 504 static const uint32_t kStopDisabledBit = 1 << 31; | 508 static const uint32_t kStopDisabledBit = 1 << 31; |
| 505 | 509 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 static inline void UnregisterCTryCatch(Isolate* isolate) { | 555 static inline void UnregisterCTryCatch(Isolate* isolate) { |
| 552 Simulator::current(isolate)->PopAddress(); | 556 Simulator::current(isolate)->PopAddress(); |
| 553 } | 557 } |
| 554 }; | 558 }; |
| 555 | 559 |
| 556 } // namespace internal | 560 } // namespace internal |
| 557 } // namespace v8 | 561 } // namespace v8 |
| 558 | 562 |
| 559 #endif // !defined(USE_SIMULATOR) | 563 #endif // !defined(USE_SIMULATOR) |
| 560 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 564 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
| OLD | NEW |