OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // that are also in spill slots at an OSR entry. NULL for environments | 502 // that are also in spill slots at an OSR entry. NULL for environments |
503 // that do not correspond to an OSR entry. | 503 // that do not correspond to an OSR entry. |
504 LOperand** spilled_registers_; | 504 LOperand** spilled_registers_; |
505 LOperand** spilled_double_registers_; | 505 LOperand** spilled_double_registers_; |
506 | 506 |
507 LEnvironment* outer_; | 507 LEnvironment* outer_; |
508 | 508 |
509 friend class LCodegen; | 509 friend class LCodegen; |
510 }; | 510 }; |
511 | 511 |
| 512 |
| 513 // Iterates over the non-null, non-constant operands in an environment. |
| 514 class ShallowIterator BASE_EMBEDDED { |
| 515 public: |
| 516 explicit ShallowIterator(LEnvironment* env) |
| 517 : env_(env), |
| 518 limit_(env != NULL ? env->values()->length() : 0), |
| 519 current_(0) { |
| 520 current_ = AdvanceToNext(0); |
| 521 } |
| 522 |
| 523 inline bool HasNext() { |
| 524 return env_ != NULL && current_ < limit_; |
| 525 } |
| 526 |
| 527 inline LOperand* Next() { |
| 528 ASSERT(HasNext()); |
| 529 return env_->values()->at(current_); |
| 530 } |
| 531 |
| 532 inline void Advance() { |
| 533 current_ = AdvanceToNext(current_ + 1); |
| 534 } |
| 535 |
| 536 inline LEnvironment* env() { return env_; } |
| 537 |
| 538 private: |
| 539 inline int AdvanceToNext(int start) { |
| 540 while (start < limit_ && |
| 541 (env_->values()->at(start) == NULL || |
| 542 env_->values()->at(start)->IsConstantOperand())) { |
| 543 start++; |
| 544 } |
| 545 return start; |
| 546 } |
| 547 |
| 548 LEnvironment* env_; |
| 549 int limit_; |
| 550 int current_; |
| 551 }; |
| 552 |
| 553 |
| 554 // Iterator for non-null, non-constant operands incl. outer environments. |
| 555 class DeepIterator BASE_EMBEDDED { |
| 556 public: |
| 557 explicit DeepIterator(LEnvironment* env) |
| 558 : current_iterator_(env) { } |
| 559 |
| 560 inline bool HasNext() { |
| 561 if (current_iterator_.HasNext()) return true; |
| 562 if (current_iterator_.env() == NULL) return false; |
| 563 AdvanceToOuter(); |
| 564 return current_iterator_.HasNext(); |
| 565 } |
| 566 |
| 567 inline LOperand* Next() { |
| 568 ASSERT(current_iterator_.HasNext()); |
| 569 return current_iterator_.Next(); |
| 570 } |
| 571 |
| 572 inline void Advance() { |
| 573 if (current_iterator_.HasNext()) { |
| 574 current_iterator_.Advance(); |
| 575 } else { |
| 576 AdvanceToOuter(); |
| 577 } |
| 578 } |
| 579 |
| 580 private: |
| 581 inline void AdvanceToOuter() { |
| 582 current_iterator_ = ShallowIterator(current_iterator_.env()->outer()); |
| 583 } |
| 584 |
| 585 ShallowIterator current_iterator_; |
| 586 }; |
| 587 |
512 } } // namespace v8::internal | 588 } } // namespace v8::internal |
513 | 589 |
514 #endif // V8_LITHIUM_H_ | 590 #endif // V8_LITHIUM_H_ |
OLD | NEW |