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 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #if V8_TARGET_ARCH_MIPS | 10 #if V8_TARGET_ARCH_MIPS |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 words = 10; | 579 words = 10; |
580 } else { | 580 } else { |
581 if (!GetValue(argv[next_arg], &words)) { | 581 if (!GetValue(argv[next_arg], &words)) { |
582 words = 10; | 582 words = 10; |
583 } | 583 } |
584 } | 584 } |
585 end = cur + words; | 585 end = cur + words; |
586 } | 586 } |
587 | 587 |
588 while (cur < end) { | 588 while (cur < end) { |
589 PrintF(" 0x%08x: 0x%08x %10d", | 589 PrintF(" 0x%08" PRIxPTR ": 0x%08x %10d", |
590 reinterpret_cast<intptr_t>(cur), *cur, *cur); | 590 reinterpret_cast<intptr_t>(cur), *cur, *cur); |
591 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); | 591 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); |
592 int value = *cur; | 592 int value = *cur; |
593 Heap* current_heap = sim_->isolate_->heap(); | 593 Heap* current_heap = sim_->isolate_->heap(); |
594 if (((value & 1) == 0) || | 594 if (((value & 1) == 0) || |
595 current_heap->ContainsSlow(obj->address())) { | 595 current_heap->ContainsSlow(obj->address())) { |
596 PrintF(" ("); | 596 PrintF(" ("); |
597 if ((value & 1) == 0) { | 597 if ((value & 1) == 0) { |
598 PrintF("smi %d", value / 2); | 598 PrintF("smi %d", value / 2); |
599 } else { | 599 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 int32_t value1; | 642 int32_t value1; |
643 int32_t value2; | 643 int32_t value2; |
644 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { | 644 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { |
645 cur = reinterpret_cast<byte*>(value1); | 645 cur = reinterpret_cast<byte*>(value1); |
646 end = cur + (value2 * Instruction::kInstrSize); | 646 end = cur + (value2 * Instruction::kInstrSize); |
647 } | 647 } |
648 } | 648 } |
649 | 649 |
650 while (cur < end) { | 650 while (cur < end) { |
651 dasm.InstructionDecode(buffer, cur); | 651 dasm.InstructionDecode(buffer, cur); |
652 PrintF(" 0x%08x %s\n", | 652 PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast<intptr_t>(cur), |
653 reinterpret_cast<intptr_t>(cur), buffer.start()); | 653 buffer.start()); |
654 cur += Instruction::kInstrSize; | 654 cur += Instruction::kInstrSize; |
655 } | 655 } |
656 } else if (strcmp(cmd, "gdb") == 0) { | 656 } else if (strcmp(cmd, "gdb") == 0) { |
657 PrintF("relinquishing control to gdb\n"); | 657 PrintF("relinquishing control to gdb\n"); |
658 v8::base::OS::DebugBreak(); | 658 v8::base::OS::DebugBreak(); |
659 PrintF("regaining control from gdb\n"); | 659 PrintF("regaining control from gdb\n"); |
660 } else if (strcmp(cmd, "break") == 0) { | 660 } else if (strcmp(cmd, "break") == 0) { |
661 if (argc == 2) { | 661 if (argc == 2) { |
662 int32_t value; | 662 int32_t value; |
663 if (GetValue(arg1, &value)) { | 663 if (GetValue(arg1, &value)) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 int32_t value1; | 764 int32_t value1; |
765 int32_t value2; | 765 int32_t value2; |
766 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { | 766 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { |
767 cur = reinterpret_cast<byte*>(value1); | 767 cur = reinterpret_cast<byte*>(value1); |
768 end = cur + (value2 * Instruction::kInstrSize); | 768 end = cur + (value2 * Instruction::kInstrSize); |
769 } | 769 } |
770 } | 770 } |
771 | 771 |
772 while (cur < end) { | 772 while (cur < end) { |
773 dasm.InstructionDecode(buffer, cur); | 773 dasm.InstructionDecode(buffer, cur); |
774 PrintF(" 0x%08x %s\n", | 774 PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast<intptr_t>(cur), |
775 reinterpret_cast<intptr_t>(cur), buffer.start()); | 775 buffer.start()); |
776 cur += Instruction::kInstrSize; | 776 cur += Instruction::kInstrSize; |
777 } | 777 } |
778 } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { | 778 } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { |
779 PrintF("cont\n"); | 779 PrintF("cont\n"); |
780 PrintF(" continue execution (alias 'c')\n"); | 780 PrintF(" continue execution (alias 'c')\n"); |
781 PrintF("stepi\n"); | 781 PrintF("stepi\n"); |
782 PrintF(" step one instruction (alias 'si')\n"); | 782 PrintF(" step one instruction (alias 'si')\n"); |
783 PrintF("print <register>\n"); | 783 PrintF("print <register>\n"); |
784 PrintF(" print register content (alias 'p')\n"); | 784 PrintF(" print register content (alias 'p')\n"); |
785 PrintF(" use register name 'all' to print all registers\n"); | 785 PrintF(" use register name 'all' to print all registers\n"); |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 SNPrintF(trace_buf_, "%08x --> [%08x]", value, addr); | 1779 SNPrintF(trace_buf_, "%08x --> [%08x]", value, addr); |
1780 break; | 1780 break; |
1781 } | 1781 } |
1782 } | 1782 } |
1783 } | 1783 } |
1784 | 1784 |
1785 | 1785 |
1786 int Simulator::ReadW(int32_t addr, Instruction* instr) { | 1786 int Simulator::ReadW(int32_t addr, Instruction* instr) { |
1787 if (addr >=0 && addr < 0x400) { | 1787 if (addr >=0 && addr < 0x400) { |
1788 // This has to be a NULL-dereference, drop into debugger. | 1788 // This has to be a NULL-dereference, drop into debugger. |
1789 PrintF("Memory read from bad address: 0x%08x, pc=0x%08x\n", | 1789 PrintF("Memory read from bad address: 0x%08x, pc=0x%08" PRIxPTR "\n", addr, |
1790 addr, reinterpret_cast<intptr_t>(instr)); | 1790 reinterpret_cast<intptr_t>(instr)); |
1791 MipsDebugger dbg(this); | 1791 MipsDebugger dbg(this); |
1792 dbg.Debug(); | 1792 dbg.Debug(); |
1793 } | 1793 } |
1794 if ((addr & kPointerAlignmentMask) == 0) { | 1794 if ((addr & kPointerAlignmentMask) == 0) { |
1795 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 1795 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
1796 TraceMemRd(addr, static_cast<int32_t>(*ptr)); | 1796 TraceMemRd(addr, static_cast<int32_t>(*ptr)); |
1797 return *ptr; | 1797 return *ptr; |
1798 } | 1798 } |
1799 PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1799 PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
1800 addr, | 1800 addr, |
1801 reinterpret_cast<intptr_t>(instr)); | 1801 reinterpret_cast<intptr_t>(instr)); |
1802 MipsDebugger dbg(this); | 1802 MipsDebugger dbg(this); |
1803 dbg.Debug(); | 1803 dbg.Debug(); |
1804 return 0; | 1804 return 0; |
1805 } | 1805 } |
1806 | 1806 |
1807 | 1807 |
1808 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { | 1808 void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { |
1809 if (addr >= 0 && addr < 0x400) { | 1809 if (addr >= 0 && addr < 0x400) { |
1810 // This has to be a NULL-dereference, drop into debugger. | 1810 // This has to be a NULL-dereference, drop into debugger. |
1811 PrintF("Memory write to bad address: 0x%08x, pc=0x%08x\n", | 1811 PrintF("Memory write to bad address: 0x%08x, pc=0x%08" PRIxPTR "\n", addr, |
1812 addr, reinterpret_cast<intptr_t>(instr)); | 1812 reinterpret_cast<intptr_t>(instr)); |
1813 MipsDebugger dbg(this); | 1813 MipsDebugger dbg(this); |
1814 dbg.Debug(); | 1814 dbg.Debug(); |
1815 } | 1815 } |
1816 if ((addr & kPointerAlignmentMask) == 0) { | 1816 if ((addr & kPointerAlignmentMask) == 0) { |
1817 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 1817 intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
1818 TraceMemWr(addr, value, WORD); | 1818 TraceMemWr(addr, value, WORD); |
1819 *ptr = value; | 1819 *ptr = value; |
1820 return; | 1820 return; |
1821 } | 1821 } |
1822 PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", | 1822 PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 } | 1946 } |
1947 | 1947 |
1948 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes | 1948 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes |
1949 // to prevent overrunning the stack when pushing values. | 1949 // to prevent overrunning the stack when pushing values. |
1950 return reinterpret_cast<uintptr_t>(stack_) + 1024; | 1950 return reinterpret_cast<uintptr_t>(stack_) + 1024; |
1951 } | 1951 } |
1952 | 1952 |
1953 | 1953 |
1954 // Unsupported instructions use Format to print an error and stop execution. | 1954 // Unsupported instructions use Format to print an error and stop execution. |
1955 void Simulator::Format(Instruction* instr, const char* format) { | 1955 void Simulator::Format(Instruction* instr, const char* format) { |
1956 PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n", | 1956 PrintF("Simulator found unsupported instruction:\n 0x%08" PRIxPTR ": %s\n", |
1957 reinterpret_cast<intptr_t>(instr), format); | 1957 reinterpret_cast<intptr_t>(instr), format); |
1958 UNIMPLEMENTED_MIPS(); | 1958 UNIMPLEMENTED_MIPS(); |
1959 } | 1959 } |
1960 | 1960 |
1961 | 1961 |
1962 // Calls into the V8 runtime are based on this very simple interface. | 1962 // Calls into the V8 runtime are based on this very simple interface. |
1963 // Note: To be able to return two values from some calls the code in runtime.cc | 1963 // Note: To be able to return two values from some calls the code in runtime.cc |
1964 // uses the ObjectPair which is essentially two 32-bit values stuffed into a | 1964 // uses the ObjectPair which is essentially two 32-bit values stuffed into a |
1965 // 64-bit value. With the code below we assume that all runtime calls return | 1965 // 64-bit value. With the code below we assume that all runtime calls return |
1966 // 64 bits of result. If they don't, the v1 result register contains a bogus | 1966 // 64 bits of result. If they don't, the v1 result register contains a bogus |
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4406 case Instruction::kImmediateType: | 4406 case Instruction::kImmediateType: |
4407 DecodeTypeImmediate(instr); | 4407 DecodeTypeImmediate(instr); |
4408 break; | 4408 break; |
4409 case Instruction::kJumpType: | 4409 case Instruction::kJumpType: |
4410 DecodeTypeJump(instr); | 4410 DecodeTypeJump(instr); |
4411 break; | 4411 break; |
4412 default: | 4412 default: |
4413 UNSUPPORTED(); | 4413 UNSUPPORTED(); |
4414 } | 4414 } |
4415 if (::v8::internal::FLAG_trace_sim) { | 4415 if (::v8::internal::FLAG_trace_sim) { |
4416 PrintF(" 0x%08x %-44s %s\n", reinterpret_cast<intptr_t>(instr), | 4416 PrintF(" 0x%08" PRIxPTR " %-44s %s\n", |
4417 buffer.start(), trace_buf_.start()); | 4417 reinterpret_cast<intptr_t>(instr), buffer.start(), |
| 4418 trace_buf_.start()); |
4418 } | 4419 } |
4419 if (!pc_modified_) { | 4420 if (!pc_modified_) { |
4420 set_register(pc, reinterpret_cast<int32_t>(instr) + | 4421 set_register(pc, reinterpret_cast<int32_t>(instr) + |
4421 Instruction::kInstrSize); | 4422 Instruction::kInstrSize); |
4422 } | 4423 } |
4423 } | 4424 } |
4424 | 4425 |
4425 | 4426 |
4426 | 4427 |
4427 void Simulator::Execute() { | 4428 void Simulator::Execute() { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4604 | 4605 |
4605 | 4606 |
4606 #undef UNSUPPORTED | 4607 #undef UNSUPPORTED |
4607 | 4608 |
4608 } // namespace internal | 4609 } // namespace internal |
4609 } // namespace v8 | 4610 } // namespace v8 |
4610 | 4611 |
4611 #endif // USE_SIMULATOR | 4612 #endif // USE_SIMULATOR |
4612 | 4613 |
4613 #endif // V8_TARGET_ARCH_MIPS | 4614 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |