OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "types.h" | 5 #include "types.h" |
6 | 6 |
7 #include "string-stream.h" | 7 #include "string-stream.h" |
8 #include "types-inl.h" | 8 #include "types-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 int TypeImpl<Config>::LubBitset(i::Object* value) { | 133 int TypeImpl<Config>::LubBitset(i::Object* value) { |
134 if (value->IsSmi()) return kSignedSmall & kTaggedInt; | 134 if (value->IsSmi()) return kSignedSmall & kTaggedInt; |
135 i::Map* map = i::HeapObject::cast(value)->map(); | 135 i::Map* map = i::HeapObject::cast(value)->map(); |
136 if (map->instance_type() == HEAP_NUMBER_TYPE) { | 136 if (map->instance_type() == HEAP_NUMBER_TYPE) { |
137 int32_t i; | 137 int32_t i; |
138 uint32_t u; | 138 uint32_t u; |
139 return kTaggedPtr & ( | 139 return kTaggedPtr & ( |
140 value->ToInt32(&i) ? (Smi::IsValid(i) ? kSignedSmall : kOtherSigned32) : | 140 value->ToInt32(&i) ? (Smi::IsValid(i) ? kSignedSmall : kOtherSigned32) : |
141 value->ToUint32(&u) ? kUnsigned32 : kFloat); | 141 value->ToUint32(&u) ? kUnsigned32 : kFloat); |
142 } | 142 } |
143 if (map->instance_type() == ODDBALL_TYPE) { | |
144 if (value->IsUndefined()) return kUndefined; | |
145 if (value->IsNull()) return kNull; | |
146 if (value->IsBoolean()) return kBoolean; | |
147 if (value->IsTheHole()) return kAny; // TODO(rossberg): kNone? | |
148 if (value->IsUninitialized()) return kNone; | |
149 UNREACHABLE(); | |
150 } | |
151 return LubBitset(map); | 143 return LubBitset(map); |
152 } | 144 } |
153 | 145 |
154 | 146 |
155 template<class Config> | 147 template<class Config> |
156 int TypeImpl<Config>::LubBitset(i::Map* map) { | 148 int TypeImpl<Config>::LubBitset(i::Map* map) { |
157 switch (map->instance_type()) { | 149 switch (map->instance_type()) { |
158 case STRING_TYPE: | 150 case STRING_TYPE: |
159 case ASCII_STRING_TYPE: | 151 case ASCII_STRING_TYPE: |
160 case CONS_STRING_TYPE: | 152 case CONS_STRING_TYPE: |
(...skipping 10 matching lines...) Expand all Loading... | |
171 case ASCII_INTERNALIZED_STRING_TYPE: | 163 case ASCII_INTERNALIZED_STRING_TYPE: |
172 case EXTERNAL_INTERNALIZED_STRING_TYPE: | 164 case EXTERNAL_INTERNALIZED_STRING_TYPE: |
173 case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: | 165 case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: |
174 case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: | 166 case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: |
175 case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE: | 167 case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE: |
176 case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: | 168 case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: |
177 case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: | 169 case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: |
178 return kString; | 170 return kString; |
179 case SYMBOL_TYPE: | 171 case SYMBOL_TYPE: |
180 return kSymbol; | 172 return kSymbol; |
181 case ODDBALL_TYPE: | 173 case ODDBALL_TYPE: { |
174 Heap* heap = map->GetHeap(); | |
175 if (map == heap->undefined_map()) return kUndefined; | |
176 if (map == heap->the_hole_map()) return kAny; // TODO(rossberg): kNone? | |
177 if (map == heap->null_map()) return kNull; | |
178 if (map == heap->boolean_map()) return kBoolean; | |
179 if (map == heap->uninitialized_map()) return kNone; | |
180 ASSERT(map == heap->oddball_map()); | |
182 return kOddball; | 181 return kOddball; |
rossberg
2014/04/07 09:04:03
I think you could now return kInternal here and el
Benedikt Meurer
2014/04/07 09:30:19
Done.
| |
182 } | |
183 case HEAP_NUMBER_TYPE: | 183 case HEAP_NUMBER_TYPE: |
184 return kFloat & kTaggedPtr; | 184 return kFloat & kTaggedPtr; |
185 case JS_VALUE_TYPE: | 185 case JS_VALUE_TYPE: |
186 case JS_DATE_TYPE: | 186 case JS_DATE_TYPE: |
187 case JS_OBJECT_TYPE: | 187 case JS_OBJECT_TYPE: |
188 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 188 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
189 case JS_GENERATOR_OBJECT_TYPE: | 189 case JS_GENERATOR_OBJECT_TYPE: |
190 case JS_MODULE_TYPE: | 190 case JS_MODULE_TYPE: |
191 case JS_GLOBAL_OBJECT_TYPE: | 191 case JS_GLOBAL_OBJECT_TYPE: |
192 case JS_BUILTINS_OBJECT_TYPE: | 192 case JS_BUILTINS_OBJECT_TYPE: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 return kNone; | 244 return kNone; |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 | 248 |
249 // Most precise _current_ type of a value (usually its class). | 249 // Most precise _current_ type of a value (usually its class). |
250 template<class Config> | 250 template<class Config> |
251 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf( | 251 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf( |
252 i::Object* value, Region* region) { | 252 i::Object* value, Region* region) { |
253 if (value->IsSmi() || | 253 if (value->IsSmi() || |
254 i::HeapObject::cast(value)->map()->instance_type() == HEAP_NUMBER_TYPE || | 254 i::HeapObject::cast(value)->map()->instance_type() == HEAP_NUMBER_TYPE) { |
255 i::HeapObject::cast(value)->map()->instance_type() == ODDBALL_TYPE) { | |
256 return Of(value, region); | 255 return Of(value, region); |
257 } | 256 } |
258 return Class(i::handle(i::HeapObject::cast(value)->map()), region); | 257 return Class(i::handle(i::HeapObject::cast(value)->map()), region); |
259 } | 258 } |
260 | 259 |
261 | 260 |
262 // Check this <= that. | 261 // Check this <= that. |
263 template<class Config> | 262 template<class Config> |
264 bool TypeImpl<Config>::SlowIs(TypeImpl* that) { | 263 bool TypeImpl<Config>::SlowIs(TypeImpl* that) { |
265 // Fast path for bitsets. | 264 // Fast path for bitsets. |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; | 675 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; |
677 | 676 |
678 template TypeImpl<ZoneTypeConfig>::TypeHandle | 677 template TypeImpl<ZoneTypeConfig>::TypeHandle |
679 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 678 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
680 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 679 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
681 template TypeImpl<HeapTypeConfig>::TypeHandle | 680 template TypeImpl<HeapTypeConfig>::TypeHandle |
682 TypeImpl<HeapTypeConfig>::Convert<Type>( | 681 TypeImpl<HeapTypeConfig>::Convert<Type>( |
683 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 682 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
684 | 683 |
685 } } // namespace v8::internal | 684 } } // namespace v8::internal |
OLD | NEW |