| 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 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11018 GetElementsKind(), new_elements); | 11018 GetElementsKind(), new_elements); |
| 11019 } | 11019 } |
| 11020 | 11020 |
| 11021 if (IsJSArray()) { | 11021 if (IsJSArray()) { |
| 11022 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 11022 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
| 11023 } | 11023 } |
| 11024 return new_elements; | 11024 return new_elements; |
| 11025 } | 11025 } |
| 11026 | 11026 |
| 11027 | 11027 |
| 11028 bool Code::IsWeakEmbeddedObject(Kind kind, Object* object) { |
| 11029 if (kind != Code::OPTIMIZED_FUNCTION) return false; |
| 11030 |
| 11031 if (object->IsMap()) { |
| 11032 return Map::cast(object)->CanTransition() && |
| 11033 FLAG_collect_maps && |
| 11034 FLAG_weak_embedded_maps_in_optimized_code; |
| 11035 } |
| 11036 |
| 11037 if (object->IsJSObject()) { |
| 11038 return FLAG_weak_embedded_objects_in_optimized_code; |
| 11039 } |
| 11040 |
| 11041 return false; |
| 11042 } |
| 11043 |
| 11028 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( | 11044 MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( |
| 11029 int capacity, | 11045 int capacity, |
| 11030 int length) { | 11046 int length) { |
| 11031 Heap* heap = GetHeap(); | 11047 Heap* heap = GetHeap(); |
| 11032 // We should never end in here with a pixel or external array. | 11048 // We should never end in here with a pixel or external array. |
| 11033 ASSERT(!HasExternalArrayElements()); | 11049 ASSERT(!HasExternalArrayElements()); |
| 11034 ASSERT(!map()->is_observed()); | 11050 ASSERT(!map()->is_observed()); |
| 11035 | 11051 |
| 11036 FixedArrayBase* elems; | 11052 FixedArrayBase* elems; |
| 11037 { MaybeObject* maybe_obj = | 11053 { MaybeObject* maybe_obj = |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11378 // Do not append the compilation info if it is already in the array. | 11394 // Do not append the compilation info if it is already in the array. |
| 11379 // It is sufficient to just check only the last element because | 11395 // It is sufficient to just check only the last element because |
| 11380 // we process embedded maps of an optimized code in one batch. | 11396 // we process embedded maps of an optimized code in one batch. |
| 11381 return entries; | 11397 return entries; |
| 11382 } | 11398 } |
| 11383 if (entries->length() < kCodesStartIndex + number_of_entries + 1) { | 11399 if (entries->length() < kCodesStartIndex + number_of_entries + 1) { |
| 11384 Factory* factory = entries->GetIsolate()->factory(); | 11400 Factory* factory = entries->GetIsolate()->factory(); |
| 11385 int capacity = kCodesStartIndex + number_of_entries + 1; | 11401 int capacity = kCodesStartIndex + number_of_entries + 1; |
| 11386 if (capacity > 5) capacity = capacity * 5 / 4; | 11402 if (capacity > 5) capacity = capacity * 5 / 4; |
| 11387 Handle<DependentCode> new_entries = Handle<DependentCode>::cast( | 11403 Handle<DependentCode> new_entries = Handle<DependentCode>::cast( |
| 11388 factory->CopySizeFixedArray(entries, capacity)); | 11404 factory->CopySizeFixedArray(entries, capacity, TENURED)); |
| 11389 // The number of codes can change after GC. | 11405 // The number of codes can change after GC. |
| 11390 starts.Recompute(*entries); | 11406 starts.Recompute(*entries); |
| 11391 start = starts.at(group); | 11407 start = starts.at(group); |
| 11392 end = starts.at(group + 1); | 11408 end = starts.at(group + 1); |
| 11393 number_of_entries = starts.number_of_entries(); | 11409 number_of_entries = starts.number_of_entries(); |
| 11394 for (int i = 0; i < number_of_entries; i++) { | 11410 for (int i = 0; i < number_of_entries; i++) { |
| 11395 entries->clear_at(i); | 11411 entries->clear_at(i); |
| 11396 } | 11412 } |
| 11397 // If the old fixed array was empty, we need to reset counters of the | 11413 // If the old fixed array was empty, we need to reset counters of the |
| 11398 // new array. | 11414 // new array. |
| (...skipping 2484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13883 // for the next probe. | 13899 // for the next probe. |
| 13884 done = false; | 13900 done = false; |
| 13885 } | 13901 } |
| 13886 } | 13902 } |
| 13887 } | 13903 } |
| 13888 } | 13904 } |
| 13889 } | 13905 } |
| 13890 | 13906 |
| 13891 | 13907 |
| 13892 template<typename Shape, typename Key> | 13908 template<typename Shape, typename Key> |
| 13893 MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) { | 13909 MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, |
| 13910 Key key, |
| 13911 PretenureFlag pretenure) { |
| 13894 int capacity = Capacity(); | 13912 int capacity = Capacity(); |
| 13895 int nof = NumberOfElements() + n; | 13913 int nof = NumberOfElements() + n; |
| 13896 int nod = NumberOfDeletedElements(); | 13914 int nod = NumberOfDeletedElements(); |
| 13897 // Return if: | 13915 // Return if: |
| 13898 // 50% is still free after adding n elements and | 13916 // 50% is still free after adding n elements and |
| 13899 // at most 50% of the free elements are deleted elements. | 13917 // at most 50% of the free elements are deleted elements. |
| 13900 if (nod <= (capacity - nof) >> 1) { | 13918 if (nod <= (capacity - nof) >> 1) { |
| 13901 int needed_free = nof >> 1; | 13919 int needed_free = nof >> 1; |
| 13902 if (nof + needed_free <= capacity) return this; | 13920 if (nof + needed_free <= capacity) return this; |
| 13903 } | 13921 } |
| 13904 | 13922 |
| 13905 const int kMinCapacityForPretenure = 256; | 13923 const int kMinCapacityForPretenure = 256; |
| 13906 bool pretenure = | 13924 bool should_pretenure = pretenure == TENURED || |
| 13907 (capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this); | 13925 ((capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this)); |
| 13908 Object* obj; | 13926 Object* obj; |
| 13909 { MaybeObject* maybe_obj = | 13927 { MaybeObject* maybe_obj = |
| 13910 Allocate(GetHeap(), | 13928 Allocate(GetHeap(), |
| 13911 nof * 2, | 13929 nof * 2, |
| 13912 USE_DEFAULT_MINIMUM_CAPACITY, | 13930 USE_DEFAULT_MINIMUM_CAPACITY, |
| 13913 pretenure ? TENURED : NOT_TENURED); | 13931 should_pretenure ? TENURED : NOT_TENURED); |
| 13914 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 13932 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 13915 } | 13933 } |
| 13916 | 13934 |
| 13917 return Rehash(HashTable::cast(obj), key); | 13935 return Rehash(HashTable::cast(obj), key); |
| 13918 } | 13936 } |
| 13919 | 13937 |
| 13920 | 13938 |
| 13921 template<typename Shape, typename Key> | 13939 template<typename Shape, typename Key> |
| 13922 MaybeObject* HashTable<Shape, Key>::Shrink(Key key) { | 13940 MaybeObject* HashTable<Shape, Key>::Shrink(Key key) { |
| 13923 int capacity = Capacity(); | 13941 int capacity = Capacity(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13971 template class HashTable<StringTableShape, HashTableKey*>; | 13989 template class HashTable<StringTableShape, HashTableKey*>; |
| 13972 | 13990 |
| 13973 template class HashTable<CompilationCacheShape, HashTableKey*>; | 13991 template class HashTable<CompilationCacheShape, HashTableKey*>; |
| 13974 | 13992 |
| 13975 template class HashTable<MapCacheShape, HashTableKey*>; | 13993 template class HashTable<MapCacheShape, HashTableKey*>; |
| 13976 | 13994 |
| 13977 template class HashTable<ObjectHashTableShape<1>, Object*>; | 13995 template class HashTable<ObjectHashTableShape<1>, Object*>; |
| 13978 | 13996 |
| 13979 template class HashTable<ObjectHashTableShape<2>, Object*>; | 13997 template class HashTable<ObjectHashTableShape<2>, Object*>; |
| 13980 | 13998 |
| 13999 template class HashTable<WeakHashTableShape<2>, Object*>; |
| 14000 |
| 13981 template class Dictionary<NameDictionaryShape, Name*>; | 14001 template class Dictionary<NameDictionaryShape, Name*>; |
| 13982 | 14002 |
| 13983 template class Dictionary<SeededNumberDictionaryShape, uint32_t>; | 14003 template class Dictionary<SeededNumberDictionaryShape, uint32_t>; |
| 13984 | 14004 |
| 13985 template class Dictionary<UnseededNumberDictionaryShape, uint32_t>; | 14005 template class Dictionary<UnseededNumberDictionaryShape, uint32_t>; |
| 13986 | 14006 |
| 13987 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>:: | 14007 template MaybeObject* Dictionary<SeededNumberDictionaryShape, uint32_t>:: |
| 13988 Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure); | 14008 Allocate(Heap* heap, int at_least_space_for, PretenureFlag pretenure); |
| 13989 | 14009 |
| 13990 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>:: | 14010 template MaybeObject* Dictionary<UnseededNumberDictionaryShape, uint32_t>:: |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15613 } | 15633 } |
| 15614 | 15634 |
| 15615 | 15635 |
| 15616 void ObjectHashTable::RemoveEntry(int entry) { | 15636 void ObjectHashTable::RemoveEntry(int entry) { |
| 15617 set_the_hole(EntryToIndex(entry)); | 15637 set_the_hole(EntryToIndex(entry)); |
| 15618 set_the_hole(EntryToIndex(entry) + 1); | 15638 set_the_hole(EntryToIndex(entry) + 1); |
| 15619 ElementRemoved(); | 15639 ElementRemoved(); |
| 15620 } | 15640 } |
| 15621 | 15641 |
| 15622 | 15642 |
| 15643 Object* WeakHashTable::Lookup(Object* key) { |
| 15644 ASSERT(IsKey(key)); |
| 15645 int entry = FindEntry(key); |
| 15646 if (entry == kNotFound) return GetHeap()->the_hole_value(); |
| 15647 return get(EntryToValueIndex(entry)); |
| 15648 } |
| 15649 |
| 15650 |
| 15651 MaybeObject* WeakHashTable::Put(Object* key, Object* value) { |
| 15652 ASSERT(IsKey(key)); |
| 15653 int entry = FindEntry(key); |
| 15654 // Key is already in table, just overwrite value. |
| 15655 if (entry != kNotFound) { |
| 15656 set(EntryToValueIndex(entry), value); |
| 15657 return this; |
| 15658 } |
| 15659 |
| 15660 // Check whether the hash table should be extended. |
| 15661 Object* obj; |
| 15662 { MaybeObject* maybe_obj = EnsureCapacity(1, key, TENURED); |
| 15663 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 15664 } |
| 15665 WeakHashTable* table = WeakHashTable::cast(obj); |
| 15666 table->AddEntry(table->FindInsertionEntry(Hash(key)), key, value); |
| 15667 return table; |
| 15668 } |
| 15669 |
| 15670 |
| 15671 void WeakHashTable::AddEntry(int entry, Object* key, Object* value) { |
| 15672 set(EntryToIndex(entry), key); |
| 15673 set(EntryToValueIndex(entry), value); |
| 15674 ElementAdded(); |
| 15675 } |
| 15676 |
| 15677 |
| 15623 DeclaredAccessorDescriptorIterator::DeclaredAccessorDescriptorIterator( | 15678 DeclaredAccessorDescriptorIterator::DeclaredAccessorDescriptorIterator( |
| 15624 DeclaredAccessorDescriptor* descriptor) | 15679 DeclaredAccessorDescriptor* descriptor) |
| 15625 : array_(descriptor->serialized_data()->GetDataStartAddress()), | 15680 : array_(descriptor->serialized_data()->GetDataStartAddress()), |
| 15626 length_(descriptor->serialized_data()->length()), | 15681 length_(descriptor->serialized_data()->length()), |
| 15627 offset_(0) { | 15682 offset_(0) { |
| 15628 } | 15683 } |
| 15629 | 15684 |
| 15630 | 15685 |
| 15631 const DeclaredAccessorDescriptorData* | 15686 const DeclaredAccessorDescriptorData* |
| 15632 DeclaredAccessorDescriptorIterator::Next() { | 15687 DeclaredAccessorDescriptorIterator::Next() { |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16169 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16224 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16170 static const char* error_messages_[] = { | 16225 static const char* error_messages_[] = { |
| 16171 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16226 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16172 }; | 16227 }; |
| 16173 #undef ERROR_MESSAGES_TEXTS | 16228 #undef ERROR_MESSAGES_TEXTS |
| 16174 return error_messages_[reason]; | 16229 return error_messages_[reason]; |
| 16175 } | 16230 } |
| 16176 | 16231 |
| 16177 | 16232 |
| 16178 } } // namespace v8::internal | 16233 } } // namespace v8::internal |
| OLD | NEW |