| 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/bytecode-array-iterator.h" | 5 #include "src/interpreter/bytecode-array-iterator.h" |
| 6 | 6 |
| 7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 case OperandSize::kByte: | 93 case OperandSize::kByte: |
| 94 return Register::FromOperand(static_cast<uint8_t>(operand)); | 94 return Register::FromOperand(static_cast<uint8_t>(operand)); |
| 95 case OperandSize::kShort: | 95 case OperandSize::kShort: |
| 96 return Register::FromWideOperand(static_cast<uint16_t>(operand)); | 96 return Register::FromWideOperand(static_cast<uint16_t>(operand)); |
| 97 case OperandSize::kNone: | 97 case OperandSize::kNone: |
| 98 UNREACHABLE(); | 98 UNREACHABLE(); |
| 99 } | 99 } |
| 100 return Register(); | 100 return Register(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { |
| 104 interpreter::OperandType operand_type = |
| 105 Bytecodes::GetOperandType(current_bytecode(), operand_index); |
| 106 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); |
| 107 switch (operand_type) { |
| 108 case OperandType::kRegPair8: |
| 109 case OperandType::kRegPair16: |
| 110 case OperandType::kRegOutPair8: |
| 111 case OperandType::kRegOutPair16: |
| 112 return 2; |
| 113 case OperandType::kRegOutTriple8: |
| 114 case OperandType::kRegOutTriple16: |
| 115 return 3; |
| 116 default: { |
| 117 if (operand_index + 1 != |
| 118 Bytecodes::NumberOfOperands(current_bytecode())) { |
| 119 // TODO(oth): Ensure all bytecodes specify the full range of registers |
| 120 // with kRegCount (currently Call/CallJSRuntime are off by one due to |
| 121 // reciever. |
| 122 OperandType next_operand_type = |
| 123 Bytecodes::GetOperandType(current_bytecode(), operand_index + 1); |
| 124 if (next_operand_type == OperandType::kRegCount8 || |
| 125 next_operand_type == OperandType::kRegCount16) { |
| 126 return GetCountOperand(operand_index + 1); |
| 127 } |
| 128 } |
| 129 return 1; |
| 130 } |
| 131 } |
| 132 } |
| 103 | 133 |
| 104 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( | 134 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( |
| 105 int operand_index) const { | 135 int operand_index) const { |
| 106 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); | 136 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); |
| 107 return FixedArray::get(constants, GetIndexOperand(operand_index)); | 137 return FixedArray::get(constants, GetIndexOperand(operand_index)); |
| 108 } | 138 } |
| 109 | 139 |
| 110 | 140 |
| 111 int BytecodeArrayIterator::GetJumpTargetOffset() const { | 141 int BytecodeArrayIterator::GetJumpTargetOffset() const { |
| 112 Bytecode bytecode = current_bytecode(); | 142 Bytecode bytecode = current_bytecode(); |
| 113 if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) { | 143 if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) { |
| 114 int relative_offset = GetImmediateOperand(0); | 144 int relative_offset = GetImmediateOperand(0); |
| 115 return current_offset() + relative_offset; | 145 return current_offset() + relative_offset; |
| 116 } else if (interpreter::Bytecodes::IsJumpConstant(bytecode) || | 146 } else if (interpreter::Bytecodes::IsJumpConstant(bytecode) || |
| 117 interpreter::Bytecodes::IsJumpConstantWide(bytecode)) { | 147 interpreter::Bytecodes::IsJumpConstantWide(bytecode)) { |
| 118 Smi* smi = Smi::cast(*GetConstantForIndexOperand(0)); | 148 Smi* smi = Smi::cast(*GetConstantForIndexOperand(0)); |
| 119 return current_offset() + smi->value(); | 149 return current_offset() + smi->value(); |
| 120 } else { | 150 } else { |
| 121 UNREACHABLE(); | 151 UNREACHABLE(); |
| 122 return kMinInt; | 152 return kMinInt; |
| 123 } | 153 } |
| 124 } | 154 } |
| 125 | 155 |
| 126 } // namespace interpreter | 156 } // namespace interpreter |
| 127 } // namespace internal | 157 } // namespace internal |
| 128 } // namespace v8 | 158 } // namespace v8 |
| OLD | NEW |