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/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 | 298 |
299 // A label representing a branch target in a bytecode array. When a | 299 // A label representing a branch target in a bytecode array. When a |
300 // label is bound, it represents a known position in the bytecode | 300 // label is bound, it represents a known position in the bytecode |
301 // array. For labels that are forward references there can be at most | 301 // array. For labels that are forward references there can be at most |
302 // one reference whilst it is unbound. | 302 // one reference whilst it is unbound. |
303 class BytecodeLabel final { | 303 class BytecodeLabel final { |
304 public: | 304 public: |
305 BytecodeLabel() : bound_(false), offset_(kInvalidOffset) {} | 305 BytecodeLabel() : bound_(false), offset_(kInvalidOffset) {} |
306 | 306 |
307 INLINE(bool is_bound() const) { return bound_; } | 307 bool is_bound() const { return bound_; } |
| 308 size_t offset() const { return offset_; } |
308 | 309 |
309 private: | 310 private: |
310 static const size_t kInvalidOffset = static_cast<size_t>(-1); | 311 static const size_t kInvalidOffset = static_cast<size_t>(-1); |
311 | 312 |
312 INLINE(void bind_to(size_t offset)) { | 313 void bind_to(size_t offset) { |
313 DCHECK(!bound_ && offset != kInvalidOffset); | 314 DCHECK(!bound_ && offset != kInvalidOffset); |
314 offset_ = offset; | 315 offset_ = offset; |
315 bound_ = true; | 316 bound_ = true; |
316 } | 317 } |
317 INLINE(void set_referrer(size_t offset)) { | 318 |
| 319 void set_referrer(size_t offset) { |
318 DCHECK(!bound_ && offset != kInvalidOffset && offset_ == kInvalidOffset); | 320 DCHECK(!bound_ && offset != kInvalidOffset && offset_ == kInvalidOffset); |
319 offset_ = offset; | 321 offset_ = offset; |
320 } | 322 } |
321 INLINE(size_t offset() const) { return offset_; } | 323 |
322 INLINE(bool is_forward_target() const) { | 324 bool is_forward_target() const { |
323 return offset() != kInvalidOffset && !is_bound(); | 325 return offset() != kInvalidOffset && !is_bound(); |
324 } | 326 } |
325 | 327 |
326 // There are three states for a label: | 328 // There are three states for a label: |
327 // bound_ offset_ | 329 // bound_ offset_ |
328 // UNSET false kInvalidOffset | 330 // UNSET false kInvalidOffset |
329 // FORWARD_TARGET false Offset of referring jump | 331 // FORWARD_TARGET false Offset of referring jump |
330 // BACKWARD_TARGET true Offset of label in bytecode array when bound | 332 // BACKWARD_TARGET true Offset of label in bytecode array when bound |
331 bool bound_; | 333 bool bound_; |
332 size_t offset_; | 334 size_t offset_; |
(...skipping 29 matching lines...) Expand all Loading... |
362 | 364 |
363 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 365 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
364 }; | 366 }; |
365 | 367 |
366 | 368 |
367 } // namespace interpreter | 369 } // namespace interpreter |
368 } // namespace internal | 370 } // namespace internal |
369 } // namespace v8 | 371 } // namespace v8 |
370 | 372 |
371 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 373 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |