| 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 #ifndef V8_INTERPRETER_BYTECODE_LABEL_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_LABEL_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_LABEL_H_ | 6 #define V8_INTERPRETER_BYTECODE_LABEL_H_ |
| 7 | 7 |
| 8 #include "src/zone-containers.h" |
| 9 |
| 8 namespace v8 { | 10 namespace v8 { |
| 9 namespace internal { | 11 namespace internal { |
| 10 namespace interpreter { | 12 namespace interpreter { |
| 11 | 13 |
| 14 class BytecodeArrayBuilder; |
| 15 |
| 12 // A label representing a branch target in a bytecode array. When a | 16 // A label representing a branch target in a bytecode array. When a |
| 13 // label is bound, it represents a known position in the bytecode | 17 // label is bound, it represents a known position in the bytecode |
| 14 // array. For labels that are forward references there can be at most | 18 // array. For labels that are forward references there can be at most |
| 15 // one reference whilst it is unbound. | 19 // one reference whilst it is unbound. |
| 16 class BytecodeLabel final { | 20 class BytecodeLabel final { |
| 17 public: | 21 public: |
| 18 BytecodeLabel() : bound_(false), offset_(kInvalidOffset) {} | 22 BytecodeLabel() : bound_(false), offset_(kInvalidOffset) {} |
| 19 | 23 |
| 20 bool is_bound() const { return bound_; } | 24 bool is_bound() const { return bound_; } |
| 21 size_t offset() const { return offset_; } | 25 size_t offset() const { return offset_; } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 42 // bound_ offset_ | 46 // bound_ offset_ |
| 43 // UNSET false kInvalidOffset | 47 // UNSET false kInvalidOffset |
| 44 // FORWARD_TARGET false Offset of referring jump | 48 // FORWARD_TARGET false Offset of referring jump |
| 45 // BACKWARD_TARGET true Offset of label in bytecode array when bound | 49 // BACKWARD_TARGET true Offset of label in bytecode array when bound |
| 46 bool bound_; | 50 bool bound_; |
| 47 size_t offset_; | 51 size_t offset_; |
| 48 | 52 |
| 49 friend class BytecodeArrayWriter; | 53 friend class BytecodeArrayWriter; |
| 50 }; | 54 }; |
| 51 | 55 |
| 56 // Class representing a branch target of multiple jumps. |
| 57 class BytecodeLabels { |
| 58 public: |
| 59 explicit BytecodeLabels(Zone* zone) : labels_(zone) {} |
| 60 |
| 61 BytecodeLabel* New(); |
| 62 |
| 63 void Bind(BytecodeArrayBuilder* builder); |
| 64 |
| 65 private: |
| 66 ZoneVector<BytecodeLabel> labels_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(BytecodeLabels); |
| 69 }; |
| 70 |
| 52 } // namespace interpreter | 71 } // namespace interpreter |
| 53 } // namespace internal | 72 } // namespace internal |
| 54 } // namespace v8 | 73 } // namespace v8 |
| 55 | 74 |
| 56 #endif // V8_INTERPRETER_BYTECODE_LABEL_H_ | 75 #endif // V8_INTERPRETER_BYTECODE_LABEL_H_ |
| OLD | NEW |