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

Side by Side Diff: src/lithium-allocator-inl.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/lithium-allocator.cc ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 LGap* LAllocator::GapAt(int index) { 56 LGap* LAllocator::GapAt(int index) {
57 return chunk_->GetGapAt(index); 57 return chunk_->GetGapAt(index);
58 } 58 }
59 59
60 60
61 TempIterator::TempIterator(LInstruction* instr) 61 TempIterator::TempIterator(LInstruction* instr)
62 : instr_(instr), 62 : instr_(instr),
63 limit_(instr->TempCount()), 63 limit_(instr->TempCount()),
64 current_(0) { 64 current_(0) {
65 current_ = AdvanceToNext(0); 65 SkipUninteresting();
66 } 66 }
67 67
68 68
69 bool TempIterator::HasNext() { return current_ < limit_; } 69 bool TempIterator::Done() { return current_ >= limit_; }
70 70
71 71
72 LOperand* TempIterator::Next() { 72 LOperand* TempIterator::Current() {
73 ASSERT(HasNext()); 73 ASSERT(!Done());
74 return instr_->TempAt(current_); 74 return instr_->TempAt(current_);
75 } 75 }
76 76
77 77
78 int TempIterator::AdvanceToNext(int start) { 78 void TempIterator::SkipUninteresting() {
79 while (start < limit_ && instr_->TempAt(start) == NULL) start++; 79 while (current_ < limit_ && instr_->TempAt(current_) == NULL) ++current_;
80 return start;
81 } 80 }
82 81
83 82
84 void TempIterator::Advance() { 83 void TempIterator::Advance() {
85 current_ = AdvanceToNext(current_ + 1); 84 ++current_;
85 SkipUninteresting();
86 } 86 }
87 87
88 88
89 InputIterator::InputIterator(LInstruction* instr) 89 InputIterator::InputIterator(LInstruction* instr)
90 : instr_(instr), 90 : instr_(instr),
91 limit_(instr->InputCount()), 91 limit_(instr->InputCount()),
92 current_(0) { 92 current_(0) {
93 current_ = AdvanceToNext(0); 93 SkipUninteresting();
94 } 94 }
95 95
96 96
97 bool InputIterator::HasNext() { return current_ < limit_; } 97 bool InputIterator::Done() { return current_ >= limit_; }
98 98
99 99
100 LOperand* InputIterator::Next() { 100 LOperand* InputIterator::Current() {
101 ASSERT(HasNext()); 101 ASSERT(!Done());
102 return instr_->InputAt(current_); 102 return instr_->InputAt(current_);
103 } 103 }
104 104
105 105
106 void InputIterator::Advance() { 106 void InputIterator::Advance() {
107 current_ = AdvanceToNext(current_ + 1); 107 ++current_;
108 SkipUninteresting();
108 } 109 }
109 110
110 111
111 int InputIterator::AdvanceToNext(int start) { 112 void InputIterator::SkipUninteresting() {
112 while (start < limit_ && instr_->InputAt(start)->IsConstantOperand()) start++; 113 while (current_ < limit_ && instr_->InputAt(current_)->IsConstantOperand()) {
113 return start; 114 ++current_;
115 }
114 } 116 }
115 117
116 118
117 UseIterator::UseIterator(LInstruction* instr) 119 UseIterator::UseIterator(LInstruction* instr)
118 : input_iterator_(instr), env_iterator_(instr->environment()) { } 120 : input_iterator_(instr), env_iterator_(instr->environment()) { }
119 121
120 122
121 bool UseIterator::HasNext() { 123 bool UseIterator::Done() {
122 return input_iterator_.HasNext() || env_iterator_.HasNext(); 124 return input_iterator_.Done() && env_iterator_.Done();
123 } 125 }
124 126
125 127
126 LOperand* UseIterator::Next() { 128 LOperand* UseIterator::Current() {
127 ASSERT(HasNext()); 129 ASSERT(!Done());
128 return input_iterator_.HasNext() 130 return input_iterator_.Done()
129 ? input_iterator_.Next() 131 ? env_iterator_.Current()
130 : env_iterator_.Next(); 132 : input_iterator_.Current();
131 } 133 }
132 134
133 135
134 void UseIterator::Advance() { 136 void UseIterator::Advance() {
135 input_iterator_.HasNext() 137 input_iterator_.Done()
136 ? input_iterator_.Advance() 138 ? env_iterator_.Advance()
137 : env_iterator_.Advance(); 139 : input_iterator_.Advance();
138 } 140 }
139 141
140 } } // namespace v8::internal 142 } } // namespace v8::internal
141 143
142 #endif // V8_LITHIUM_ALLOCATOR_INL_H_ 144 #endif // V8_LITHIUM_ALLOCATOR_INL_H_
OLDNEW
« no previous file with comments | « src/lithium-allocator.cc ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698