Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index d81b1f6b8c8bcfc1803ad3708c1df0d957c28916..907dc1e126bcdde97f63acbbf199e9a5d0dab208 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -15063,7 +15063,16 @@ void BytecodeArray::Disassemble(std::ostream& os) { |
| const uint8_t* bytecode_start = &first_bytecode_address[i]; |
| interpreter::Bytecode bytecode = |
| interpreter::Bytecodes::FromByte(bytecode_start[0]); |
| - bytecode_size = interpreter::Bytecodes::Size(bytecode); |
| + int prefix_offset = 0; |
|
rmcilroy
2016/03/10 16:45:38
It might be time to rework this so that it uses th
oth
2016/03/11 16:26:13
Ack.
|
| + int operand_scale = |
| + interpreter::Bytecodes::GetPrefixBytecodeScale(bytecode); |
| + if (operand_scale > 1) { |
| + // Bytecode is a prefix for wider operands in the next bytecode. |
| + prefix_offset += 1; |
| + bytecode = interpreter::Bytecodes::FromByte(bytecode_start[1]); |
| + } |
| + bytecode_size = |
| + prefix_offset + interpreter::Bytecodes::Size(bytecode, operand_scale); |
| if (!source_positions.done() && i == source_positions.bytecode_offset()) { |
| os << std::setw(5) << source_positions.source_position(); |
| @@ -15077,25 +15086,36 @@ void BytecodeArray::Disassemble(std::ostream& os) { |
| os << buf.start() << " : "; |
| interpreter::Bytecodes::Decode(os, bytecode_start, parameter_count()); |
| - if (interpreter::Bytecodes::IsJumpConstantWide(bytecode)) { |
| - DCHECK_EQ(bytecode_size, 3); |
| - int index = static_cast<int>(ReadUnalignedUInt16(bytecode_start + 1)); |
| - int offset = Smi::cast(constant_pool()->get(index))->value(); |
| - SNPrintF(buf, " (%p)", bytecode_start + offset); |
| - os << buf.start(); |
| - } else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) { |
| - DCHECK_EQ(bytecode_size, 2); |
| - int index = static_cast<int>(bytecode_start[1]); |
| - int offset = Smi::cast(constant_pool()->get(index))->value(); |
| - SNPrintF(buf, " (%p)", bytecode_start + offset); |
| - os << buf.start(); |
| - } else if (interpreter::Bytecodes::IsJump(bytecode)) { |
| - DCHECK_EQ(bytecode_size, 2); |
| - int offset = static_cast<int8_t>(bytecode_start[1]); |
| + if (interpreter::Bytecodes::IsJump(bytecode)) { |
| + static const int operand_offset = 1; |
| + int operand; |
| + switch (operand_scale) { |
| + case 1: |
| + operand = static_cast<int8_t>(bytecode_start[operand_offset]); |
| + break; |
| + case 2: |
| + operand = static_cast<int16_t>(ReadUnalignedUInt16( |
| + bytecode_start + prefix_offset + operand_offset)); |
| + break; |
| + case 4: |
| + operand = static_cast<int>(ReadUnalignedUInt32( |
| + bytecode_start + prefix_offset + operand_offset)); |
| + break; |
| + default: |
| + UNREACHABLE(); |
| + } |
| + int offset; |
| + if (interpreter::Bytecodes::IsJumpConstant(bytecode)) { |
| + offset = Smi::cast(constant_pool()->get(operand))->value(); |
| + } else { |
| + offset = operand; |
| + } |
| + offset += prefix_offset; |
| SNPrintF(buf, " (%p)", bytecode_start + offset); |
| + DCHECK_GE(i + offset, 0); |
| + DCHECK_LT(i + offset, length()); |
| os << buf.start(); |
| } |
| - |
| os << std::endl; |
| } |