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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 int FormatOption(Instruction* instr, const char* option); | 75 int FormatOption(Instruction* instr, const char* option); |
76 void Format(Instruction* instr, const char* format); | 76 void Format(Instruction* instr, const char* format); |
77 void Unknown(Instruction* instr); | 77 void Unknown(Instruction* instr); |
78 void UnknownFormat(Instruction* instr, const char* opcname); | 78 void UnknownFormat(Instruction* instr, const char* opcname); |
79 | 79 |
80 void DecodeExt1(Instruction* instr); | 80 void DecodeExt1(Instruction* instr); |
81 void DecodeExt2(Instruction* instr); | 81 void DecodeExt2(Instruction* instr); |
82 void DecodeExt3(Instruction* instr); | 82 void DecodeExt3(Instruction* instr); |
83 void DecodeExt4(Instruction* instr); | 83 void DecodeExt4(Instruction* instr); |
84 void DecodeExt5(Instruction* instr); | 84 void DecodeExt5(Instruction* instr); |
| 85 void DecodeExt6(Instruction* instr); |
85 | 86 |
86 const disasm::NameConverter& converter_; | 87 const disasm::NameConverter& converter_; |
87 Vector<char> out_buffer_; | 88 Vector<char> out_buffer_; |
88 int out_buffer_pos_; | 89 int out_buffer_pos_; |
89 | 90 |
90 DISALLOW_COPY_AND_ASSIGN(Decoder); | 91 DISALLOW_COPY_AND_ASSIGN(Decoder); |
91 }; | 92 }; |
92 | 93 |
93 | 94 |
94 // Support for assertions in the Decoder formatting functions. | 95 // Support for assertions in the Decoder formatting functions. |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 } | 1067 } |
1067 switch (instr->Bits(4, 1) << 1) { | 1068 switch (instr->Bits(4, 1) << 1) { |
1068 case RLDCL: { | 1069 case RLDCL: { |
1069 Format(instr, "rldcl'. 'ra, 'rs, 'sb, 'mb"); | 1070 Format(instr, "rldcl'. 'ra, 'rs, 'sb, 'mb"); |
1070 return; | 1071 return; |
1071 } | 1072 } |
1072 } | 1073 } |
1073 Unknown(instr); // not used by V8 | 1074 Unknown(instr); // not used by V8 |
1074 } | 1075 } |
1075 | 1076 |
| 1077 void Decoder::DecodeExt6(Instruction* instr) { |
| 1078 switch (instr->Bits(10, 3) << 3) { |
| 1079 #define DECODE_XX3_INSTRUCTIONS(name, opcode_name, opcode_value) \ |
| 1080 case opcode_name: { \ |
| 1081 Format(instr, #name" 'Dt, 'Da, 'Db"); \ |
| 1082 return; \ |
| 1083 } |
| 1084 XX3_OPCODE_LIST(DECODE_XX3_INSTRUCTIONS) |
| 1085 #undef DECODE_XX3_INSTRUCTIONS |
| 1086 } |
| 1087 switch (instr->Bits(10, 2) << 2) { |
| 1088 #define DECODE_XX2_INSTRUCTIONS(name, opcode_name, opcode_value) \ |
| 1089 case opcode_name: { \ |
| 1090 Format(instr, #name" 'Dt, 'Db"); \ |
| 1091 return; \ |
| 1092 } |
| 1093 XX2_OPCODE_LIST(DECODE_XX2_INSTRUCTIONS) |
| 1094 } |
| 1095 #undef DECODE_XX3_INSTRUCTIONS |
| 1096 Unknown(instr); // not used by V8 |
| 1097 } |
| 1098 |
1076 #undef VERIFIY | 1099 #undef VERIFIY |
1077 | 1100 |
1078 // Disassemble the instruction at *instr_ptr into the output buffer. | 1101 // Disassemble the instruction at *instr_ptr into the output buffer. |
1079 int Decoder::InstructionDecode(byte* instr_ptr) { | 1102 int Decoder::InstructionDecode(byte* instr_ptr) { |
1080 Instruction* instr = Instruction::At(instr_ptr); | 1103 Instruction* instr = Instruction::At(instr_ptr); |
1081 // Print raw instruction bytes. | 1104 // Print raw instruction bytes. |
1082 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%08x ", | 1105 out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%08x ", |
1083 instr->InstructionBits()); | 1106 instr->InstructionBits()); |
1084 | 1107 |
1085 if (ABI_USES_FUNCTION_DESCRIPTORS && instr->InstructionBits() == 0) { | 1108 if (ABI_USES_FUNCTION_DESCRIPTORS && instr->InstructionBits() == 0) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 break; | 1376 break; |
1354 } | 1377 } |
1355 case EXT4: { | 1378 case EXT4: { |
1356 DecodeExt4(instr); | 1379 DecodeExt4(instr); |
1357 break; | 1380 break; |
1358 } | 1381 } |
1359 case EXT5: { | 1382 case EXT5: { |
1360 DecodeExt5(instr); | 1383 DecodeExt5(instr); |
1361 break; | 1384 break; |
1362 } | 1385 } |
| 1386 case EXT6: { |
| 1387 DecodeExt6(instr); |
| 1388 break; |
| 1389 } |
1363 #if V8_TARGET_ARCH_PPC64 | 1390 #if V8_TARGET_ARCH_PPC64 |
1364 case LD: { | 1391 case LD: { |
1365 switch (instr->Bits(1, 0)) { | 1392 switch (instr->Bits(1, 0)) { |
1366 case 0: | 1393 case 0: |
1367 Format(instr, "ld 'rt, 'd('ra)"); | 1394 Format(instr, "ld 'rt, 'd('ra)"); |
1368 break; | 1395 break; |
1369 case 1: | 1396 case 1: |
1370 Format(instr, "ldu 'rt, 'd('ra)"); | 1397 Format(instr, "ldu 'rt, 'd('ra)"); |
1371 break; | 1398 break; |
1372 case 2: | 1399 case 2: |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 pc += d.InstructionDecode(buffer, pc); | 1491 pc += d.InstructionDecode(buffer, pc); |
1465 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), | 1492 v8::internal::PrintF(f, "%p %08x %s\n", static_cast<void*>(prev_pc), |
1466 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1493 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
1467 } | 1494 } |
1468 } | 1495 } |
1469 | 1496 |
1470 | 1497 |
1471 } // namespace disasm | 1498 } // namespace disasm |
1472 | 1499 |
1473 #endif // V8_TARGET_ARCH_PPC | 1500 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |