| 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 7717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7728 for (int i = 0; i < result->length(); i++) { | 7728 for (int i = 0; i < result->length(); i++) { |
| 7729 Object* current = result->get(i); | 7729 Object* current = result->get(i); |
| 7730 ASSERT(current->IsNumber() || current->IsName()); | 7730 ASSERT(current->IsNumber() || current->IsName()); |
| 7731 } | 7731 } |
| 7732 } | 7732 } |
| 7733 #endif | 7733 #endif |
| 7734 return result; | 7734 return result; |
| 7735 } | 7735 } |
| 7736 | 7736 |
| 7737 | 7737 |
| 7738 MaybeObject* FixedArray::CopySize(int new_length) { | 7738 MaybeObject* FixedArray::CopySize(int new_length, PretenureFlag pretenure) { |
| 7739 Heap* heap = GetHeap(); | 7739 Heap* heap = GetHeap(); |
| 7740 if (new_length == 0) return heap->empty_fixed_array(); | 7740 if (new_length == 0) return heap->empty_fixed_array(); |
| 7741 Object* obj; | 7741 Object* obj; |
| 7742 { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length); | 7742 { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length, pretenure); |
| 7743 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 7743 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 7744 } | 7744 } |
| 7745 FixedArray* result = FixedArray::cast(obj); | 7745 FixedArray* result = FixedArray::cast(obj); |
| 7746 // Copy the content | 7746 // Copy the content |
| 7747 DisallowHeapAllocation no_gc; | 7747 DisallowHeapAllocation no_gc; |
| 7748 int len = length(); | 7748 int len = length(); |
| 7749 if (new_length < len) len = new_length; | 7749 if (new_length < len) len = new_length; |
| 7750 // We are taking the map from the old fixed array so the map is sure to | 7750 // We are taking the map from the old fixed array so the map is sure to |
| 7751 // be an immortal immutable object. | 7751 // be an immortal immutable object. |
| 7752 result->set_map_no_write_barrier(map()); | 7752 result->set_map_no_write_barrier(map()); |
| (...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11012 GetElementsKind(), new_elements); | 11012 GetElementsKind(), new_elements); |
| 11013 } | 11013 } |
| 11014 | 11014 |
| 11015 if (IsJSArray()) { | 11015 if (IsJSArray()) { |
| 11016 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 11016 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
| 11017 } | 11017 } |
| 11018 return new_elements; | 11018 return new_elements; |
| 11019 } | 11019 } |
| 11020 | 11020 |
| 11021 | 11021 |
| 11022 bool Code::IsWeakEmbeddedObject(Kind kind, Object* object) { |
| 11023 if (kind != Code::OPTIMIZED_FUNCTION) return false; |
| 11024 |
| 11025 if (object->IsMap()) { |
| 11026 return Map::cast(object)->CanTransition() && |
| 11027 FLAG_collect_maps && |
| 11028 FLAG_weak_embedded_maps_in_optimized_code; |
| 11029 } |
| 11030 |
| 11031 if (object->IsJSObject()) { |
| 11032 return FLAG_weak_embedded_objects_in_optimized_code; |
| 11033 } |
| 11034 |
| 11035 return false; |
| 11036 } |
| 11037 |
| 11022 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( | 11038 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( |
| 11023 int capacity, | 11039 int capacity, |
| 11024 int length) { | 11040 int length) { |
| 11025 Heap* heap = GetHeap(); | 11041 Heap* heap = GetHeap(); |
| 11026 // We should never end in here with a pixel or external array. | 11042 // We should never end in here with a pixel or external array. |
| 11027 ASSERT(!HasExternalArrayElements()); | 11043 ASSERT(!HasExternalArrayElements()); |
| 11028 ASSERT(!map()->is_observed()); | 11044 ASSERT(!map()->is_observed()); |
| 11029 | 11045 |
| 11030 FixedArrayBase* elems; | 11046 FixedArrayBase* elems; |
| 11031 { MaybeObject* maybe_obj = | 11047 { MaybeObject* maybe_obj = |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11372 // Do not append the compilation info if it is already in the array. | 11388 // Do not append the compilation info if it is already in the array. |
| 11373 // It is sufficient to just check only the last element because | 11389 // It is sufficient to just check only the last element because |
| 11374 // we process embedded maps of an optimized code in one batch. | 11390 // we process embedded maps of an optimized code in one batch. |
| 11375 return entries; | 11391 return entries; |
| 11376 } | 11392 } |
| 11377 if (entries->length() < kCodesStartIndex + number_of_entries + 1) { | 11393 if (entries->length() < kCodesStartIndex + number_of_entries + 1) { |
| 11378 Factory* factory = entries->GetIsolate()->factory(); | 11394 Factory* factory = entries->GetIsolate()->factory(); |
| 11379 int capacity = kCodesStartIndex + number_of_entries + 1; | 11395 int capacity = kCodesStartIndex + number_of_entries + 1; |
| 11380 if (capacity > 5) capacity = capacity * 5 / 4; | 11396 if (capacity > 5) capacity = capacity * 5 / 4; |
| 11381 Handle<DependentCode> new_entries = Handle<DependentCode>::cast( | 11397 Handle<DependentCode> new_entries = Handle<DependentCode>::cast( |
| 11382 factory->CopySizeFixedArray(entries, capacity)); | 11398 factory->CopySizeFixedArray(entries, capacity, TENURED)); |
| 11383 // The number of codes can change after GC. | 11399 // The number of codes can change after GC. |
| 11384 starts.Recompute(*entries); | 11400 starts.Recompute(*entries); |
| 11385 start = starts.at(group); | 11401 start = starts.at(group); |
| 11386 end = starts.at(group + 1); | 11402 end = starts.at(group + 1); |
| 11387 number_of_entries = starts.number_of_entries(); | 11403 number_of_entries = starts.number_of_entries(); |
| 11388 for (int i = 0; i < number_of_entries; i++) { | 11404 for (int i = 0; i < number_of_entries; i++) { |
| 11389 entries->clear_at(i); | 11405 entries->clear_at(i); |
| 11390 } | 11406 } |
| 11391 // If the old fixed array was empty, we need to reset counters of the | 11407 // If the old fixed array was empty, we need to reset counters of the |
| 11392 // new array. | 11408 // new array. |
| (...skipping 2484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13877 // for the next probe. | 13893 // for the next probe. |
| 13878 done = false; | 13894 done = false; |
| 13879 } | 13895 } |
| 13880 } | 13896 } |
| 13881 } | 13897 } |
| 13882 } | 13898 } |
| 13883 } | 13899 } |
| 13884 | 13900 |
| 13885 | 13901 |
| 13886 template<typename Shape, typename Key> | 13902 template<typename Shape, typename Key> |
| 13887 MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) { | 13903 MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, |
| 13904 Key key, |
| 13905 PretenureFlag pretenure) { |
| 13888 int capacity = Capacity(); | 13906 int capacity = Capacity(); |
| 13889 int nof = NumberOfElements() + n; | 13907 int nof = NumberOfElements() + n; |
| 13890 int nod = NumberOfDeletedElements(); | 13908 int nod = NumberOfDeletedElements(); |
| 13891 // Return if: | 13909 // Return if: |
| 13892 // 50% is still free after adding n elements and | 13910 // 50% is still free after adding n elements and |
| 13893 // at most 50% of the free elements are deleted elements. | 13911 // at most 50% of the free elements are deleted elements. |
| 13894 if (nod <= (capacity - nof) >> 1) { | 13912 if (nod <= (capacity - nof) >> 1) { |
| 13895 int needed_free = nof >> 1; | 13913 int needed_free = nof >> 1; |
| 13896 if (nof + needed_free <= capacity) return this; | 13914 if (nof + needed_free <= capacity) return this; |
| 13897 } | 13915 } |
| 13898 | 13916 |
| 13899 const int kMinCapacityForPretenure = 256; | 13917 const int kMinCapacityForPretenure = 256; |
| 13900 bool pretenure = | 13918 bool should_pretenure = pretenure == TENURED || |
| 13901 (capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this); | 13919 ((capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this)); |
| 13902 Object* obj; | 13920 Object* obj; |
| 13903 { MaybeObject* maybe_obj = | 13921 { MaybeObject* maybe_obj = |
| 13904 Allocate(GetHeap(), | 13922 Allocate(GetHeap(), |
| 13905 nof * 2, | 13923 nof * 2, |
| 13906 USE_DEFAULT_MINIMUM_CAPACITY, | 13924 USE_DEFAULT_MINIMUM_CAPACITY, |
| 13907 pretenure ? TENURED : NOT_TENURED); | 13925 should_pretenure ? TENURED : NOT_TENURED); |
| 13908 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 13926 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 13909 } | 13927 } |
| 13910 | 13928 |
| 13911 return Rehash(HashTable::cast(obj), key); | 13929 return Rehash(HashTable::cast(obj), key); |
| 13912 } | 13930 } |
| 13913 | 13931 |
| 13914 | 13932 |
| 13915 template<typename Shape, typename Key> | 13933 template<typename Shape, typename Key> |
| 13916 MaybeObject* HashTable<Shape, Key>::Shrink(Key key) { | 13934 MaybeObject* HashTable<Shape, Key>::Shrink(Key key) { |
| 13917 int capacity = Capacity(); | 13935 int capacity = Capacity(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13965 template class HashTable<StringTableShape, HashTableKey*>; | 13983 template class HashTable<StringTableShape, HashTableKey*>; |
| 13966 | 13984 |
| 13967 template class HashTable<CompilationCacheShape, HashTableKey*>; | 13985 template class HashTable<CompilationCacheShape, HashTableKey*>; |
| 13968 | 13986 |
| 13969 template class HashTable<MapCacheShape, HashTableKey*>; | 13987 template class HashTable<MapCacheShape, HashTableKey*>; |
| 13970 | 13988 |
| 13971 template class HashTable<ObjectHashTableShape<1>, Object*>; | 13989 template class HashTable<ObjectHashTableShape<1>, Object*>; |
| 13972 | 13990 |
| 13973 template class HashTable<ObjectHashTableShape<2>, Object*>; | 13991 template class HashTable<ObjectHashTableShape<2>, Object*>; |
| 13974 | 13992 |
| 13993 template class HashTable<WeakHashTableShape<2>, Object*>; |
| 13994 |
| 13975 template class Dictionary<NameDictionaryShape, Name*>; | 13995 template class Dictionary<NameDictionaryShape, Name*>; |
| 13976 | 13996 |
| 13977 template class Dictionary<SeededNumberDictionaryShape, uint32_t>; | 13997 template class Dictionary<SeededNumberDictionaryShape, uint32_t>; |
| 13978 | 13998 |
| 13979 template class Dictionary<UnseededNumberDictionaryShape, uint32_t>; | 13999 template class Dictionary<UnseededNumberDictionaryShape, uint32_t>; |
| 13980 | 14000 |
| 13981 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>:: | 14001 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>:: |
| 13982 Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure); | 14002 Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure); |
| 13983 | 14003 |
| 13984 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>:: | 14004 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>:: |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15607 } | 15627 } |
| 15608 | 15628 |
| 15609 | 15629 |
| 15610 void ObjectHashTable::RemoveEntry(int entry) { | 15630 void ObjectHashTable::RemoveEntry(int entry) { |
| 15611 set_the_hole(EntryToIndex(entry)); | 15631 set_the_hole(EntryToIndex(entry)); |
| 15612 set_the_hole(EntryToIndex(entry) + 1); | 15632 set_the_hole(EntryToIndex(entry) + 1); |
| 15613 ElementRemoved(); | 15633 ElementRemoved(); |
| 15614 } | 15634 } |
| 15615 | 15635 |
| 15616 | 15636 |
| 15637 Object* WeakHashTable::Lookup(Object* key) { |
| 15638 ASSERT(IsKey(key)); |
| 15639 int entry = FindEntry(key); |
| 15640 if (entry == kNotFound) return GetHeap()->the_hole_value(); |
| 15641 return get(EntryToValueIndex(entry)); |
| 15642 } |
| 15643 |
| 15644 |
| 15645 MaybeObject* WeakHashTable::Put(Object* key, Object* value) { |
| 15646 ASSERT(IsKey(key)); |
| 15647 int entry = FindEntry(key); |
| 15648 // Key is already in table, just overwrite value. |
| 15649 if (entry != kNotFound) { |
| 15650 set(EntryToValueIndex(entry), value); |
| 15651 return this; |
| 15652 } |
| 15653 |
| 15654 // Check whether the hash table should be extended. |
| 15655 Object* obj; |
| 15656 { MaybeObject* maybe_obj = EnsureCapacity(1, key, TENURED); |
| 15657 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 15658 } |
| 15659 WeakHashTable* table = WeakHashTable::cast(obj); |
| 15660 table->AddEntry(table->FindInsertionEntry(Hash(key)), key, value); |
| 15661 return table; |
| 15662 } |
| 15663 |
| 15664 |
| 15665 void WeakHashTable::AddEntry(int entry, Object* key, Object* value) { |
| 15666 set(EntryToIndex(entry), key); |
| 15667 set(EntryToValueIndex(entry), value); |
| 15668 ElementAdded(); |
| 15669 } |
| 15670 |
| 15671 |
| 15617 DeclaredAccessorDescriptorIterator::DeclaredAccessorDescriptorIterator( | 15672 DeclaredAccessorDescriptorIterator::DeclaredAccessorDescriptorIterator( |
| 15618 DeclaredAccessorDescriptor* descriptor) | 15673 DeclaredAccessorDescriptor* descriptor) |
| 15619 : array_(descriptor->serialized_data()->GetDataStartAddress()), | 15674 : array_(descriptor->serialized_data()->GetDataStartAddress()), |
| 15620 length_(descriptor->serialized_data()->length()), | 15675 length_(descriptor->serialized_data()->length()), |
| 15621 offset_(0) { | 15676 offset_(0) { |
| 15622 } | 15677 } |
| 15623 | 15678 |
| 15624 | 15679 |
| 15625 const DeclaredAccessorDescriptorData* | 15680 const DeclaredAccessorDescriptorData* |
| 15626 DeclaredAccessorDescriptorIterator::Next() { | 15681 DeclaredAccessorDescriptorIterator::Next() { |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16163 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16218 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16164 static const char* error_messages_[] = { | 16219 static const char* error_messages_[] = { |
| 16165 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16220 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16166 }; | 16221 }; |
| 16167 #undef ERROR_MESSAGES_TEXTS | 16222 #undef ERROR_MESSAGES_TEXTS |
| 16168 return error_messages_[reason]; | 16223 return error_messages_[reason]; |
| 16169 } | 16224 } |
| 16170 | 16225 |
| 16171 | 16226 |
| 16172 } } // namespace v8::internal | 16227 } } // namespace v8::internal |
| OLD | NEW |