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, ...@@ -311,7 +311,7 @@ void CacheTemplateInstantiation(Isolate* isolate, int serial_number,
Handle<UnseededNumberDictionary> cache = Handle<UnseededNumberDictionary> cache =
isolate->slow_template_instantiations_cache(); isolate->slow_template_instantiations_cache();
auto new_cache = auto new_cache =
UnseededNumberDictionary::AtNumberPut(cache, serial_number, object); UnseededNumberDictionary::Set(cache, serial_number, object);
if (*new_cache != *cache) { if (*new_cache != *cache) {
isolate->native_context()->set_slow_template_instantiations_cache( isolate->native_context()->set_slow_template_instantiations_cache(
*new_cache); *new_cache);
......
...@@ -461,8 +461,8 @@ class ArrayConcatVisitor { ...@@ -461,8 +461,8 @@ class ArrayConcatVisitor {
// The object holding this backing store has just been allocated, so // The object holding this backing store has just been allocated, so
// it cannot yet be used as a prototype. // it cannot yet be used as a prototype.
Handle<JSObject> not_a_prototype_holder; Handle<JSObject> not_a_prototype_holder;
Handle<SeededNumberDictionary> result = SeededNumberDictionary::AtNumberPut( Handle<SeededNumberDictionary> result =
dict, index, elm, not_a_prototype_holder); SeededNumberDictionary::Set(dict, index, elm, not_a_prototype_holder);
if (!result.is_identical_to(dict)) { if (!result.is_identical_to(dict)) {
// Dictionary needed to grow. // Dictionary needed to grow.
clear_storage(); clear_storage();
...@@ -535,7 +535,7 @@ class ArrayConcatVisitor { ...@@ -535,7 +535,7 @@ class ArrayConcatVisitor {
// it cannot yet be used as a prototype. // it cannot yet be used as a prototype.
Handle<JSObject> not_a_prototype_holder; Handle<JSObject> not_a_prototype_holder;
Handle<SeededNumberDictionary> new_storage = Handle<SeededNumberDictionary> new_storage =
SeededNumberDictionary::AtNumberPut(slow_storage, i, element, SeededNumberDictionary::Set(slow_storage, i, element,
not_a_prototype_holder); not_a_prototype_holder);
if (!new_storage.is_identical_to(slow_storage)) { if (!new_storage.is_identical_to(slow_storage)) {
slow_storage = loop_scope.CloseAndEscape(new_storage); slow_storage = loop_scope.CloseAndEscape(new_storage);
......
...@@ -188,11 +188,8 @@ Handle<Code> CodeStub::GetCode() { ...@@ -188,11 +188,8 @@ Handle<Code> CodeStub::GetCode() {
AddToSpecialCache(new_object); AddToSpecialCache(new_object);
} else { } else {
// Update the dictionary and the root in Heap. // Update the dictionary and the root in Heap.
Handle<UnseededNumberDictionary> dict = Handle<UnseededNumberDictionary> dict = UnseededNumberDictionary::Set(
UnseededNumberDictionary::AtNumberPut( handle(heap->code_stubs()), GetKey(), new_object);
Handle<UnseededNumberDictionary>(heap->code_stubs()),
GetKey(),
new_object);
heap->SetRootCodeStubs(*dict); heap->SetRootCodeStubs(*dict);
} }
code = *new_object; code = *new_object;
......
...@@ -708,8 +708,7 @@ class CaptureStackTraceHelper { ...@@ -708,8 +708,7 @@ class CaptureStackTraceHelper {
frame->set_is_constructor(summ.is_constructor()); frame->set_is_constructor(summ.is_constructor());
frame->set_is_wasm(false); frame->set_is_wasm(false);
if (!FLAG_optimize_for_size) { if (!FLAG_optimize_for_size) {
auto new_cache = auto new_cache = UnseededNumberDictionary::Set(cache, code_offset, frame);
UnseededNumberDictionary::AtNumberPut(cache, code_offset, frame);
if (*new_cache != *cache || !maybe_cache->IsUnseededNumberDictionary()) { if (*new_cache != *cache || !maybe_cache->IsUnseededNumberDictionary()) {
AbstractCode::SetStackFrameCache(summ.abstract_code(), new_cache); AbstractCode::SetStackFrameCache(summ.abstract_code(), new_cache);
} }
......
...@@ -538,8 +538,8 @@ void LookupIterator::TransitionToAccessorPair(Handle<Object> pair, ...@@ -538,8 +538,8 @@ void LookupIterator::TransitionToAccessorPair(Handle<Object> pair,
Handle<SeededNumberDictionary> dictionary = Handle<SeededNumberDictionary> dictionary =
JSObject::NormalizeElements(receiver); JSObject::NormalizeElements(receiver);
dictionary = SeededNumberDictionary::Set(dictionary, index_, pair, details, dictionary = SeededNumberDictionary::Set(dictionary, index_, pair, receiver,
receiver); details);
receiver->RequireSlowElements(*dictionary); receiver->RequireSlowElements(*dictionary);
if (receiver->HasSlowArgumentsElements()) { if (receiver->HasSlowArgumentsElements()) {
......
...@@ -16204,11 +16204,13 @@ Dictionary<GlobalDictionary, GlobalDictionaryShape>::New( ...@@ -16204,11 +16204,13 @@ Dictionary<GlobalDictionary, GlobalDictionaryShape>::New(
template Handle<SeededNumberDictionary> template Handle<SeededNumberDictionary>
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape>::AtPut( Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape>::AtPut(
Handle<SeededNumberDictionary>, uint32_t, Handle<Object>); Handle<SeededNumberDictionary>, uint32_t, Handle<Object>,
PropertyDetails);
template Handle<UnseededNumberDictionary> template Handle<UnseededNumberDictionary>
Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape>::AtPut( Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape>::AtPut(
Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>); Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>,
PropertyDetails);
template Object* template Object*
Dictionary<SeededNumberDictionary, Dictionary<SeededNumberDictionary,
...@@ -17550,17 +17552,20 @@ Handle<Object> Dictionary<Derived, Shape>::DeleteProperty( ...@@ -17550,17 +17552,20 @@ Handle<Object> Dictionary<Derived, Shape>::DeleteProperty(
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
Handle<Derived> Dictionary<Derived, Shape>::AtPut(Handle<Derived> dictionary, Handle<Derived> Dictionary<Derived, Shape>::AtPut(Handle<Derived> dictionary,
Key key, Key key, Handle<Object> value,
Handle<Object> value) { PropertyDetails details) {
int entry = dictionary->FindEntry(key); int entry = dictionary->FindEntry(key);
// If the entry is present set the value; // If the entry is present set the value;
if (entry != Dictionary::kNotFound) { if (entry == Dictionary::kNotFound) {
dictionary->ValueAtPut(entry, *value); return Add(dictionary, key, value, details);
return dictionary;
} }
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> template <typename Derived, typename Shape>
...@@ -17664,11 +17669,12 @@ Handle<UnseededNumberDictionary> UnseededNumberDictionary::DeleteKey( ...@@ -17664,11 +17669,12 @@ Handle<UnseededNumberDictionary> UnseededNumberDictionary::DeleteKey(
return dictionary->Shrink(dictionary); return dictionary->Shrink(dictionary);
} }
Handle<SeededNumberDictionary> SeededNumberDictionary::AtNumberPut( 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,
PropertyDetails details) {
dictionary->UpdateMaxNumberKey(key, dictionary_holder); dictionary->UpdateMaxNumberKey(key, dictionary_holder);
return AtPut(dictionary, key, value); return AtPut(dictionary, key, value, details);
} }
void SeededNumberDictionary::CopyValuesTo(FixedArray* elements) { void SeededNumberDictionary::CopyValuesTo(FixedArray* elements) {
...@@ -17686,40 +17692,11 @@ void SeededNumberDictionary::CopyValuesTo(FixedArray* elements) { ...@@ -17686,40 +17692,11 @@ void SeededNumberDictionary::CopyValuesTo(FixedArray* elements) {
DCHECK(pos == elements->length()); 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> UnseededNumberDictionary::Set(
Handle<UnseededNumberDictionary> dictionary, Handle<UnseededNumberDictionary> dictionary,
uint32_t key, uint32_t key,
Handle<Object> value) { Handle<Object> value) {
int entry = dictionary->FindEntry(key); return AtPut(dictionary, key, value, PropertyDetails::Empty());
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;
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
......
...@@ -130,7 +130,8 @@ class Dictionary : public HashTable<Derived, Shape> { ...@@ -130,7 +130,8 @@ class Dictionary : public HashTable<Derived, Shape> {
protected: protected:
// Generic at put operation. // Generic at put operation.
MUST_USE_RESULT static Handle<Derived> AtPut(Handle<Derived> dictionary, 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> template <typename Key>
...@@ -265,21 +266,15 @@ class SeededNumberDictionary ...@@ -265,21 +266,15 @@ class SeededNumberDictionary
DECLARE_CAST(SeededNumberDictionary) DECLARE_CAST(SeededNumberDictionary)
// Type specific at put (default NONE attributes is used when adding). // 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<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( MUST_USE_RESULT static Handle<SeededNumberDictionary> AddNumberEntry(
Handle<SeededNumberDictionary> dictionary, uint32_t key, Handle<SeededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value, PropertyDetails details, Handle<Object> value, PropertyDetails details,
Handle<JSObject> dictionary_holder); 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); void UpdateMaxNumberKey(uint32_t key, Handle<JSObject> dictionary_holder);
// Returns true if the dictionary contains any elements that are non-writable, // Returns true if the dictionary contains any elements that are non-writable,
...@@ -322,7 +317,7 @@ class UnseededNumberDictionary ...@@ -322,7 +317,7 @@ class UnseededNumberDictionary
DECLARE_CAST(UnseededNumberDictionary) DECLARE_CAST(UnseededNumberDictionary)
// Type specific at put (default NONE attributes is used when adding). // 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<UnseededNumberDictionary> dictionary, uint32_t key,
Handle<Object> value); Handle<Object> value);
MUST_USE_RESULT static Handle<UnseededNumberDictionary> AddNumberEntry( MUST_USE_RESULT static Handle<UnseededNumberDictionary> AddNumberEntry(
...@@ -331,12 +326,6 @@ class UnseededNumberDictionary ...@@ -331,12 +326,6 @@ class UnseededNumberDictionary
static Handle<UnseededNumberDictionary> DeleteKey( static Handle<UnseededNumberDictionary> DeleteKey(
Handle<UnseededNumberDictionary> dictionary, uint32_t key); 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 kEntryValueIndex = 1;
static const int kEntryDetailsIndex = 2; static const int kEntryDetailsIndex = 2;
}; };
......
...@@ -1069,9 +1069,8 @@ void ValueDeserializer::TransferArrayBuffer( ...@@ -1069,9 +1069,8 @@ void ValueDeserializer::TransferArrayBuffer(
Handle<SeededNumberDictionary> dictionary = Handle<SeededNumberDictionary> dictionary =
array_buffer_transfer_map_.ToHandleChecked(); array_buffer_transfer_map_.ToHandleChecked();
Handle<JSObject> not_a_prototype_holder; Handle<JSObject> not_a_prototype_holder;
Handle<SeededNumberDictionary> new_dictionary = Handle<SeededNumberDictionary> new_dictionary = SeededNumberDictionary::Set(
SeededNumberDictionary::AtNumberPut(dictionary, transfer_id, array_buffer, dictionary, transfer_id, array_buffer, not_a_prototype_holder);
not_a_prototype_holder);
if (!new_dictionary.is_identical_to(dictionary)) { if (!new_dictionary.is_identical_to(dictionary)) {
GlobalHandles::Destroy(Handle<Object>::cast(dictionary).location()); GlobalHandles::Destroy(Handle<Object>::cast(dictionary).location());
array_buffer_transfer_map_ = 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