Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 1fee95b6b9a897615b25bcc36309a0a1206fdf6a..56f3491b8c24a9b09410f2cfe7323adf6916343e 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -5302,7 +5302,8 @@ void JSObject::DeleteHiddenProperty(Handle<JSObject> object, Handle<Name> key) { |
if (inline_value->IsUndefined() || inline_value->IsSmi()) return; |
Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); |
- ObjectHashTable::Put(hashtable, key, isolate->factory()->the_hole_value()); |
+ bool was_present = false; |
+ ObjectHashTable::Remove(hashtable, key, &was_present); |
} |
@@ -16173,6 +16174,7 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, |
Handle<Object> key, |
Handle<Object> value) { |
ASSERT(table->IsKey(*key)); |
+ ASSERT(!value->IsTheHole()); |
Isolate* isolate = table->GetIsolate(); |
@@ -16181,13 +16183,6 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, |
int entry = table->FindEntry(key); |
- // Check whether to perform removal operation. |
- if (value->IsTheHole()) { |
- if (entry == kNotFound) return table; |
- table->RemoveEntry(entry); |
- return Shrink(table, key); |
- } |
- |
// Key is already in table, just overwrite value. |
if (entry != kNotFound) { |
table->set(EntryToIndex(entry) + 1, *value); |
@@ -16203,6 +16198,29 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, |
} |
+Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, |
+ Handle<Object> key, |
+ bool* was_present) { |
+ ASSERT(table->IsKey(*key)); |
+ |
+ Object* hash = key->GetHash(); |
+ if (hash->IsUndefined()) { |
+ *was_present = false; |
+ return table; |
+ } |
+ |
+ int entry = table->FindEntry(key); |
+ if (entry == kNotFound) { |
+ *was_present = false; |
+ return table; |
+ } |
+ |
+ *was_present = true; |
+ table->RemoveEntry(entry); |
+ return Shrink(table, key); |
+} |
+ |
+ |
void ObjectHashTable::AddEntry(int entry, Object* key, Object* value) { |
set(EntryToIndex(entry), key); |
set(EntryToIndex(entry) + 1, value); |
@@ -16335,6 +16353,20 @@ Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Clear( |
template<class Derived, class Iterator, int entrysize> |
+Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Remove( |
+ Handle<Derived> table, Handle<Object> key, bool* was_present) { |
+ int entry = table->FindEntry(key); |
+ if (entry == kNotFound) { |
+ *was_present = false; |
+ return table; |
+ } |
+ *was_present = true; |
+ table->RemoveEntry(entry); |
+ return Shrink(table); |
+} |
+ |
+ |
+template<class Derived, class Iterator, int entrysize> |
Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Rehash( |
Handle<Derived> table, int new_capacity) { |
ASSERT(!table->IsObsolete()); |
@@ -16443,6 +16475,10 @@ template Handle<OrderedHashSet> |
OrderedHashTable<OrderedHashSet, JSSetIterator, 1>::Clear( |
Handle<OrderedHashSet> table); |
+template Handle<OrderedHashSet> |
+OrderedHashTable<OrderedHashSet, JSSetIterator, 1>::Remove( |
+ Handle<OrderedHashSet> table, Handle<Object> key, bool* was_present); |
+ |
template int |
OrderedHashTable<OrderedHashSet, JSSetIterator, 1>::FindEntry( |
Handle<Object> key); |
@@ -16470,6 +16506,10 @@ template Handle<OrderedHashMap> |
OrderedHashTable<OrderedHashMap, JSMapIterator, 2>::Clear( |
Handle<OrderedHashMap> table); |
+template Handle<OrderedHashMap> |
+OrderedHashTable<OrderedHashMap, JSMapIterator, 2>::Remove( |
+ Handle<OrderedHashMap> table, Handle<Object> key, bool* was_present); |
+ |
template int |
OrderedHashTable<OrderedHashMap, JSMapIterator, 2>::FindEntry( |
Handle<Object> key); |
@@ -16499,20 +16539,6 @@ Handle<OrderedHashSet> OrderedHashSet::Add(Handle<OrderedHashSet> table, |
} |
-Handle<OrderedHashSet> OrderedHashSet::Remove(Handle<OrderedHashSet> table, |
- Handle<Object> key, |
- bool* was_present) { |
- int entry = table->FindEntry(key); |
- if (entry == kNotFound) { |
- *was_present = false; |
- return table; |
- } |
- *was_present = true; |
- table->RemoveEntry(entry); |
- return Shrink(table); |
-} |
- |
- |
Object* OrderedHashMap::Lookup(Handle<Object> key) { |
DisallowHeapAllocation no_gc; |
int entry = FindEntry(key); |
@@ -16524,13 +16550,9 @@ Object* OrderedHashMap::Lookup(Handle<Object> key) { |
Handle<OrderedHashMap> OrderedHashMap::Put(Handle<OrderedHashMap> table, |
Handle<Object> key, |
Handle<Object> value) { |
- int entry = table->FindEntry(key); |
+ ASSERT(!key->IsTheHole()); |
- if (value->IsTheHole()) { |
- if (entry == kNotFound) return table; |
- table->RemoveEntry(entry); |
- return Shrink(table); |
- } |
+ int entry = table->FindEntry(key); |
if (entry != kNotFound) { |
table->set(table->EntryToIndex(entry) + kValueOffset, *value); |