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: { |
182 return kOddball; | 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->no_interceptor_result_sentinel_map() || |
| 181 map == heap->termination_exception_map() || |
| 182 map == heap->arguments_marker_map()); |
| 183 return kInternal & kTaggedPtr; |
| 184 } |
183 case HEAP_NUMBER_TYPE: | 185 case HEAP_NUMBER_TYPE: |
184 return kFloat & kTaggedPtr; | 186 return kFloat & kTaggedPtr; |
185 case JS_VALUE_TYPE: | 187 case JS_VALUE_TYPE: |
186 case JS_DATE_TYPE: | 188 case JS_DATE_TYPE: |
187 case JS_OBJECT_TYPE: | 189 case JS_OBJECT_TYPE: |
188 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 190 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
189 case JS_GENERATOR_OBJECT_TYPE: | 191 case JS_GENERATOR_OBJECT_TYPE: |
190 case JS_MODULE_TYPE: | 192 case JS_MODULE_TYPE: |
191 case JS_GLOBAL_OBJECT_TYPE: | 193 case JS_GLOBAL_OBJECT_TYPE: |
192 case JS_BUILTINS_OBJECT_TYPE: | 194 case JS_BUILTINS_OBJECT_TYPE: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return kNone; | 246 return kNone; |
245 } | 247 } |
246 } | 248 } |
247 | 249 |
248 | 250 |
249 // Most precise _current_ type of a value (usually its class). | 251 // Most precise _current_ type of a value (usually its class). |
250 template<class Config> | 252 template<class Config> |
251 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf( | 253 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf( |
252 i::Object* value, Region* region) { | 254 i::Object* value, Region* region) { |
253 if (value->IsSmi() || | 255 if (value->IsSmi() || |
254 i::HeapObject::cast(value)->map()->instance_type() == HEAP_NUMBER_TYPE || | 256 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); | 257 return Of(value, region); |
257 } | 258 } |
258 return Class(i::handle(i::HeapObject::cast(value)->map()), region); | 259 return Class(i::handle(i::HeapObject::cast(value)->map()), region); |
259 } | 260 } |
260 | 261 |
261 | 262 |
262 // Check this <= that. | 263 // Check this <= that. |
263 template<class Config> | 264 template<class Config> |
264 bool TypeImpl<Config>::SlowIs(TypeImpl* that) { | 265 bool TypeImpl<Config>::SlowIs(TypeImpl* that) { |
265 // Fast path for bitsets. | 266 // 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>; | 677 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; |
677 | 678 |
678 template TypeImpl<ZoneTypeConfig>::TypeHandle | 679 template TypeImpl<ZoneTypeConfig>::TypeHandle |
679 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 680 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
680 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 681 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
681 template TypeImpl<HeapTypeConfig>::TypeHandle | 682 template TypeImpl<HeapTypeConfig>::TypeHandle |
682 TypeImpl<HeapTypeConfig>::Convert<Type>( | 683 TypeImpl<HeapTypeConfig>::Convert<Type>( |
683 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 684 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
684 | 685 |
685 } } // namespace v8::internal | 686 } } // namespace v8::internal |
OLD | NEW |