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 OperandType next_operand_type = | |
oth
2016/01/27 15:10:09
Can you add a TODO(oth) here to update bytecodes s
rmcilroy
2016/01/28 16:39:51
Done.
| |
120 Bytecodes::GetOperandType(current_bytecode(), operand_index + 1); | |
121 if (next_operand_type == OperandType::kRegCount8 || | |
122 next_operand_type == OperandType::kRegCount16) { | |
123 return GetCountOperand(operand_index + 1); | |
124 } | |
125 } | |
126 return 1; | |
127 } | |
128 } | |
129 } | |
103 | 130 |
104 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( | 131 Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( |
105 int operand_index) const { | 132 int operand_index) const { |
106 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); | 133 Handle<FixedArray> constants = handle(bytecode_array()->constant_pool()); |
107 return FixedArray::get(constants, GetIndexOperand(operand_index)); | 134 return FixedArray::get(constants, GetIndexOperand(operand_index)); |
108 } | 135 } |
109 | 136 |
110 | 137 |
111 int BytecodeArrayIterator::GetJumpTargetOffset() const { | 138 int BytecodeArrayIterator::GetJumpTargetOffset() const { |
112 Bytecode bytecode = current_bytecode(); | 139 Bytecode bytecode = current_bytecode(); |
113 if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) { | 140 if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) { |
114 int relative_offset = GetImmediateOperand(0); | 141 int relative_offset = GetImmediateOperand(0); |
115 return current_offset() + relative_offset; | 142 return current_offset() + relative_offset; |
116 } else if (interpreter::Bytecodes::IsJumpConstant(bytecode) || | 143 } else if (interpreter::Bytecodes::IsJumpConstant(bytecode) || |
117 interpreter::Bytecodes::IsJumpConstantWide(bytecode)) { | 144 interpreter::Bytecodes::IsJumpConstantWide(bytecode)) { |
118 Smi* smi = Smi::cast(*GetConstantForIndexOperand(0)); | 145 Smi* smi = Smi::cast(*GetConstantForIndexOperand(0)); |
119 return current_offset() + smi->value(); | 146 return current_offset() + smi->value(); |
120 } else { | 147 } else { |
121 UNREACHABLE(); | 148 UNREACHABLE(); |
122 return kMinInt; | 149 return kMinInt; |
123 } | 150 } |
124 } | 151 } |
125 | 152 |
126 } // namespace interpreter | 153 } // namespace interpreter |
127 } // namespace internal | 154 } // namespace internal |
128 } // namespace v8 | 155 } // namespace v8 |
OLD | NEW |