Commit 95d18f7b authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Replace SeededNumberDictionary::AddNumberEntry with Add

UpdateMaxNumberKey calls are moved to clients, who do have the
dictionary-holder.  ::Add should basically always UpdateMaxNumberKey. I'm
reducing the number of entry points before looking into how to guarantee this.

Bug: 
Change-Id: Iefe8a7fdf7c1e0a6d731bfd948d22849714498a9
Reviewed-on: https://chromium-review.googlesource.com/542895
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46104}
parent 12b2c5ec
......@@ -1484,8 +1484,8 @@ class DictionaryElementsAccessor
? JSObject::NormalizeElements(object)
: handle(SeededNumberDictionary::cast(object->elements()));
Handle<SeededNumberDictionary> new_dictionary =
SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
details, object);
SeededNumberDictionary::Add(dictionary, index, value, details);
new_dictionary->UpdateMaxNumberKey(index, object);
if (attributes != NONE) object->RequireSlowElements(*new_dictionary);
if (dictionary.is_identical_to(new_dictionary)) return;
object->set_elements(*new_dictionary);
......@@ -1826,15 +1826,21 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
PropertyDetails details = PropertyDetails::Empty();
int j = 0;
int max_number_key = -1;
for (int i = 0; j < capacity; i++) {
if (IsHoleyElementsKind(kind)) {
if (BackingStore::cast(*store)->is_the_hole(isolate, i)) continue;
}
max_number_key = i;
Handle<Object> value = Subclass::GetImpl(isolate, *store, i);
dictionary = SeededNumberDictionary::AddNumberEntry(dictionary, i, value,
details, object);
dictionary = SeededNumberDictionary::Add(dictionary, i, value, details);
j++;
}
if (max_number_key > 0) {
dictionary->UpdateMaxNumberKey(static_cast<uint32_t>(max_number_key),
object);
}
return dictionary;
}
......@@ -3734,8 +3740,7 @@ class SlowSloppyArgumentsElementsAccessor
: JSObject::NormalizeElements(object);
PropertyDetails details(kData, attributes, 0, PropertyCellType::kNoCell);
Handle<SeededNumberDictionary> new_dictionary =
SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
details, object);
SeededNumberDictionary::Add(dictionary, index, value, details);
if (attributes != NONE) object->RequireSlowElements(*new_dictionary);
if (*dictionary != *new_dictionary) {
elements->set_arguments(*new_dictionary);
......@@ -3768,8 +3773,7 @@ class SlowSloppyArgumentsElementsAccessor
PropertyDetails details(kData, attributes, 0, PropertyCellType::kNoCell);
Handle<SeededNumberDictionary> arguments(
SeededNumberDictionary::cast(elements->arguments()), isolate);
arguments = SeededNumberDictionary::AddNumberEntry(
arguments, entry, value, details, object);
arguments = SeededNumberDictionary::Add(arguments, entry, value, details);
// If the attributes were NONE, we would have called set rather than
// reconfigure.
DCHECK_NE(NONE, attributes);
......
......@@ -16365,8 +16365,8 @@ Handle<Object> JSObject::PrepareSlowElementsForSort(
// allocation. Bailout.
return bailout;
} else {
Handle<Object> result = SeededNumberDictionary::AddNumberEntry(
new_dict, pos, value, details, object);
Handle<Object> result =
SeededNumberDictionary::Add(new_dict, pos, value, details);
DCHECK(result.is_identical_to(new_dict));
USE(result);
pos++;
......@@ -16376,8 +16376,8 @@ Handle<Object> JSObject::PrepareSlowElementsForSort(
// allocation. Bailout.
return bailout;
} else {
Handle<Object> result = SeededNumberDictionary::AddNumberEntry(
new_dict, key, value, details, object);
Handle<Object> result =
SeededNumberDictionary::Add(new_dict, key, value, details);
DCHECK(result.is_identical_to(new_dict));
USE(result);
}
......@@ -16392,9 +16392,8 @@ Handle<Object> JSObject::PrepareSlowElementsForSort(
return bailout;
}
HandleScope scope(isolate);
Handle<Object> result = SeededNumberDictionary::AddNumberEntry(
new_dict, pos, isolate->factory()->undefined_value(), no_details,
object);
Handle<Object> result = SeededNumberDictionary::Add(
new_dict, pos, isolate->factory()->undefined_value(), no_details);
DCHECK(result.is_identical_to(new_dict));
USE(result);
pos++;
......@@ -16402,6 +16401,7 @@ Handle<Object> JSObject::PrepareSlowElementsForSort(
}
object->set_elements(*new_dict);
new_dict->UpdateMaxNumberKey(pos - 1, object);
AllowHeapAllocation allocate_return_value;
return isolate->factory()->NewNumberFromUint(result);
......@@ -17643,24 +17643,6 @@ void SeededNumberDictionary::UpdateMaxNumberKey(
}
}
Handle<SeededNumberDictionary> SeededNumberDictionary::AddNumberEntry(
Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, PropertyDetails details,
Handle<JSObject> dictionary_holder) {
dictionary->UpdateMaxNumberKey(key, dictionary_holder);
SLOW_DCHECK(dictionary->FindEntry(key) == kNotFound);
return Add(dictionary, key, value, details);
}
Handle<UnseededNumberDictionary> UnseededNumberDictionary::AddNumberEntry(
Handle<UnseededNumberDictionary> dictionary,
uint32_t key,
Handle<Object> value) {
SLOW_DCHECK(dictionary->FindEntry(key) == kNotFound);
return Add(dictionary, key, value, PropertyDetails::Empty());
}
Handle<UnseededNumberDictionary> UnseededNumberDictionary::DeleteKey(
Handle<UnseededNumberDictionary> dictionary, uint32_t key) {
int entry = dictionary->FindEntry(key);
......
......@@ -276,10 +276,6 @@ class SeededNumberDictionary
Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, Handle<JSObject> dictionary_holder,
PropertyDetails details = PropertyDetails::Empty());
MUST_USE_RESULT static Handle<SeededNumberDictionary> AddNumberEntry(
Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, PropertyDetails details,
Handle<JSObject> dictionary_holder);
static const int kMaxNumberKeyIndex = kPrefixStartIndex;
void UpdateMaxNumberKey(uint32_t key, Handle<JSObject> dictionary_holder);
......@@ -327,9 +323,6 @@ class UnseededNumberDictionary
MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
Handle<UnseededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value);
MUST_USE_RESULT static Handle<UnseededNumberDictionary> AddNumberEntry(
Handle<UnseededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value);
static Handle<UnseededNumberDictionary> DeleteKey(
Handle<UnseededNumberDictionary> dictionary, uint32_t key);
......
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