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 24 matching lines...) Expand all Loading... |
35 if (this->is_bitset()) { | 35 if (this->is_bitset()) { |
36 return this->as_bitset(); | 36 return this->as_bitset(); |
37 } else if (this->is_union()) { | 37 } else if (this->is_union()) { |
38 Handle<Unioned> unioned = this->as_union(); | 38 Handle<Unioned> unioned = this->as_union(); |
39 int bitset = kNone; | 39 int bitset = kNone; |
40 for (int i = 0; i < unioned->length(); ++i) { | 40 for (int i = 0; i < unioned->length(); ++i) { |
41 bitset |= union_get(unioned, i)->LubBitset(); | 41 bitset |= union_get(unioned, i)->LubBitset(); |
42 } | 42 } |
43 return bitset; | 43 return bitset; |
44 } else { | 44 } else { |
45 Map* map = | 45 Map* map = NULL; |
46 this->is_class() ? *this->as_class() : this->as_constant()->map(); | 46 if (this->is_class()) { |
| 47 map = *this->as_class(); |
| 48 } else { |
| 49 v8::internal::Object* value = this->as_constant()->value(); |
| 50 if (value->IsSmi()) return kSmi; |
| 51 map = HeapObject::cast(value)->map(); |
| 52 } |
47 switch (map->instance_type()) { | 53 switch (map->instance_type()) { |
48 case STRING_TYPE: | 54 case STRING_TYPE: |
49 case ASCII_STRING_TYPE: | 55 case ASCII_STRING_TYPE: |
50 case CONS_STRING_TYPE: | 56 case CONS_STRING_TYPE: |
51 case CONS_ASCII_STRING_TYPE: | 57 case CONS_ASCII_STRING_TYPE: |
52 case SLICED_STRING_TYPE: | 58 case SLICED_STRING_TYPE: |
53 case EXTERNAL_STRING_TYPE: | 59 case EXTERNAL_STRING_TYPE: |
54 case EXTERNAL_ASCII_STRING_TYPE: | 60 case EXTERNAL_ASCII_STRING_TYPE: |
55 case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: | 61 case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: |
56 case SHORT_EXTERNAL_STRING_TYPE: | 62 case SHORT_EXTERNAL_STRING_TYPE: |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 bool Type::Is(Handle<Type> that) { | 125 bool Type::Is(Handle<Type> that) { |
120 // Fast path for bitsets. | 126 // Fast path for bitsets. |
121 if (that->is_bitset()) { | 127 if (that->is_bitset()) { |
122 return (this->LubBitset() | that->as_bitset()) == that->as_bitset(); | 128 return (this->LubBitset() | that->as_bitset()) == that->as_bitset(); |
123 } | 129 } |
124 | 130 |
125 if (that->is_class()) { | 131 if (that->is_class()) { |
126 return this->is_class() && *this->as_class() == *that->as_class(); | 132 return this->is_class() && *this->as_class() == *that->as_class(); |
127 } | 133 } |
128 if (that->is_constant()) { | 134 if (that->is_constant()) { |
129 return this->is_constant() && *this->as_constant() == *that->as_constant(); | 135 return this->is_constant() && |
| 136 this->as_constant()->value() == that->as_constant()->value(); |
130 } | 137 } |
131 | 138 |
132 // (T1 \/ ... \/ Tn) <= T <=> (T1 <= T) /\ ... /\ (Tn <= T) | 139 // (T1 \/ ... \/ Tn) <= T <=> (T1 <= T) /\ ... /\ (Tn <= T) |
133 if (this->is_union()) { | 140 if (this->is_union()) { |
134 Handle<Unioned> unioned = this->as_union(); | 141 Handle<Unioned> unioned = this->as_union(); |
135 for (int i = 0; i < unioned->length(); ++i) { | 142 for (int i = 0; i < unioned->length(); ++i) { |
136 Handle<Type> this_i = union_get(unioned, i); | 143 Handle<Type> this_i = union_get(unioned, i); |
137 if (!this_i->Is(that)) return false; | 144 if (!this_i->Is(that)) return false; |
138 } | 145 } |
139 return true; | 146 return true; |
(...skipping 22 matching lines...) Expand all Loading... |
162 return (this->as_bitset() & that->LubBitset()) != 0; | 169 return (this->as_bitset() & that->LubBitset()) != 0; |
163 } | 170 } |
164 if (that->is_bitset()) { | 171 if (that->is_bitset()) { |
165 return (this->LubBitset() & that->as_bitset()) != 0; | 172 return (this->LubBitset() & that->as_bitset()) != 0; |
166 } | 173 } |
167 | 174 |
168 if (this->is_class()) { | 175 if (this->is_class()) { |
169 return that->is_class() && *this->as_class() == *that->as_class(); | 176 return that->is_class() && *this->as_class() == *that->as_class(); |
170 } | 177 } |
171 if (this->is_constant()) { | 178 if (this->is_constant()) { |
172 return that->is_constant() && *this->as_constant() == *that->as_constant(); | 179 return that->is_constant() && |
| 180 this->as_constant()->value() == that->as_constant()->value(); |
173 } | 181 } |
174 | 182 |
175 // (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T) | 183 // (T1 \/ ... \/ Tn) overlaps T <=> (T1 overlaps T) \/ ... \/ (Tn overlaps T) |
176 if (this->is_union()) { | 184 if (this->is_union()) { |
177 Handle<Unioned> unioned = this->as_union(); | 185 Handle<Unioned> unioned = this->as_union(); |
178 for (int i = 0; i < unioned->length(); ++i) { | 186 for (int i = 0; i < unioned->length(); ++i) { |
179 Handle<Type> this_i = union_get(unioned, i); | 187 Handle<Type> this_i = union_get(unioned, i); |
180 if (this_i->Maybe(that)) return true; | 188 if (this_i->Maybe(that)) return true; |
181 } | 189 } |
182 return false; | 190 return false; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 280 } |
273 | 281 |
274 | 282 |
275 Type* Type::Optional(Handle<Type> type) { | 283 Type* Type::Optional(Handle<Type> type) { |
276 return type->is_bitset() | 284 return type->is_bitset() |
277 ? from_bitset(type->as_bitset() | kUndefined) | 285 ? from_bitset(type->as_bitset() | kUndefined) |
278 : Union(type, Undefined()->handle_via_isolate_of(*type)); | 286 : Union(type, Undefined()->handle_via_isolate_of(*type)); |
279 } | 287 } |
280 | 288 |
281 } } // namespace v8::internal | 289 } } // namespace v8::internal |
OLD | NEW |