| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_ITERATOR_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_ITERATOR_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_ARRAY_ITERATOR_H_ | 6 #define V8_INTERPRETER_BYTECODE_ARRAY_ITERATOR_H_ |
| 7 | 7 |
| 8 #include "src/globals.h" | 8 #include "src/interpreter/bytecode-array-accessor.h" |
| 9 #include "src/handles.h" | |
| 10 #include "src/interpreter/bytecode-register.h" | |
| 11 #include "src/interpreter/bytecodes.h" | |
| 12 #include "src/objects.h" | |
| 13 #include "src/runtime/runtime.h" | |
| 14 | 9 |
| 15 namespace v8 { | 10 namespace v8 { |
| 16 namespace internal { | 11 namespace internal { |
| 17 namespace interpreter { | 12 namespace interpreter { |
| 18 | 13 |
| 19 class V8_EXPORT_PRIVATE BytecodeArrayIterator { | 14 class V8_EXPORT_PRIVATE BytecodeArrayIterator final |
| 15 : public BytecodeArrayAccessor { |
| 20 public: | 16 public: |
| 21 explicit BytecodeArrayIterator(Handle<BytecodeArray> bytecode_array); | 17 explicit BytecodeArrayIterator(Handle<BytecodeArray> bytecode_array); |
| 22 | 18 |
| 23 void Advance(); | 19 void Advance(); |
| 24 bool done() const; | 20 bool done() const; |
| 25 Bytecode current_bytecode() const; | |
| 26 int current_bytecode_size() const; | |
| 27 int current_offset() const { return bytecode_offset_; } | |
| 28 OperandScale current_operand_scale() const { return operand_scale_; } | |
| 29 int current_prefix_offset() const { return prefix_offset_; } | |
| 30 const Handle<BytecodeArray>& bytecode_array() const { | |
| 31 return bytecode_array_; | |
| 32 } | |
| 33 | |
| 34 uint32_t GetFlagOperand(int operand_index) const; | |
| 35 uint32_t GetUnsignedImmediateOperand(int operand_index) const; | |
| 36 int32_t GetImmediateOperand(int operand_index) const; | |
| 37 uint32_t GetIndexOperand(int operand_index) const; | |
| 38 uint32_t GetRegisterCountOperand(int operand_index) const; | |
| 39 Register GetRegisterOperand(int operand_index) const; | |
| 40 int GetRegisterOperandRange(int operand_index) const; | |
| 41 Runtime::FunctionId GetRuntimeIdOperand(int operand_index) const; | |
| 42 Runtime::FunctionId GetIntrinsicIdOperand(int operand_index) const; | |
| 43 Handle<Object> GetConstantForIndexOperand(int operand_index) const; | |
| 44 | |
| 45 // Returns the absolute offset of the branch target at the current | |
| 46 // bytecode. It is an error to call this method if the bytecode is | |
| 47 // not for a jump or conditional jump. | |
| 48 int GetJumpTargetOffset() const; | |
| 49 | 21 |
| 50 private: | 22 private: |
| 51 uint32_t GetUnsignedOperand(int operand_index, | |
| 52 OperandType operand_type) const; | |
| 53 int32_t GetSignedOperand(int operand_index, OperandType operand_type) const; | |
| 54 | |
| 55 void UpdateOperandScale(); | |
| 56 | |
| 57 Handle<BytecodeArray> bytecode_array_; | |
| 58 int bytecode_offset_; | |
| 59 OperandScale operand_scale_; | |
| 60 int prefix_offset_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayIterator); | 23 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayIterator); |
| 63 }; | 24 }; |
| 64 | 25 |
| 65 } // namespace interpreter | 26 } // namespace interpreter |
| 66 } // namespace internal | 27 } // namespace internal |
| 67 } // namespace v8 | 28 } // namespace v8 |
| 68 | 29 |
| 69 #endif // V8_INTERPRETER_BYTECODE_GRAPH_ITERATOR_H_ | 30 #endif // V8_INTERPRETER_BYTECODE_ARRAY_ITERATOR_H_ |
| OLD | NEW |