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 19 matching lines...) Expand all Loading... |
30 #if V8_TARGET_ARCH_S390 | 30 #if V8_TARGET_ARCH_S390 |
31 | 31 |
32 #include "src/base/platform/platform.h" | 32 #include "src/base/platform/platform.h" |
33 #include "src/disasm.h" | 33 #include "src/disasm.h" |
34 #include "src/macro-assembler.h" | 34 #include "src/macro-assembler.h" |
35 #include "src/s390/constants-s390.h" | 35 #include "src/s390/constants-s390.h" |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
| 40 const auto GetRegConfig = RegisterConfiguration::Crankshaft; |
| 41 |
40 //------------------------------------------------------------------------------ | 42 //------------------------------------------------------------------------------ |
41 | 43 |
42 // Decoder decodes and disassembles instructions into an output buffer. | 44 // Decoder decodes and disassembles instructions into an output buffer. |
43 // It uses the converter to convert register names and call destinations into | 45 // It uses the converter to convert register names and call destinations into |
44 // more informative description. | 46 // more informative description. |
45 class Decoder { | 47 class Decoder { |
46 public: | 48 public: |
47 Decoder(const disasm::NameConverter& converter, Vector<char> out_buffer) | 49 Decoder(const disasm::NameConverter& converter, Vector<char> out_buffer) |
48 : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { | 50 : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { |
49 out_buffer_[out_buffer_pos_] = '\0'; | 51 out_buffer_[out_buffer_pos_] = '\0'; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 out_buffer_[out_buffer_pos_] = 0; | 106 out_buffer_[out_buffer_pos_] = 0; |
105 } | 107 } |
106 | 108 |
107 // Print the register name according to the active name converter. | 109 // Print the register name according to the active name converter. |
108 void Decoder::PrintRegister(int reg) { | 110 void Decoder::PrintRegister(int reg) { |
109 Print(converter_.NameOfCPURegister(reg)); | 111 Print(converter_.NameOfCPURegister(reg)); |
110 } | 112 } |
111 | 113 |
112 // Print the double FP register name according to the active name converter. | 114 // Print the double FP register name according to the active name converter. |
113 void Decoder::PrintDRegister(int reg) { | 115 void Decoder::PrintDRegister(int reg) { |
114 Print(DoubleRegister::from_code(reg).ToString()); | 116 Print(GetRegConfig()->GetDoubleRegisterName(reg)); |
115 } | 117 } |
116 | 118 |
117 // Print SoftwareInterrupt codes. Factoring this out reduces the complexity of | 119 // Print SoftwareInterrupt codes. Factoring this out reduces the complexity of |
118 // the FormatOption method. | 120 // the FormatOption method. |
119 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { | 121 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) { |
120 switch (svc) { | 122 switch (svc) { |
121 case kCallRtRedirected: | 123 case kCallRtRedirected: |
122 Print("call rt redirected"); | 124 Print("call rt redirected"); |
123 return; | 125 return; |
124 case kBreakpoint: | 126 case kBreakpoint: |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 const char* NameConverter::NameOfAddress(byte* addr) const { | 1361 const char* NameConverter::NameOfAddress(byte* addr) const { |
1360 v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr)); | 1362 v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr)); |
1361 return tmp_buffer_.start(); | 1363 return tmp_buffer_.start(); |
1362 } | 1364 } |
1363 | 1365 |
1364 const char* NameConverter::NameOfConstant(byte* addr) const { | 1366 const char* NameConverter::NameOfConstant(byte* addr) const { |
1365 return NameOfAddress(addr); | 1367 return NameOfAddress(addr); |
1366 } | 1368 } |
1367 | 1369 |
1368 const char* NameConverter::NameOfCPURegister(int reg) const { | 1370 const char* NameConverter::NameOfCPURegister(int reg) const { |
1369 return v8::internal::Register::from_code(reg).ToString(); | 1371 return v8::internal::GetRegConfig()->GetGeneralRegisterName(reg); |
1370 } | 1372 } |
1371 | 1373 |
1372 const char* NameConverter::NameOfByteCPURegister(int reg) const { | 1374 const char* NameConverter::NameOfByteCPURegister(int reg) const { |
1373 UNREACHABLE(); // S390 does not have the concept of a byte register | 1375 UNREACHABLE(); // S390 does not have the concept of a byte register |
1374 return "nobytereg"; | 1376 return "nobytereg"; |
1375 } | 1377 } |
1376 | 1378 |
1377 const char* NameConverter::NameOfXMMRegister(int reg) const { | 1379 const char* NameConverter::NameOfXMMRegister(int reg) const { |
1378 // S390 does not have XMM register | 1380 // S390 does not have XMM register |
1379 // TODO(joransiu): Consider update this for Vector Regs | 1381 // TODO(joransiu): Consider update this for Vector Regs |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 byte* prev_pc = pc; | 1414 byte* prev_pc = pc; |
1413 pc += d.InstructionDecode(buffer, pc); | 1415 pc += d.InstructionDecode(buffer, pc); |
1414 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), | 1416 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), |
1415 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1417 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
1416 } | 1418 } |
1417 } | 1419 } |
1418 | 1420 |
1419 } // namespace disasm | 1421 } // namespace disasm |
1420 | 1422 |
1421 #endif // V8_TARGET_ARCH_S390 | 1423 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |