Chromium Code Reviews| 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 } | 481 } |
| 482 | 482 |
| 483 void SetSpilledRegisters(LOperand** registers, | 483 void SetSpilledRegisters(LOperand** registers, |
| 484 LOperand** double_registers) { | 484 LOperand** double_registers) { |
| 485 spilled_registers_ = registers; | 485 spilled_registers_ = registers; |
| 486 spilled_double_registers_ = double_registers; | 486 spilled_double_registers_ = double_registers; |
| 487 } | 487 } |
| 488 | 488 |
| 489 void PrintTo(StringStream* stream); | 489 void PrintTo(StringStream* stream); |
| 490 | 490 |
| 491 class ShallowIterator BASE_EMBEDDED { | |
| 492 public: | |
| 493 explicit ShallowIterator(LEnvironment* env) : env_(env), current_(0) { | |
| 494 Advance(); | |
| 495 } | |
| 496 inline bool HasNext() { | |
| 497 return env_ != NULL && current_ < env_->values()->length(); | |
| 498 } | |
| 499 | |
| 500 inline LOperand* Next() { | |
| 501 ASSERT(env_ != NULL); | |
|
Kevin Millikin (Chromium)
2011/01/20 12:20:30
In normal use, should one ever call Next on an env
fschneider
2011/01/20 17:13:08
Done.
| |
| 502 LOperand* elem = HasNext() ? env_->values()->at(current_++) : NULL; | |
| 503 Advance(); | |
| 504 return elem; | |
| 505 } | |
| 506 | |
| 507 private: | |
| 508 inline void Advance() { | |
| 509 while (HasNext() && | |
| 510 (env_->values()->at(current_) == NULL || | |
| 511 env_->values()->at(current_)->IsConstantOperand())) { | |
| 512 current_++; | |
| 513 } | |
| 514 } | |
| 515 | |
| 516 LEnvironment* env_; | |
| 517 int current_; | |
| 518 }; | |
| 519 | |
| 520 // Iterates over the non-null, non-constant operands in this environment. | |
| 521 ShallowIterator shallow_iterator() { return ShallowIterator(this); } | |
|
Kevin Millikin (Chromium)
2011/01/20 12:20:30
This function (and deep_iterator) probably shouldn
fschneider
2011/01/20 17:13:08
Done.
| |
| 522 | |
| 523 class DeepIterator BASE_EMBEDDED { | |
| 524 public: | |
| 525 explicit DeepIterator(LEnvironment* env) | |
| 526 : current_env_(env), current_iterator_(env) { } | |
| 527 | |
| 528 inline bool HasNext() { | |
| 529 if (current_env_ == NULL) return false; | |
|
Kevin Millikin (Chromium)
2011/01/20 12:20:30
I think you can simplify this class's implementati
fschneider
2011/01/20 17:13:08
Done.
| |
| 530 if (current_iterator_.HasNext()) return true; | |
| 531 if (current_env_->outer() == NULL) return false; | |
| 532 Advance(); | |
| 533 return current_iterator_.HasNext(); | |
| 534 } | |
| 535 | |
| 536 inline LOperand* Next() { | |
|
Kevin Millikin (Chromium)
2011/01/20 12:20:30
inline LOperand* Next() {
ASSERT(current_iterato
fschneider
2011/01/20 17:13:08
Done.
| |
| 537 if (current_iterator_.HasNext()) return current_iterator_.Next(); | |
| 538 if (current_env_->outer() == NULL) return NULL; | |
| 539 Advance(); | |
| 540 return current_iterator_.Next(); | |
| 541 } | |
| 542 | |
| 543 private: | |
| 544 inline void Advance() { | |
|
Kevin Millikin (Chromium)
2011/01/20 12:20:30
inline void Advance() {
while (!current_iterator
fschneider
2011/01/20 17:13:08
Done.
| |
| 545 current_iterator_ = LEnvironment::ShallowIterator(current_env_->outer()); | |
| 546 current_env_ = current_env_->outer(); | |
| 547 } | |
| 548 | |
| 549 LEnvironment* current_env_; | |
| 550 ShallowIterator current_iterator_; | |
| 551 }; | |
| 552 | |
| 553 // Iterator for non-null, non-constant operands incl. outer environments. | |
| 554 DeepIterator deep_iterator() { return DeepIterator(this); } | |
| 555 | |
| 491 private: | 556 private: |
| 492 Handle<JSFunction> closure_; | 557 Handle<JSFunction> closure_; |
| 493 int arguments_stack_height_; | 558 int arguments_stack_height_; |
| 494 int deoptimization_index_; | 559 int deoptimization_index_; |
| 495 int translation_index_; | 560 int translation_index_; |
| 496 int ast_id_; | 561 int ast_id_; |
| 497 int parameter_count_; | 562 int parameter_count_; |
| 498 ZoneList<LOperand*> values_; | 563 ZoneList<LOperand*> values_; |
| 499 ZoneList<Representation> representations_; | 564 ZoneList<Representation> representations_; |
| 500 | 565 |
| 501 // Allocation index indexed arrays of spill slot operands for registers | 566 // Allocation index indexed arrays of spill slot operands for registers |
| 502 // that are also in spill slots at an OSR entry. NULL for environments | 567 // that are also in spill slots at an OSR entry. NULL for environments |
| 503 // that do not correspond to an OSR entry. | 568 // that do not correspond to an OSR entry. |
| 504 LOperand** spilled_registers_; | 569 LOperand** spilled_registers_; |
| 505 LOperand** spilled_double_registers_; | 570 LOperand** spilled_double_registers_; |
| 506 | 571 |
| 507 LEnvironment* outer_; | 572 LEnvironment* outer_; |
| 508 | 573 |
| 509 friend class LCodegen; | 574 friend class LCodegen; |
| 510 }; | 575 }; |
| 511 | 576 |
| 512 } } // namespace v8::internal | 577 } } // namespace v8::internal |
| 513 | 578 |
| 514 #endif // V8_LITHIUM_H_ | 579 #endif // V8_LITHIUM_H_ |
| OLD | NEW |