| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 121 } |
| 122 return bitset; | 122 return bitset; |
| 123 } else { | 123 } else { |
| 124 Map* map = NULL; | 124 Map* map = NULL; |
| 125 if (this->is_class()) { | 125 if (this->is_class()) { |
| 126 map = *this->as_class(); | 126 map = *this->as_class(); |
| 127 } else { | 127 } else { |
| 128 Handle<v8::internal::Object> value = this->as_constant(); | 128 Handle<v8::internal::Object> value = this->as_constant(); |
| 129 if (value->IsSmi()) return kSmi; | 129 if (value->IsSmi()) return kSmi; |
| 130 map = HeapObject::cast(*value)->map(); | 130 map = HeapObject::cast(*value)->map(); |
| 131 if (map->instance_type() == HEAP_NUMBER_TYPE) { |
| 132 int32_t i; |
| 133 uint32_t u; |
| 134 if (value->ToInt32(&i)) return Smi::IsValid(i) ? kSmi : kOtherSigned32; |
| 135 if (value->ToUint32(&u)) return kUnsigned32; |
| 136 return kDouble; |
| 137 } |
| 131 if (map->instance_type() == ODDBALL_TYPE) { | 138 if (map->instance_type() == ODDBALL_TYPE) { |
| 132 if (value->IsUndefined()) return kUndefined; | 139 if (value->IsUndefined()) return kUndefined; |
| 133 if (value->IsNull()) return kNull; | 140 if (value->IsNull()) return kNull; |
| 134 if (value->IsTrue() || value->IsFalse()) return kBoolean; | 141 if (value->IsTrue() || value->IsFalse()) return kBoolean; |
| 135 if (value->IsTheHole()) return kAny; | 142 if (value->IsTheHole()) return kAny; // TODO(rossberg): kNone? |
| 143 UNREACHABLE(); |
| 136 } | 144 } |
| 137 } | 145 } |
| 138 switch (map->instance_type()) { | 146 switch (map->instance_type()) { |
| 139 case STRING_TYPE: | 147 case STRING_TYPE: |
| 140 case ASCII_STRING_TYPE: | 148 case ASCII_STRING_TYPE: |
| 141 case CONS_STRING_TYPE: | 149 case CONS_STRING_TYPE: |
| 142 case CONS_ASCII_STRING_TYPE: | 150 case CONS_ASCII_STRING_TYPE: |
| 143 case SLICED_STRING_TYPE: | 151 case SLICED_STRING_TYPE: |
| 144 case SLICED_ASCII_STRING_TYPE: | 152 case SLICED_ASCII_STRING_TYPE: |
| 145 case EXTERNAL_STRING_TYPE: | 153 case EXTERNAL_STRING_TYPE: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } else if (this->is_union()) { | 231 } else if (this->is_union()) { |
| 224 // All but the first are non-bitsets and thus would yield kNone anyway. | 232 // All but the first are non-bitsets and thus would yield kNone anyway. |
| 225 return union_get(this->as_union(), 0)->GlbBitset(); | 233 return union_get(this->as_union(), 0)->GlbBitset(); |
| 226 } else { | 234 } else { |
| 227 return kNone; | 235 return kNone; |
| 228 } | 236 } |
| 229 } | 237 } |
| 230 | 238 |
| 231 | 239 |
| 232 // Check this <= that. | 240 // Check this <= that. |
| 233 bool Type::IsSlowCase(Type* that) { | 241 bool Type::SlowIs(Type* that) { |
| 234 // Fast path for bitsets. | 242 // Fast path for bitsets. |
| 243 if (this->is_none()) return true; |
| 235 if (that->is_bitset()) { | 244 if (that->is_bitset()) { |
| 236 return (this->LubBitset() | that->as_bitset()) == that->as_bitset(); | 245 return (this->LubBitset() | that->as_bitset()) == that->as_bitset(); |
| 237 } | 246 } |
| 238 | 247 |
| 239 if (that->is_class()) { | 248 if (that->is_class()) { |
| 240 return this->is_class() && *this->as_class() == *that->as_class(); | 249 return this->is_class() && *this->as_class() == *that->as_class(); |
| 241 } | 250 } |
| 242 if (that->is_constant()) { | 251 if (that->is_constant()) { |
| 243 return this->is_constant() && *this->as_constant() == *that->as_constant(); | 252 return this->is_constant() && *this->as_constant() == *that->as_constant(); |
| 244 } | 253 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 for (unsigned i = 0; i < sizeof(val)*8; ++i) { | 520 for (unsigned i = 0; i < sizeof(val)*8; ++i) { |
| 512 int mask = (1 << i); | 521 int mask = (1 << i); |
| 513 if ((val & mask) != 0) { | 522 if ((val & mask) != 0) { |
| 514 if (!first_entry) PrintF(out, ","); | 523 if (!first_entry) PrintF(out, ","); |
| 515 first_entry = false; | 524 first_entry = false; |
| 516 PrintF(out, "%s", GetPrimitiveName(mask)); | 525 PrintF(out, "%s", GetPrimitiveName(mask)); |
| 517 } | 526 } |
| 518 } | 527 } |
| 519 PrintF(out, "}"); | 528 PrintF(out, "}"); |
| 520 } else if (is_constant()) { | 529 } else if (is_constant()) { |
| 521 PrintF(out, "Constant(%p)", static_cast<void*>(*as_constant())); | 530 PrintF(out, "Constant(%p : ", static_cast<void*>(*as_constant())); |
| 531 from_bitset(LubBitset())->TypePrint(out); |
| 532 PrintF(")"); |
| 522 } else if (is_class()) { | 533 } else if (is_class()) { |
| 523 PrintF(out, "Class(%p)", static_cast<void*>(*as_class())); | 534 PrintF(out, "Class(%p < ", static_cast<void*>(*as_class())); |
| 535 from_bitset(LubBitset())->TypePrint(out); |
| 536 PrintF(")"); |
| 524 } else if (is_union()) { | 537 } else if (is_union()) { |
| 525 PrintF(out, "{"); | 538 PrintF(out, "{"); |
| 526 Handle<Unioned> unioned = as_union(); | 539 Handle<Unioned> unioned = as_union(); |
| 527 for (int i = 0; i < unioned->length(); ++i) { | 540 for (int i = 0; i < unioned->length(); ++i) { |
| 528 Handle<Type> type_i = union_get(unioned, i); | 541 Handle<Type> type_i = union_get(unioned, i); |
| 529 if (i > 0) PrintF(out, ","); | 542 if (i > 0) PrintF(out, ","); |
| 530 type_i->TypePrint(out); | 543 type_i->TypePrint(out); |
| 531 } | 544 } |
| 532 PrintF(out, "}"); | 545 PrintF(out, "}"); |
| 533 } | 546 } |
| 534 } | 547 } |
| 535 #endif | 548 #endif |
| 536 | 549 |
| 537 | 550 |
| 538 } } // namespace v8::internal | 551 } } // namespace v8::internal |
| OLD | NEW |