| OLD | NEW |
| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } else if (this->is_union()) { | 237 } else if (this->is_union()) { |
| 238 // All but the first are non-bitsets and thus would yield kNone anyway. | 238 // All but the first are non-bitsets and thus would yield kNone anyway. |
| 239 return union_get(this->as_union(), 0)->GlbBitset(); | 239 return union_get(this->as_union(), 0)->GlbBitset(); |
| 240 } else { | 240 } else { |
| 241 return kNone; | 241 return kNone; |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 | 245 |
| 246 // Most precise _current_ type of a value (usually its class). | 246 // Most precise _current_ type of a value (usually its class). |
| 247 Type* Type::CurrentOf(Handle<i::Object> value) { | 247 Type* Type::OfCurrently(Handle<i::Object> value) { |
| 248 if (value->IsSmi()) return Smi(); | 248 if (value->IsSmi()) return Smi(); |
| 249 i::Map* map = i::HeapObject::cast(*value)->map(); | 249 i::Map* map = i::HeapObject::cast(*value)->map(); |
| 250 if (map->instance_type() == HEAP_NUMBER_TYPE || | 250 if (map->instance_type() == HEAP_NUMBER_TYPE || |
| 251 map->instance_type() == ODDBALL_TYPE) { | 251 map->instance_type() == ODDBALL_TYPE) { |
| 252 return Type::Of(value); | 252 return Type::Of(value); |
| 253 } | 253 } |
| 254 return Class(i::handle(map)); | 254 return Class(i::handle(map)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 | 257 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (this->Is(that_i)) return true; | 290 if (this->Is(that_i)) return true; |
| 291 if (this->is_bitset()) break; // Fast fail, no other field is a bitset. | 291 if (this->is_bitset()) break; // Fast fail, no other field is a bitset. |
| 292 } | 292 } |
| 293 return false; | 293 return false; |
| 294 } | 294 } |
| 295 | 295 |
| 296 return false; | 296 return false; |
| 297 } | 297 } |
| 298 | 298 |
| 299 | 299 |
| 300 bool Type::IsCurrently(Type* that) { |
| 301 return this->Is(that) || |
| 302 (this->is_constant() && that->is_class() && |
| 303 this->as_constant()->IsHeapObject() && |
| 304 i::HeapObject::cast(*this->as_constant())->map() == *that->as_class()); |
| 305 } |
| 306 |
| 307 |
| 300 // Check this overlaps that. | 308 // Check this overlaps that. |
| 301 bool Type::Maybe(Type* that) { | 309 bool Type::Maybe(Type* that) { |
| 302 // Fast path for bitsets. | 310 // Fast path for bitsets. |
| 303 if (this->is_bitset()) { | 311 if (this->is_bitset()) { |
| 304 return (this->as_bitset() & that->LubBitset()) != 0; | 312 return (this->as_bitset() & that->LubBitset()) != 0; |
| 305 } | 313 } |
| 306 if (that->is_bitset()) { | 314 if (that->is_bitset()) { |
| 307 return (this->LubBitset() & that->as_bitset()) != 0; | 315 return (this->LubBitset() & that->as_bitset()) != 0; |
| 308 } | 316 } |
| 309 | 317 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 526 |
| 519 | 527 |
| 520 #ifdef OBJECT_PRINT | 528 #ifdef OBJECT_PRINT |
| 521 void Type::TypePrint() { | 529 void Type::TypePrint() { |
| 522 TypePrint(stdout); | 530 TypePrint(stdout); |
| 523 PrintF(stdout, "\n"); | 531 PrintF(stdout, "\n"); |
| 524 Flush(stdout); | 532 Flush(stdout); |
| 525 } | 533 } |
| 526 | 534 |
| 527 | 535 |
| 536 const char* Type::bitset_name(int bitset) { |
| 537 switch (bitset) { |
| 538 #define PRINT_COMPOSED_TYPE(type, value) case k##type: return #type; |
| 539 BITSET_TYPE_LIST(PRINT_COMPOSED_TYPE) |
| 540 #undef PRINT_COMPOSED_TYPE |
| 541 default: |
| 542 return NULL; |
| 543 } |
| 544 } |
| 545 |
| 546 |
| 528 void Type::TypePrint(FILE* out) { | 547 void Type::TypePrint(FILE* out) { |
| 529 if (is_bitset()) { | 548 if (is_bitset()) { |
| 530 int val = as_bitset(); | 549 int bitset = as_bitset(); |
| 531 const char* composed_name = GetComposedName(val); | 550 const char* name = bitset_name(bitset); |
| 532 if (composed_name != NULL) { | 551 if (name != NULL) { |
| 533 PrintF(out, "%s", composed_name); | 552 PrintF(out, "%s", name); |
| 534 return; | 553 } else { |
| 554 bool is_first = true; |
| 555 PrintF(out, "("); |
| 556 for (int mask = 1; mask != 0; mask = mask << 1) { |
| 557 if ((bitset & mask) != 0) { |
| 558 if (!is_first) PrintF(out, " | "); |
| 559 is_first = false; |
| 560 PrintF(out, "%s", bitset_name(mask)); |
| 561 } |
| 562 } |
| 563 PrintF(out, ")"); |
| 535 } | 564 } |
| 536 bool first_entry = true; | |
| 537 PrintF(out, "{"); | |
| 538 for (unsigned i = 0; i < sizeof(val)*8; ++i) { | |
| 539 int mask = (1 << i); | |
| 540 if ((val & mask) != 0) { | |
| 541 if (!first_entry) PrintF(out, ","); | |
| 542 first_entry = false; | |
| 543 PrintF(out, "%s", GetPrimitiveName(mask)); | |
| 544 } | |
| 545 } | |
| 546 PrintF(out, "}"); | |
| 547 } else if (is_constant()) { | 565 } else if (is_constant()) { |
| 548 PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant())); | 566 PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant())); |
| 549 from_bitset(LubBitset())->TypePrint(out); | 567 from_bitset(LubBitset())->TypePrint(out); |
| 550 PrintF(")"); | 568 PrintF(")"); |
| 551 } else if (is_class()) { | 569 } else if (is_class()) { |
| 552 PrintF(out, "Class(%p < ", static_cast<void*>(*as_class())); | 570 PrintF(out, "Class(%p < ", static_cast<void*>(*as_class())); |
| 553 from_bitset(LubBitset())->TypePrint(out); | 571 from_bitset(LubBitset())->TypePrint(out); |
| 554 PrintF(")"); | 572 PrintF(")"); |
| 555 } else if (is_union()) { | 573 } else if (is_union()) { |
| 556 PrintF(out, "{"); | 574 PrintF(out, "("); |
| 557 Handle<Unioned> unioned = as_union(); | 575 Handle<Unioned> unioned = as_union(); |
| 558 for (int i = 0; i < unioned->length(); ++i) { | 576 for (int i = 0; i < unioned->length(); ++i) { |
| 559 Handle<Type> type_i = union_get(unioned, i); | 577 Handle<Type> type_i = union_get(unioned, i); |
| 560 if (i > 0) PrintF(out, ","); | 578 if (i > 0) PrintF(out, " | "); |
| 561 type_i->TypePrint(out); | 579 type_i->TypePrint(out); |
| 562 } | 580 } |
| 563 PrintF(out, "}"); | 581 PrintF(out, ")"); |
| 564 } | 582 } |
| 565 } | 583 } |
| 566 #endif | 584 #endif |
| 567 | 585 |
| 568 | 586 |
| 569 } } // namespace v8::internal | 587 } } // namespace v8::internal |
| OLD | NEW |