Commit a1a05e5e authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Remove UND::DeleteKey and Shrink in DeleteProperty

Bug: 
Change-Id: Id05ac179899cfa802575c90ea1745375e2833825
Reviewed-on: https://chromium-review.googlesource.com/542617
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46117}
parent d54ffadf
...@@ -334,13 +334,8 @@ void UncacheTemplateInstantiation(Isolate* isolate, int serial_number, ...@@ -334,13 +334,8 @@ void UncacheTemplateInstantiation(Isolate* isolate, int serial_number,
isolate->slow_template_instantiations_cache(); isolate->slow_template_instantiations_cache();
int entry = cache->FindEntry(serial_number); int entry = cache->FindEntry(serial_number);
DCHECK_NE(UnseededNumberDictionary::kNotFound, entry); DCHECK_NE(UnseededNumberDictionary::kNotFound, entry);
Handle<Object> result = cache = UnseededNumberDictionary::DeleteEntry(cache, entry);
UnseededNumberDictionary::DeleteProperty(cache, entry); isolate->native_context()->set_slow_template_instantiations_cache(*cache);
USE(result);
DCHECK(result->IsTrue(isolate));
auto new_cache = UnseededNumberDictionary::Shrink(cache);
isolate->native_context()->set_slow_template_instantiations_cache(
*new_cache);
} }
} }
......
...@@ -120,7 +120,9 @@ Handle<Code> CodeStub::GetCodeCopy(const FindAndReplacePattern& pattern) { ...@@ -120,7 +120,9 @@ Handle<Code> CodeStub::GetCodeCopy(const FindAndReplacePattern& pattern) {
void CodeStub::DeleteStubFromCacheForTesting() { void CodeStub::DeleteStubFromCacheForTesting() {
Heap* heap = isolate_->heap(); Heap* heap = isolate_->heap();
Handle<UnseededNumberDictionary> dict(heap->code_stubs()); Handle<UnseededNumberDictionary> dict(heap->code_stubs());
dict = UnseededNumberDictionary::DeleteKey(dict, GetKey()); int entry = dict->FindEntry(GetKey());
DCHECK_NE(UnseededNumberDictionary::kNotFound, entry);
dict = UnseededNumberDictionary::DeleteEntry(dict, entry);
heap->SetRootCodeStubs(*dict); heap->SetRootCodeStubs(*dict);
} }
......
...@@ -1418,11 +1418,8 @@ class DictionaryElementsAccessor ...@@ -1418,11 +1418,8 @@ class DictionaryElementsAccessor
// TODO(verwaest): Remove reliance on index in Shrink. // TODO(verwaest): Remove reliance on index in Shrink.
Handle<SeededNumberDictionary> dict( Handle<SeededNumberDictionary> dict(
SeededNumberDictionary::cast(obj->elements())); SeededNumberDictionary::cast(obj->elements()));
Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); dict = SeededNumberDictionary::DeleteEntry(dict, entry);
USE(result); obj->set_elements(*dict);
DCHECK(result->IsTrue(dict->GetIsolate()));
Handle<FixedArray> new_elements = SeededNumberDictionary::Shrink(dict);
obj->set_elements(*new_elements);
} }
static bool HasAccessorsImpl(JSObject* holder, static bool HasAccessorsImpl(JSObject* holder,
...@@ -3718,14 +3715,9 @@ class SlowSloppyArgumentsElementsAccessor ...@@ -3718,14 +3715,9 @@ class SlowSloppyArgumentsElementsAccessor
Handle<SeededNumberDictionary> dict( Handle<SeededNumberDictionary> dict(
SeededNumberDictionary::cast(elements->arguments()), isolate); SeededNumberDictionary::cast(elements->arguments()), isolate);
int length = elements->parameter_map_length(); int length = elements->parameter_map_length();
Handle<Object> result = dict = SeededNumberDictionary::DeleteEntry(dict, entry - length);
SeededNumberDictionary::DeleteProperty(dict, entry - length); elements->set_arguments(*dict);
USE(result);
DCHECK(result->IsTrue(isolate));
Handle<FixedArray> new_elements = SeededNumberDictionary::Shrink(dict);
elements->set_arguments(*new_elements);
} }
static void AddImpl(Handle<JSObject> object, uint32_t index, static void AddImpl(Handle<JSObject> object, uint32_t index,
Handle<Object> value, PropertyAttributes attributes, Handle<Object> value, PropertyAttributes attributes,
uint32_t new_capacity) { uint32_t new_capacity) {
......
...@@ -6046,9 +6046,8 @@ void JSReceiver::DeleteNormalizedProperty(Handle<JSReceiver> object, ...@@ -6046,9 +6046,8 @@ void JSReceiver::DeleteNormalizedProperty(Handle<JSReceiver> object,
Handle<NameDictionary> dictionary(object->property_dictionary()); Handle<NameDictionary> dictionary(object->property_dictionary());
DCHECK_NE(NameDictionary::kNotFound, entry); DCHECK_NE(NameDictionary::kNotFound, entry);
NameDictionary::DeleteProperty(dictionary, entry); dictionary = NameDictionary::DeleteEntry(dictionary, entry);
Handle<NameDictionary> new_properties = NameDictionary::Shrink(dictionary); object->set_properties(*dictionary);
object->set_properties(*new_properties);
} }
} }
...@@ -16219,17 +16218,17 @@ Dictionary<SeededNumberDictionary, ...@@ -16219,17 +16218,17 @@ Dictionary<SeededNumberDictionary,
template Object* Dictionary< template Object* Dictionary<
NameDictionary, NameDictionaryShape>::SlowReverseLookup(Object* value); NameDictionary, NameDictionaryShape>::SlowReverseLookup(Object* value);
template Handle<Object> template Handle<NameDictionary>
Dictionary<NameDictionary, NameDictionaryShape>::DeleteProperty( Dictionary<NameDictionary, NameDictionaryShape>::DeleteEntry(
Handle<NameDictionary>, int); Handle<NameDictionary>, int);
template Handle<Object> template Handle<SeededNumberDictionary>
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape>::DeleteProperty( Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape>::DeleteEntry(
Handle<SeededNumberDictionary>, int); Handle<SeededNumberDictionary>, int);
template Handle<Object> template Handle<UnseededNumberDictionary>
Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape>:: Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape>::
DeleteProperty(Handle<UnseededNumberDictionary>, int); DeleteEntry(Handle<UnseededNumberDictionary>, int);
template Handle<NameDictionary> template Handle<NameDictionary>
HashTable<NameDictionary, NameDictionaryShape>::New(Isolate*, int, HashTable<NameDictionary, NameDictionaryShape>::New(Isolate*, int,
...@@ -17542,16 +17541,15 @@ Handle<Derived> Dictionary<Derived, Shape>::EnsureCapacity( ...@@ -17542,16 +17541,15 @@ Handle<Derived> Dictionary<Derived, Shape>::EnsureCapacity(
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
Handle<Object> Dictionary<Derived, Shape>::DeleteProperty( Handle<Derived> Dictionary<Derived, Shape>::DeleteEntry(
Handle<Derived> dictionary, int entry) { Handle<Derived> dictionary, int entry) {
Factory* factory = dictionary->GetIsolate()->factory(); Factory* factory = dictionary->GetIsolate()->factory();
PropertyDetails details = dictionary->DetailsAt(entry); DCHECK(Shape::kEntrySize != 3 ||
if (!details.IsConfigurable()) return factory->false_value(); dictionary->DetailsAt(entry).IsConfigurable());
dictionary->SetEntry( dictionary->SetEntry(
entry, factory->the_hole_value(), factory->the_hole_value()); entry, factory->the_hole_value(), factory->the_hole_value());
dictionary->ElementRemoved(); dictionary->ElementRemoved();
return factory->true_value(); return Shrink(dictionary);
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
...@@ -17643,18 +17641,6 @@ void SeededNumberDictionary::UpdateMaxNumberKey( ...@@ -17643,18 +17641,6 @@ void SeededNumberDictionary::UpdateMaxNumberKey(
} }
} }
Handle<UnseededNumberDictionary> UnseededNumberDictionary::DeleteKey(
Handle<UnseededNumberDictionary> dictionary, uint32_t key) {
int entry = dictionary->FindEntry(key);
if (entry == kNotFound) return dictionary;
Factory* factory = dictionary->GetIsolate()->factory();
dictionary->SetEntry(entry, factory->the_hole_value(),
factory->the_hole_value());
dictionary->ElementRemoved();
return dictionary->Shrink(dictionary);
}
Handle<SeededNumberDictionary> SeededNumberDictionary::Set( Handle<SeededNumberDictionary> SeededNumberDictionary::Set(
Handle<SeededNumberDictionary> dictionary, uint32_t key, Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, Handle<JSObject> dictionary_holder, Handle<Object> value, Handle<JSObject> dictionary_holder,
......
...@@ -53,7 +53,8 @@ class Dictionary : public HashTable<Derived, Shape> { ...@@ -53,7 +53,8 @@ class Dictionary : public HashTable<Derived, Shape> {
} }
// Delete a property from the dictionary. // Delete a property from the dictionary.
static Handle<Object> DeleteProperty(Handle<Derived> dictionary, int entry); MUST_USE_RESULT static Handle<Derived> DeleteEntry(Handle<Derived> dictionary,
int entry);
// Attempt to shrink the dictionary after deletion of key. // Attempt to shrink the dictionary after deletion of key.
MUST_USE_RESULT static inline Handle<Derived> Shrink( MUST_USE_RESULT static inline Handle<Derived> Shrink(
...@@ -323,8 +324,6 @@ class UnseededNumberDictionary ...@@ -323,8 +324,6 @@ class UnseededNumberDictionary
MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set( MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
Handle<UnseededNumberDictionary> dictionary, uint32_t key, Handle<UnseededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value); Handle<Object> value);
static Handle<UnseededNumberDictionary> DeleteKey(
Handle<UnseededNumberDictionary> dictionary, uint32_t key);
static const int kEntryValueIndex = 1; static const int kEntryValueIndex = 1;
static const int kEntryDetailsIndex = 2; static const int kEntryDetailsIndex = 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment