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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 class InstructionTable { | 154 class InstructionTable { |
155 public: | 155 public: |
156 InstructionTable(); | 156 InstructionTable(); |
157 const InstructionDesc& Get(byte x) const { return instructions_[x]; } | 157 const InstructionDesc& Get(byte x) const { return instructions_[x]; } |
158 | 158 |
159 private: | 159 private: |
160 InstructionDesc instructions_[256]; | 160 InstructionDesc instructions_[256]; |
161 void Clear(); | 161 void Clear(); |
162 void Init(); | 162 void Init(); |
163 void CopyTable(ByteMnemonic bm[], InstructionType type); | 163 void CopyTable(const ByteMnemonic bm[], InstructionType type); |
164 void SetTableRange(InstructionType type, | 164 void SetTableRange(InstructionType type, |
165 byte start, | 165 byte start, |
166 byte end, | 166 byte end, |
167 const char* mnem); | 167 const char* mnem); |
168 void AddJumpConditionalShort(); | 168 void AddJumpConditionalShort(); |
169 }; | 169 }; |
170 | 170 |
171 | 171 |
172 InstructionTable::InstructionTable() { | 172 InstructionTable::InstructionTable() { |
173 Clear(); | 173 Clear(); |
(...skipping 18 matching lines...) Expand all Loading... |
192 AddJumpConditionalShort(); | 192 AddJumpConditionalShort(); |
193 SetTableRange(REGISTER_INSTR, 0x40, 0x47, "inc"); | 193 SetTableRange(REGISTER_INSTR, 0x40, 0x47, "inc"); |
194 SetTableRange(REGISTER_INSTR, 0x48, 0x4F, "dec"); | 194 SetTableRange(REGISTER_INSTR, 0x48, 0x4F, "dec"); |
195 SetTableRange(REGISTER_INSTR, 0x50, 0x57, "push"); | 195 SetTableRange(REGISTER_INSTR, 0x50, 0x57, "push"); |
196 SetTableRange(REGISTER_INSTR, 0x58, 0x5F, "pop"); | 196 SetTableRange(REGISTER_INSTR, 0x58, 0x5F, "pop"); |
197 SetTableRange(REGISTER_INSTR, 0x91, 0x97, "xchg eax,"); // 0x90 is nop. | 197 SetTableRange(REGISTER_INSTR, 0x91, 0x97, "xchg eax,"); // 0x90 is nop. |
198 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, "mov"); | 198 SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, "mov"); |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 void InstructionTable::CopyTable(ByteMnemonic bm[], InstructionType type) { | 202 void InstructionTable::CopyTable(const ByteMnemonic bm[], |
| 203 InstructionType type) { |
203 for (int i = 0; bm[i].b >= 0; i++) { | 204 for (int i = 0; bm[i].b >= 0; i++) { |
204 InstructionDesc* id = &instructions_[bm[i].b]; | 205 InstructionDesc* id = &instructions_[bm[i].b]; |
205 id->mnem = bm[i].mnem; | 206 id->mnem = bm[i].mnem; |
206 id->op_order_ = bm[i].op_order_; | 207 id->op_order_ = bm[i].op_order_; |
207 ASSERT_EQ(NO_INSTR, id->type); // Information not already entered. | 208 ASSERT_EQ(NO_INSTR, id->type); // Information not already entered. |
208 id->type = type; | 209 id->type = type; |
209 } | 210 } |
210 } | 211 } |
211 | 212 |
212 | 213 |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" | 1211 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" |
1211 }; | 1212 }; |
1212 | 1213 |
1213 | 1214 |
1214 static const char* xmm_regs[8] = { | 1215 static const char* xmm_regs[8] = { |
1215 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" | 1216 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" |
1216 }; | 1217 }; |
1217 | 1218 |
1218 | 1219 |
1219 const char* NameConverter::NameOfAddress(byte* addr) const { | 1220 const char* NameConverter::NameOfAddress(byte* addr) const { |
1220 static v8::internal::EmbeddedVector<char, 32> tmp_buffer; | 1221 v8::internal::EmbeddedVector<char, 32>& tmp_buffer = |
| 1222 v8::v8_context()->disassembler_data_->tmp_buffer_; |
1221 v8::internal::OS::SNPrintF(tmp_buffer, "%p", addr); | 1223 v8::internal::OS::SNPrintF(tmp_buffer, "%p", addr); |
1222 return tmp_buffer.start(); | 1224 return tmp_buffer.start(); |
1223 } | 1225 } |
1224 | 1226 |
1225 | 1227 |
1226 const char* NameConverter::NameOfConstant(byte* addr) const { | 1228 const char* NameConverter::NameOfConstant(byte* addr) const { |
1227 return NameOfAddress(addr); | 1229 return NameOfAddress(addr); |
1228 } | 1230 } |
1229 | 1231 |
1230 | 1232 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 } | 1291 } |
1290 for (int i = 6 - (pc - prev_pc); i >= 0; i--) { | 1292 for (int i = 6 - (pc - prev_pc); i >= 0; i--) { |
1291 fprintf(f, " "); | 1293 fprintf(f, " "); |
1292 } | 1294 } |
1293 fprintf(f, " %s\n", buffer.start()); | 1295 fprintf(f, " %s\n", buffer.start()); |
1294 } | 1296 } |
1295 } | 1297 } |
1296 | 1298 |
1297 | 1299 |
1298 } // namespace disasm | 1300 } // namespace disasm |
OLD | NEW |