OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 | 193 |
194 | 194 |
195 bool Object::IsSpecFunction() { | 195 bool Object::IsSpecFunction() { |
196 if (!Object::IsHeapObject()) return false; | 196 if (!Object::IsHeapObject()) return false; |
197 InstanceType type = HeapObject::cast(this)->map()->instance_type(); | 197 InstanceType type = HeapObject::cast(this)->map()->instance_type(); |
198 return type == JS_FUNCTION_TYPE || type == JS_FUNCTION_PROXY_TYPE; | 198 return type == JS_FUNCTION_TYPE || type == JS_FUNCTION_PROXY_TYPE; |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 bool Object::IsSymbol() { | 202 bool Object::IsInternalizedString() { |
203 if (!this->IsHeapObject()) return false; | 203 if (!this->IsHeapObject()) return false; |
204 uint32_t type = HeapObject::cast(this)->map()->instance_type(); | 204 uint32_t type = HeapObject::cast(this)->map()->instance_type(); |
205 // Because the symbol tag is non-zero and no non-string types have the | 205 // Because the internalized tag is non-zero and no non-string types have the |
206 // symbol bit set we can test for symbols with a very simple test | 206 // internalized bit set we can test for internalized strings with a very |
207 // operation. | 207 // simple test operation. |
208 STATIC_ASSERT(kSymbolTag != 0); | 208 STATIC_ASSERT(kInternalizedTag != 0); |
209 ASSERT(kNotStringTag + kIsSymbolMask > LAST_TYPE); | 209 ASSERT(kNotStringTag + kIsInternalizedMask > LAST_TYPE); |
210 return (type & kIsSymbolMask) != 0; | 210 return (type & kIsInternalizedMask) != 0; |
211 } | 211 } |
212 | 212 |
213 | 213 |
214 bool Object::IsConsString() { | 214 bool Object::IsConsString() { |
215 if (!IsString()) return false; | 215 if (!IsString()) return false; |
216 return StringShape(String::cast(this)).IsCons(); | 216 return StringShape(String::cast(this)).IsCons(); |
217 } | 217 } |
218 | 218 |
219 | 219 |
220 bool Object::IsSlicedString() { | 220 bool Object::IsSlicedString() { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 | 282 |
283 | 283 |
284 StringShape::StringShape(InstanceType t) | 284 StringShape::StringShape(InstanceType t) |
285 : type_(static_cast<uint32_t>(t)) { | 285 : type_(static_cast<uint32_t>(t)) { |
286 set_valid(); | 286 set_valid(); |
287 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 287 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
288 } | 288 } |
289 | 289 |
290 | 290 |
291 bool StringShape::IsSymbol() { | 291 bool StringShape::IsInternalized() { |
292 ASSERT(valid()); | 292 ASSERT(valid()); |
293 STATIC_ASSERT(kSymbolTag != 0); | 293 STATIC_ASSERT(kInternalizedTag != 0); |
294 return (type_ & kIsSymbolMask) != 0; | 294 return (type_ & kIsInternalizedMask) != 0; |
295 } | 295 } |
296 | 296 |
297 | 297 |
298 bool String::IsOneByteRepresentation() { | 298 bool String::IsOneByteRepresentation() { |
299 uint32_t type = map()->instance_type(); | 299 uint32_t type = map()->instance_type(); |
300 return (type & kStringEncodingMask) == kOneByteStringTag; | 300 return (type & kStringEncodingMask) == kOneByteStringTag; |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 bool String::IsTwoByteRepresentation() { | 304 bool String::IsTwoByteRepresentation() { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 | 673 |
674 bool Object::IsHashTable() { | 674 bool Object::IsHashTable() { |
675 return Object::IsHeapObject() && | 675 return Object::IsHeapObject() && |
676 HeapObject::cast(this)->map() == | 676 HeapObject::cast(this)->map() == |
677 HeapObject::cast(this)->GetHeap()->hash_table_map(); | 677 HeapObject::cast(this)->GetHeap()->hash_table_map(); |
678 } | 678 } |
679 | 679 |
680 | 680 |
681 bool Object::IsDictionary() { | 681 bool Object::IsDictionary() { |
682 return IsHashTable() && | 682 return IsHashTable() && |
683 this != HeapObject::cast(this)->GetHeap()->symbol_table(); | 683 this != HeapObject::cast(this)->GetHeap()->string_table(); |
684 } | 684 } |
685 | 685 |
686 | 686 |
687 bool Object::IsSymbolTable() { | 687 bool Object::IsStringTable() { |
688 return IsHashTable() && | 688 return IsHashTable() && |
689 this == HeapObject::cast(this)->GetHeap()->raw_unchecked_symbol_table(); | 689 this == HeapObject::cast(this)->GetHeap()->raw_unchecked_string_table(); |
690 } | 690 } |
691 | 691 |
692 | 692 |
693 bool Object::IsJSFunctionResultCache() { | 693 bool Object::IsJSFunctionResultCache() { |
694 if (!IsFixedArray()) return false; | 694 if (!IsFixedArray()) return false; |
695 FixedArray* self = FixedArray::cast(this); | 695 FixedArray* self = FixedArray::cast(this); |
696 int length = self->length(); | 696 int length = self->length(); |
697 if (length < JSFunctionResultCache::kEntriesIndex) return false; | 697 if (length < JSFunctionResultCache::kEntriesIndex) return false; |
698 if ((length - JSFunctionResultCache::kEntriesIndex) | 698 if ((length - JSFunctionResultCache::kEntriesIndex) |
699 % JSFunctionResultCache::kEntrySize != 0) { | 699 % JSFunctionResultCache::kEntrySize != 0) { |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 // Find entry for key otherwise return kNotFound. | 2346 // Find entry for key otherwise return kNotFound. |
2347 template<typename Shape, typename Key> | 2347 template<typename Shape, typename Key> |
2348 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { | 2348 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { |
2349 uint32_t capacity = Capacity(); | 2349 uint32_t capacity = Capacity(); |
2350 uint32_t entry = FirstProbe(HashTable<Shape, Key>::Hash(key), capacity); | 2350 uint32_t entry = FirstProbe(HashTable<Shape, Key>::Hash(key), capacity); |
2351 uint32_t count = 1; | 2351 uint32_t count = 1; |
2352 // EnsureCapacity will guarantee the hash table is never full. | 2352 // EnsureCapacity will guarantee the hash table is never full. |
2353 while (true) { | 2353 while (true) { |
2354 Object* element = KeyAt(entry); | 2354 Object* element = KeyAt(entry); |
2355 // Empty entry. Uses raw unchecked accessors because it is called by the | 2355 // Empty entry. Uses raw unchecked accessors because it is called by the |
2356 // symbol table during bootstrapping. | 2356 // string table during bootstrapping. |
2357 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; | 2357 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; |
2358 if (element != isolate->heap()->raw_unchecked_the_hole_value() && | 2358 if (element != isolate->heap()->raw_unchecked_the_hole_value() && |
2359 Shape::IsMatch(key, element)) return entry; | 2359 Shape::IsMatch(key, element)) return entry; |
2360 entry = NextProbe(entry, count++, capacity); | 2360 entry = NextProbe(entry, count++, capacity); |
2361 } | 2361 } |
2362 return kNotFound; | 2362 return kNotFound; |
2363 } | 2363 } |
2364 | 2364 |
2365 | 2365 |
2366 bool SeededNumberDictionary::requires_slow_elements() { | 2366 bool SeededNumberDictionary::requires_slow_elements() { |
(...skipping 20 matching lines...) Expand all Loading... |
2387 // Cast operations | 2387 // Cast operations |
2388 | 2388 |
2389 | 2389 |
2390 CAST_ACCESSOR(FixedArray) | 2390 CAST_ACCESSOR(FixedArray) |
2391 CAST_ACCESSOR(FixedDoubleArray) | 2391 CAST_ACCESSOR(FixedDoubleArray) |
2392 CAST_ACCESSOR(DescriptorArray) | 2392 CAST_ACCESSOR(DescriptorArray) |
2393 CAST_ACCESSOR(DeoptimizationInputData) | 2393 CAST_ACCESSOR(DeoptimizationInputData) |
2394 CAST_ACCESSOR(DeoptimizationOutputData) | 2394 CAST_ACCESSOR(DeoptimizationOutputData) |
2395 CAST_ACCESSOR(DependentCodes) | 2395 CAST_ACCESSOR(DependentCodes) |
2396 CAST_ACCESSOR(TypeFeedbackCells) | 2396 CAST_ACCESSOR(TypeFeedbackCells) |
2397 CAST_ACCESSOR(SymbolTable) | 2397 CAST_ACCESSOR(StringTable) |
2398 CAST_ACCESSOR(JSFunctionResultCache) | 2398 CAST_ACCESSOR(JSFunctionResultCache) |
2399 CAST_ACCESSOR(NormalizedMapCache) | 2399 CAST_ACCESSOR(NormalizedMapCache) |
2400 CAST_ACCESSOR(ScopeInfo) | 2400 CAST_ACCESSOR(ScopeInfo) |
2401 CAST_ACCESSOR(CompilationCacheTable) | 2401 CAST_ACCESSOR(CompilationCacheTable) |
2402 CAST_ACCESSOR(CodeCacheHashTable) | 2402 CAST_ACCESSOR(CodeCacheHashTable) |
2403 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) | 2403 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) |
2404 CAST_ACCESSOR(MapCache) | 2404 CAST_ACCESSOR(MapCache) |
2405 CAST_ACCESSOR(String) | 2405 CAST_ACCESSOR(String) |
2406 CAST_ACCESSOR(SeqString) | 2406 CAST_ACCESSOR(SeqString) |
2407 CAST_ACCESSOR(SeqOneByteString) | 2407 CAST_ACCESSOR(SeqOneByteString) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2475 void String::set_hash_field(uint32_t value) { | 2475 void String::set_hash_field(uint32_t value) { |
2476 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); | 2476 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); |
2477 #if V8_HOST_ARCH_64_BIT | 2477 #if V8_HOST_ARCH_64_BIT |
2478 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); | 2478 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); |
2479 #endif | 2479 #endif |
2480 } | 2480 } |
2481 | 2481 |
2482 | 2482 |
2483 bool String::Equals(String* other) { | 2483 bool String::Equals(String* other) { |
2484 if (other == this) return true; | 2484 if (other == this) return true; |
2485 if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { | 2485 if (StringShape(this).IsInternalized() && |
| 2486 StringShape(other).IsInternalized()) { |
2486 return false; | 2487 return false; |
2487 } | 2488 } |
2488 return SlowEquals(other); | 2489 return SlowEquals(other); |
2489 } | 2490 } |
2490 | 2491 |
2491 | 2492 |
2492 MaybeObject* String::TryFlatten(PretenureFlag pretenure) { | 2493 MaybeObject* String::TryFlatten(PretenureFlag pretenure) { |
2493 if (!StringShape(this).IsCons()) return this; | 2494 if (!StringShape(this).IsCons()) return this; |
2494 ConsString* cons = ConsString::cast(this); | 2495 ConsString* cons = ConsString::cast(this); |
2495 if (cons->IsFlat()) return cons->first(); | 2496 if (cons->IsFlat()) return cons->first(); |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3204 | 3205 |
3205 | 3206 |
3206 int Map::pre_allocated_property_fields() { | 3207 int Map::pre_allocated_property_fields() { |
3207 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | 3208 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); |
3208 } | 3209 } |
3209 | 3210 |
3210 | 3211 |
3211 int HeapObject::SizeFromMap(Map* map) { | 3212 int HeapObject::SizeFromMap(Map* map) { |
3212 int instance_size = map->instance_size(); | 3213 int instance_size = map->instance_size(); |
3213 if (instance_size != kVariableSizeSentinel) return instance_size; | 3214 if (instance_size != kVariableSizeSentinel) return instance_size; |
3214 // We can ignore the "symbol" bit becase it is only set for symbols | 3215 // We can ignore the "internalized" bit becase it is only set for strings |
3215 // and implies a string type. | 3216 // and thus implies a string type. |
3216 int instance_type = static_cast<int>(map->instance_type()) & ~kIsSymbolMask; | 3217 int instance_type = |
| 3218 static_cast<int>(map->instance_type()) & ~kIsInternalizedMask; |
3217 // Only inline the most frequent cases. | 3219 // Only inline the most frequent cases. |
3218 if (instance_type == FIXED_ARRAY_TYPE) { | 3220 if (instance_type == FIXED_ARRAY_TYPE) { |
3219 return FixedArray::BodyDescriptor::SizeOf(map, this); | 3221 return FixedArray::BodyDescriptor::SizeOf(map, this); |
3220 } | 3222 } |
3221 if (instance_type == ASCII_STRING_TYPE) { | 3223 if (instance_type == ASCII_STRING_TYPE) { |
3222 return SeqOneByteString::SizeFor( | 3224 return SeqOneByteString::SizeFor( |
3223 reinterpret_cast<SeqOneByteString*>(this)->length()); | 3225 reinterpret_cast<SeqOneByteString*>(this)->length()); |
3224 } | 3226 } |
3225 if (instance_type == BYTE_ARRAY_TYPE) { | 3227 if (instance_type == BYTE_ARRAY_TYPE) { |
3226 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); | 3228 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); |
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5890 #undef WRITE_UINT32_FIELD | 5892 #undef WRITE_UINT32_FIELD |
5891 #undef READ_SHORT_FIELD | 5893 #undef READ_SHORT_FIELD |
5892 #undef WRITE_SHORT_FIELD | 5894 #undef WRITE_SHORT_FIELD |
5893 #undef READ_BYTE_FIELD | 5895 #undef READ_BYTE_FIELD |
5894 #undef WRITE_BYTE_FIELD | 5896 #undef WRITE_BYTE_FIELD |
5895 | 5897 |
5896 | 5898 |
5897 } } // namespace v8::internal | 5899 } } // namespace v8::internal |
5898 | 5900 |
5899 #endif // V8_OBJECTS_INL_H_ | 5901 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |