Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/objects.h

Issue 7190032: Shrink dictionaries on deletion if number of elements are less than a (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 } 2583 }
2584 2584
2585 static uint32_t FirstProbe(uint32_t hash, uint32_t size) { 2585 static uint32_t FirstProbe(uint32_t hash, uint32_t size) {
2586 return hash & (size - 1); 2586 return hash & (size - 1);
2587 } 2587 }
2588 2588
2589 static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size) { 2589 static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size) {
2590 return (last + number) & (size - 1); 2590 return (last + number) & (size - 1);
2591 } 2591 }
2592 2592
2593 // Rehashes this hash-table into the new table.
2594 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key);
2595
2596 // Attempt to shrink hash table after removal of key.
2597 MUST_USE_RESULT MaybeObject* Shrink(Key key);
2598
2593 // Ensure enough space for n additional elements. 2599 // Ensure enough space for n additional elements.
2594 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); 2600 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
2595 }; 2601 };
2596 2602
2597 2603
2598 2604
2599 // HashTableKey is an abstract superclass for virtual key behavior. 2605 // HashTableKey is an abstract superclass for virtual key behavior.
2600 class HashTableKey { 2606 class HashTableKey {
2601 public: 2607 public:
2602 // Returns whether the other object matches this key. 2608 // Returns whether the other object matches this key.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 void DetailsAtPut(int entry, PropertyDetails value) { 2753 void DetailsAtPut(int entry, PropertyDetails value) {
2748 this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 2, value.AsSmi()); 2754 this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 2, value.AsSmi());
2749 } 2755 }
2750 2756
2751 // Sorting support 2757 // Sorting support
2752 void CopyValuesTo(FixedArray* elements); 2758 void CopyValuesTo(FixedArray* elements);
2753 2759
2754 // Delete a property from the dictionary. 2760 // Delete a property from the dictionary.
2755 Object* DeleteProperty(int entry, JSObject::DeleteMode mode); 2761 Object* DeleteProperty(int entry, JSObject::DeleteMode mode);
2756 2762
2763 // Attempt to shrink the dictionary after deletion of key.
2764 MUST_USE_RESULT MaybeObject* Shrink(Key key);
2765
2757 // Returns the number of elements in the dictionary filtering out properties 2766 // Returns the number of elements in the dictionary filtering out properties
2758 // with the specified attributes. 2767 // with the specified attributes.
2759 int NumberOfElementsFilterAttributes(PropertyAttributes filter); 2768 int NumberOfElementsFilterAttributes(PropertyAttributes filter);
2760 2769
2761 // Returns the number of enumerable elements in the dictionary. 2770 // Returns the number of enumerable elements in the dictionary.
2762 int NumberOfEnumElements(); 2771 int NumberOfEnumElements();
2763 2772
2764 // Copies keys to preallocated fixed array. 2773 // Copies keys to preallocated fixed array.
2765 void CopyKeysTo(FixedArray* storage, PropertyAttributes filter); 2774 void CopyKeysTo(FixedArray* storage, PropertyAttributes filter);
2766 // Fill in details for properties into storage. 2775 // Fill in details for properties into storage.
(...skipping 4354 matching lines...) Expand 10 before | Expand all | Expand 10 after
7121 } else { 7130 } else {
7122 value &= ~(1 << bit_position); 7131 value &= ~(1 << bit_position);
7123 } 7132 }
7124 return value; 7133 return value;
7125 } 7134 }
7126 }; 7135 };
7127 7136
7128 } } // namespace v8::internal 7137 } } // namespace v8::internal
7129 7138
7130 #endif // V8_OBJECTS_H_ 7139 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698