| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void EnsureReturn(); | 257 void EnsureReturn(); |
| 258 | 258 |
| 259 bool OperandIsValid(Bytecode bytecode, int operand_index, | 259 bool OperandIsValid(Bytecode bytecode, int operand_index, |
| 260 uint32_t operand_value) const; | 260 uint32_t operand_value) const; |
| 261 bool LastBytecodeInSameBlock() const; | 261 bool LastBytecodeInSameBlock() const; |
| 262 | 262 |
| 263 bool NeedToBooleanCast(); | 263 bool NeedToBooleanCast(); |
| 264 bool IsRegisterInAccumulator(Register reg); | 264 bool IsRegisterInAccumulator(Register reg); |
| 265 | 265 |
| 266 int BorrowTemporaryRegister(); | 266 int BorrowTemporaryRegister(); |
| 267 int BorrowTemporaryRegisterNotInRange(int start_index, int end_index); |
| 268 int AllocateAndBorrowTemporaryRegister(); |
| 267 void ReturnTemporaryRegister(int reg_index); | 269 void ReturnTemporaryRegister(int reg_index); |
| 268 int PrepareForConsecutiveTemporaryRegisters(size_t count); | 270 int PrepareForConsecutiveTemporaryRegisters(size_t count); |
| 269 void BorrowConsecutiveTemporaryRegister(int reg_index); | 271 void BorrowConsecutiveTemporaryRegister(int reg_index); |
| 270 bool TemporaryRegisterIsLive(Register reg) const; | 272 bool TemporaryRegisterIsLive(Register reg) const; |
| 271 | 273 |
| 272 Register first_temporary_register() const; | 274 Register first_temporary_register() const; |
| 273 Register last_temporary_register() const; | 275 Register last_temporary_register() const; |
| 274 | 276 |
| 275 Isolate* isolate_; | 277 Isolate* isolate_; |
| 276 Zone* zone_; | 278 Zone* zone_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 341 |
| 340 // A stack-allocated class than allows the instantiator to allocate | 342 // A stack-allocated class than allows the instantiator to allocate |
| 341 // temporary registers that are cleaned up when scope is closed. | 343 // temporary registers that are cleaned up when scope is closed. |
| 342 // TODO(oth): Deprecate TemporaryRegisterScope use. Code should be | 344 // TODO(oth): Deprecate TemporaryRegisterScope use. Code should be |
| 343 // using result scopes as far as possible. | 345 // using result scopes as far as possible. |
| 344 class TemporaryRegisterScope { | 346 class TemporaryRegisterScope { |
| 345 public: | 347 public: |
| 346 explicit TemporaryRegisterScope(BytecodeArrayBuilder* builder); | 348 explicit TemporaryRegisterScope(BytecodeArrayBuilder* builder); |
| 347 ~TemporaryRegisterScope(); | 349 ~TemporaryRegisterScope(); |
| 348 Register NewRegister(); | 350 Register NewRegister(); |
| 351 Register AllocateNewRegister(); |
| 349 | 352 |
| 350 void PrepareForConsecutiveAllocations(size_t count); | 353 void PrepareForConsecutiveAllocations(size_t count); |
| 351 Register NextConsecutiveRegister(); | 354 Register NextConsecutiveRegister(); |
| 352 | 355 |
| 353 bool RegisterIsAllocatedInThisScope(Register reg) const; | 356 bool RegisterIsAllocatedInThisScope(Register reg) const; |
| 354 | 357 |
| 358 bool hasConsecutiveAllocations() const { return next_consecutive_count_ > 0; } |
| 359 |
| 355 private: | 360 private: |
| 356 void* operator new(size_t size); | 361 void* operator new(size_t size); |
| 357 void operator delete(void* p); | 362 void operator delete(void* p); |
| 358 | 363 |
| 359 BytecodeArrayBuilder* builder_; | 364 BytecodeArrayBuilder* builder_; |
| 360 const TemporaryRegisterScope* outer_; | 365 const TemporaryRegisterScope* outer_; |
| 361 ZoneVector<int> allocated_; | 366 ZoneVector<int> allocated_; |
| 362 int next_consecutive_register_; | 367 int next_consecutive_register_; |
| 363 int next_consecutive_count_; | 368 int next_consecutive_count_; |
| 364 | 369 |
| 365 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 370 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
| 366 }; | 371 }; |
| 367 | 372 |
| 368 | 373 |
| 369 } // namespace interpreter | 374 } // namespace interpreter |
| 370 } // namespace internal | 375 } // namespace internal |
| 371 } // namespace v8 | 376 } // namespace v8 |
| 372 | 377 |
| 373 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 378 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |