| 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 // A Disassembler object is used to disassemble a block of code instruction by | 5 // A Disassembler object is used to disassemble a block of code instruction by |
| 6 // instruction. The default implementation of the NameConverter object can be | 6 // instruction. The default implementation of the NameConverter object can be |
| 7 // overriden to modify register names or to do symbol lookup on addresses. | 7 // overriden to modify register names or to do symbol lookup on addresses. |
| 8 // | 8 // |
| 9 // The example below will disassemble a block of code and print it to stdout. | 9 // The example below will disassemble a block of code and print it to stdout. |
| 10 // | 10 // |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #include "src/base/platform/platform.h" | 33 #include "src/base/platform/platform.h" |
| 34 #include "src/disasm.h" | 34 #include "src/disasm.h" |
| 35 #include "src/macro-assembler.h" | 35 #include "src/macro-assembler.h" |
| 36 #include "src/ppc/constants-ppc.h" | 36 #include "src/ppc/constants-ppc.h" |
| 37 | 37 |
| 38 | 38 |
| 39 namespace v8 { | 39 namespace v8 { |
| 40 namespace internal { | 40 namespace internal { |
| 41 | 41 |
| 42 const auto GetRegConfig = RegisterConfiguration::Crankshaft; |
| 42 | 43 |
| 43 //------------------------------------------------------------------------------ | 44 //------------------------------------------------------------------------------ |
| 44 | 45 |
| 45 // Decoder decodes and disassembles instructions into an output buffer. | 46 // Decoder decodes and disassembles instructions into an output buffer. |
| 46 // It uses the converter to convert register names and call destinations into | 47 // It uses the converter to convert register names and call destinations into |
| 47 // more informative description. | 48 // more informative description. |
| 48 class Decoder { | 49 class Decoder { |
| 49 public: | 50 public: |
| 50 Decoder(const disasm::NameConverter& converter, Vector<char> out_buffer) | 51 Decoder(const disasm::NameConverter& converter, Vector<char> out_buffer) |
| 51 : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { | 52 : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 | 113 |
| 113 // Print the register name according to the active name converter. | 114 // Print the register name according to the active name converter. |
| 114 void Decoder::PrintRegister(int reg) { | 115 void Decoder::PrintRegister(int reg) { |
| 115 Print(converter_.NameOfCPURegister(reg)); | 116 Print(converter_.NameOfCPURegister(reg)); |
| 116 } | 117 } |
| 117 | 118 |
| 118 | 119 |
| 119 // Print the double FP register name according to the active name converter. | 120 // Print the double FP register name according to the active name converter. |
| 120 void Decoder::PrintDRegister(int reg) { | 121 void Decoder::PrintDRegister(int reg) { |
| 121 Print(DoubleRegister::from_code(reg).ToString()); | 122 Print(GetRegConfig()->GetDoubleRegisterName(reg)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 | 125 |
| 125 // Print SoftwareInterrupt codes. Factoring this out reduces the complexity of | 126 // Print SoftwareInterrupt codes. Factoring this out reduces the complexity of |
| 126 // the FormatOption method. | 127 // the FormatOption method. |
| 127 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { | 128 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { |
| 128 switch (svc) { | 129 switch (svc) { |
| 129 case kCallRtRedirected: | 130 case kCallRtRedirected: |
| 130 Print("call rt redirected"); | 131 Print("call rt redirected"); |
| 131 return; | 132 return; |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 return tmp_buffer_.start(); | 1406 return tmp_buffer_.start(); |
| 1406 } | 1407 } |
| 1407 | 1408 |
| 1408 | 1409 |
| 1409 const char* NameConverter::NameOfConstant(byte* addr) const { | 1410 const char* NameConverter::NameOfConstant(byte* addr) const { |
| 1410 return NameOfAddress(addr); | 1411 return NameOfAddress(addr); |
| 1411 } | 1412 } |
| 1412 | 1413 |
| 1413 | 1414 |
| 1414 const char* NameConverter::NameOfCPURegister(int reg) const { | 1415 const char* NameConverter::NameOfCPURegister(int reg) const { |
| 1415 return v8::internal::Register::from_code(reg).ToString(); | 1416 return v8::internal::GetRegConfig()->GetGeneralRegisterName(reg); |
| 1416 } | 1417 } |
| 1417 | 1418 |
| 1418 const char* NameConverter::NameOfByteCPURegister(int reg) const { | 1419 const char* NameConverter::NameOfByteCPURegister(int reg) const { |
| 1419 UNREACHABLE(); // PPC does not have the concept of a byte register | 1420 UNREACHABLE(); // PPC does not have the concept of a byte register |
| 1420 return "nobytereg"; | 1421 return "nobytereg"; |
| 1421 } | 1422 } |
| 1422 | 1423 |
| 1423 | 1424 |
| 1424 const char* NameConverter::NameOfXMMRegister(int reg) const { | 1425 const char* NameConverter::NameOfXMMRegister(int reg) const { |
| 1425 UNREACHABLE(); // PPC does not have any XMM registers | 1426 UNREACHABLE(); // PPC does not have any XMM registers |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 pc += d.InstructionDecode(buffer, pc); | 1464 pc += d.InstructionDecode(buffer, pc); |
| 1464 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), | 1465 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), |
| 1465 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1466 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 1466 } | 1467 } |
| 1467 } | 1468 } |
| 1468 | 1469 |
| 1469 | 1470 |
| 1470 } // namespace disasm | 1471 } // namespace disasm |
| 1471 | 1472 |
| 1472 #endif // V8_TARGET_ARCH_PPC | 1473 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |