| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 282 |
| 283 | 283 |
| 284 // Printing of instruction name. | 284 // Printing of instruction name. |
| 285 void Decoder::PrintInstructionName(Instruction* instr) { | 285 void Decoder::PrintInstructionName(Instruction* instr) { |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 // Handle all register based formatting in this function to reduce the | 289 // Handle all register based formatting in this function to reduce the |
| 290 // complexity of FormatOption. | 290 // complexity of FormatOption. |
| 291 int Decoder::FormatRegister(Instruction* instr, const char* format) { | 291 int Decoder::FormatRegister(Instruction* instr, const char* format) { |
| 292 ASSERT(format[0] == 'r'); | 292 DCHECK(format[0] == 'r'); |
| 293 if (format[1] == 's') { // 'rs: Rs register. | 293 if (format[1] == 's') { // 'rs: Rs register. |
| 294 int reg = instr->RsValue(); | 294 int reg = instr->RsValue(); |
| 295 PrintRegister(reg); | 295 PrintRegister(reg); |
| 296 return 2; | 296 return 2; |
| 297 } else if (format[1] == 't') { // 'rt: rt register. | 297 } else if (format[1] == 't') { // 'rt: rt register. |
| 298 int reg = instr->RtValue(); | 298 int reg = instr->RtValue(); |
| 299 PrintRegister(reg); | 299 PrintRegister(reg); |
| 300 return 2; | 300 return 2; |
| 301 } else if (format[1] == 'd') { // 'rd: rd register. | 301 } else if (format[1] == 'd') { // 'rd: rd register. |
| 302 int reg = instr->RdValue(); | 302 int reg = instr->RdValue(); |
| 303 PrintRegister(reg); | 303 PrintRegister(reg); |
| 304 return 2; | 304 return 2; |
| 305 } | 305 } |
| 306 UNREACHABLE(); | 306 UNREACHABLE(); |
| 307 return -1; | 307 return -1; |
| 308 } | 308 } |
| 309 | 309 |
| 310 | 310 |
| 311 // Handle all FPUregister based formatting in this function to reduce the | 311 // Handle all FPUregister based formatting in this function to reduce the |
| 312 // complexity of FormatOption. | 312 // complexity of FormatOption. |
| 313 int Decoder::FormatFPURegister(Instruction* instr, const char* format) { | 313 int Decoder::FormatFPURegister(Instruction* instr, const char* format) { |
| 314 ASSERT(format[0] == 'f'); | 314 DCHECK(format[0] == 'f'); |
| 315 if (format[1] == 's') { // 'fs: fs register. | 315 if (format[1] == 's') { // 'fs: fs register. |
| 316 int reg = instr->FsValue(); | 316 int reg = instr->FsValue(); |
| 317 PrintFPURegister(reg); | 317 PrintFPURegister(reg); |
| 318 return 2; | 318 return 2; |
| 319 } else if (format[1] == 't') { // 'ft: ft register. | 319 } else if (format[1] == 't') { // 'ft: ft register. |
| 320 int reg = instr->FtValue(); | 320 int reg = instr->FtValue(); |
| 321 PrintFPURegister(reg); | 321 PrintFPURegister(reg); |
| 322 return 2; | 322 return 2; |
| 323 } else if (format[1] == 'd') { // 'fd: fd register. | 323 } else if (format[1] == 'd') { // 'fd: fd register. |
| 324 int reg = instr->FdValue(); | 324 int reg = instr->FdValue(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 335 | 335 |
| 336 | 336 |
| 337 // FormatOption takes a formatting string and interprets it based on | 337 // FormatOption takes a formatting string and interprets it based on |
| 338 // the current instructions. The format string points to the first | 338 // the current instructions. The format string points to the first |
| 339 // character of the option string (the option escape has already been | 339 // character of the option string (the option escape has already been |
| 340 // consumed by the caller.) FormatOption returns the number of | 340 // consumed by the caller.) FormatOption returns the number of |
| 341 // characters that were consumed from the formatting string. | 341 // characters that were consumed from the formatting string. |
| 342 int Decoder::FormatOption(Instruction* instr, const char* format) { | 342 int Decoder::FormatOption(Instruction* instr, const char* format) { |
| 343 switch (format[0]) { | 343 switch (format[0]) { |
| 344 case 'c': { // 'code for break or trap instructions. | 344 case 'c': { // 'code for break or trap instructions. |
| 345 ASSERT(STRING_STARTS_WITH(format, "code")); | 345 DCHECK(STRING_STARTS_WITH(format, "code")); |
| 346 PrintCode(instr); | 346 PrintCode(instr); |
| 347 return 4; | 347 return 4; |
| 348 } | 348 } |
| 349 case 'i': { // 'imm16u or 'imm26. | 349 case 'i': { // 'imm16u or 'imm26. |
| 350 if (format[3] == '1') { | 350 if (format[3] == '1') { |
| 351 ASSERT(STRING_STARTS_WITH(format, "imm16")); | 351 DCHECK(STRING_STARTS_WITH(format, "imm16")); |
| 352 if (format[5] == 's') { | 352 if (format[5] == 's') { |
| 353 ASSERT(STRING_STARTS_WITH(format, "imm16s")); | 353 DCHECK(STRING_STARTS_WITH(format, "imm16s")); |
| 354 PrintSImm16(instr); | 354 PrintSImm16(instr); |
| 355 } else if (format[5] == 'u') { | 355 } else if (format[5] == 'u') { |
| 356 ASSERT(STRING_STARTS_WITH(format, "imm16u")); | 356 DCHECK(STRING_STARTS_WITH(format, "imm16u")); |
| 357 PrintSImm16(instr); | 357 PrintSImm16(instr); |
| 358 } else { | 358 } else { |
| 359 ASSERT(STRING_STARTS_WITH(format, "imm16x")); | 359 DCHECK(STRING_STARTS_WITH(format, "imm16x")); |
| 360 PrintXImm16(instr); | 360 PrintXImm16(instr); |
| 361 } | 361 } |
| 362 return 6; | 362 return 6; |
| 363 } else { | 363 } else { |
| 364 ASSERT(STRING_STARTS_WITH(format, "imm26x")); | 364 DCHECK(STRING_STARTS_WITH(format, "imm26x")); |
| 365 PrintXImm26(instr); | 365 PrintXImm26(instr); |
| 366 return 6; | 366 return 6; |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 case 'r': { // 'r: registers. | 369 case 'r': { // 'r: registers. |
| 370 return FormatRegister(instr, format); | 370 return FormatRegister(instr, format); |
| 371 } | 371 } |
| 372 case 'f': { // 'f: FPUregisters. | 372 case 'f': { // 'f: FPUregisters. |
| 373 return FormatFPURegister(instr, format); | 373 return FormatFPURegister(instr, format); |
| 374 } | 374 } |
| 375 case 's': { // 'sa. | 375 case 's': { // 'sa. |
| 376 switch (format[1]) { | 376 switch (format[1]) { |
| 377 case 'a': { | 377 case 'a': { |
| 378 ASSERT(STRING_STARTS_WITH(format, "sa")); | 378 DCHECK(STRING_STARTS_WITH(format, "sa")); |
| 379 PrintSa(instr); | 379 PrintSa(instr); |
| 380 return 2; | 380 return 2; |
| 381 } | 381 } |
| 382 case 'd': { | 382 case 'd': { |
| 383 ASSERT(STRING_STARTS_WITH(format, "sd")); | 383 DCHECK(STRING_STARTS_WITH(format, "sd")); |
| 384 PrintSd(instr); | 384 PrintSd(instr); |
| 385 return 2; | 385 return 2; |
| 386 } | 386 } |
| 387 case 's': { | 387 case 's': { |
| 388 if (format[2] == '1') { | 388 if (format[2] == '1') { |
| 389 ASSERT(STRING_STARTS_WITH(format, "ss1")); /* ext size */ | 389 DCHECK(STRING_STARTS_WITH(format, "ss1")); /* ext size */ |
| 390 PrintSs1(instr); | 390 PrintSs1(instr); |
| 391 return 3; | 391 return 3; |
| 392 } else { | 392 } else { |
| 393 ASSERT(STRING_STARTS_WITH(format, "ss2")); /* ins size */ | 393 DCHECK(STRING_STARTS_WITH(format, "ss2")); /* ins size */ |
| 394 PrintSs2(instr); | 394 PrintSs2(instr); |
| 395 return 3; | 395 return 3; |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 case 'b': { // 'bc - Special for bc1 cc field. | 400 case 'b': { // 'bc - Special for bc1 cc field. |
| 401 ASSERT(STRING_STARTS_WITH(format, "bc")); | 401 DCHECK(STRING_STARTS_WITH(format, "bc")); |
| 402 PrintBc(instr); | 402 PrintBc(instr); |
| 403 return 2; | 403 return 2; |
| 404 } | 404 } |
| 405 case 'C': { // 'Cc - Special for c.xx.d cc field. | 405 case 'C': { // 'Cc - Special for c.xx.d cc field. |
| 406 ASSERT(STRING_STARTS_WITH(format, "Cc")); | 406 DCHECK(STRING_STARTS_WITH(format, "Cc")); |
| 407 PrintCc(instr); | 407 PrintCc(instr); |
| 408 return 2; | 408 return 2; |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 UNREACHABLE(); | 411 UNREACHABLE(); |
| 412 return -1; | 412 return -1; |
| 413 } | 413 } |
| 414 | 414 |
| 415 | 415 |
| 416 // Format takes a formatting string for a whole instruction and prints it into | 416 // Format takes a formatting string for a whole instruction and prints it into |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1032 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 1033 } | 1033 } |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 | 1036 |
| 1037 #undef UNSUPPORTED | 1037 #undef UNSUPPORTED |
| 1038 | 1038 |
| 1039 } // namespace disasm | 1039 } // namespace disasm |
| 1040 | 1040 |
| 1041 #endif // V8_TARGET_ARCH_MIPS | 1041 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |