| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include <stdarg.h> | 5 #include <stdarg.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_S390 | 9 #if V8_TARGET_ARCH_S390 |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 268 |
| 269 // If at a breakpoint, proceed past it. | 269 // If at a breakpoint, proceed past it. |
| 270 if ((reinterpret_cast<Instruction*>(sim_->get_pc())) | 270 if ((reinterpret_cast<Instruction*>(sim_->get_pc())) |
| 271 ->InstructionBits() == 0x7d821008) { | 271 ->InstructionBits() == 0x7d821008) { |
| 272 sim_->set_pc(sim_->get_pc() + sizeof(FourByteInstr)); | 272 sim_->set_pc(sim_->get_pc() + sizeof(FourByteInstr)); |
| 273 } else { | 273 } else { |
| 274 sim_->ExecuteInstruction( | 274 sim_->ExecuteInstruction( |
| 275 reinterpret_cast<Instruction*>(sim_->get_pc())); | 275 reinterpret_cast<Instruction*>(sim_->get_pc())); |
| 276 } | 276 } |
| 277 | 277 |
| 278 if (argc == 2 && last_pc != sim_->get_pc() && GetValue(arg1, &value)) { | 278 if (argc == 2 && last_pc != sim_->get_pc()) { |
| 279 for (int i = 1; (!sim_->has_bad_pc()) && i < value; i++) { | 279 disasm::NameConverter converter; |
| 280 disasm::NameConverter converter; | 280 disasm::Disassembler dasm(converter); |
| 281 disasm::Disassembler dasm(converter); | 281 // use a reasonably large buffer |
| 282 // use a reasonably large buffer | 282 v8::internal::EmbeddedVector<char, 256> buffer; |
| 283 v8::internal::EmbeddedVector<char, 256> buffer; | 283 |
| 284 dasm.InstructionDecode(buffer, | 284 if (GetValue(arg1, &value)) { |
| 285 reinterpret_cast<byte*>(sim_->get_pc())); | 285 // Interpret a numeric argument as the number of instructions to |
| 286 PrintF(" 0x%08" V8PRIxPTR " %s\n", sim_->get_pc(), | 286 // step past. |
| 287 buffer.start()); | 287 for (int i = 1; (!sim_->has_bad_pc()) && i < value; i++) { |
| 288 sim_->ExecuteInstruction( | 288 dasm.InstructionDecode(buffer, |
| 289 reinterpret_cast<Instruction*>(sim_->get_pc())); | 289 reinterpret_cast<byte*>(sim_->get_pc())); |
| 290 PrintF(" 0x%08" V8PRIxPTR " %s\n", sim_->get_pc(), |
| 291 buffer.start()); |
| 292 sim_->ExecuteInstruction( |
| 293 reinterpret_cast<Instruction*>(sim_->get_pc())); |
| 294 } |
| 295 } else { |
| 296 // Otherwise treat it as the mnemonic of the opcode to stop at. |
| 297 char mnemonic[256]; |
| 298 while (!sim_->has_bad_pc()) { |
| 299 dasm.InstructionDecode(buffer, |
| 300 reinterpret_cast<byte*>(sim_->get_pc())); |
| 301 char* mnemonicStart = buffer.start(); |
| 302 while (*mnemonicStart != 0 && *mnemonicStart != ' ') |
| 303 mnemonicStart++; |
| 304 SScanF(mnemonicStart, "%s", mnemonic); |
| 305 if (!strcmp(arg1, mnemonic)) break; |
| 306 |
| 307 PrintF(" 0x%08" V8PRIxPTR " %s\n", sim_->get_pc(), |
| 308 buffer.start()); |
| 309 sim_->ExecuteInstruction( |
| 310 reinterpret_cast<Instruction*>(sim_->get_pc())); |
| 311 } |
| 290 } | 312 } |
| 291 } | 313 } |
| 292 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { | 314 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { |
| 293 // If at a breakpoint, proceed past it. | 315 // If at a breakpoint, proceed past it. |
| 294 if ((reinterpret_cast<Instruction*>(sim_->get_pc())) | 316 if ((reinterpret_cast<Instruction*>(sim_->get_pc())) |
| 295 ->InstructionBits() == 0x7d821008) { | 317 ->InstructionBits() == 0x7d821008) { |
| 296 sim_->set_pc(sim_->get_pc() + sizeof(FourByteInstr)); | 318 sim_->set_pc(sim_->get_pc() + sizeof(FourByteInstr)); |
| 297 } else { | 319 } else { |
| 298 // Execute the one instruction we broke at with breakpoints disabled. | 320 // Execute the one instruction we broke at with breakpoints disabled. |
| 299 sim_->ExecuteInstruction( | 321 sim_->ExecuteInstruction( |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 590 } |
| 569 } else if (GetValue(arg2, &value)) { | 591 } else if (GetValue(arg2, &value)) { |
| 570 sim_->DisableStop(value); | 592 sim_->DisableStop(value); |
| 571 } else { | 593 } else { |
| 572 PrintF("Unrecognized argument.\n"); | 594 PrintF("Unrecognized argument.\n"); |
| 573 } | 595 } |
| 574 } | 596 } |
| 575 } else { | 597 } else { |
| 576 PrintF("Wrong usage. Use help command for more information.\n"); | 598 PrintF("Wrong usage. Use help command for more information.\n"); |
| 577 } | 599 } |
| 600 } else if (strcmp(cmd, "icount") == 0) { |
| 601 PrintF("%05d\n", sim_->icount_); |
| 578 } else if ((strcmp(cmd, "t") == 0) || strcmp(cmd, "trace") == 0) { | 602 } else if ((strcmp(cmd, "t") == 0) || strcmp(cmd, "trace") == 0) { |
| 579 ::v8::internal::FLAG_trace_sim = !::v8::internal::FLAG_trace_sim; | 603 ::v8::internal::FLAG_trace_sim = !::v8::internal::FLAG_trace_sim; |
| 580 PrintF("Trace of executed instructions is %s\n", | 604 PrintF("Trace of executed instructions is %s\n", |
| 581 ::v8::internal::FLAG_trace_sim ? "on" : "off"); | 605 ::v8::internal::FLAG_trace_sim ? "on" : "off"); |
| 582 } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { | 606 } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { |
| 583 PrintF("cont\n"); | 607 PrintF("cont\n"); |
| 584 PrintF(" continue execution (alias 'c')\n"); | 608 PrintF(" continue execution (alias 'c')\n"); |
| 585 PrintF("stepi [num instructions]\n"); | 609 PrintF("stepi [num instructions]\n"); |
| 586 PrintF(" step one/num instruction(s) (alias 'si')\n"); | 610 PrintF(" step one/num instruction(s) (alias 'si')\n"); |
| 587 PrintF("print <register>\n"); | 611 PrintF("print <register>\n"); |
| (...skipping 4968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5556 } | 5580 } |
| 5557 | 5581 |
| 5558 int Simulator::DecodeInstruction(Instruction* instr) { | 5582 int Simulator::DecodeInstruction(Instruction* instr) { |
| 5559 Opcode op = instr->S390OpcodeValue(); | 5583 Opcode op = instr->S390OpcodeValue(); |
| 5560 DCHECK(EvalTable[op] != NULL); | 5584 DCHECK(EvalTable[op] != NULL); |
| 5561 return (this->*EvalTable[op])(instr); | 5585 return (this->*EvalTable[op])(instr); |
| 5562 } | 5586 } |
| 5563 | 5587 |
| 5564 // Executes the current instruction. | 5588 // Executes the current instruction. |
| 5565 void Simulator::ExecuteInstruction(Instruction* instr, bool auto_incr_pc) { | 5589 void Simulator::ExecuteInstruction(Instruction* instr, bool auto_incr_pc) { |
| 5590 icount_++; |
| 5591 |
| 5566 if (v8::internal::FLAG_check_icache) { | 5592 if (v8::internal::FLAG_check_icache) { |
| 5567 CheckICache(isolate_->simulator_i_cache(), instr); | 5593 CheckICache(isolate_->simulator_i_cache(), instr); |
| 5568 } | 5594 } |
| 5569 | 5595 |
| 5570 pc_modified_ = false; | 5596 pc_modified_ = false; |
| 5571 | 5597 |
| 5572 if (::v8::internal::FLAG_trace_sim) { | 5598 if (::v8::internal::FLAG_trace_sim) { |
| 5573 disasm::NameConverter converter; | 5599 disasm::NameConverter converter; |
| 5574 disasm::Disassembler dasm(converter); | 5600 disasm::Disassembler dasm(converter); |
| 5575 // use a reasonably large buffer | 5601 // use a reasonably large buffer |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5601 void Simulator::Execute() { | 5627 void Simulator::Execute() { |
| 5602 // Get the PC to simulate. Cannot use the accessor here as we need the | 5628 // Get the PC to simulate. Cannot use the accessor here as we need the |
| 5603 // raw PC value and not the one used as input to arithmetic instructions. | 5629 // raw PC value and not the one used as input to arithmetic instructions. |
| 5604 intptr_t program_counter = get_pc(); | 5630 intptr_t program_counter = get_pc(); |
| 5605 | 5631 |
| 5606 if (::v8::internal::FLAG_stop_sim_at == 0) { | 5632 if (::v8::internal::FLAG_stop_sim_at == 0) { |
| 5607 // Fast version of the dispatch loop without checking whether the simulator | 5633 // Fast version of the dispatch loop without checking whether the simulator |
| 5608 // should be stopping at a particular executed instruction. | 5634 // should be stopping at a particular executed instruction. |
| 5609 while (program_counter != end_sim_pc) { | 5635 while (program_counter != end_sim_pc) { |
| 5610 Instruction* instr = reinterpret_cast<Instruction*>(program_counter); | 5636 Instruction* instr = reinterpret_cast<Instruction*>(program_counter); |
| 5611 icount_++; | |
| 5612 ExecuteInstruction(instr); | 5637 ExecuteInstruction(instr); |
| 5613 program_counter = get_pc(); | 5638 program_counter = get_pc(); |
| 5614 } | 5639 } |
| 5615 } else { | 5640 } else { |
| 5616 // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when | 5641 // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when |
| 5617 // we reach the particular instuction count. | 5642 // we reach the particular instuction count. |
| 5618 while (program_counter != end_sim_pc) { | 5643 while (program_counter != end_sim_pc) { |
| 5619 Instruction* instr = reinterpret_cast<Instruction*>(program_counter); | 5644 Instruction* instr = reinterpret_cast<Instruction*>(program_counter); |
| 5620 icount_++; | |
| 5621 if (icount_ == ::v8::internal::FLAG_stop_sim_at) { | 5645 if (icount_ == ::v8::internal::FLAG_stop_sim_at) { |
| 5622 S390Debugger dbg(this); | 5646 S390Debugger dbg(this); |
| 5623 dbg.Debug(); | 5647 dbg.Debug(); |
| 5624 } else { | 5648 } else { |
| 5625 ExecuteInstruction(instr); | 5649 ExecuteInstruction(instr); |
| 5626 } | 5650 } |
| 5627 program_counter = get_pc(); | 5651 program_counter = get_pc(); |
| 5628 } | 5652 } |
| 5629 } | 5653 } |
| 5630 } | 5654 } |
| (...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7665 | 7689 |
| 7666 EVALUATE(CXZT) { return DecodeInstructionOriginal(instr); } | 7690 EVALUATE(CXZT) { return DecodeInstructionOriginal(instr); } |
| 7667 | 7691 |
| 7668 #undef EVALUATE | 7692 #undef EVALUATE |
| 7669 | 7693 |
| 7670 } // namespace internal | 7694 } // namespace internal |
| 7671 } // namespace v8 | 7695 } // namespace v8 |
| 7672 | 7696 |
| 7673 #endif // USE_SIMULATOR | 7697 #endif // USE_SIMULATOR |
| 7674 #endif // V8_TARGET_ARCH_S390 | 7698 #endif // V8_TARGET_ARCH_S390 |
| OLD | NEW |