| 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 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 int offset = instr->ImmPCRel(); | 1599 int offset = instr->ImmPCRel(); |
| 1600 | 1600 |
| 1601 // Only ADR (AddrPCRelByte) is supported. | 1601 // Only ADR (AddrPCRelByte) is supported. |
| 1602 ASSERT(strcmp(format, "AddrPCRelByte") == 0); | 1602 ASSERT(strcmp(format, "AddrPCRelByte") == 0); |
| 1603 | 1603 |
| 1604 char sign = '+'; | 1604 char sign = '+'; |
| 1605 if (offset < 0) { | 1605 if (offset < 0) { |
| 1606 offset = -offset; | 1606 offset = -offset; |
| 1607 sign = '-'; | 1607 sign = '-'; |
| 1608 } | 1608 } |
| 1609 // TODO(jbramley): Can we print the target address here? | 1609 STATIC_ASSERT(sizeof(*instr) == 1); |
| 1610 AppendToOutput("#%c0x%x", sign, offset); | 1610 AppendToOutput("#%c0x%x (addr %p)", sign, offset, instr + offset); |
| 1611 return 13; | 1611 return 13; |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 | 1614 |
| 1615 int Disassembler::SubstituteBranchTargetField(Instruction* instr, | 1615 int Disassembler::SubstituteBranchTargetField(Instruction* instr, |
| 1616 const char* format) { | 1616 const char* format) { |
| 1617 ASSERT(strncmp(format, "BImm", 4) == 0); | 1617 ASSERT(strncmp(format, "BImm", 4) == 0); |
| 1618 | 1618 |
| 1619 int64_t offset = 0; | 1619 int64_t offset = 0; |
| 1620 switch (format[5]) { | 1620 switch (format[5]) { |
| 1621 // BImmUncn - unconditional branch immediate. | 1621 // BImmUncn - unconditional branch immediate. |
| 1622 case 'n': offset = instr->ImmUncondBranch(); break; | 1622 case 'n': offset = instr->ImmUncondBranch(); break; |
| 1623 // BImmCond - conditional branch immediate. | 1623 // BImmCond - conditional branch immediate. |
| 1624 case 'o': offset = instr->ImmCondBranch(); break; | 1624 case 'o': offset = instr->ImmCondBranch(); break; |
| 1625 // BImmCmpa - compare and branch immediate. | 1625 // BImmCmpa - compare and branch immediate. |
| 1626 case 'm': offset = instr->ImmCmpBranch(); break; | 1626 case 'm': offset = instr->ImmCmpBranch(); break; |
| 1627 // BImmTest - test and branch immediate. | 1627 // BImmTest - test and branch immediate. |
| 1628 case 'e': offset = instr->ImmTestBranch(); break; | 1628 case 'e': offset = instr->ImmTestBranch(); break; |
| 1629 default: UNIMPLEMENTED(); | 1629 default: UNIMPLEMENTED(); |
| 1630 } | 1630 } |
| 1631 offset <<= kInstructionSizeLog2; | 1631 offset <<= kInstructionSizeLog2; |
| 1632 char sign = '+'; | 1632 char sign = '+'; |
| 1633 if (offset < 0) { | 1633 if (offset < 0) { |
| 1634 offset = -offset; | 1634 offset = -offset; |
| 1635 sign = '-'; | 1635 sign = '-'; |
| 1636 } | 1636 } |
| 1637 // TODO(mcapewel): look up pc + offset in label table. | 1637 STATIC_ASSERT(sizeof(*instr) == 1); |
| 1638 AppendToOutput("#%c0x%" PRIx64, sign, offset); | 1638 AppendToOutput("#%c0x%" PRIx64 " (addr %p)", sign, offset, instr + offset); |
| 1639 return 8; | 1639 return 8; |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 | 1642 |
| 1643 int Disassembler::SubstituteExtendField(Instruction* instr, | 1643 int Disassembler::SubstituteExtendField(Instruction* instr, |
| 1644 const char* format) { | 1644 const char* format) { |
| 1645 ASSERT(strncmp(format, "Ext", 3) == 0); | 1645 ASSERT(strncmp(format, "Ext", 3) == 0); |
| 1646 ASSERT(instr->ExtendMode() <= 7); | 1646 ASSERT(instr->ExtendMode() <= 7); |
| 1647 USE(format); | 1647 USE(format); |
| 1648 | 1648 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 decoder.AppendVisitor(&disasm); | 1846 decoder.AppendVisitor(&disasm); |
| 1847 | 1847 |
| 1848 for (byte* pc = start; pc < end; pc += v8::internal::kInstructionSize) { | 1848 for (byte* pc = start; pc < end; pc += v8::internal::kInstructionSize) { |
| 1849 decoder.Decode(reinterpret_cast<v8::internal::Instruction*>(pc)); | 1849 decoder.Decode(reinterpret_cast<v8::internal::Instruction*>(pc)); |
| 1850 } | 1850 } |
| 1851 } | 1851 } |
| 1852 | 1852 |
| 1853 } // namespace disasm | 1853 } // namespace disasm |
| 1854 | 1854 |
| 1855 #endif // V8_TARGET_ARCH_A64 | 1855 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |