| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 | 292 |
| 293 // Printing of instruction name. | 293 // Printing of instruction name. |
| 294 void Decoder::PrintInstructionName(Instruction* instr) { | 294 void Decoder::PrintInstructionName(Instruction* instr) { |
| 295 } | 295 } |
| 296 | 296 |
| 297 | 297 |
| 298 // Handle all register based formatting in this function to reduce the | 298 // Handle all register based formatting in this function to reduce the |
| 299 // complexity of FormatOption. | 299 // complexity of FormatOption. |
| 300 int Decoder::FormatRegister(Instruction* instr, const char* format) { | 300 int Decoder::FormatRegister(Instruction* instr, const char* format) { |
| 301 ASSERT(format[0] == 'r'); | 301 DCHECK(format[0] == 'r'); |
| 302 if (format[1] == 's') { // 'rs: Rs register. | 302 if (format[1] == 's') { // 'rs: Rs register. |
| 303 int reg = instr->RsValue(); | 303 int reg = instr->RsValue(); |
| 304 PrintRegister(reg); | 304 PrintRegister(reg); |
| 305 return 2; | 305 return 2; |
| 306 } else if (format[1] == 't') { // 'rt: rt register. | 306 } else if (format[1] == 't') { // 'rt: rt register. |
| 307 int reg = instr->RtValue(); | 307 int reg = instr->RtValue(); |
| 308 PrintRegister(reg); | 308 PrintRegister(reg); |
| 309 return 2; | 309 return 2; |
| 310 } else if (format[1] == 'd') { // 'rd: rd register. | 310 } else if (format[1] == 'd') { // 'rd: rd register. |
| 311 int reg = instr->RdValue(); | 311 int reg = instr->RdValue(); |
| 312 PrintRegister(reg); | 312 PrintRegister(reg); |
| 313 return 2; | 313 return 2; |
| 314 } | 314 } |
| 315 UNREACHABLE(); | 315 UNREACHABLE(); |
| 316 return -1; | 316 return -1; |
| 317 } | 317 } |
| 318 | 318 |
| 319 | 319 |
| 320 // Handle all FPUregister based formatting in this function to reduce the | 320 // Handle all FPUregister based formatting in this function to reduce the |
| 321 // complexity of FormatOption. | 321 // complexity of FormatOption. |
| 322 int Decoder::FormatFPURegister(Instruction* instr, const char* format) { | 322 int Decoder::FormatFPURegister(Instruction* instr, const char* format) { |
| 323 ASSERT(format[0] == 'f'); | 323 DCHECK(format[0] == 'f'); |
| 324 if (format[1] == 's') { // 'fs: fs register. | 324 if (format[1] == 's') { // 'fs: fs register. |
| 325 int reg = instr->FsValue(); | 325 int reg = instr->FsValue(); |
| 326 PrintFPURegister(reg); | 326 PrintFPURegister(reg); |
| 327 return 2; | 327 return 2; |
| 328 } else if (format[1] == 't') { // 'ft: ft register. | 328 } else if (format[1] == 't') { // 'ft: ft register. |
| 329 int reg = instr->FtValue(); | 329 int reg = instr->FtValue(); |
| 330 PrintFPURegister(reg); | 330 PrintFPURegister(reg); |
| 331 return 2; | 331 return 2; |
| 332 } else if (format[1] == 'd') { // 'fd: fd register. | 332 } else if (format[1] == 'd') { // 'fd: fd register. |
| 333 int reg = instr->FdValue(); | 333 int reg = instr->FdValue(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 344 | 344 |
| 345 | 345 |
| 346 // FormatOption takes a formatting string and interprets it based on | 346 // FormatOption takes a formatting string and interprets it based on |
| 347 // the current instructions. The format string points to the first | 347 // the current instructions. The format string points to the first |
| 348 // character of the option string (the option escape has already been | 348 // character of the option string (the option escape has already been |
| 349 // consumed by the caller.) FormatOption returns the number of | 349 // consumed by the caller.) FormatOption returns the number of |
| 350 // characters that were consumed from the formatting string. | 350 // characters that were consumed from the formatting string. |
| 351 int Decoder::FormatOption(Instruction* instr, const char* format) { | 351 int Decoder::FormatOption(Instruction* instr, const char* format) { |
| 352 switch (format[0]) { | 352 switch (format[0]) { |
| 353 case 'c': { // 'code for break or trap instructions. | 353 case 'c': { // 'code for break or trap instructions. |
| 354 ASSERT(STRING_STARTS_WITH(format, "code")); | 354 DCHECK(STRING_STARTS_WITH(format, "code")); |
| 355 PrintCode(instr); | 355 PrintCode(instr); |
| 356 return 4; | 356 return 4; |
| 357 } | 357 } |
| 358 case 'i': { // 'imm16u or 'imm26. | 358 case 'i': { // 'imm16u or 'imm26. |
| 359 if (format[3] == '1') { | 359 if (format[3] == '1') { |
| 360 ASSERT(STRING_STARTS_WITH(format, "imm16")); | 360 DCHECK(STRING_STARTS_WITH(format, "imm16")); |
| 361 if (format[5] == 's') { | 361 if (format[5] == 's') { |
| 362 ASSERT(STRING_STARTS_WITH(format, "imm16s")); | 362 DCHECK(STRING_STARTS_WITH(format, "imm16s")); |
| 363 PrintSImm16(instr); | 363 PrintSImm16(instr); |
| 364 } else if (format[5] == 'u') { | 364 } else if (format[5] == 'u') { |
| 365 ASSERT(STRING_STARTS_WITH(format, "imm16u")); | 365 DCHECK(STRING_STARTS_WITH(format, "imm16u")); |
| 366 PrintSImm16(instr); | 366 PrintSImm16(instr); |
| 367 } else { | 367 } else { |
| 368 ASSERT(STRING_STARTS_WITH(format, "imm16x")); | 368 DCHECK(STRING_STARTS_WITH(format, "imm16x")); |
| 369 PrintXImm16(instr); | 369 PrintXImm16(instr); |
| 370 } | 370 } |
| 371 return 6; | 371 return 6; |
| 372 } else if (format[3] == '2' && format[4] == '1') { | 372 } else if (format[3] == '2' && format[4] == '1') { |
| 373 ASSERT(STRING_STARTS_WITH(format, "imm21x")); | 373 DCHECK(STRING_STARTS_WITH(format, "imm21x")); |
| 374 PrintXImm21(instr); | 374 PrintXImm21(instr); |
| 375 return 6; | 375 return 6; |
| 376 } else if (format[3] == '2' && format[4] == '6') { | 376 } else if (format[3] == '2' && format[4] == '6') { |
| 377 ASSERT(STRING_STARTS_WITH(format, "imm26x")); | 377 DCHECK(STRING_STARTS_WITH(format, "imm26x")); |
| 378 PrintXImm26(instr); | 378 PrintXImm26(instr); |
| 379 return 6; | 379 return 6; |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 case 'r': { // 'r: registers. | 382 case 'r': { // 'r: registers. |
| 383 return FormatRegister(instr, format); | 383 return FormatRegister(instr, format); |
| 384 } | 384 } |
| 385 case 'f': { // 'f: FPUregisters. | 385 case 'f': { // 'f: FPUregisters. |
| 386 return FormatFPURegister(instr, format); | 386 return FormatFPURegister(instr, format); |
| 387 } | 387 } |
| 388 case 's': { // 'sa. | 388 case 's': { // 'sa. |
| 389 switch (format[1]) { | 389 switch (format[1]) { |
| 390 case 'a': { | 390 case 'a': { |
| 391 ASSERT(STRING_STARTS_WITH(format, "sa")); | 391 DCHECK(STRING_STARTS_WITH(format, "sa")); |
| 392 PrintSa(instr); | 392 PrintSa(instr); |
| 393 return 2; | 393 return 2; |
| 394 } | 394 } |
| 395 case 'd': { | 395 case 'd': { |
| 396 ASSERT(STRING_STARTS_WITH(format, "sd")); | 396 DCHECK(STRING_STARTS_WITH(format, "sd")); |
| 397 PrintSd(instr); | 397 PrintSd(instr); |
| 398 return 2; | 398 return 2; |
| 399 } | 399 } |
| 400 case 's': { | 400 case 's': { |
| 401 if (format[2] == '1') { | 401 if (format[2] == '1') { |
| 402 ASSERT(STRING_STARTS_WITH(format, "ss1")); /* ext size */ | 402 DCHECK(STRING_STARTS_WITH(format, "ss1")); /* ext size */ |
| 403 PrintSs1(instr); | 403 PrintSs1(instr); |
| 404 return 3; | 404 return 3; |
| 405 } else { | 405 } else { |
| 406 ASSERT(STRING_STARTS_WITH(format, "ss2")); /* ins size */ | 406 DCHECK(STRING_STARTS_WITH(format, "ss2")); /* ins size */ |
| 407 PrintSs2(instr); | 407 PrintSs2(instr); |
| 408 return 3; | 408 return 3; |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 case 'b': { // 'bc - Special for bc1 cc field. | 413 case 'b': { // 'bc - Special for bc1 cc field. |
| 414 ASSERT(STRING_STARTS_WITH(format, "bc")); | 414 DCHECK(STRING_STARTS_WITH(format, "bc")); |
| 415 PrintBc(instr); | 415 PrintBc(instr); |
| 416 return 2; | 416 return 2; |
| 417 } | 417 } |
| 418 case 'C': { // 'Cc - Special for c.xx.d cc field. | 418 case 'C': { // 'Cc - Special for c.xx.d cc field. |
| 419 ASSERT(STRING_STARTS_WITH(format, "Cc")); | 419 DCHECK(STRING_STARTS_WITH(format, "Cc")); |
| 420 PrintCc(instr); | 420 PrintCc(instr); |
| 421 return 2; | 421 return 2; |
| 422 } | 422 } |
| 423 } | 423 } |
| 424 UNREACHABLE(); | 424 UNREACHABLE(); |
| 425 return -1; | 425 return -1; |
| 426 } | 426 } |
| 427 | 427 |
| 428 | 428 |
| 429 // Format takes a formatting string for a whole instruction and prints it into | 429 // Format takes a formatting string for a whole instruction and prints it into |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); | 1495 prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); |
| 1496 } | 1496 } |
| 1497 } | 1497 } |
| 1498 | 1498 |
| 1499 | 1499 |
| 1500 #undef UNSUPPORTED | 1500 #undef UNSUPPORTED |
| 1501 | 1501 |
| 1502 } // namespace disasm | 1502 } // namespace disasm |
| 1503 | 1503 |
| 1504 #endif // V8_TARGET_ARCH_MIPS64 | 1504 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |