Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/disassembler.h" | 5 #include "vm/disassembler.h" |
| 6 | 6 |
| 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 8 #if defined(TARGET_ARCH_IA32) | 8 #if defined(TARGET_ARCH_IA32) |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 | 298 |
| 299 // Handle special encodings. | 299 // Handle special encodings. |
| 300 int JumpShort(uint8_t* data); | 300 int JumpShort(uint8_t* data); |
| 301 int JumpConditional(uint8_t* data, const char* comment); | 301 int JumpConditional(uint8_t* data, const char* comment); |
| 302 int JumpConditionalShort(uint8_t* data, const char* comment); | 302 int JumpConditionalShort(uint8_t* data, const char* comment); |
| 303 int SetCC(uint8_t* data); | 303 int SetCC(uint8_t* data); |
| 304 int CMov(uint8_t* data); | 304 int CMov(uint8_t* data); |
| 305 int D1D3C1Instruction(uint8_t* data); | 305 int D1D3C1Instruction(uint8_t* data); |
| 306 int F7Instruction(uint8_t* data); | 306 int F7Instruction(uint8_t* data); |
| 307 int FPUInstruction(uint8_t* data); | 307 int FPUInstruction(uint8_t* data); |
| 308 int BitwisePDInstruction(uint8_t* data); | |
| 309 int Packed660F38Instruction(uint8_t* data); | |
| 308 int DecodeEnter(uint8_t* data); | 310 int DecodeEnter(uint8_t* data); |
| 309 void CheckPrintStop(uint8_t* data); | 311 void CheckPrintStop(uint8_t* data); |
| 310 | 312 |
| 311 // Disassembler helper functions. | 313 // Disassembler helper functions. |
| 312 static void GetModRm(uint8_t data, int* mod, int* regop, int* rm) { | 314 static void GetModRm(uint8_t data, int* mod, int* regop, int* rm) { |
| 313 *mod = (data >> 6) & 3; | 315 *mod = (data >> 6) & 3; |
| 314 *regop = (data & 0x38) >> 3; | 316 *regop = (data & 0x38) >> 3; |
| 315 *rm = data & 7; | 317 *rm = data & 7; |
| 316 } | 318 } |
| 317 | 319 |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 969 } else if (b1 == 0xDA && b2 == 0xE9) { | 971 } else if (b1 == 0xDA && b2 == 0xE9) { |
| 970 const char* mnem = "fucompp"; | 972 const char* mnem = "fucompp"; |
| 971 Print(mnem); | 973 Print(mnem); |
| 972 return 2; | 974 return 2; |
| 973 } | 975 } |
| 974 Print("Unknown FP instruction"); | 976 Print("Unknown FP instruction"); |
| 975 return 2; | 977 return 2; |
| 976 } | 978 } |
| 977 | 979 |
| 978 | 980 |
| 981 int X86Decoder::BitwisePDInstruction(uint8_t* data) { | |
| 982 const char* mnem = (*data == 0x57) | |
| 983 ? "xorpd" | |
| 984 : (*data == 0x56) | |
| 985 ? "orpd" | |
| 986 : "andpd"; | |
| 987 int mod, regop, rm; | |
| 988 GetModRm(*(data+1), &mod, ®op, &rm); | |
| 989 Print(mnem); | |
| 990 Print(" "); | |
| 991 PrintXmmRegister(regop); | |
| 992 Print(","); | |
| 993 return 1 + PrintRightXmmOperand(data+1); | |
| 994 } | |
| 995 | |
| 996 | |
| 997 int X86Decoder::Packed660F38Instruction(uint8_t* data) { | |
| 998 if (*(data+1) == 0x25) { | |
| 999 Print("pmovsxdq "); | |
| 1000 int mod, regop, rm; | |
| 1001 GetModRm(*(data+2), &mod, ®op, &rm); | |
| 1002 PrintXmmRegister(regop); | |
| 1003 Print(","); | |
| 1004 return 2 + PrintRightXmmOperand(data+2); | |
| 1005 } else if (*(data+1) == 0x29) { | |
| 1006 Print("pcmpeqq "); | |
| 1007 int mod, regop, rm; | |
| 1008 GetModRm(*(data+2), &mod, ®op, &rm); | |
| 1009 PrintXmmRegister(regop); | |
| 1010 Print(","); | |
| 1011 return 2 + PrintRightXmmOperand(data+2); | |
| 1012 } | |
| 1013 UNIMPLEMENTED(); | |
|
srdjan
2012/09/28 16:50:26
UNREACHABLE() ?
Florian Schneider
2012/10/02 11:10:31
Done.
| |
| 1014 return 1; | |
| 1015 } | |
| 1016 | |
| 1017 | |
| 979 // Called when disassembling test eax, 0xXXXXX. | 1018 // Called when disassembling test eax, 0xXXXXX. |
| 980 void X86Decoder::CheckPrintStop(uint8_t* data) { | 1019 void X86Decoder::CheckPrintStop(uint8_t* data) { |
| 981 // Recognize stop pattern. | 1020 // Recognize stop pattern. |
| 982 if (*reinterpret_cast<uint8_t*>(data + 5) == 0xCC) { | 1021 if (*reinterpret_cast<uint8_t*>(data + 5) == 0xCC) { |
| 983 Print(" STOP:'"); | 1022 Print(" STOP:'"); |
| 984 const char* text = *reinterpret_cast<const char**>(data + 1); | 1023 const char* text = *reinterpret_cast<const char**>(data + 1); |
| 985 Print(text); | 1024 Print(text); |
| 986 Print("'"); | 1025 Print("'"); |
| 987 } | 1026 } |
| 988 } | 1027 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1326 data++; | 1365 data++; |
| 1327 } else if (*data == 0X7E) { | 1366 } else if (*data == 0X7E) { |
| 1328 data++; | 1367 data++; |
| 1329 int mod, regop, rm; | 1368 int mod, regop, rm; |
| 1330 GetModRm(*data, &mod, ®op, &rm); | 1369 GetModRm(*data, &mod, ®op, &rm); |
| 1331 Print("movd "); | 1370 Print("movd "); |
| 1332 PrintCPURegister(rm); | 1371 PrintCPURegister(rm); |
| 1333 Print(","); | 1372 Print(","); |
| 1334 PrintXmmRegister(regop); | 1373 PrintXmmRegister(regop); |
| 1335 data++; | 1374 data++; |
| 1336 } else if (*data == 0x57 || *data == 0x54) { | 1375 } else if (*data == 0x57 || *data == 0x56 || *data == 0x54) { |
| 1337 const char* mnem = (*data == 0x57) ? "xorpd" : "andpd"; | 1376 data += BitwisePDInstruction(data); |
| 1338 data++; | |
| 1339 int mod, regop, rm; | |
| 1340 GetModRm(*data, &mod, ®op, &rm); | |
| 1341 Print(mnem); | |
| 1342 Print(" "); | |
| 1343 PrintXmmRegister(regop); | |
| 1344 Print(","); | |
| 1345 data += PrintRightXmmOperand(data); | |
| 1346 } else if (*data == 0x1F && | 1377 } else if (*data == 0x1F && |
| 1347 *(data+1) == 0x44 && | 1378 *(data+1) == 0x44 && |
| 1348 *(data+2) == 0x00 && | 1379 *(data+2) == 0x00 && |
| 1349 *(data+3) == 0x00) { | 1380 *(data+3) == 0x00) { |
| 1350 data += 4; | 1381 data += 4; |
| 1351 Print("nop"); | 1382 Print("nop"); |
| 1352 } else if (*data == 0x50) { | 1383 } else if (*data == 0x50) { |
| 1353 Print("movmskpd "); | 1384 Print("movmskpd "); |
| 1354 data++; | 1385 data++; |
| 1355 int mod, regop, rm; | 1386 int mod, regop, rm; |
| 1356 GetModRm(*data, &mod, ®op, &rm); | 1387 GetModRm(*data, &mod, ®op, &rm); |
| 1357 PrintCPURegister(regop); | 1388 PrintCPURegister(regop); |
| 1358 Print(","); | 1389 Print(","); |
| 1359 data += PrintRightXmmOperand(data); | 1390 data += PrintRightXmmOperand(data); |
| 1391 } else if (*data == 0x3A && | |
| 1392 *(data+1) == 0x16) { | |
| 1393 Print("pextrd "); | |
| 1394 data += 2; | |
| 1395 int mod, regop, rm; | |
| 1396 GetModRm(*data, &mod, ®op, &rm); | |
| 1397 PrintCPURegister(rm); | |
| 1398 Print(","); | |
| 1399 PrintXmmRegister(regop); | |
| 1400 Print(","); | |
| 1401 PrintHex(*(data+1)); | |
| 1402 data += 2; | |
| 1403 } else if (*data == 0x38) { | |
| 1404 data += Packed660F38Instruction(data); | |
| 1360 } else { | 1405 } else { |
| 1361 UNIMPLEMENTED(); | 1406 UNIMPLEMENTED(); |
| 1362 } | 1407 } |
| 1363 } else if (*data == 0x90) { | 1408 } else if (*data == 0x90) { |
| 1364 data++; | 1409 data++; |
| 1365 Print("nop"); | 1410 Print("nop"); |
| 1366 } else { | 1411 } else { |
| 1367 UNIMPLEMENTED(); | 1412 UNIMPLEMENTED(); |
| 1368 } | 1413 } |
| 1369 break; | 1414 break; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1640 human_buffer, | 1685 human_buffer, |
| 1641 sizeof(human_buffer), | 1686 sizeof(human_buffer), |
| 1642 pc); | 1687 pc); |
| 1643 pc += instruction_length; | 1688 pc += instruction_length; |
| 1644 } | 1689 } |
| 1645 } | 1690 } |
| 1646 | 1691 |
| 1647 } // namespace dart | 1692 } // namespace dart |
| 1648 | 1693 |
| 1649 #endif // defined TARGET_ARCH_IA32 | 1694 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |