Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1163)

Side by Side Diff: src/x64/disasm-x64.cc

Issue 1872203005: Fix printf formats (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix unused param found by GC mole Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-result.h ('k') | src/x87/disasm-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #include <assert.h> 5 #include <assert.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #if V8_TARGET_ARCH_X64 9 #if V8_TARGET_ARCH_X64
10 10
11 #include "src/base/compiler-specific.h"
11 #include "src/base/lazy-instance.h" 12 #include "src/base/lazy-instance.h"
12 #include "src/disasm.h" 13 #include "src/disasm.h"
13 14
14 namespace disasm { 15 namespace disasm {
15 16
16 enum OperandType { 17 enum OperandType {
17 UNSET_OP_ORDER = 0, 18 UNSET_OP_ORDER = 0,
18 // Operand size decides between 16, 32 and 64 bit operands. 19 // Operand size decides between 16, 32 and 64 bit operands.
19 REG_OPER_OP_ORDER = 1, // Register destination, operand source. 20 REG_OPER_OP_ORDER = 1, // Register destination, operand source.
20 OPER_REG_OP_ORDER = 2, // Operand destination, register source. 21 OPER_REG_OP_ORDER = 2, // Operand destination, register source.
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 int F6F7Instruction(byte* data); 473 int F6F7Instruction(byte* data);
473 int ShiftInstruction(byte* data); 474 int ShiftInstruction(byte* data);
474 int JumpShort(byte* data); 475 int JumpShort(byte* data);
475 int JumpConditional(byte* data); 476 int JumpConditional(byte* data);
476 int JumpConditionalShort(byte* data); 477 int JumpConditionalShort(byte* data);
477 int SetCC(byte* data); 478 int SetCC(byte* data);
478 int FPUInstruction(byte* data); 479 int FPUInstruction(byte* data);
479 int MemoryFPUInstruction(int escape_opcode, int regop, byte* modrm_start); 480 int MemoryFPUInstruction(int escape_opcode, int regop, byte* modrm_start);
480 int RegisterFPUInstruction(int escape_opcode, byte modrm_byte); 481 int RegisterFPUInstruction(int escape_opcode, byte modrm_byte);
481 int AVXInstruction(byte* data); 482 int AVXInstruction(byte* data);
482 void AppendToBuffer(const char* format, ...); 483 PRINTF_FORMAT(2, 3) void AppendToBuffer(const char* format, ...);
483 484
484 void UnimplementedInstruction() { 485 void UnimplementedInstruction() {
485 if (abort_on_unimplemented_) { 486 if (abort_on_unimplemented_) {
486 CHECK(false); 487 CHECK(false);
487 } else { 488 } else {
488 AppendToBuffer("'Unimplemented Instruction'"); 489 AppendToBuffer("'Unimplemented Instruction'");
489 } 490 }
490 } 491 }
491 }; 492 };
492 493
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 break; 612 break;
612 case OPERAND_QUADWORD_SIZE: 613 case OPERAND_QUADWORD_SIZE:
613 value = *reinterpret_cast<int32_t*>(data); 614 value = *reinterpret_cast<int32_t*>(data);
614 count = 4; 615 count = 4;
615 break; 616 break;
616 default: 617 default:
617 UNREACHABLE(); 618 UNREACHABLE();
618 value = 0; // Initialize variables on all paths to satisfy the compiler. 619 value = 0; // Initialize variables on all paths to satisfy the compiler.
619 count = 0; 620 count = 0;
620 } 621 }
621 AppendToBuffer("%" V8_PTR_PREFIX "x", value); 622 AppendToBuffer("%" PRIx64, value);
622 return count; 623 return count;
623 } 624 }
624 625
625 626
626 int DisassemblerX64::PrintRightOperand(byte* modrmp) { 627 int DisassemblerX64::PrintRightOperand(byte* modrmp) {
627 return PrintRightOperandHelper(modrmp, 628 return PrintRightOperandHelper(modrmp,
628 &DisassemblerX64::NameOfCPURegister); 629 &DisassemblerX64::NameOfCPURegister);
629 } 630 }
630 631
631 632
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 case ZERO_OPERANDS_INSTR: 1993 case ZERO_OPERANDS_INSTR:
1993 if (current >= 0xA4 && current <= 0xA7) { 1994 if (current >= 0xA4 && current <= 0xA7) {
1994 // String move or compare operations. 1995 // String move or compare operations.
1995 if (group_1_prefix_ == REP_PREFIX) { 1996 if (group_1_prefix_ == REP_PREFIX) {
1996 // REP. 1997 // REP.
1997 AppendToBuffer("rep "); 1998 AppendToBuffer("rep ");
1998 } 1999 }
1999 if (rex_w()) AppendToBuffer("REX.W "); 2000 if (rex_w()) AppendToBuffer("REX.W ");
2000 AppendToBuffer("%s%c", idesc.mnem, operand_size_code()); 2001 AppendToBuffer("%s%c", idesc.mnem, operand_size_code());
2001 } else { 2002 } else {
2002 AppendToBuffer("%s", idesc.mnem, operand_size_code()); 2003 AppendToBuffer("%s%c", idesc.mnem, operand_size_code());
2003 } 2004 }
2004 data++; 2005 data++;
2005 break; 2006 break;
2006 2007
2007 case TWO_OPERANDS_INSTR: 2008 case TWO_OPERANDS_INSTR:
2008 data++; 2009 data++;
2009 data += PrintOperands(idesc.mnem, idesc.op_order_, data); 2010 data += PrintOperands(idesc.mnem, idesc.op_order_, data);
2010 break; 2011 break;
2011 2012
2012 case JUMP_CONDITIONAL_SHORT_INSTR: 2013 case JUMP_CONDITIONAL_SHORT_INSTR:
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 break; 2135 break;
2135 case 4: 2136 case 4:
2136 mnem = "jmp"; 2137 mnem = "jmp";
2137 break; 2138 break;
2138 case 6: 2139 case 6:
2139 mnem = "push"; 2140 mnem = "push";
2140 break; 2141 break;
2141 default: 2142 default:
2142 mnem = "???"; 2143 mnem = "???";
2143 } 2144 }
2144 AppendToBuffer(((regop <= 1) ? "%s%c " : "%s "), 2145 if (regop <= 1) {
2145 mnem, 2146 AppendToBuffer("%s%c ", mnem, operand_size_code());
2146 operand_size_code()); 2147 } else {
2148 AppendToBuffer("%s ", mnem);
2149 }
2147 data += PrintRightOperand(data); 2150 data += PrintRightOperand(data);
2148 } 2151 }
2149 break; 2152 break;
2150 2153
2151 case 0xC7: // imm32, fall through 2154 case 0xC7: // imm32, fall through
2152 case 0xC6: // imm8 2155 case 0xC6: // imm8
2153 { 2156 {
2154 bool is_byte = *data == 0xC6; 2157 bool is_byte = *data == 0xC6;
2155 data++; 2158 data++;
2156 if (is_byte) { 2159 if (is_byte) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 value = *reinterpret_cast<uint32_t*>(data + 1); 2330 value = *reinterpret_cast<uint32_t*>(data + 1);
2328 data += 5; 2331 data += 5;
2329 break; 2332 break;
2330 case OPERAND_QUADWORD_SIZE: 2333 case OPERAND_QUADWORD_SIZE:
2331 value = *reinterpret_cast<int32_t*>(data + 1); 2334 value = *reinterpret_cast<int32_t*>(data + 1);
2332 data += 5; 2335 data += 5;
2333 break; 2336 break;
2334 default: 2337 default:
2335 UNREACHABLE(); 2338 UNREACHABLE();
2336 } 2339 }
2337 AppendToBuffer("test%c rax,0x%" V8_PTR_PREFIX "x", 2340 AppendToBuffer("test%c rax,0x%" PRIx64, operand_size_code(), value);
2338 operand_size_code(),
2339 value);
2340 break; 2341 break;
2341 } 2342 }
2342 case 0xD1: // fall through 2343 case 0xD1: // fall through
2343 case 0xD3: // fall through 2344 case 0xD3: // fall through
2344 case 0xC1: 2345 case 0xC1:
2345 data += ShiftInstruction(data); 2346 data += ShiftInstruction(data);
2346 break; 2347 break;
2347 case 0xD0: // fall through 2348 case 0xD0: // fall through
2348 case 0xD2: // fall through 2349 case 0xD2: // fall through
2349 case 0xC0: 2350 case 0xC0:
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) { 2503 for (int i = 6 - static_cast<int>(pc - prev_pc); i >= 0; i--) {
2503 fprintf(f, " "); 2504 fprintf(f, " ");
2504 } 2505 }
2505 fprintf(f, " %s\n", buffer.start()); 2506 fprintf(f, " %s\n", buffer.start());
2506 } 2507 }
2507 } 2508 }
2508 2509
2509 } // namespace disasm 2510 } // namespace disasm
2510 2511
2511 #endif // V8_TARGET_ARCH_X64 2512 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/wasm/wasm-result.h ('k') | src/x87/disasm-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698