Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1507)

Unified Diff: src/lithium.h

Issue 6993023: Fix a bug in Lithium environment iteration. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added x64 and ARM files. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/lithium-allocator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lithium.h
diff --git a/src/lithium.h b/src/lithium.h
index a3e574d89e32c656c8db7bafef090ea57dfc37d2..ea023a980b86fb228d93d1758a26398919dcc58a 100644
--- a/src/lithium.h
+++ b/src/lithium.h
@@ -518,34 +518,34 @@ class ShallowIterator BASE_EMBEDDED {
: env_(env),
limit_(env != NULL ? env->values()->length() : 0),
current_(0) {
- current_ = AdvanceToNext(0);
+ SkipUninteresting();
}
- inline bool HasNext() {
- return env_ != NULL && current_ < limit_;
- }
+ bool Done() { return current_ >= limit_; }
- inline LOperand* Next() {
- ASSERT(HasNext());
+ LOperand* Current() {
+ ASSERT(!Done());
return env_->values()->at(current_);
}
- inline void Advance() {
- current_ = AdvanceToNext(current_ + 1);
+ void Advance() {
+ ASSERT(!Done());
+ ++current_;
+ SkipUninteresting();
}
- inline LEnvironment* env() { return env_; }
+ LEnvironment* env() { return env_; }
private:
- inline bool ShouldSkip(LOperand* op) {
+ bool ShouldSkip(LOperand* op) {
return op == NULL || op->IsConstantOperand() || op->IsArgument();
}
- inline int AdvanceToNext(int start) {
- while (start < limit_ && ShouldSkip(env_->values()->at(start))) {
- start++;
+ // Skip until something interesting, beginning with and including current_.
+ void SkipUninteresting() {
+ while (current_ < limit_ && ShouldSkip(env_->values()->at(current_))) {
+ ++current_;
}
- return start;
}
LEnvironment* env_;
@@ -558,31 +558,27 @@ class ShallowIterator BASE_EMBEDDED {
class DeepIterator BASE_EMBEDDED {
public:
explicit DeepIterator(LEnvironment* env)
- : current_iterator_(env) { }
-
- inline bool HasNext() {
- if (current_iterator_.HasNext()) return true;
- if (current_iterator_.env() == NULL) return false;
- AdvanceToOuter();
- return current_iterator_.HasNext();
+ : current_iterator_(env) {
+ SkipUninteresting();
}
- inline LOperand* Next() {
- ASSERT(current_iterator_.HasNext());
- return current_iterator_.Next();
+ bool Done() { return current_iterator_.Done(); }
+
+ LOperand* Current() {
+ ASSERT(!current_iterator_.Done());
+ return current_iterator_.Current();
}
- inline void Advance() {
- if (current_iterator_.HasNext()) {
- current_iterator_.Advance();
- } else {
- AdvanceToOuter();
- }
+ void Advance() {
+ current_iterator_.Advance();
+ SkipUninteresting();
}
private:
- inline void AdvanceToOuter() {
- current_iterator_ = ShallowIterator(current_iterator_.env()->outer());
+ void SkipUninteresting() {
+ while (current_iterator_.env() != NULL && current_iterator_.Done()) {
+ current_iterator_ = ShallowIterator(current_iterator_.env()->outer());
+ }
}
ShallowIterator current_iterator_;
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/lithium-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698