Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/interpreter/bytecodes.h" | 5 #include "src/interpreter/bytecodes.h" |
| 6 | 6 |
| 7 #include "src/frames.h" | 7 #include "src/frames.h" |
| 8 #include "src/interpreter/bytecode-traits.h" | 8 #include "src/interpreter/bytecode-traits.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 return ReadUnalignedUInt32(operand_start); | 477 return ReadUnalignedUInt32(operand_start); |
| 478 case OperandSize::kNone: | 478 case OperandSize::kNone: |
| 479 UNREACHABLE(); | 479 UNREACHABLE(); |
| 480 } | 480 } |
| 481 return 0; | 481 return 0; |
| 482 } | 482 } |
| 483 | 483 |
| 484 // static | 484 // static |
| 485 std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start, | 485 std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start, |
| 486 int parameter_count) { | 486 int parameter_count) { |
| 487 Vector<char> buf = Vector<char>::New(50); | 487 ScopedVector<char> buf(50); |
| 488 | 488 |
| 489 Bytecode bytecode = Bytecodes::FromByte(bytecode_start[0]); | 489 Bytecode bytecode = Bytecodes::FromByte(bytecode_start[0]); |
| 490 int prefix_offset = 0; | 490 int prefix_offset = 0; |
| 491 OperandScale operand_scale = OperandScale::kSingle; | 491 OperandScale operand_scale = OperandScale::kSingle; |
| 492 if (IsPrefixScalingBytecode(bytecode)) { | 492 if (IsPrefixScalingBytecode(bytecode)) { |
| 493 prefix_offset = 1; | 493 prefix_offset = 1; |
| 494 operand_scale = Bytecodes::PrefixBytecodeToOperandScale(bytecode); | 494 operand_scale = Bytecodes::PrefixBytecodeToOperandScale(bytecode); |
| 495 bytecode = Bytecodes::FromByte(bytecode_start[1]); | 495 bytecode = Bytecodes::FromByte(bytecode_start[1]); |
| 496 } | 496 } |
| 497 int bytecode_size = Bytecodes::Size(bytecode, operand_scale); | 497 int bytecode_size = Bytecodes::Size(bytecode, operand_scale); |
| 498 for (int i = 0; i < prefix_offset + bytecode_size; i++) { | 498 for (int i = 0; i < prefix_offset + bytecode_size; i++) { |
| 499 SNPrintF(buf, "%02x ", bytecode_start[i]); | 499 SNPrintF(buf, "%02x ", bytecode_start[i]); |
|
rmcilroy
2016/03/24 08:51:26
Could we just use something like:
os << std::width
| |
| 500 os << buf.start(); | 500 os << buf.start(); |
| 501 } | 501 } |
| 502 const int kBytecodeColumnSize = 6; | 502 const int kBytecodeColumnSize = 6; |
| 503 for (int i = prefix_offset + bytecode_size; i < kBytecodeColumnSize; i++) { | 503 for (int i = prefix_offset + bytecode_size; i < kBytecodeColumnSize; i++) { |
| 504 os << " "; | 504 os << " "; |
| 505 } | 505 } |
| 506 | 506 |
| 507 os << Bytecodes::ToString(bytecode, operand_scale) << " "; | 507 os << Bytecodes::ToString(bytecode, operand_scale) << " "; |
| 508 | 508 |
| 509 // Operands for the debug break are from the original instruction. | 509 // Operands for the debug break are from the original instruction. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 } else { | 677 } else { |
| 678 std::ostringstream s; | 678 std::ostringstream s; |
| 679 s << "r" << index(); | 679 s << "r" << index(); |
| 680 return s.str(); | 680 return s.str(); |
| 681 } | 681 } |
| 682 } | 682 } |
| 683 | 683 |
| 684 } // namespace interpreter | 684 } // namespace interpreter |
| 685 } // namespace internal | 685 } // namespace internal |
| 686 } // namespace v8 | 686 } // namespace v8 |
| OLD | NEW |