| 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_ARRAY_BUILDER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "src/ast.h" | 10 #include "src/ast.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 | 282 |
| 283 // A label representing a branch target in a bytecode array. When a | 283 // A label representing a branch target in a bytecode array. When a |
| 284 // label is bound, it represents a known position in the bytecode | 284 // label is bound, it represents a known position in the bytecode |
| 285 // array. For labels that are forward references there can be at most | 285 // array. For labels that are forward references there can be at most |
| 286 // one reference whilst it is unbound. | 286 // one reference whilst it is unbound. |
| 287 class BytecodeLabel final { | 287 class BytecodeLabel final { |
| 288 public: | 288 public: |
| 289 BytecodeLabel() : bound_(false), offset_(kInvalidOffset) {} | 289 BytecodeLabel() : bound_(false), offset_(kInvalidOffset) {} |
| 290 | 290 |
| 291 INLINE(bool is_bound() const) { return bound_; } |
| 292 |
| 291 private: | 293 private: |
| 292 static const size_t kInvalidOffset = static_cast<size_t>(-1); | 294 static const size_t kInvalidOffset = static_cast<size_t>(-1); |
| 293 | 295 |
| 294 INLINE(void bind_to(size_t offset)) { | 296 INLINE(void bind_to(size_t offset)) { |
| 295 DCHECK(!bound_ && offset != kInvalidOffset); | 297 DCHECK(!bound_ && offset != kInvalidOffset); |
| 296 offset_ = offset; | 298 offset_ = offset; |
| 297 bound_ = true; | 299 bound_ = true; |
| 298 } | 300 } |
| 299 INLINE(void set_referrer(size_t offset)) { | 301 INLINE(void set_referrer(size_t offset)) { |
| 300 DCHECK(!bound_ && offset != kInvalidOffset && offset_ == kInvalidOffset); | 302 DCHECK(!bound_ && offset != kInvalidOffset && offset_ == kInvalidOffset); |
| 301 offset_ = offset; | 303 offset_ = offset; |
| 302 } | 304 } |
| 303 INLINE(size_t offset() const) { return offset_; } | 305 INLINE(size_t offset() const) { return offset_; } |
| 304 INLINE(bool is_bound() const) { return bound_; } | |
| 305 INLINE(bool is_forward_target() const) { | 306 INLINE(bool is_forward_target() const) { |
| 306 return offset() != kInvalidOffset && !is_bound(); | 307 return offset() != kInvalidOffset && !is_bound(); |
| 307 } | 308 } |
| 308 | 309 |
| 309 // There are three states for a label: | 310 // There are three states for a label: |
| 310 // bound_ offset_ | 311 // bound_ offset_ |
| 311 // UNSET false kInvalidOffset | 312 // UNSET false kInvalidOffset |
| 312 // FORWARD_TARGET false Offset of referring jump | 313 // FORWARD_TARGET false Offset of referring jump |
| 313 // BACKWARD_TARGET true Offset of label in bytecode array when bound | 314 // BACKWARD_TARGET true Offset of label in bytecode array when bound |
| 314 bool bound_; | 315 bool bound_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 345 | 346 |
| 346 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 347 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
| 347 }; | 348 }; |
| 348 | 349 |
| 349 | 350 |
| 350 } // namespace interpreter | 351 } // namespace interpreter |
| 351 } // namespace internal | 352 } // namespace internal |
| 352 } // namespace v8 | 353 } // namespace v8 |
| 353 | 354 |
| 354 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 355 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |