| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 uint32_t operand = GetRawOperand(operand_index, operand_type); | 82 uint32_t operand = GetRawOperand(operand_index, operand_type); |
| 83 return static_cast<int>(operand); | 83 return static_cast<int>(operand); |
| 84 } | 84 } |
| 85 | 85 |
| 86 | 86 |
| 87 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { | 87 Register BytecodeArrayIterator::GetRegisterOperand(int operand_index) const { |
| 88 OperandType operand_type = | 88 OperandType operand_type = |
| 89 Bytecodes::GetOperandType(current_bytecode(), operand_index); | 89 Bytecodes::GetOperandType(current_bytecode(), operand_index); |
| 90 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); | 90 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); |
| 91 uint32_t operand = GetRawOperand(operand_index, operand_type); | 91 uint32_t operand = GetRawOperand(operand_index, operand_type); |
| 92 Register reg; |
| 92 switch (Bytecodes::GetOperandSize(current_bytecode(), operand_index)) { | 93 switch (Bytecodes::GetOperandSize(current_bytecode(), operand_index)) { |
| 93 case OperandSize::kByte: | 94 case OperandSize::kByte: |
| 94 return Register::FromOperand(static_cast<uint8_t>(operand)); | 95 reg = Register::FromOperand(static_cast<uint8_t>(operand)); |
| 96 break; |
| 95 case OperandSize::kShort: | 97 case OperandSize::kShort: |
| 96 return Register::FromWideOperand(static_cast<uint16_t>(operand)); | 98 reg = Register::FromWideOperand(static_cast<uint16_t>(operand)); |
| 99 break; |
| 97 case OperandSize::kNone: | 100 case OperandSize::kNone: |
| 98 UNREACHABLE(); | 101 UNREACHABLE(); |
| 102 reg = Register::invalid_value(); |
| 103 break; |
| 99 } | 104 } |
| 100 return Register(); | 105 DCHECK_GE(reg.index(), |
| 106 Register::FromParameterIndex(0, bytecode_array()->parameter_count()) |
| 107 .index()); |
| 108 DCHECK(reg.index() < bytecode_array()->register_count() || |
| 109 (reg.index() == 0 && |
| 110 Bytecodes::IsMaybeRegisterOperandType( |
| 111 Bytecodes::GetOperandType(current_bytecode(), operand_index)))); |
| 112 return reg; |
| 101 } | 113 } |
| 102 | 114 |
| 103 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { | 115 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { |
| 104 interpreter::OperandType operand_type = | 116 interpreter::OperandType operand_type = |
| 105 Bytecodes::GetOperandType(current_bytecode(), operand_index); | 117 Bytecodes::GetOperandType(current_bytecode(), operand_index); |
| 106 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); | 118 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); |
| 107 switch (operand_type) { | 119 switch (operand_type) { |
| 108 case OperandType::kRegPair8: | 120 case OperandType::kRegPair8: |
| 109 case OperandType::kRegPair16: | 121 case OperandType::kRegPair16: |
| 110 case OperandType::kRegOutPair8: | 122 case OperandType::kRegOutPair8: |
| 111 case OperandType::kRegOutPair16: | 123 case OperandType::kRegOutPair16: |
| 112 return 2; | 124 return 2; |
| 113 case OperandType::kRegOutTriple8: | 125 case OperandType::kRegOutTriple8: |
| 114 case OperandType::kRegOutTriple16: | 126 case OperandType::kRegOutTriple16: |
| 115 return 3; | 127 return 3; |
| 116 default: { | 128 default: { |
| 117 if (operand_index + 1 != | 129 if (operand_index + 1 != |
| 118 Bytecodes::NumberOfOperands(current_bytecode())) { | 130 Bytecodes::NumberOfOperands(current_bytecode())) { |
| 119 // TODO(oth): Ensure all bytecodes specify the full range of registers | 131 // TODO(oth): Ensure all bytecodes specify the full range of registers |
| 120 // with kRegCount (currently Call/CallJSRuntime are off by one due to | 132 // with kRegCount (currently Call/CallJSRuntime are off by one due to |
| 121 // reciever. | 133 // reciever. |
| 122 OperandType next_operand_type = | 134 OperandType next_operand_type = |
| 123 Bytecodes::GetOperandType(current_bytecode(), operand_index + 1); | 135 Bytecodes::GetOperandType(current_bytecode(), operand_index + 1); |
| 124 if (next_operand_type == OperandType::kRegCount8 || | 136 if (Bytecodes::IsRegisterCountOperandType(next_operand_type)) { |
| 125 next_operand_type == OperandType::kRegCount16) { | |
| 126 return GetCountOperand(operand_index + 1); | 137 return GetCountOperand(operand_index + 1); |
| 127 } | 138 } |
| 128 } | 139 } |
| 129 return 1; | 140 return 1; |
| 130 } | 141 } |
| 131 } | 142 } |
| 132 } | 143 } |
| 133 | 144 |
| 134 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( | 145 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( |
| 135 int operand_index) const { | 146 int operand_index) const { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 150 return current_offset() + smi->value(); | 161 return current_offset() + smi->value(); |
| 151 } else { | 162 } else { |
| 152 UNREACHABLE(); | 163 UNREACHABLE(); |
| 153 return kMinInt; | 164 return kMinInt; |
| 154 } | 165 } |
| 155 } | 166 } |
| 156 | 167 |
| 157 } // namespace interpreter | 168 } // namespace interpreter |
| 158 } // namespace internal | 169 } // namespace internal |
| 159 } // namespace v8 | 170 } // namespace v8 |
| OLD | NEW |