| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 public: | 169 public: |
| 170 InstructionTable(); | 170 InstructionTable(); |
| 171 const InstructionDesc& Get(byte x) const { | 171 const InstructionDesc& Get(byte x) const { |
| 172 return instructions_[x]; | 172 return instructions_[x]; |
| 173 } | 173 } |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 InstructionDesc instructions_[256]; | 176 InstructionDesc instructions_[256]; |
| 177 void Clear(); | 177 void Clear(); |
| 178 void Init(); | 178 void Init(); |
| 179 void CopyTable(ByteMnemonic bm[], InstructionType type); | 179 void CopyTable(const ByteMnemonic bm[], InstructionType type); |
| 180 void SetTableRange(InstructionType type, byte start, byte end, bool byte_size, | 180 void SetTableRange(InstructionType type, byte start, byte end, bool byte_size, |
| 181 const char* mnem); | 181 const char* mnem); |
| 182 void AddJumpConditionalShort(); | 182 void AddJumpConditionalShort(); |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 | 185 |
| 186 InstructionTable::InstructionTable() { | 186 InstructionTable::InstructionTable() { |
| 187 Clear(); | 187 Clear(); |
| 188 Init(); | 188 Init(); |
| 189 } | 189 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 204 CopyTable(zero_operands_instr, ZERO_OPERANDS_INSTR); | 204 CopyTable(zero_operands_instr, ZERO_OPERANDS_INSTR); |
| 205 CopyTable(call_jump_instr, CALL_JUMP_INSTR); | 205 CopyTable(call_jump_instr, CALL_JUMP_INSTR); |
| 206 CopyTable(short_immediate_instr, SHORT_IMMEDIATE_INSTR); | 206 CopyTable(short_immediate_instr, SHORT_IMMEDIATE_INSTR); |
| 207 AddJumpConditionalShort(); | 207 AddJumpConditionalShort(); |
| 208 SetTableRange(PUSHPOP_INSTR, 0x50, 0x57, false, "push"); | 208 SetTableRange(PUSHPOP_INSTR, 0x50, 0x57, false, "push"); |
| 209 SetTableRange(PUSHPOP_INSTR, 0x58, 0x5F, false, "pop"); | 209 SetTableRange(PUSHPOP_INSTR, 0x58, 0x5F, false, "pop"); |
| 210 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, false, "mov"); | 210 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, false, "mov"); |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| 214 void InstructionTable::CopyTable(ByteMnemonic bm[], InstructionType type) { | 214 void InstructionTable::CopyTable(const ByteMnemonic bm[], |
| 215 InstructionType type) { |
| 215 for (int i = 0; bm[i].b >= 0; i++) { | 216 for (int i = 0; bm[i].b >= 0; i++) { |
| 216 InstructionDesc* id = &instructions_[bm[i].b]; | 217 InstructionDesc* id = &instructions_[bm[i].b]; |
| 217 id->mnem = bm[i].mnem; | 218 id->mnem = bm[i].mnem; |
| 218 OperandType op_order = bm[i].op_order_; | 219 OperandType op_order = bm[i].op_order_; |
| 219 id->op_order_ = | 220 id->op_order_ = |
| 220 static_cast<OperandType>(op_order & ~BYTE_SIZE_OPERAND_FLAG); | 221 static_cast<OperandType>(op_order & ~BYTE_SIZE_OPERAND_FLAG); |
| 221 ASSERT_EQ(NO_INSTR, id->type); // Information not already entered | 222 ASSERT_EQ(NO_INSTR, id->type); // Information not already entered |
| 222 id->type = type; | 223 id->type = type; |
| 223 id->byte_size_operation = ((op_order & BYTE_SIZE_OPERAND_FLAG) != 0); | 224 id->byte_size_operation = ((op_order & BYTE_SIZE_OPERAND_FLAG) != 0); |
| 224 } | 225 } |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 }; | 1507 }; |
| 1507 | 1508 |
| 1508 | 1509 |
| 1509 static const char* xmm_regs[16] = { | 1510 static const char* xmm_regs[16] = { |
| 1510 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", | 1511 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", |
| 1511 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" | 1512 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" |
| 1512 }; | 1513 }; |
| 1513 | 1514 |
| 1514 | 1515 |
| 1515 const char* NameConverter::NameOfAddress(byte* addr) const { | 1516 const char* NameConverter::NameOfAddress(byte* addr) const { |
| 1516 static v8::internal::EmbeddedVector<char, 32> tmp_buffer; | 1517 v8::internal::EmbeddedVector<char, 32>& tmp_buffer = |
| 1518 v8::v8_context()->disassembler_data_->tmp_buffer_; |
| 1517 v8::internal::OS::SNPrintF(tmp_buffer, "%p", addr); | 1519 v8::internal::OS::SNPrintF(tmp_buffer, "%p", addr); |
| 1518 return tmp_buffer.start(); | 1520 return tmp_buffer.start(); |
| 1519 } | 1521 } |
| 1520 | 1522 |
| 1521 | 1523 |
| 1522 const char* NameConverter::NameOfConstant(byte* addr) const { | 1524 const char* NameConverter::NameOfConstant(byte* addr) const { |
| 1523 return NameOfAddress(addr); | 1525 return NameOfAddress(addr); |
| 1524 } | 1526 } |
| 1525 | 1527 |
| 1526 | 1528 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 fprintf(f, "%02x", *bp); | 1589 fprintf(f, "%02x", *bp); |
| 1588 } | 1590 } |
| 1589 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { | 1591 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { |
| 1590 fprintf(f, " "); | 1592 fprintf(f, " "); |
| 1591 } | 1593 } |
| 1592 fprintf(f, " %s\n", buffer.start()); | 1594 fprintf(f, " %s\n", buffer.start()); |
| 1593 } | 1595 } |
| 1594 } | 1596 } |
| 1595 | 1597 |
| 1596 } // namespace disasm | 1598 } // namespace disasm |
| OLD | NEW |