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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 // Accessor to the internal simulator stack area. | 220 // Accessor to the internal simulator stack area. |
221 uintptr_t StackLimit(uintptr_t c_limit) const; | 221 uintptr_t StackLimit(uintptr_t c_limit) const; |
222 | 222 |
223 // Executes MIPS instructions until the PC reaches end_sim_pc. | 223 // Executes MIPS instructions until the PC reaches end_sim_pc. |
224 void Execute(); | 224 void Execute(); |
225 | 225 |
226 // Call on program start. | 226 // Call on program start. |
227 static void Initialize(Isolate* isolate); | 227 static void Initialize(Isolate* isolate); |
228 | 228 |
229 static void TearDown(HashMap* i_cache, Redirection* first); | 229 static void TearDown(base::HashMap* i_cache, Redirection* first); |
230 | 230 |
231 // V8 generally calls into generated JS code with 5 parameters and into | 231 // V8 generally calls into generated JS code with 5 parameters and into |
232 // generated RegExp code with 7 parameters. This is a convenience function, | 232 // generated RegExp code with 7 parameters. This is a convenience function, |
233 // which sets up the simulator state and grabs the result on return. | 233 // which sets up the simulator state and grabs the result on return. |
234 int64_t Call(byte* entry, int argument_count, ...); | 234 int64_t Call(byte* entry, int argument_count, ...); |
235 // Alternative: call a 2-argument double function. | 235 // Alternative: call a 2-argument double function. |
236 double CallFP(byte* entry, double d0, double d1); | 236 double CallFP(byte* entry, double d0, double d1); |
237 | 237 |
238 // Push an address onto the JS stack. | 238 // Push an address onto the JS stack. |
239 uintptr_t PushAddress(uintptr_t address); | 239 uintptr_t PushAddress(uintptr_t address); |
240 | 240 |
241 // Pop an address from the JS stack. | 241 // Pop an address from the JS stack. |
242 uintptr_t PopAddress(); | 242 uintptr_t PopAddress(); |
243 | 243 |
244 // Debugger input. | 244 // Debugger input. |
245 void set_last_debugger_input(char* input); | 245 void set_last_debugger_input(char* input); |
246 char* last_debugger_input() { return last_debugger_input_; } | 246 char* last_debugger_input() { return last_debugger_input_; } |
247 | 247 |
248 // ICache checking. | 248 // ICache checking. |
249 static void FlushICache(v8::internal::HashMap* i_cache, void* start, | 249 static void FlushICache(base::HashMap* i_cache, void* start, |
250 size_t size); | 250 size_t size); |
251 | 251 |
252 // Returns true if pc register contains one of the 'special_values' defined | 252 // Returns true if pc register contains one of the 'special_values' defined |
253 // below (bad_ra, end_sim_pc). | 253 // below (bad_ra, end_sim_pc). |
254 bool has_bad_pc() const; | 254 bool has_bad_pc() const; |
255 | 255 |
256 private: | 256 private: |
257 enum special_values { | 257 enum special_values { |
258 // Known bad pc value to ensure that the simulator does not execute | 258 // Known bad pc value to ensure that the simulator does not execute |
259 // without being properly setup. | 259 // without being properly setup. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 if (instr->IsForbiddenAfterBranch()) { | 408 if (instr->IsForbiddenAfterBranch()) { |
409 V8_Fatal(__FILE__, __LINE__, | 409 V8_Fatal(__FILE__, __LINE__, |
410 "Eror:Unexpected %i opcode in a branch delay slot.", | 410 "Eror:Unexpected %i opcode in a branch delay slot.", |
411 instr->OpcodeValue()); | 411 instr->OpcodeValue()); |
412 } | 412 } |
413 InstructionDecode(instr); | 413 InstructionDecode(instr); |
414 SNPrintF(trace_buf_, " "); | 414 SNPrintF(trace_buf_, " "); |
415 } | 415 } |
416 | 416 |
417 // ICache. | 417 // ICache. |
418 static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr); | 418 static void CheckICache(base::HashMap* i_cache, Instruction* instr); |
419 static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, | 419 static void FlushOnePage(base::HashMap* i_cache, intptr_t start, |
420 size_t size); | 420 size_t size); |
421 static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page); | 421 static CachePage* GetCachePage(base::HashMap* i_cache, void* page); |
422 | 422 |
423 enum Exception { | 423 enum Exception { |
424 none, | 424 none, |
425 kIntegerOverflow, | 425 kIntegerOverflow, |
426 kIntegerUnderflow, | 426 kIntegerUnderflow, |
427 kDivideByZero, | 427 kDivideByZero, |
428 kNumExceptions | 428 kNumExceptions |
429 }; | 429 }; |
430 | 430 |
431 // Exceptions. | 431 // Exceptions. |
(...skipping 24 matching lines...) Expand all Loading... |
456 char* stack_; | 456 char* stack_; |
457 bool pc_modified_; | 457 bool pc_modified_; |
458 int64_t icount_; | 458 int64_t icount_; |
459 int break_count_; | 459 int break_count_; |
460 EmbeddedVector<char, 128> trace_buf_; | 460 EmbeddedVector<char, 128> trace_buf_; |
461 | 461 |
462 // Debugger input. | 462 // Debugger input. |
463 char* last_debugger_input_; | 463 char* last_debugger_input_; |
464 | 464 |
465 // Icache simulation. | 465 // Icache simulation. |
466 v8::internal::HashMap* i_cache_; | 466 base::HashMap* i_cache_; |
467 | 467 |
468 v8::internal::Isolate* isolate_; | 468 v8::internal::Isolate* isolate_; |
469 | 469 |
470 // Registered breakpoints. | 470 // Registered breakpoints. |
471 Instruction* break_pc_; | 471 Instruction* break_pc_; |
472 Instr break_instr_; | 472 Instr break_instr_; |
473 | 473 |
474 // Stop is disabled if bit 31 is set. | 474 // Stop is disabled if bit 31 is set. |
475 static const uint32_t kStopDisabledBit = 1 << 31; | 475 static const uint32_t kStopDisabledBit = 1 << 31; |
476 | 476 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 static inline void UnregisterCTryCatch(Isolate* isolate) { | 522 static inline void UnregisterCTryCatch(Isolate* isolate) { |
523 Simulator::current(isolate)->PopAddress(); | 523 Simulator::current(isolate)->PopAddress(); |
524 } | 524 } |
525 }; | 525 }; |
526 | 526 |
527 } // namespace internal | 527 } // namespace internal |
528 } // namespace v8 | 528 } // namespace v8 |
529 | 529 |
530 #endif // !defined(USE_SIMULATOR) | 530 #endif // !defined(USE_SIMULATOR) |
531 #endif // V8_MIPS_SIMULATOR_MIPS_H_ | 531 #endif // V8_MIPS_SIMULATOR_MIPS_H_ |
OLD | NEW |