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

Side by Side Diff: src/types.cc

Issue 219523003: Provide Type::Contains methods. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Allow raw pointers 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 | « src/types.h ('k') | src/typing.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 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // All but the first are non-bitsets and thus would yield kNone anyway. 264 // All but the first are non-bitsets and thus would yield kNone anyway.
265 return Config::union_get(this->AsUnion(), 0)->GlbBitset(); 265 return Config::union_get(this->AsUnion(), 0)->GlbBitset();
266 } else { 266 } else {
267 return kNone; 267 return kNone;
268 } 268 }
269 } 269 }
270 270
271 271
272 // Most precise _current_ type of a value (usually its class). 272 // Most precise _current_ type of a value (usually its class).
273 template<class Config> 273 template<class Config>
274 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::OfCurrently( 274 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf(
275 i::Handle<i::Object> value, Region* region) { 275 i::Handle<i::Object> value, Region* region) {
276 if (value->IsSmi() || 276 if (value->IsSmi() ||
277 i::HeapObject::cast(*value)->map()->instance_type() == HEAP_NUMBER_TYPE || 277 i::HeapObject::cast(*value)->map()->instance_type() == HEAP_NUMBER_TYPE ||
278 i::HeapObject::cast(*value)->map()->instance_type() == ODDBALL_TYPE) { 278 i::HeapObject::cast(*value)->map()->instance_type() == ODDBALL_TYPE) {
279 return Of(value, region); 279 return Of(value, region);
280 } 280 }
281 return Class(i::handle(i::HeapObject::cast(*value)->map()), region); 281 return Class(i::handle(i::HeapObject::cast(*value)->map()), region);
282 } 282 }
283 283
284 284
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (this->IsBitset()) break; // Fast fail, only first field is a bitset. 319 if (this->IsBitset()) break; // Fast fail, only first field is a bitset.
320 } 320 }
321 return false; 321 return false;
322 } 322 }
323 323
324 return false; 324 return false;
325 } 325 }
326 326
327 327
328 template<class Config> 328 template<class Config>
329 bool TypeImpl<Config>::IsCurrently(TypeImpl* that) { 329 bool TypeImpl<Config>::NowIs(TypeImpl* that) {
330 return this->Is(that) || 330 return this->Is(that) ||
331 (this->IsConstant() && that->IsClass() && 331 (this->IsConstant() && that->IsClass() &&
332 this->AsConstant()->IsHeapObject() && 332 this->AsConstant()->IsHeapObject() &&
333 i::HeapObject::cast(*this->AsConstant())->map() == *that->AsClass()); 333 i::HeapObject::cast(*this->AsConstant())->map() == *that->AsClass());
334 } 334 }
335 335
336 336
337 // Check this overlaps that. 337 // Check this overlaps that.
338 template<class Config> 338 template<class Config>
339 bool TypeImpl<Config>::Maybe(TypeImpl* that) { 339 bool TypeImpl<Config>::Maybe(TypeImpl* that) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 if (this->IsConstant()) { 372 if (this->IsConstant()) {
373 return that->IsConstant() && *this->AsConstant() == *that->AsConstant(); 373 return that->IsConstant() && *this->AsConstant() == *that->AsConstant();
374 } 374 }
375 375
376 return false; 376 return false;
377 } 377 }
378 378
379 379
380 template<class Config> 380 template<class Config>
381 bool TypeImpl<Config>::Contains(i::Object* value) {
382 if (this->IsConstant()) {
383 return *this->AsConstant() == value;
384 }
385 return Config::from_bitset(LubBitset(value))->Is(this);
386 }
387
388
389 template<class Config>
390 bool TypeImpl<Config>::NowContains(i::Object* value) {
391 return this->Contains(value) ||
392 (this->IsClass() && value->IsHeapObject() &&
393 *this->AsClass() == i::HeapObject::cast(value)->map());
394 }
395
396
397 template<class Config>
381 bool TypeImpl<Config>::InUnion(UnionedHandle unioned, int current_size) { 398 bool TypeImpl<Config>::InUnion(UnionedHandle unioned, int current_size) {
382 ASSERT(!this->IsUnion()); 399 ASSERT(!this->IsUnion());
383 for (int i = 0; i < current_size; ++i) { 400 for (int i = 0; i < current_size; ++i) {
384 TypeHandle type = Config::union_get(unioned, i); 401 TypeHandle type = Config::union_get(unioned, i);
385 if (this->Is(type)) return true; 402 if (this->Is(type)) return true;
386 } 403 }
387 return false; 404 return false;
388 } 405 }
389 406
390 407
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 704
688 template TypeImpl<ZoneTypeConfig>::TypeHandle 705 template TypeImpl<ZoneTypeConfig>::TypeHandle
689 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( 706 TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
690 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); 707 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
691 template TypeImpl<HeapTypeConfig>::TypeHandle 708 template TypeImpl<HeapTypeConfig>::TypeHandle
692 TypeImpl<HeapTypeConfig>::Convert<Type>( 709 TypeImpl<HeapTypeConfig>::Convert<Type>(
693 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); 710 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
694 711
695 712
696 } } // namespace v8::internal 713 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/types.h ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698