[runtime] Unify *DictionaryShape::SetEntry into *Dictionary::SetEntry
Bug: Change-Id: I45414453378c77f00ba01ca79fd4d84245c5a423 Reviewed-on: https://chromium-review.googlesource.com/544862 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#46143}
This commit is contained in:
parent
ab22e64ebe
commit
731d1b73af
@ -1385,13 +1385,12 @@ class DictionaryElementsAccessor
|
||||
DisallowHeapAllocation no_gc;
|
||||
// Remove elements that should be deleted.
|
||||
int removed_entries = 0;
|
||||
Handle<Object> the_hole_value = isolate->factory()->the_hole_value();
|
||||
for (int entry = 0; entry < capacity; entry++) {
|
||||
Object* index = dict->KeyAt(entry);
|
||||
if (index->IsNumber()) {
|
||||
uint32_t number = static_cast<uint32_t>(index->Number());
|
||||
if (length <= number && number < old_length) {
|
||||
dict->SetEntry(entry, the_hole_value, the_hole_value);
|
||||
dict->ClearEntry(entry);
|
||||
removed_entries++;
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ void LookupIterator::ReconfigureDataProperty(Handle<Object> value,
|
||||
int enumeration_index = original_details.dictionary_index();
|
||||
DCHECK(enumeration_index > 0);
|
||||
details = details.set_index(enumeration_index);
|
||||
dictionary->SetEntry(dictionary_entry(), name(), value, details);
|
||||
dictionary->SetEntry(dictionary_entry(), *name(), *value, details);
|
||||
property_details_ = details;
|
||||
}
|
||||
state_ = DATA;
|
||||
|
@ -6043,51 +6043,22 @@ bool AccessorPair::IsJSAccessor(Object* obj) {
|
||||
}
|
||||
|
||||
template <typename Derived, typename Shape>
|
||||
void Dictionary<Derived, Shape>::SetEntry(int entry, Handle<Object> key,
|
||||
Handle<Object> value) {
|
||||
this->SetEntry(entry, key, value, PropertyDetails(Smi::kZero));
|
||||
void Dictionary<Derived, Shape>::ClearEntry(int entry) {
|
||||
Object* the_hole = this->GetHeap()->the_hole_value();
|
||||
SetEntry(entry, the_hole, the_hole, PropertyDetails::Empty());
|
||||
}
|
||||
|
||||
template <typename Derived, typename Shape>
|
||||
void Dictionary<Derived, Shape>::SetEntry(int entry, Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
void Dictionary<Derived, Shape>::SetEntry(int entry, Object* key, Object* value,
|
||||
PropertyDetails details) {
|
||||
Shape::SetEntry(static_cast<Derived*>(this), entry, key, value, details);
|
||||
}
|
||||
|
||||
|
||||
template <typename Key>
|
||||
template <typename Dictionary>
|
||||
void BaseDictionaryShape<Key>::SetEntry(Dictionary* dict, int entry,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details) {
|
||||
STATIC_ASSERT(Dictionary::kEntrySize == 2 || Dictionary::kEntrySize == 3);
|
||||
DCHECK(!key->IsName() || details.dictionary_index() > 0);
|
||||
int index = dict->EntryToIndex(entry);
|
||||
int index = DerivedHashTable::EntryToIndex(entry);
|
||||
DisallowHeapAllocation no_gc;
|
||||
WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
|
||||
dict->set(index + Dictionary::kEntryKeyIndex, *key, mode);
|
||||
dict->set(index + Dictionary::kEntryValueIndex, *value, mode);
|
||||
if (Dictionary::kEntrySize == 3) {
|
||||
dict->set(index + Dictionary::kEntryDetailsIndex, details.AsSmi());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename Dictionary>
|
||||
void GlobalDictionaryShape::SetEntry(Dictionary* dict, int entry,
|
||||
Handle<Object> key, Handle<Object> value,
|
||||
PropertyDetails details) {
|
||||
STATIC_ASSERT(Dictionary::kEntrySize == 2);
|
||||
DCHECK(!key->IsName() || details.dictionary_index() > 0);
|
||||
DCHECK(value->IsPropertyCell());
|
||||
int index = dict->EntryToIndex(entry);
|
||||
DisallowHeapAllocation no_gc;
|
||||
WriteBarrierMode mode = dict->GetWriteBarrierMode(no_gc);
|
||||
dict->set(index + Dictionary::kEntryKeyIndex, *key, mode);
|
||||
dict->set(index + Dictionary::kEntryValueIndex, *value, mode);
|
||||
PropertyCell::cast(*value)->set_property_details(details);
|
||||
WriteBarrierMode mode = this->GetWriteBarrierMode(no_gc);
|
||||
this->set(index + Derived::kEntryKeyIndex, key, mode);
|
||||
this->set(index + Derived::kEntryValueIndex, value, mode);
|
||||
if (Shape::kHasDetails) DetailsAtPut(entry, details);
|
||||
}
|
||||
|
||||
|
||||
@ -6152,7 +6123,7 @@ Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate,
|
||||
|
||||
template <typename Dictionary>
|
||||
PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary* dict, int entry) {
|
||||
DCHECK(entry >= 0); // Not found is -1, which is not caught by get().
|
||||
DCHECK_LE(0, entry); // Not found is -1, which is not caught by get().
|
||||
Object* raw_value = dict->ValueAt(entry);
|
||||
DCHECK(raw_value->IsPropertyCell());
|
||||
PropertyCell* cell = PropertyCell::cast(raw_value);
|
||||
@ -6163,10 +6134,8 @@ PropertyDetails GlobalDictionaryShape::DetailsAt(Dictionary* dict, int entry) {
|
||||
template <typename Dictionary>
|
||||
void GlobalDictionaryShape::DetailsAtPut(Dictionary* dict, int entry,
|
||||
PropertyDetails value) {
|
||||
DCHECK(entry >= 0); // Not found is -1, which is not caught by get().
|
||||
Object* raw_value = dict->ValueAt(entry);
|
||||
DCHECK(raw_value->IsPropertyCell());
|
||||
PropertyCell* cell = PropertyCell::cast(raw_value);
|
||||
DCHECK_LE(0, entry); // Not found is -1, which is not caught by get().
|
||||
PropertyCell* cell = PropertyCell::cast(dict->ValueAt(entry));
|
||||
if (cell->property_details().IsReadOnly() != value.IsReadOnly()) {
|
||||
cell->dependent_code()->DeoptimizeDependentCodeGroup(
|
||||
cell->GetIsolate(), DependentCode::kPropertyCellChangedGroup);
|
||||
@ -6174,7 +6143,6 @@ void GlobalDictionaryShape::DetailsAtPut(Dictionary* dict, int entry,
|
||||
cell->set_property_details(value);
|
||||
}
|
||||
|
||||
|
||||
template <typename Dictionary>
|
||||
bool GlobalDictionaryShape::IsDeleted(Dictionary* dict, int entry) {
|
||||
DCHECK(dict->ValueAt(entry)->IsPropertyCell());
|
||||
|
@ -1953,7 +1953,7 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
|
||||
int enumeration_index = original_details.dictionary_index();
|
||||
DCHECK(enumeration_index > 0);
|
||||
details = details.set_index(enumeration_index);
|
||||
dictionary->SetEntry(entry, name, value, details);
|
||||
dictionary->SetEntry(entry, *name, *value, details);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17570,11 +17570,9 @@ Handle<Derived> BaseNameDictionary<Derived, Shape>::EnsureCapacity(
|
||||
template <typename Derived, typename Shape>
|
||||
Handle<Derived> Dictionary<Derived, Shape>::DeleteEntry(
|
||||
Handle<Derived> dictionary, int entry) {
|
||||
Factory* factory = dictionary->GetIsolate()->factory();
|
||||
DCHECK(Shape::kEntrySize != 3 ||
|
||||
dictionary->DetailsAt(entry).IsConfigurable());
|
||||
dictionary->SetEntry(
|
||||
entry, factory->the_hole_value(), factory->the_hole_value());
|
||||
dictionary->ClearEntry(entry);
|
||||
dictionary->ElementRemoved();
|
||||
return Shrink(dictionary);
|
||||
}
|
||||
@ -17627,7 +17625,7 @@ Handle<Derived> Dictionary<Derived, Shape>::Add(Handle<Derived> dictionary,
|
||||
Handle<Object> k = Shape::AsHandle(isolate, key);
|
||||
|
||||
uint32_t entry = dictionary->FindInsertionEntry(hash);
|
||||
dictionary->SetEntry(entry, k, value, details);
|
||||
dictionary->SetEntry(entry, *k, *value, details);
|
||||
DCHECK(dictionary->KeyAt(entry)->IsNumber() ||
|
||||
dictionary->KeyAt(entry)->IsUniqueName());
|
||||
dictionary->ElementAdded();
|
||||
|
@ -74,8 +74,8 @@ class Dictionary : public HashTable<Derived, Shape> {
|
||||
Object* SlowReverseLookup(Object* value);
|
||||
|
||||
// Sets the entry to (key, value) pair.
|
||||
inline void SetEntry(int entry, Handle<Object> key, Handle<Object> value);
|
||||
inline void SetEntry(int entry, Handle<Object> key, Handle<Object> value,
|
||||
inline void ClearEntry(int entry);
|
||||
inline void SetEntry(int entry, Object* key, Object* value,
|
||||
PropertyDetails details);
|
||||
|
||||
MUST_USE_RESULT static Handle<Derived> Add(Handle<Derived> dictionary,
|
||||
@ -93,6 +93,7 @@ class Dictionary : public HashTable<Derived, Shape> {
|
||||
template <typename Key>
|
||||
class BaseDictionaryShape : public BaseShape<Key> {
|
||||
public:
|
||||
static const bool kHasDetails = true;
|
||||
template <typename Dictionary>
|
||||
static inline PropertyDetails DetailsAt(Dictionary* dict, int entry) {
|
||||
STATIC_ASSERT(Dictionary::kEntrySize == 3);
|
||||
@ -113,10 +114,6 @@ class BaseDictionaryShape : public BaseShape<Key> {
|
||||
static bool IsDeleted(Dictionary* dict, int entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Dictionary>
|
||||
static inline void SetEntry(Dictionary* dict, int entry, Handle<Object> key,
|
||||
Handle<Object> value, PropertyDetails details);
|
||||
};
|
||||
|
||||
class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
|
||||
@ -200,10 +197,6 @@ class GlobalDictionaryShape : public NameDictionaryShape {
|
||||
|
||||
template <typename Dictionary>
|
||||
static bool IsDeleted(Dictionary* dict, int entry);
|
||||
|
||||
template <typename Dictionary>
|
||||
static inline void SetEntry(Dictionary* dict, int entry, Handle<Object> key,
|
||||
Handle<Object> value, PropertyDetails details);
|
||||
};
|
||||
|
||||
class GlobalDictionary
|
||||
@ -231,6 +224,7 @@ class SeededNumberDictionaryShape : public NumberDictionaryShape {
|
||||
|
||||
class UnseededNumberDictionaryShape : public NumberDictionaryShape {
|
||||
public:
|
||||
static const bool kHasDetails = false;
|
||||
static const int kPrefixSize = 0;
|
||||
static const int kEntrySize = 2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user