Commit 3568a433 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Merge *NumberDictionary::Set and AtNumberPut

Bug: 
Change-Id: Idf5673ef3262c64d1c214362accc42554dbc2e69
Reviewed-on: https://chromium-review.googlesource.com/541340Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46090}
parent 94c95971
......@@ -311,7 +311,7 @@ void CacheTemplateInstantiation(Isolate* isolate, int serial_number,
Handle<UnseededNumberDictionary> cache =
isolate->slow_template_instantiations_cache();
auto new_cache =
UnseededNumberDictionary::AtNumberPut(cache, serial_number, object);
UnseededNumberDictionary::Set(cache, serial_number, object);
if (*new_cache != *cache) {
isolate->native_context()->set_slow_template_instantiations_cache(
*new_cache);
......
......@@ -461,8 +461,8 @@ class ArrayConcatVisitor {
// The object holding this backing store has just been allocated, so
// it cannot yet be used as a prototype.
Handle<JSObject> not_a_prototype_holder;
Handle<SeededNumberDictionary> result = SeededNumberDictionary::AtNumberPut(
dict, index, elm, not_a_prototype_holder);
Handle<SeededNumberDictionary> result =
SeededNumberDictionary::Set(dict, index, elm, not_a_prototype_holder);
if (!result.is_identical_to(dict)) {
// Dictionary needed to grow.
clear_storage();
......@@ -535,8 +535,8 @@ class ArrayConcatVisitor {
// it cannot yet be used as a prototype.
Handle<JSObject> not_a_prototype_holder;
Handle<SeededNumberDictionary> new_storage =
SeededNumberDictionary::AtNumberPut(slow_storage, i, element,
not_a_prototype_holder);
SeededNumberDictionary::Set(slow_storage, i, element,
not_a_prototype_holder);
if (!new_storage.is_identical_to(slow_storage)) {
slow_storage = loop_scope.CloseAndEscape(new_storage);
}
......
......@@ -188,11 +188,8 @@ Handle<Code> CodeStub::GetCode() {
AddToSpecialCache(new_object);
} else {
// Update the dictionary and the root in Heap.
Handle<UnseededNumberDictionary> dict =
UnseededNumberDictionary::AtNumberPut(
Handle<UnseededNumberDictionary>(heap->code_stubs()),
GetKey(),
new_object);
Handle<UnseededNumberDictionary> dict = UnseededNumberDictionary::Set(
handle(heap->code_stubs()), GetKey(), new_object);
heap->SetRootCodeStubs(*dict);
}
code = *new_object;
......
......@@ -708,8 +708,7 @@ class CaptureStackTraceHelper {
frame->set_is_constructor(summ.is_constructor());
frame->set_is_wasm(false);
if (!FLAG_optimize_for_size) {
auto new_cache =
UnseededNumberDictionary::AtNumberPut(cache, code_offset, frame);
auto new_cache = UnseededNumberDictionary::Set(cache, code_offset, frame);
if (*new_cache != *cache || !maybe_cache->IsUnseededNumberDictionary()) {
AbstractCode::SetStackFrameCache(summ.abstract_code(), new_cache);
}
......
......@@ -538,8 +538,8 @@ void LookupIterator::TransitionToAccessorPair(Handle<Object> pair,
Handle<SeededNumberDictionary> dictionary =
JSObject::NormalizeElements(receiver);
dictionary = SeededNumberDictionary::Set(dictionary, index_, pair, details,
receiver);
dictionary = SeededNumberDictionary::Set(dictionary, index_, pair, receiver,
details);
receiver->RequireSlowElements(*dictionary);
if (receiver->HasSlowArgumentsElements()) {
......
......@@ -16204,11 +16204,13 @@ Dictionary<GlobalDictionary, GlobalDictionaryShape>::New(
template Handle<SeededNumberDictionary>
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape>::AtPut(
Handle<SeededNumberDictionary>, uint32_t, Handle<Object>);
Handle<SeededNumberDictionary>, uint32_t, Handle<Object>,
PropertyDetails);
template Handle<UnseededNumberDictionary>
Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape>::AtPut(
Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>);
Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>,
PropertyDetails);
template Object*
Dictionary<SeededNumberDictionary,
......@@ -17550,17 +17552,20 @@ Handle<Object> Dictionary<Derived, Shape>::DeleteProperty(
template <typename Derived, typename Shape>
Handle<Derived> Dictionary<Derived, Shape>::AtPut(Handle<Derived> dictionary,
Key key,
Handle<Object> value) {
Key key, Handle<Object> value,
PropertyDetails details) {
int entry = dictionary->FindEntry(key);
// If the entry is present set the value;
if (entry != Dictionary::kNotFound) {
dictionary->ValueAtPut(entry, *value);
return dictionary;
if (entry == Dictionary::kNotFound) {
return Add(dictionary, key, value, details);
}
return Add(dictionary, key, value, PropertyDetails::Empty());
// We don't need to copy over the enumeration index.
DCHECK(!Shape::kIsEnumerable);
dictionary->ValueAtPut(entry, *value);
if (Shape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details);
return dictionary;
}
template <typename Derived, typename Shape>
......@@ -17664,11 +17669,12 @@ Handle<UnseededNumberDictionary> UnseededNumberDictionary::DeleteKey(
return dictionary->Shrink(dictionary);
}
Handle<SeededNumberDictionary> SeededNumberDictionary::AtNumberPut(
Handle<SeededNumberDictionary> SeededNumberDictionary::Set(
Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, Handle<JSObject> dictionary_holder) {
Handle<Object> value, Handle<JSObject> dictionary_holder,
PropertyDetails details) {
dictionary->UpdateMaxNumberKey(key, dictionary_holder);
return AtPut(dictionary, key, value);
return AtPut(dictionary, key, value, details);
}
void SeededNumberDictionary::CopyValuesTo(FixedArray* elements) {
......@@ -17686,40 +17692,11 @@ void SeededNumberDictionary::CopyValuesTo(FixedArray* elements) {
DCHECK(pos == elements->length());
}
Handle<UnseededNumberDictionary> UnseededNumberDictionary::AtNumberPut(
Handle<UnseededNumberDictionary> dictionary,
uint32_t key,
Handle<Object> value) {
return AtPut(dictionary, key, value);
}
Handle<SeededNumberDictionary> SeededNumberDictionary::Set(
Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, PropertyDetails details,
Handle<JSObject> dictionary_holder) {
int entry = dictionary->FindEntry(key);
if (entry == kNotFound) {
return AddNumberEntry(dictionary, key, value, details, dictionary_holder);
}
// Preserve enumeration index.
details = details.set_index(dictionary->DetailsAt(entry).dictionary_index());
Handle<Object> object_key =
SeededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
dictionary->SetEntry(entry, object_key, value, details);
return dictionary;
}
Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set(
Handle<UnseededNumberDictionary> dictionary,
uint32_t key,
Handle<Object> value) {
int entry = dictionary->FindEntry(key);
if (entry == kNotFound) return AddNumberEntry(dictionary, key, value);
Handle<Object> object_key =
UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
dictionary->SetEntry(entry, object_key, value);
return dictionary;
return AtPut(dictionary, key, value, PropertyDetails::Empty());
}
template <typename Derived, typename Shape>
......
......@@ -130,7 +130,8 @@ class Dictionary : public HashTable<Derived, Shape> {
protected:
// Generic at put operation.
MUST_USE_RESULT static Handle<Derived> AtPut(Handle<Derived> dictionary,
Key key, Handle<Object> value);
Key key, Handle<Object> value,
PropertyDetails details);
};
template <typename Key>
......@@ -265,21 +266,15 @@ class SeededNumberDictionary
DECLARE_CAST(SeededNumberDictionary)
// Type specific at put (default NONE attributes is used when adding).
MUST_USE_RESULT static Handle<SeededNumberDictionary> AtNumberPut(
MUST_USE_RESULT static Handle<SeededNumberDictionary> Set(
Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, Handle<JSObject> dictionary_holder);
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);
// Set an existing entry or add a new one if needed.
// Return the updated dictionary.
MUST_USE_RESULT static Handle<SeededNumberDictionary> Set(
Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, PropertyDetails details,
Handle<JSObject> dictionary_holder);
void UpdateMaxNumberKey(uint32_t key, Handle<JSObject> dictionary_holder);
// Returns true if the dictionary contains any elements that are non-writable,
......@@ -322,7 +317,7 @@ class UnseededNumberDictionary
DECLARE_CAST(UnseededNumberDictionary)
// Type specific at put (default NONE attributes is used when adding).
MUST_USE_RESULT static Handle<UnseededNumberDictionary> AtNumberPut(
MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
Handle<UnseededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value);
MUST_USE_RESULT static Handle<UnseededNumberDictionary> AddNumberEntry(
......@@ -331,12 +326,6 @@ class UnseededNumberDictionary
static Handle<UnseededNumberDictionary> DeleteKey(
Handle<UnseededNumberDictionary> dictionary, uint32_t key);
// Set an existing entry or add a new one if needed.
// Return the updated dictionary.
MUST_USE_RESULT static Handle<UnseededNumberDictionary> Set(
Handle<UnseededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value);
static const int kEntryValueIndex = 1;
static const int kEntryDetailsIndex = 2;
};
......
......@@ -1069,9 +1069,8 @@ void ValueDeserializer::TransferArrayBuffer(
Handle<SeededNumberDictionary> dictionary =
array_buffer_transfer_map_.ToHandleChecked();
Handle<JSObject> not_a_prototype_holder;
Handle<SeededNumberDictionary> new_dictionary =
SeededNumberDictionary::AtNumberPut(dictionary, transfer_id, array_buffer,
not_a_prototype_holder);
Handle<SeededNumberDictionary> new_dictionary = SeededNumberDictionary::Set(
dictionary, transfer_id, array_buffer, not_a_prototype_holder);
if (!new_dictionary.is_identical_to(dictionary)) {
GlobalHandles::Destroy(Handle<Object>::cast(dictionary).location());
array_buffer_transfer_map_ =
......
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