| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 {0x0D, "or", UNSET_OP_ORDER}, | 110 {0x0D, "or", UNSET_OP_ORDER}, |
| 111 {0x15, "adc", UNSET_OP_ORDER}, | 111 {0x15, "adc", UNSET_OP_ORDER}, |
| 112 {0x25, "and", UNSET_OP_ORDER}, | 112 {0x25, "and", UNSET_OP_ORDER}, |
| 113 {0x2D, "sub", UNSET_OP_ORDER}, | 113 {0x2D, "sub", UNSET_OP_ORDER}, |
| 114 {0x35, "xor", UNSET_OP_ORDER}, | 114 {0x35, "xor", UNSET_OP_ORDER}, |
| 115 {0x3D, "cmp", UNSET_OP_ORDER}, | 115 {0x3D, "cmp", UNSET_OP_ORDER}, |
| 116 {-1, "", UNSET_OP_ORDER} | 116 {-1, "", UNSET_OP_ORDER} |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 | 119 |
| 120 // Generally we don't want to generate these because they are subject to partial |
| 121 // register stalls. They are included for completeness and because the cmp |
| 122 // variant is used by the RecordWrite stub. Because it does not update the |
| 123 // register it is npt subject to partial register stalls. |
| 124 static ByteMnemonic byte_immediate_instr[] = { |
| 125 {0x0c, "or", UNSET_OP_ORDER}, |
| 126 {0x24, "and", UNSET_OP_ORDER}, |
| 127 {0x34, "xor", UNSET_OP_ORDER}, |
| 128 {0x3c, "cmp", UNSET_OP_ORDER}, |
| 129 {-1, "", UNSET_OP_ORDER} |
| 130 }; |
| 131 |
| 132 |
| 120 static const char* jump_conditional_mnem[] = { | 133 static const char* jump_conditional_mnem[] = { |
| 121 /*0*/ "jo", "jno", "jc", "jnc", | 134 /*0*/ "jo", "jno", "jc", "jnc", |
| 122 /*4*/ "jz", "jnz", "jna", "ja", | 135 /*4*/ "jz", "jnz", "jna", "ja", |
| 123 /*8*/ "js", "jns", "jpe", "jpo", | 136 /*8*/ "js", "jns", "jpe", "jpo", |
| 124 /*12*/ "jl", "jnl", "jng", "jg" | 137 /*12*/ "jl", "jnl", "jng", "jg" |
| 125 }; | 138 }; |
| 126 | 139 |
| 127 | 140 |
| 128 static const char* set_conditional_mnem[] = { | 141 static const char* set_conditional_mnem[] = { |
| 129 /*0*/ "seto", "setno", "setc", "setnc", | 142 /*0*/ "seto", "setno", "setc", "setnc", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 142 | 155 |
| 143 | 156 |
| 144 enum InstructionType { | 157 enum InstructionType { |
| 145 NO_INSTR, | 158 NO_INSTR, |
| 146 ZERO_OPERANDS_INSTR, | 159 ZERO_OPERANDS_INSTR, |
| 147 TWO_OPERANDS_INSTR, | 160 TWO_OPERANDS_INSTR, |
| 148 JUMP_CONDITIONAL_SHORT_INSTR, | 161 JUMP_CONDITIONAL_SHORT_INSTR, |
| 149 REGISTER_INSTR, | 162 REGISTER_INSTR, |
| 150 MOVE_REG_INSTR, | 163 MOVE_REG_INSTR, |
| 151 CALL_JUMP_INSTR, | 164 CALL_JUMP_INSTR, |
| 152 SHORT_IMMEDIATE_INSTR | 165 SHORT_IMMEDIATE_INSTR, |
| 166 BYTE_IMMEDIATE_INSTR |
| 153 }; | 167 }; |
| 154 | 168 |
| 155 | 169 |
| 156 struct InstructionDesc { | 170 struct InstructionDesc { |
| 157 const char* mnem; | 171 const char* mnem; |
| 158 InstructionType type; | 172 InstructionType type; |
| 159 OperandOrder op_order_; | 173 OperandOrder op_order_; |
| 160 }; | 174 }; |
| 161 | 175 |
| 162 | 176 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 191 instructions_[i].op_order_ = UNSET_OP_ORDER; | 205 instructions_[i].op_order_ = UNSET_OP_ORDER; |
| 192 } | 206 } |
| 193 } | 207 } |
| 194 | 208 |
| 195 | 209 |
| 196 void InstructionTable::Init() { | 210 void InstructionTable::Init() { |
| 197 CopyTable(two_operands_instr, TWO_OPERANDS_INSTR); | 211 CopyTable(two_operands_instr, TWO_OPERANDS_INSTR); |
| 198 CopyTable(zero_operands_instr, ZERO_OPERANDS_INSTR); | 212 CopyTable(zero_operands_instr, ZERO_OPERANDS_INSTR); |
| 199 CopyTable(call_jump_instr, CALL_JUMP_INSTR); | 213 CopyTable(call_jump_instr, CALL_JUMP_INSTR); |
| 200 CopyTable(short_immediate_instr, SHORT_IMMEDIATE_INSTR); | 214 CopyTable(short_immediate_instr, SHORT_IMMEDIATE_INSTR); |
| 215 CopyTable(byte_immediate_instr, BYTE_IMMEDIATE_INSTR); |
| 201 AddJumpConditionalShort(); | 216 AddJumpConditionalShort(); |
| 202 SetTableRange(REGISTER_INSTR, 0x40, 0x47, "inc"); | 217 SetTableRange(REGISTER_INSTR, 0x40, 0x47, "inc"); |
| 203 SetTableRange(REGISTER_INSTR, 0x48, 0x4F, "dec"); | 218 SetTableRange(REGISTER_INSTR, 0x48, 0x4F, "dec"); |
| 204 SetTableRange(REGISTER_INSTR, 0x50, 0x57, "push"); | 219 SetTableRange(REGISTER_INSTR, 0x50, 0x57, "push"); |
| 205 SetTableRange(REGISTER_INSTR, 0x58, 0x5F, "pop"); | 220 SetTableRange(REGISTER_INSTR, 0x58, 0x5F, "pop"); |
| 206 SetTableRange(REGISTER_INSTR, 0x91, 0x97, "xchg eax,"); // 0x90 is nop. | 221 SetTableRange(REGISTER_INSTR, 0x91, 0x97, "xchg eax,"); // 0x90 is nop. |
| 207 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, "mov"); | 222 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, "mov"); |
| 208 } | 223 } |
| 209 | 224 |
| 210 | 225 |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 break; | 919 break; |
| 905 } | 920 } |
| 906 | 921 |
| 907 case SHORT_IMMEDIATE_INSTR: { | 922 case SHORT_IMMEDIATE_INSTR: { |
| 908 byte* addr = reinterpret_cast<byte*>(*reinterpret_cast<int32_t*>(data+1)); | 923 byte* addr = reinterpret_cast<byte*>(*reinterpret_cast<int32_t*>(data+1)); |
| 909 AppendToBuffer("%s eax, %s", idesc.mnem, NameOfAddress(addr)); | 924 AppendToBuffer("%s eax, %s", idesc.mnem, NameOfAddress(addr)); |
| 910 data += 5; | 925 data += 5; |
| 911 break; | 926 break; |
| 912 } | 927 } |
| 913 | 928 |
| 929 case BYTE_IMMEDIATE_INSTR: { |
| 930 AppendToBuffer("%s al, 0x%x", idesc.mnem, data[1]); |
| 931 data += 2; |
| 932 break; |
| 933 } |
| 934 |
| 914 case NO_INSTR: | 935 case NO_INSTR: |
| 915 processed = false; | 936 processed = false; |
| 916 break; | 937 break; |
| 917 | 938 |
| 918 default: | 939 default: |
| 919 UNIMPLEMENTED(); // This type is not implemented. | 940 UNIMPLEMENTED(); // This type is not implemented. |
| 920 } | 941 } |
| 921 //---------------------------- | 942 //---------------------------- |
| 922 if (!processed) { | 943 if (!processed) { |
| 923 switch (*data) { | 944 switch (*data) { |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 case 0x6A: | 1341 case 0x6A: |
| 1321 AppendToBuffer("push 0x%x", *reinterpret_cast<int8_t*>(data + 1)); | 1342 AppendToBuffer("push 0x%x", *reinterpret_cast<int8_t*>(data + 1)); |
| 1322 data += 2; | 1343 data += 2; |
| 1323 break; | 1344 break; |
| 1324 | 1345 |
| 1325 case 0xA8: | 1346 case 0xA8: |
| 1326 AppendToBuffer("test al,0x%x", *reinterpret_cast<uint8_t*>(data+1)); | 1347 AppendToBuffer("test al,0x%x", *reinterpret_cast<uint8_t*>(data+1)); |
| 1327 data += 2; | 1348 data += 2; |
| 1328 break; | 1349 break; |
| 1329 | 1350 |
| 1330 case 0x2C: | |
| 1331 AppendToBuffer("subb eax,0x%x", *reinterpret_cast<uint8_t*>(data+1)); | |
| 1332 data += 2; | |
| 1333 break; | |
| 1334 | |
| 1335 case 0xA9: | 1351 case 0xA9: |
| 1336 AppendToBuffer("test eax,0x%x", *reinterpret_cast<int32_t*>(data+1)); | 1352 AppendToBuffer("test eax,0x%x", *reinterpret_cast<int32_t*>(data+1)); |
| 1337 data += 5; | 1353 data += 5; |
| 1338 break; | 1354 break; |
| 1339 | 1355 |
| 1340 case 0xD1: // fall through | 1356 case 0xD1: // fall through |
| 1341 case 0xD3: // fall through | 1357 case 0xD3: // fall through |
| 1342 case 0xC1: | 1358 case 0xC1: |
| 1343 data += D1D3C1Instruction(data); | 1359 data += D1D3C1Instruction(data); |
| 1344 break; | 1360 break; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 fprintf(f, " "); | 1607 fprintf(f, " "); |
| 1592 } | 1608 } |
| 1593 fprintf(f, " %s\n", buffer.start()); | 1609 fprintf(f, " %s\n", buffer.start()); |
| 1594 } | 1610 } |
| 1595 } | 1611 } |
| 1596 | 1612 |
| 1597 | 1613 |
| 1598 } // namespace disasm | 1614 } // namespace disasm |
| 1599 | 1615 |
| 1600 #endif // V8_TARGET_ARCH_IA32 | 1616 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |