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 "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/interpreter/bytecodes.h" | 9 #include "src/interpreter/bytecodes.h" |
10 #include "src/interpreter/constant-array-builder.h" | 10 #include "src/interpreter/constant-array-builder.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 bool exit_seen_in_block_; | 327 bool exit_seen_in_block_; |
328 int unbound_jumps_; | 328 int unbound_jumps_; |
329 | 329 |
330 int parameter_count_; | 330 int parameter_count_; |
331 int local_register_count_; | 331 int local_register_count_; |
332 int context_register_count_; | 332 int context_register_count_; |
333 int temporary_register_count_; | 333 int temporary_register_count_; |
334 ZoneSet<int> free_temporaries_; | 334 ZoneSet<int> free_temporaries_; |
335 | 335 |
336 class PreviousBytecodeHelper; | 336 class PreviousBytecodeHelper; |
337 friend class TemporaryRegisterScope; | 337 friend class BytecodeRegisterAllocator; |
| 338 |
338 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); | 339 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); |
339 }; | 340 }; |
340 | 341 |
341 | 342 |
342 // A label representing a branch target in a bytecode array. When a | 343 // A label representing a branch target in a bytecode array. When a |
343 // label is bound, it represents a known position in the bytecode | 344 // label is bound, it represents a known position in the bytecode |
344 // array. For labels that are forward references there can be at most | 345 // array. For labels that are forward references there can be at most |
345 // one reference whilst it is unbound. | 346 // one reference whilst it is unbound. |
346 class BytecodeLabel final { | 347 class BytecodeLabel final { |
347 public: | 348 public: |
(...skipping 24 matching lines...) Expand all Loading... |
372 // bound_ offset_ | 373 // bound_ offset_ |
373 // UNSET false kInvalidOffset | 374 // UNSET false kInvalidOffset |
374 // FORWARD_TARGET false Offset of referring jump | 375 // FORWARD_TARGET false Offset of referring jump |
375 // BACKWARD_TARGET true Offset of label in bytecode array when bound | 376 // BACKWARD_TARGET true Offset of label in bytecode array when bound |
376 bool bound_; | 377 bool bound_; |
377 size_t offset_; | 378 size_t offset_; |
378 | 379 |
379 friend class BytecodeArrayBuilder; | 380 friend class BytecodeArrayBuilder; |
380 }; | 381 }; |
381 | 382 |
382 | |
383 // A stack-allocated class than allows the instantiator to allocate | |
384 // temporary registers that are cleaned up when scope is closed. | |
385 // TODO(oth): Deprecate TemporaryRegisterScope use. Code should be | |
386 // using result scopes as far as possible. | |
387 class TemporaryRegisterScope { | |
388 public: | |
389 explicit TemporaryRegisterScope(BytecodeArrayBuilder* builder); | |
390 ~TemporaryRegisterScope(); | |
391 Register NewRegister(); | |
392 | |
393 void PrepareForConsecutiveAllocations(size_t count); | |
394 Register NextConsecutiveRegister(); | |
395 | |
396 bool RegisterIsAllocatedInThisScope(Register reg) const; | |
397 | |
398 bool hasConsecutiveAllocations() const { return next_consecutive_count_ > 0; } | |
399 | |
400 private: | |
401 void* operator new(size_t size); | |
402 void operator delete(void* p); | |
403 | |
404 BytecodeArrayBuilder* builder_; | |
405 const TemporaryRegisterScope* outer_; | |
406 ZoneVector<int> allocated_; | |
407 int next_consecutive_register_; | |
408 int next_consecutive_count_; | |
409 | |
410 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | |
411 }; | |
412 | |
413 | |
414 } // namespace interpreter | 383 } // namespace interpreter |
415 } // namespace internal | 384 } // namespace internal |
416 } // namespace v8 | 385 } // namespace v8 |
417 | 386 |
418 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 387 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |