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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 bool LastBytecodeInSameBlock() const; | 299 bool LastBytecodeInSameBlock() const; |
300 | 300 |
301 bool NeedToBooleanCast(); | 301 bool NeedToBooleanCast(); |
302 bool IsRegisterInAccumulator(Register reg); | 302 bool IsRegisterInAccumulator(Register reg); |
303 | 303 |
304 bool RegisterIsValid(Register reg) const; | 304 bool RegisterIsValid(Register reg) const; |
305 | 305 |
306 // Temporary register management. | 306 // Temporary register management. |
307 int BorrowTemporaryRegister(); | 307 int BorrowTemporaryRegister(); |
308 int BorrowTemporaryRegisterNotInRange(int start_index, int end_index); | 308 int BorrowTemporaryRegisterNotInRange(int start_index, int end_index); |
309 int AllocateAndBorrowTemporaryRegister(); | |
310 void ReturnTemporaryRegister(int reg_index); | 309 void ReturnTemporaryRegister(int reg_index); |
311 int PrepareForConsecutiveTemporaryRegisters(size_t count); | 310 int PrepareForConsecutiveTemporaryRegisters(size_t count); |
312 void BorrowConsecutiveTemporaryRegister(int reg_index); | 311 void BorrowConsecutiveTemporaryRegister(int reg_index); |
313 bool TemporaryRegisterIsLive(Register reg) const; | 312 bool TemporaryRegisterIsLive(Register reg) const; |
314 | 313 |
315 Register first_temporary_register() const; | 314 Register first_temporary_register() const; |
316 Register last_temporary_register() const; | 315 Register last_temporary_register() const; |
317 | 316 |
318 // Gets a constant pool entry for the |object|. | 317 // Gets a constant pool entry for the |object|. |
319 size_t GetConstantPoolEntry(Handle<Object> object); | 318 size_t GetConstantPoolEntry(Handle<Object> object); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 382 |
384 // A stack-allocated class than allows the instantiator to allocate | 383 // A stack-allocated class than allows the instantiator to allocate |
385 // temporary registers that are cleaned up when scope is closed. | 384 // temporary registers that are cleaned up when scope is closed. |
386 // TODO(oth): Deprecate TemporaryRegisterScope use. Code should be | 385 // TODO(oth): Deprecate TemporaryRegisterScope use. Code should be |
387 // using result scopes as far as possible. | 386 // using result scopes as far as possible. |
388 class TemporaryRegisterScope { | 387 class TemporaryRegisterScope { |
389 public: | 388 public: |
390 explicit TemporaryRegisterScope(BytecodeArrayBuilder* builder); | 389 explicit TemporaryRegisterScope(BytecodeArrayBuilder* builder); |
391 ~TemporaryRegisterScope(); | 390 ~TemporaryRegisterScope(); |
392 Register NewRegister(); | 391 Register NewRegister(); |
393 Register AllocateNewRegister(); | |
394 | 392 |
395 void PrepareForConsecutiveAllocations(size_t count); | 393 void PrepareForConsecutiveAllocations(size_t count); |
396 Register NextConsecutiveRegister(); | 394 Register NextConsecutiveRegister(); |
397 | 395 |
398 bool RegisterIsAllocatedInThisScope(Register reg) const; | 396 bool RegisterIsAllocatedInThisScope(Register reg) const; |
399 | 397 |
400 bool hasConsecutiveAllocations() const { return next_consecutive_count_ > 0; } | 398 bool hasConsecutiveAllocations() const { return next_consecutive_count_ > 0; } |
401 | 399 |
402 private: | 400 private: |
403 void* operator new(size_t size); | 401 void* operator new(size_t size); |
404 void operator delete(void* p); | 402 void operator delete(void* p); |
405 | 403 |
406 BytecodeArrayBuilder* builder_; | 404 BytecodeArrayBuilder* builder_; |
407 const TemporaryRegisterScope* outer_; | 405 const TemporaryRegisterScope* outer_; |
408 ZoneVector<int> allocated_; | 406 ZoneVector<int> allocated_; |
409 int next_consecutive_register_; | 407 int next_consecutive_register_; |
410 int next_consecutive_count_; | 408 int next_consecutive_count_; |
411 | 409 |
412 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 410 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
413 }; | 411 }; |
414 | 412 |
415 | 413 |
416 } // namespace interpreter | 414 } // namespace interpreter |
417 } // namespace internal | 415 } // namespace internal |
418 } // namespace v8 | 416 } // namespace v8 |
419 | 417 |
420 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 418 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |