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/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(); | |
|
rmcilroy
2016/02/02 10:53:28
break;
oth
2016/02/02 11:20:24
Done.
| |
| 99 } | 103 } |
| 100 return Register(); | 104 DCHECK_GE(reg.index(), |
| 105 Register::FromParameterIndex(0, bytecode_array()->parameter_count()) | |
| 106 .index()); | |
| 107 DCHECK(reg.index() < bytecode_array()->register_count() || | |
| 108 (reg.index() == 0 && | |
| 109 (Bytecodes::GetOperandType(current_bytecode(), operand_index) == | |
| 110 OperandType::kMaybeReg8 || | |
| 111 Bytecodes::GetOperandType(current_bytecode(), operand_index) == | |
| 112 OperandType::kMaybeReg16))); | |
|
rmcilroy
2016/02/02 10:53:28
nit - could you pull out a helper for IsMaybeRegis
oth
2016/02/02 11:20:24
Done. Also IsRegisterCountOperandType used just be
| |
| 113 return reg; | |
| 101 } | 114 } |
| 102 | 115 |
| 103 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { | 116 int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { |
| 104 interpreter::OperandType operand_type = | 117 interpreter::OperandType operand_type = |
| 105 Bytecodes::GetOperandType(current_bytecode(), operand_index); | 118 Bytecodes::GetOperandType(current_bytecode(), operand_index); |
| 106 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); | 119 DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); |
| 107 switch (operand_type) { | 120 switch (operand_type) { |
| 108 case OperandType::kRegPair8: | 121 case OperandType::kRegPair8: |
| 109 case OperandType::kRegPair16: | 122 case OperandType::kRegPair16: |
| 110 case OperandType::kRegOutPair8: | 123 case OperandType::kRegOutPair8: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 return current_offset() + smi->value(); | 163 return current_offset() + smi->value(); |
| 151 } else { | 164 } else { |
| 152 UNREACHABLE(); | 165 UNREACHABLE(); |
| 153 return kMinInt; | 166 return kMinInt; |
| 154 } | 167 } |
| 155 } | 168 } |
| 156 | 169 |
| 157 } // namespace interpreter | 170 } // namespace interpreter |
| 158 } // namespace internal | 171 } // namespace internal |
| 159 } // namespace v8 | 172 } // namespace v8 |
| OLD | NEW |