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

Side by Side Diff: src/unique.h

Issue 23866016: Implement local check elimination on basic blocks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 array_[i] = uniq; 155 array_[i] = uniq;
156 size_++; 156 size_++;
157 return; 157 return;
158 } 158 }
159 } 159 }
160 // Append the element to the the end. 160 // Append the element to the the end.
161 Grow(size_ + 1, zone); 161 Grow(size_ + 1, zone);
162 array_[size_++] = uniq; 162 array_[size_++] = uniq;
163 } 163 }
164 164
165 // Remove an element from this set. Mutates this set. O(|this|)
166 void Remove(Unique<T> uniq) {
167 for (int i = 0; i < size_; i++) {
168 if (array_[i] == uniq) {
169 while (++i < size_) array_[i - 1] = array_[i];
170 size_--;
171 return;
172 }
173 }
174 }
175
165 // Compare this set against another set. O(|this|). 176 // Compare this set against another set. O(|this|).
166 bool Equals(UniqueSet<T>* that) const { 177 bool Equals(UniqueSet<T>* that) const {
167 if (that->size_ != this->size_) return false; 178 if (that->size_ != this->size_) return false;
168 for (int i = 0; i < this->size_; i++) { 179 for (int i = 0; i < this->size_; i++) {
169 if (this->array_[i] != that->array_[i]) return false; 180 if (this->array_[i] != that->array_[i]) return false;
170 } 181 }
171 return true; 182 return true;
172 } 183 }
173 184
174 template <typename U> 185 template <typename U>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Makes an exact copy of this set. O(|this| + |that|). 269 // Makes an exact copy of this set. O(|this| + |that|).
259 UniqueSet<T>* Copy(Zone* zone) const { 270 UniqueSet<T>* Copy(Zone* zone) const {
260 UniqueSet<T>* copy = new(zone) UniqueSet<T>(); 271 UniqueSet<T>* copy = new(zone) UniqueSet<T>();
261 copy->size_ = this->size_; 272 copy->size_ = this->size_;
262 copy->capacity_ = this->size_; 273 copy->capacity_ = this->size_;
263 copy->array_ = zone->NewArray<Unique<T> >(this->size_); 274 copy->array_ = zone->NewArray<Unique<T> >(this->size_);
264 memcpy(copy->array_, this->array_, this->size_ * sizeof(Unique<T>)); 275 memcpy(copy->array_, this->array_, this->size_ * sizeof(Unique<T>));
265 return copy; 276 return copy;
266 } 277 }
267 278
279 void Clear() {
280 size_ = 0;
281 }
282
268 inline int size() const { 283 inline int size() const {
269 return size_; 284 return size_;
270 } 285 }
271 286
272 inline Unique<T> at(int index) const { 287 inline Unique<T> at(int index) const {
273 ASSERT(index >= 0 && index < size_); 288 ASSERT(index >= 0 && index < size_);
274 return array_[index]; 289 return array_[index];
275 } 290 }
276 291
277 private: 292 private:
(...skipping 18 matching lines...) Expand all
296 capacity_ = new_capacity; 311 capacity_ = new_capacity;
297 array_ = new_array; 312 array_ = new_array;
298 } 313 }
299 } 314 }
300 }; 315 };
301 316
302 317
303 } } // namespace v8::internal 318 } } // namespace v8::internal
304 319
305 #endif // V8_HYDROGEN_UNIQUE_H_ 320 #endif // V8_HYDROGEN_UNIQUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698