OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 }; | 188 }; |
189 typedef SimRegisterBase<kXRegSizeInBytes> SimRegister; // r0-r31 | 189 typedef SimRegisterBase<kXRegSizeInBytes> SimRegister; // r0-r31 |
190 typedef SimRegisterBase<kDRegSizeInBytes> SimFPRegister; // v0-v31 | 190 typedef SimRegisterBase<kDRegSizeInBytes> SimFPRegister; // v0-v31 |
191 | 191 |
192 | 192 |
193 class Simulator : public DecoderVisitor { | 193 class Simulator : public DecoderVisitor { |
194 public: | 194 public: |
195 explicit Simulator(Decoder<DispatchingDecoderVisitor>* decoder, | 195 explicit Simulator(Decoder<DispatchingDecoderVisitor>* decoder, |
196 Isolate* isolate = NULL, | 196 Isolate* isolate = NULL, |
197 FILE* stream = stderr); | 197 FILE* stream = stderr); |
| 198 Simulator(); |
198 ~Simulator(); | 199 ~Simulator(); |
199 | 200 |
200 // System functions. | 201 // System functions. |
201 | 202 |
202 static void Initialize(Isolate* isolate); | 203 static void Initialize(Isolate* isolate); |
203 | 204 |
204 static Simulator* current(v8::internal::Isolate* isolate); | 205 static Simulator* current(v8::internal::Isolate* isolate); |
205 | 206 |
206 class CallArgument; | 207 class CallArgument; |
207 | 208 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 Instruction* pc() { return pc_; } | 328 Instruction* pc() { return pc_; } |
328 | 329 |
329 void increment_pc() { | 330 void increment_pc() { |
330 if (!pc_modified_) { | 331 if (!pc_modified_) { |
331 pc_ = pc_->NextInstruction(); | 332 pc_ = pc_->NextInstruction(); |
332 } | 333 } |
333 | 334 |
334 pc_modified_ = false; | 335 pc_modified_ = false; |
335 } | 336 } |
336 | 337 |
| 338 virtual void Decode(Instruction* instr) { |
| 339 decoder_->Decode(instr); |
| 340 } |
| 341 |
337 void ExecuteInstruction() { | 342 void ExecuteInstruction() { |
338 ASSERT(IsAligned(reinterpret_cast<uintptr_t>(pc_), kInstructionSize)); | 343 ASSERT(IsAligned(reinterpret_cast<uintptr_t>(pc_), kInstructionSize)); |
339 CheckBreakNext(); | 344 CheckBreakNext(); |
340 decoder_->Decode(pc_); | 345 Decode(pc_); |
341 LogProcessorState(); | 346 LogProcessorState(); |
342 increment_pc(); | 347 increment_pc(); |
343 CheckBreakpoints(); | 348 CheckBreakpoints(); |
344 } | 349 } |
345 | 350 |
346 // Declare all Visitor functions. | 351 // Declare all Visitor functions. |
347 #define DECLARE(A) void Visit##A(Instruction* instr); | 352 #define DECLARE(A) void Visit##A(Instruction* instr); |
348 VISITOR_LIST(DECLARE) | 353 VISITOR_LIST(DECLARE) |
349 #undef DECLARE | 354 #undef DECLARE |
350 | 355 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 LogSystemRegisters(); | 580 LogSystemRegisters(); |
576 LogRegisters(); | 581 LogRegisters(); |
577 LogFPRegisters(); | 582 LogFPRegisters(); |
578 } | 583 } |
579 void LogWrite(uint8_t* address, uint64_t value, unsigned num_bytes) { | 584 void LogWrite(uint8_t* address, uint64_t value, unsigned num_bytes) { |
580 if (log_parameters_ & LOG_WRITE) PrintWrite(address, value, num_bytes); | 585 if (log_parameters_ & LOG_WRITE) PrintWrite(address, value, num_bytes); |
581 } | 586 } |
582 | 587 |
583 int log_parameters() { return log_parameters_; } | 588 int log_parameters() { return log_parameters_; } |
584 void set_log_parameters(int new_parameters) { | 589 void set_log_parameters(int new_parameters) { |
| 590 log_parameters_ = new_parameters; |
| 591 if (!decoder_) { |
| 592 if (new_parameters & LOG_DISASM) { |
| 593 PrintF("Run --debug-sim to dynamically turn on disassembler\n"); |
| 594 } |
| 595 return; |
| 596 } |
585 if (new_parameters & LOG_DISASM) { | 597 if (new_parameters & LOG_DISASM) { |
586 decoder_->InsertVisitorBefore(print_disasm_, this); | 598 decoder_->InsertVisitorBefore(print_disasm_, this); |
587 } else { | 599 } else { |
588 decoder_->RemoveVisitor(print_disasm_); | 600 decoder_->RemoveVisitor(print_disasm_); |
589 } | 601 } |
590 log_parameters_ = new_parameters; | |
591 } | 602 } |
592 | 603 |
593 static inline const char* WRegNameForCode(unsigned code, | 604 static inline const char* WRegNameForCode(unsigned code, |
594 Reg31Mode mode = Reg31IsZeroRegister); | 605 Reg31Mode mode = Reg31IsZeroRegister); |
595 static inline const char* XRegNameForCode(unsigned code, | 606 static inline const char* XRegNameForCode(unsigned code, |
596 Reg31Mode mode = Reg31IsZeroRegister); | 607 Reg31Mode mode = Reg31IsZeroRegister); |
597 static inline const char* SRegNameForCode(unsigned code); | 608 static inline const char* SRegNameForCode(unsigned code); |
598 static inline const char* DRegNameForCode(unsigned code); | 609 static inline const char* DRegNameForCode(unsigned code); |
599 static inline const char* VRegNameForCode(unsigned code); | 610 static inline const char* VRegNameForCode(unsigned code); |
600 static inline int CodeFromName(const char* name); | 611 static inline int CodeFromName(const char* name); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 | 823 |
813 // Debugger input. | 824 // Debugger input. |
814 void set_last_debugger_input(char* input) { | 825 void set_last_debugger_input(char* input) { |
815 DeleteArray(last_debugger_input_); | 826 DeleteArray(last_debugger_input_); |
816 last_debugger_input_ = input; | 827 last_debugger_input_ = input; |
817 } | 828 } |
818 char* last_debugger_input() { return last_debugger_input_; } | 829 char* last_debugger_input() { return last_debugger_input_; } |
819 char* last_debugger_input_; | 830 char* last_debugger_input_; |
820 | 831 |
821 private: | 832 private: |
| 833 void Init(FILE* stream); |
| 834 |
822 int log_parameters_; | 835 int log_parameters_; |
823 Isolate* isolate_; | 836 Isolate* isolate_; |
824 }; | 837 }; |
825 | 838 |
826 | 839 |
827 // When running with the simulator transition into simulated execution at this | 840 // When running with the simulator transition into simulated execution at this |
828 // point. | 841 // point. |
829 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ | 842 #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ |
830 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->CallJS( \ | 843 reinterpret_cast<Object*>(Simulator::current(Isolate::Current())->CallJS( \ |
831 FUNCTION_ADDR(entry), \ | 844 FUNCTION_ADDR(entry), \ |
(...skipping 27 matching lines...) Expand all Loading... |
859 static void UnregisterCTryCatch() { | 872 static void UnregisterCTryCatch() { |
860 Simulator::current(Isolate::Current())->PopAddress(); | 873 Simulator::current(Isolate::Current())->PopAddress(); |
861 } | 874 } |
862 }; | 875 }; |
863 | 876 |
864 #endif // !defined(USE_SIMULATOR) | 877 #endif // !defined(USE_SIMULATOR) |
865 | 878 |
866 } } // namespace v8::internal | 879 } } // namespace v8::internal |
867 | 880 |
868 #endif // V8_A64_SIMULATOR_A64_H_ | 881 #endif // V8_A64_SIMULATOR_A64_H_ |
OLD | NEW |