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

Side by Side Diff: runtime/vm/disassembler_ia32.cc

Issue 2748023003: Sign extend correctly in disassembler (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | runtime/vm/disassembler_x64.cc » ('j') | runtime/vm/disassembler_x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/disassembler.h" 5 #include "vm/disassembler.h"
6 6
7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
8 #if defined(TARGET_ARCH_IA32) 8 #if defined(TARGET_ARCH_IA32)
9 #include "platform/utils.h" 9 #include "platform/utils.h"
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 edx = 2, 318 edx = 2,
319 ebx = 3, 319 ebx = 3,
320 esp = 4, 320 esp = 4,
321 ebp = 5, 321 ebp = 5,
322 esi = 6, 322 esi = 6,
323 edi = 7 323 edi = 7
324 }; 324 };
325 325
326 // Bottleneck functions to print into the out_buffer. 326 // Bottleneck functions to print into the out_buffer.
327 void PrintInt(int value); 327 void PrintInt(int value);
328 void PrintHex(int value); 328 void PrintHex(int value, bool signed_value = false);
329 void Print(const char* str); 329 void Print(const char* str);
330 const char* GetBranchPrefix(uint8_t** data); 330 const char* GetBranchPrefix(uint8_t** data);
331 331
332 bool DecodeInstructionType(const InstructionDesc& idesc, 332 bool DecodeInstructionType(const InstructionDesc& idesc,
333 const char* branch_hint, 333 const char* branch_hint,
334 uint8_t** data); 334 uint8_t** data);
335 335
336 // Printing of common values. 336 // Printing of common values.
337 void PrintCPURegister(int reg); 337 void PrintCPURegister(int reg);
338 void PrintCPUByteRegister(int reg); 338 void PrintCPUByteRegister(int reg);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 395
396 void X86Decoder::PrintInt(int value) { 396 void X86Decoder::PrintInt(int value) {
397 char int_buffer[16]; 397 char int_buffer[16];
398 OS::SNPrint(int_buffer, sizeof(int_buffer), "%#x", value); 398 OS::SNPrint(int_buffer, sizeof(int_buffer), "%#x", value);
399 Print(int_buffer); 399 Print(int_buffer);
400 } 400 }
401 401
402 402
403 // Append the int value (printed in hex) to the output buffer. 403 // Append the int value (printed in hex) to the output buffer.
404 void X86Decoder::PrintHex(int value) { 404 void X86Decoder::PrintHex(int value, bool signed_value) {
405 char hex_buffer[16]; 405 char hex_buffer[16];
406 OS::SNPrint(hex_buffer, sizeof(hex_buffer), "%#x", value); 406 if (signed_value && value < 0) {
407 OS::SNPrint(hex_buffer, sizeof(hex_buffer), "-%#x", -value);
408 } else {
409 OS::SNPrint(hex_buffer, sizeof(hex_buffer), "%#x", value);
410 }
407 Print(hex_buffer); 411 Print(hex_buffer);
408 } 412 }
409 413
410 414
411 // Append the str to the output buffer. 415 // Append the str to the output buffer.
412 void X86Decoder::Print(const char* str) { 416 void X86Decoder::Print(const char* str) {
413 char cur = *str++; 417 char cur = *str++;
414 while (cur != '\0' && (buffer_pos_ < (buffer_size_ - 1))) { 418 while (cur != '\0' && (buffer_pos_ < (buffer_size_ - 1))) {
415 buffer_[buffer_pos_++] = cur; 419 buffer_[buffer_pos_++] = cur;
416 cur = *str++; 420 cur = *str++;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 UNIMPLEMENTED(); 682 UNIMPLEMENTED();
679 } 683 }
680 Print(mnem); 684 Print(mnem);
681 Print(" "); 685 Print(" ");
682 int count = PrintRightOperand(data + 1); 686 int count = PrintRightOperand(data + 1);
683 Print(","); 687 Print(",");
684 if (size_override) { 688 if (size_override) {
685 PrintHex(*reinterpret_cast<int16_t*>(data + 1 + count)); 689 PrintHex(*reinterpret_cast<int16_t*>(data + 1 + count));
686 return 1 + count + 2 /*int16_t*/; 690 return 1 + count + 2 /*int16_t*/;
687 } else if (sign_extension_bit) { 691 } else if (sign_extension_bit) {
688 PrintHex(*(data + 1 + count)); 692 PrintHex(*reinterpret_cast<int8_t*>(data + 1 + count), sign_extension_bit);
689 return 1 + count + 1 /*int8_t*/; 693 return 1 + count + 1 /*int8_t*/;
690 } else { 694 } else {
691 PrintHex(*reinterpret_cast<int32_t*>(data + 1 + count)); 695 PrintHex(*reinterpret_cast<int32_t*>(data + 1 + count));
692 return 1 + count + 4 /*int32_t*/; 696 return 1 + count + 4 /*int32_t*/;
693 } 697 }
694 } 698 }
695 699
696 700
697 int X86Decoder::DecodeEnter(uint8_t* data) { 701 int X86Decoder::DecodeEnter(uint8_t* data) {
698 uint16_t size = *reinterpret_cast<uint16_t*>(data + 1); 702 uint16_t size = *reinterpret_cast<uint16_t*>(data + 1);
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 } 1949 }
1946 } 1950 }
1947 } 1951 }
1948 } 1952 }
1949 1953
1950 #endif // !PRODUCT 1954 #endif // !PRODUCT
1951 1955
1952 } // namespace dart 1956 } // namespace dart
1953 1957
1954 #endif // defined TARGET_ARCH_IA32 1958 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/disassembler_x64.cc » ('j') | runtime/vm/disassembler_x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698