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

Side by Side Diff: src/unique.h

Issue 300423003: Handle HCheckInstanceType and HIsStringAndBranch in check elimination. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 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/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HYDROGEN_UNIQUE_H_ 5 #ifndef V8_HYDROGEN_UNIQUE_H_
6 #define V8_HYDROGEN_UNIQUE_H_ 6 #define V8_HYDROGEN_UNIQUE_H_
7 7
8 #include "handles.h" 8 #include "handles.h"
9 #include "objects.h" 9 #include "objects.h"
10 #include "utils.h" 10 #include "utils.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 } 269 }
270 270
271 while (i < this->size_) out->array_[k++] = this->array_[i++]; 271 while (i < this->size_) out->array_[k++] = this->array_[i++];
272 while (j < that->size_) out->array_[k++] = that->array_[j++]; 272 while (j < that->size_) out->array_[k++] = that->array_[j++];
273 273
274 out->size_ = k; 274 out->size_ = k;
275 return out; 275 return out;
276 } 276 }
277 277
278 // Returns a new set representing all elements from this set which are not in
279 // that set. O(|this| * |that|).
280 UniqueSet<T>* Subtract(const UniqueSet<T>* that, Zone* zone) const {
281 if (that->size_ == 0) return this->Copy(zone);
282
283 UniqueSet<T>* out = new(zone) UniqueSet<T>(this->size_, zone);
284
285 int i = 0, j = 0;
286 while (i < this->size_) {
287 Unique<T> cand = this->array_[i];
288 if (!that->Contains(cand)) {
289 out->array_[j++] = cand;
290 }
291 }
292
293 out->size_ = j;
294 return out;
295 }
296
278 // Makes an exact copy of this set. O(|this|). 297 // Makes an exact copy of this set. O(|this|).
279 UniqueSet<T>* Copy(Zone* zone) const { 298 UniqueSet<T>* Copy(Zone* zone) const {
280 UniqueSet<T>* copy = new(zone) UniqueSet<T>(this->size_, zone); 299 UniqueSet<T>* copy = new(zone) UniqueSet<T>(this->size_, zone);
281 copy->size_ = this->size_; 300 copy->size_ = this->size_;
282 memcpy(copy->array_, this->array_, this->size_ * sizeof(Unique<T>)); 301 memcpy(copy->array_, this->array_, this->size_ * sizeof(Unique<T>));
283 return copy; 302 return copy;
284 } 303 }
285 304
286 void Clear() { 305 void Clear() {
287 size_ = 0; 306 size_ = 0;
(...skipping 30 matching lines...) Expand all
318 capacity_ = new_capacity; 337 capacity_ = new_capacity;
319 array_ = new_array; 338 array_ = new_array;
320 } 339 }
321 } 340 }
322 }; 341 };
323 342
324 343
325 } } // namespace v8::internal 344 } } // namespace v8::internal
326 345
327 #endif // V8_HYDROGEN_UNIQUE_H_ 346 #endif // V8_HYDROGEN_UNIQUE_H_
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698