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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 if (this->is_class()) { | 124 if (this->is_class()) { |
125 map = *this->as_class(); | 125 map = *this->as_class(); |
126 } else { | 126 } else { |
127 Handle<v8::internal::Object> value = this->as_constant(); | 127 Handle<v8::internal::Object> value = this->as_constant(); |
128 if (value->IsSmi()) return kSmi; | 128 if (value->IsSmi()) return kSmi; |
129 map = HeapObject::cast(*value)->map(); | 129 map = HeapObject::cast(*value)->map(); |
130 if (map->instance_type() == ODDBALL_TYPE) { | 130 if (map->instance_type() == ODDBALL_TYPE) { |
131 if (value->IsUndefined()) return kUndefined; | 131 if (value->IsUndefined()) return kUndefined; |
132 if (value->IsNull()) return kNull; | 132 if (value->IsNull()) return kNull; |
133 if (value->IsTrue() || value->IsFalse()) return kBoolean; | 133 if (value->IsTrue() || value->IsFalse()) return kBoolean; |
| 134 if (value->IsTheHole()) return kAny; |
134 } | 135 } |
135 } | 136 } |
136 switch (map->instance_type()) { | 137 switch (map->instance_type()) { |
137 case STRING_TYPE: | 138 case STRING_TYPE: |
138 case ASCII_STRING_TYPE: | 139 case ASCII_STRING_TYPE: |
139 case CONS_STRING_TYPE: | 140 case CONS_STRING_TYPE: |
140 case CONS_ASCII_STRING_TYPE: | 141 case CONS_ASCII_STRING_TYPE: |
141 case SLICED_STRING_TYPE: | 142 case SLICED_STRING_TYPE: |
142 case SLICED_ASCII_STRING_TYPE: | 143 case SLICED_ASCII_STRING_TYPE: |
143 case EXTERNAL_STRING_TYPE: | 144 case EXTERNAL_STRING_TYPE: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // When compiling stub templates, the meta map is used as a place holder | 194 // When compiling stub templates, the meta map is used as a place holder |
194 // for the actual map with which the template is later instantiated. | 195 // for the actual map with which the template is later instantiated. |
195 // We treat it as a kind of type variable whose upper bound is Any. | 196 // We treat it as a kind of type variable whose upper bound is Any. |
196 // TODO(rossberg): for caching of CompareNilIC stubs to work correctly, | 197 // TODO(rossberg): for caching of CompareNilIC stubs to work correctly, |
197 // we must exclude Undetectable here. This makes no sense, really, | 198 // we must exclude Undetectable here. This makes no sense, really, |
198 // because it means that the template isn't actually parametric. | 199 // because it means that the template isn't actually parametric. |
199 // Also, it doesn't apply elsewhere. 8-( | 200 // Also, it doesn't apply elsewhere. 8-( |
200 // We ought to find a cleaner solution for compiling stubs parameterised | 201 // We ought to find a cleaner solution for compiling stubs parameterised |
201 // over type or class variables, esp ones with bounds... | 202 // over type or class variables, esp ones with bounds... |
202 return kDetectable; | 203 return kDetectable; |
| 204 case DECLARED_ACCESSOR_INFO_TYPE: |
| 205 case EXECUTABLE_ACCESSOR_INFO_TYPE: |
| 206 case ACCESSOR_PAIR_TYPE: |
| 207 return kInternal; |
203 default: | 208 default: |
204 UNREACHABLE(); | 209 UNREACHABLE(); |
205 return kNone; | 210 return kNone; |
206 } | 211 } |
207 } | 212 } |
208 } | 213 } |
209 | 214 |
210 | 215 |
211 // Get the largest bitset subsumed by this type. | 216 // Get the largest bitset subsumed by this type. |
212 int Type::GlbBitset() { | 217 int Type::GlbBitset() { |
213 if (this->is_bitset()) { | 218 if (this->is_bitset()) { |
214 return this->as_bitset(); | 219 return this->as_bitset(); |
215 } else if (this->is_union()) { | 220 } else if (this->is_union()) { |
216 // All but the first are non-bitsets and thus would yield kNone anyway. | 221 // All but the first are non-bitsets and thus would yield kNone anyway. |
217 return union_get(this->as_union(), 0)->GlbBitset(); | 222 return union_get(this->as_union(), 0)->GlbBitset(); |
218 } else { | 223 } else { |
219 return kNone; | 224 return kNone; |
220 } | 225 } |
221 } | 226 } |
222 | 227 |
223 | 228 |
224 // Check this <= that. | 229 // Check this <= that. |
225 bool Type::Is(Type* that) { | 230 bool Type::IsSlowCase(Type* that) { |
226 // Fast path for bitsets. | 231 // Fast path for bitsets. |
227 if (that->is_bitset()) { | 232 if (that->is_bitset()) { |
228 return (this->LubBitset() | that->as_bitset()) == that->as_bitset(); | 233 return (this->LubBitset() | that->as_bitset()) == that->as_bitset(); |
229 } | 234 } |
230 | 235 |
231 if (that->is_class()) { | 236 if (that->is_class()) { |
232 return this->is_class() && *this->as_class() == *that->as_class(); | 237 return this->is_class() && *this->as_class() == *that->as_class(); |
233 } | 238 } |
234 if (that->is_constant()) { | 239 if (that->is_constant()) { |
235 return this->is_constant() && *this->as_constant() == *that->as_constant(); | 240 return this->is_constant() && *this->as_constant() == *that->as_constant(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 311 |
307 bool Type::InUnion(Handle<Unioned> unioned, int current_size) { | 312 bool Type::InUnion(Handle<Unioned> unioned, int current_size) { |
308 ASSERT(!this->is_union()); | 313 ASSERT(!this->is_union()); |
309 for (int i = 0; i < current_size; ++i) { | 314 for (int i = 0; i < current_size; ++i) { |
310 Handle<Type> type = union_get(unioned, i); | 315 Handle<Type> type = union_get(unioned, i); |
311 if (this->Is(type)) return true; | 316 if (this->Is(type)) return true; |
312 } | 317 } |
313 return false; | 318 return false; |
314 } | 319 } |
315 | 320 |
| 321 |
316 // Get non-bitsets from this which are not subsumed by union, store at unioned, | 322 // Get non-bitsets from this which are not subsumed by union, store at unioned, |
317 // starting at index. Returns updated index. | 323 // starting at index. Returns updated index. |
318 int Type::ExtendUnion(Handle<Unioned> result, int current_size) { | 324 int Type::ExtendUnion(Handle<Unioned> result, int current_size) { |
319 int old_size = current_size; | 325 int old_size = current_size; |
320 if (this->is_class() || this->is_constant()) { | 326 if (this->is_class() || this->is_constant()) { |
321 if (!this->InUnion(result, old_size)) result->set(current_size++, this); | 327 if (!this->InUnion(result, old_size)) result->set(current_size++, this); |
322 } else if (this->is_union()) { | 328 } else if (this->is_union()) { |
323 Handle<Unioned> unioned = this->as_union(); | 329 Handle<Unioned> unioned = this->as_union(); |
324 for (int i = 0; i < unioned->length(); ++i) { | 330 for (int i = 0; i < unioned->length(); ++i) { |
325 Handle<Type> type = union_get(unioned, i); | 331 Handle<Type> type = union_get(unioned, i); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 return from_handle(result); | 470 return from_handle(result); |
465 } | 471 } |
466 | 472 |
467 | 473 |
468 Type* Type::Optional(Handle<Type> type) { | 474 Type* Type::Optional(Handle<Type> type) { |
469 return type->is_bitset() | 475 return type->is_bitset() |
470 ? from_bitset(type->as_bitset() | kUndefined) | 476 ? from_bitset(type->as_bitset() | kUndefined) |
471 : Union(type, Undefined()->handle_via_isolate_of(*type)); | 477 : Union(type, Undefined()->handle_via_isolate_of(*type)); |
472 } | 478 } |
473 | 479 |
| 480 |
| 481 Representation Representation::FromType(Handle<Type> type) { |
| 482 if (type->Is(Type::None())) return Representation::None(); |
| 483 if (type->Is(Type::Signed32())) return Representation::Integer32(); |
| 484 if (type->Is(Type::Number())) return Representation::Double(); |
| 485 return Representation::Tagged(); |
| 486 } |
| 487 |
| 488 |
474 } } // namespace v8::internal | 489 } } // namespace v8::internal |
OLD | NEW |