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/types.cc

Issue 230893002: Fix symmetry of Maybe predicate Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Style Created 6 years, 8 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 | « no previous file | test/cctest/test-types.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "types.h" 5 #include "types.h"
6 6
7 #include "string-stream.h" 7 #include "string-stream.h"
8 #include "types-inl.h" 8 #include "types-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (*it.Current() == *map) return true; 313 if (*it.Current() == *map) return true;
314 } 314 }
315 } 315 }
316 return false; 316 return false;
317 } 317 }
318 318
319 319
320 // Check this overlaps that. 320 // Check this overlaps that.
321 template<class Config> 321 template<class Config>
322 bool TypeImpl<Config>::Maybe(TypeImpl* that) { 322 bool TypeImpl<Config>::Maybe(TypeImpl* that) {
323 // Fast path for bitsets.
324 if (this->IsBitset()) {
325 return IsInhabited(this->AsBitset() & that->LubBitset());
326 }
327 if (that->IsBitset()) {
328 return IsInhabited(this->LubBitset() & that->AsBitset());
329 }
330
331 // (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T) 323 // (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T)
332 if (this->IsUnion()) { 324 if (this->IsUnion()) {
333 StructHandle unioned = this->AsUnion(); 325 StructHandle unioned = this->AsUnion();
334 for (int i = 0; i < Config::struct_length(unioned); ++i) { 326 for (int i = 0; i < Config::struct_length(unioned); ++i) {
335 TypeHandle this_i = Config::struct_get(unioned, i); 327 TypeHandle this_i = Config::struct_get(unioned, i);
336 if (this_i->Maybe(that)) return true; 328 if (this_i->Maybe(that)) return true;
337 } 329 }
338 return false; 330 return false;
339 } 331 }
340 332
341 // T overlaps (T1 \/ ... \/ Tn) <=> (T overlaps T1) \/ ... \/ (T overlaps Tn) 333 // T overlaps (T1 \/ ... \/ Tn) <=> (T overlaps T1) \/ ... \/ (T overlaps Tn)
342 if (that->IsUnion()) { 334 if (that->IsUnion()) {
343 StructHandle unioned = that->AsUnion(); 335 StructHandle unioned = that->AsUnion();
344 for (int i = 0; i < Config::struct_length(unioned); ++i) { 336 for (int i = 0; i < Config::struct_length(unioned); ++i) {
345 TypeHandle that_i = Config::struct_get(unioned, i); 337 TypeHandle that_i = Config::struct_get(unioned, i);
346 if (this->Maybe(that_i)) return true; 338 if (this->Maybe(that_i)) return true;
347 } 339 }
348 return false; 340 return false;
349 } 341 }
350 342
351 ASSERT(!this->IsUnion() && !that->IsUnion()); 343 ASSERT(!this->IsUnion() && !that->IsUnion());
344 if (this->IsBitset()) {
345 return IsInhabited(this->AsBitset() & that->LubBitset());
346 }
347 if (that->IsBitset()) {
348 return IsInhabited(this->LubBitset() & that->AsBitset());
349 }
350
352 if (this->IsClass()) { 351 if (this->IsClass()) {
353 return that->IsClass() && *this->AsClass() == *that->AsClass(); 352 return that->IsClass() && *this->AsClass() == *that->AsClass();
354 } 353 }
355 if (this->IsConstant()) { 354 if (this->IsConstant()) {
356 return that->IsConstant() && *this->AsConstant() == *that->AsConstant(); 355 return that->IsConstant() && *this->AsConstant() == *that->AsConstant();
357 } 356 }
358 357
359 return false; 358 return false;
360 } 359 }
361 360
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; 680 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
682 681
683 template TypeImpl<ZoneTypeConfig>::TypeHandle 682 template TypeImpl<ZoneTypeConfig>::TypeHandle
684 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( 683 TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
685 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); 684 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
686 template TypeImpl<HeapTypeConfig>::TypeHandle 685 template TypeImpl<HeapTypeConfig>::TypeHandle
687 TypeImpl<HeapTypeConfig>::Convert<Type>( 686 TypeImpl<HeapTypeConfig>::Convert<Type>(
688 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); 687 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
689 688
690 } } // namespace v8::internal 689 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698