| 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-accessor.h" | 5 #include "src/interpreter/bytecode-array-accessor.h" |
| 6 | 6 |
| 7 #include "src/interpreter/bytecode-decoder.h" | 7 #include "src/interpreter/bytecode-decoder.h" |
| 8 #include "src/interpreter/interpreter-intrinsics.h" | 8 #include "src/interpreter/interpreter-intrinsics.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 | 10 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand( | 171 Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand( |
| 172 int operand_index) const { | 172 int operand_index) const { |
| 173 return FixedArray::get(bytecode_array()->constant_pool(), | 173 return FixedArray::get(bytecode_array()->constant_pool(), |
| 174 GetIndexOperand(operand_index), | 174 GetIndexOperand(operand_index), |
| 175 bytecode_array()->GetIsolate()); | 175 bytecode_array()->GetIsolate()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 int BytecodeArrayAccessor::GetJumpTargetOffset() const { | 178 int BytecodeArrayAccessor::GetJumpTargetOffset() const { |
| 179 Bytecode bytecode = current_bytecode(); | 179 Bytecode bytecode = current_bytecode(); |
| 180 if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) { | 180 if (interpreter::Bytecodes::IsJumpImmediate(bytecode)) { |
| 181 int relative_offset = GetImmediateOperand(0); | 181 int relative_offset = GetUnsignedImmediateOperand(0); |
| 182 if (bytecode == Bytecode::kJumpLoop) { |
| 183 relative_offset = -relative_offset; |
| 184 } |
| 182 return current_offset() + relative_offset + current_prefix_offset(); | 185 return current_offset() + relative_offset + current_prefix_offset(); |
| 183 } else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) { | 186 } else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) { |
| 184 Smi* smi = Smi::cast(*GetConstantForIndexOperand(0)); | 187 Smi* smi = Smi::cast(*GetConstantForIndexOperand(0)); |
| 185 return current_offset() + smi->value() + current_prefix_offset(); | 188 return current_offset() + smi->value() + current_prefix_offset(); |
| 186 } else { | 189 } else { |
| 187 UNREACHABLE(); | 190 UNREACHABLE(); |
| 188 return kMinInt; | 191 return kMinInt; |
| 189 } | 192 } |
| 190 } | 193 } |
| 191 | 194 |
| 192 bool BytecodeArrayAccessor::OffsetWithinBytecode(int offset) const { | 195 bool BytecodeArrayAccessor::OffsetWithinBytecode(int offset) const { |
| 193 return current_offset() <= offset && | 196 return current_offset() <= offset && |
| 194 offset < current_offset() + current_bytecode_size(); | 197 offset < current_offset() + current_bytecode_size(); |
| 195 } | 198 } |
| 196 | 199 |
| 197 std::ostream& BytecodeArrayAccessor::PrintTo(std::ostream& os) const { | 200 std::ostream& BytecodeArrayAccessor::PrintTo(std::ostream& os) const { |
| 198 return BytecodeDecoder::Decode( | 201 return BytecodeDecoder::Decode( |
| 199 os, bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_, | 202 os, bytecode_array()->GetFirstBytecodeAddress() + bytecode_offset_, |
| 200 bytecode_array()->parameter_count()); | 203 bytecode_array()->parameter_count()); |
| 201 } | 204 } |
| 202 | 205 |
| 203 } // namespace interpreter | 206 } // namespace interpreter |
| 204 } // namespace internal | 207 } // namespace internal |
| 205 } // namespace v8 | 208 } // namespace v8 |
| OLD | NEW |