Commit 2d3311b8 authored by dcarney's avatar dcarney Committed by Commit bot

remove DeletedField from PropertyDetails

R=verwaest@chromium.org

BUG=

Review URL: https://codereview.chromium.org/1002703002

Cr-Commit-Position: refs/heads/master@{#27166}
parent c071af5a
......@@ -1751,8 +1751,7 @@ HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoad(HValue* receiver,
details_index->ClearFlag(HValue::kCanOverflow);
HValue* details =
Add<HLoadKeyed>(elements, details_index, nullptr, FAST_ELEMENTS);
int details_mask = PropertyDetails::TypeField::kMask |
PropertyDetails::DeletedField::kMask;
int details_mask = PropertyDetails::TypeField::kMask;
details = AddUncasted<HBitwise>(Token::BIT_AND, details,
Add<HConstant>(details_mask));
IfBuilder details_compare(this);
......
......@@ -57,12 +57,11 @@ LookupIterator::State LookupIterator::LookupInHolder(Map* map,
NameDictionary* dict = JSObject::cast(holder)->property_dictionary();
number_ = dict->FindEntry(name_);
if (number_ == NameDictionary::kNotFound) return NOT_FOUND;
property_details_ = dict->DetailsAt(number_);
if (holder->IsGlobalObject()) {
if (property_details_.IsDeleted()) return NOT_FOUND;
PropertyCell* cell = PropertyCell::cast(dict->ValueAt(number_));
if (cell->value()->IsTheHole()) return NOT_FOUND;
}
property_details_ = dict->DetailsAt(number_);
} else {
DescriptorArray* descriptors = map->instance_descriptors();
number_ = descriptors->SearchWithCache(*name_, map);
......
......@@ -51,12 +51,6 @@ Smi* PropertyDetails::AsSmi() const {
}
PropertyDetails PropertyDetails::AsDeleted() const {
Smi* smi = Smi::FromInt(value_ | DeletedField::encode(1));
return PropertyDetails(smi);
}
int PropertyDetails::field_width_in_words() const {
DCHECK(location() == kField);
if (!FLAG_unbox_double_fields) return 1;
......@@ -7004,9 +6998,7 @@ void Dictionary<Derived, Shape, Key>::SetEntry(int entry,
Handle<Object> key,
Handle<Object> value,
PropertyDetails details) {
DCHECK(!key->IsName() ||
details.IsDeleted() ||
details.dictionary_index() > 0);
DCHECK(!key->IsName() || details.dictionary_index() > 0);
int index = DerivedHashTable::EntryToIndex(entry);
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc);
......
This diff is collapsed.
......@@ -3527,6 +3527,9 @@ class StringTable: public HashTable<StringTable,
};
enum class DictionaryEntryType { kObjects, kCells };
template <typename Derived, typename Shape, typename Key>
class Dictionary: public HashTable<Derived, Shape, Key> {
protected:
......@@ -3555,9 +3558,6 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
this->set(DerivedHashTable::EntryToIndex(entry) + 2, value.AsSmi());
}
// Sorting support
void CopyValuesTo(FixedArray* elements);
// Delete a property from the dictionary.
static Handle<Object> DeleteProperty(Handle<Derived> dictionary, int entry);
......@@ -3568,27 +3568,82 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
return DerivedHashTable::Shrink(dictionary, key);
}
// Sorting support
// TODO(dcarney): templatize or move to SeededNumberDictionary
void CopyValuesTo(FixedArray* elements);
// Returns the number of elements in the dictionary filtering out properties
// with the specified attributes.
template <DictionaryEntryType type>
int NumberOfElementsFilterAttributes(PropertyAttributes filter);
int NumberOfElementsFilterAttributes(Object* holder,
PropertyAttributes filter) {
if (holder->IsGlobalObject()) {
return NumberOfElementsFilterAttributes<DictionaryEntryType::kCells>(
filter);
} else {
return NumberOfElementsFilterAttributes<DictionaryEntryType::kObjects>(
filter);
}
}
// Returns the number of enumerable elements in the dictionary.
int NumberOfEnumElements();
template <DictionaryEntryType type>
int NumberOfEnumElements() {
return NumberOfElementsFilterAttributes<type>(
static_cast<PropertyAttributes>(DONT_ENUM | SYMBOLIC));
}
int NumberOfEnumElements(Object* holder) {
if (holder->IsGlobalObject()) {
return NumberOfEnumElements<DictionaryEntryType::kCells>();
} else {
return NumberOfEnumElements<DictionaryEntryType::kObjects>();
}
}
// Returns true if the dictionary contains any elements that are non-writable,
// non-configurable, non-enumerable, or have getters/setters.
template <DictionaryEntryType type>
bool HasComplexElements();
bool HasComplexElements(Object* holder) {
if (holder->IsGlobalObject()) {
return HasComplexElements<DictionaryEntryType::kCells>();
} else {
return HasComplexElements<DictionaryEntryType::kObjects>();
}
}
enum SortMode { UNSORTED, SORTED };
// Copies keys to preallocated fixed array.
void CopyKeysTo(FixedArray* storage,
PropertyAttributes filter,
template <DictionaryEntryType type>
void CopyKeysTo(FixedArray* storage, PropertyAttributes filter,
SortMode sort_mode);
void CopyKeysTo(Object* holder, FixedArray* storage,
PropertyAttributes filter, SortMode sort_mode) {
if (holder->IsGlobalObject()) {
return CopyKeysTo<DictionaryEntryType::kCells>(storage, filter,
sort_mode);
} else {
return CopyKeysTo<DictionaryEntryType::kObjects>(storage, filter,
sort_mode);
}
}
// Fill in details for properties into storage.
void CopyKeysTo(FixedArray* storage,
int index,
PropertyAttributes filter,
template <DictionaryEntryType type>
void CopyKeysTo(FixedArray* storage, int index, PropertyAttributes filter,
SortMode sort_mode);
void CopyKeysTo(Object* holder, FixedArray* storage, int index,
PropertyAttributes filter, SortMode sort_mode) {
if (holder->IsGlobalObject()) {
return CopyKeysTo<DictionaryEntryType::kCells>(storage, index, filter,
sort_mode);
} else {
return CopyKeysTo<DictionaryEntryType::kObjects>(storage, index, filter,
sort_mode);
}
}
// Accessors for next enumeration index.
void SetNextEnumerationIndex(int index) {
......@@ -3681,7 +3736,16 @@ class NameDictionary: public Dictionary<NameDictionary,
DECLARE_CAST(NameDictionary)
// Copies enumerable keys to preallocated fixed array.
template <DictionaryEntryType type>
void CopyEnumKeysTo(FixedArray* storage);
void CopyEnumKeysTo(Object* holder, FixedArray* storage) {
if (holder->IsGlobalObject()) {
return CopyEnumKeysTo<DictionaryEntryType::kCells>(storage);
} else {
return CopyEnumKeysTo<DictionaryEntryType::kObjects>(storage);
}
}
inline static Handle<FixedArray> DoGenerateNewEnumerationIndices(
Handle<NameDictionary> dictionary);
......
......@@ -267,8 +267,6 @@ class PropertyDetails BASE_EMBEDDED {
inline int field_width_in_words() const;
inline PropertyDetails AsDeleted() const;
static bool IsValidIndex(int index) {
return DictionaryStorageField::is_valid(index);
}
......@@ -276,7 +274,6 @@ class PropertyDetails BASE_EMBEDDED {
bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; }
bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
bool IsDeleted() const { return DeletedField::decode(value_) != 0; }
// Bit fields in value_ (type, shift, size). Must be public so the
// constants can be embedded in generated code.
......@@ -285,8 +282,7 @@ class PropertyDetails BASE_EMBEDDED {
class AttributesField : public BitField<PropertyAttributes, 2, 3> {};
// Bit fields for normalized objects.
class DeletedField : public BitField<uint32_t, 5, 1> {};
class DictionaryStorageField : public BitField<uint32_t, 6, 24> {};
class DictionaryStorageField : public BitField<uint32_t, 5, 24> {};
// Bit fields for fast objects.
class RepresentationField : public BitField<uint32_t, 5, 4> {};
......
......@@ -1228,7 +1228,8 @@ RUNTIME_FUNCTION(Runtime_HasComplexElements) {
return isolate->heap()->true_value();
}
if (!current->HasDictionaryElements()) continue;
if (current->element_dictionary()->HasComplexElements()) {
if (current->element_dictionary()
->HasComplexElements<DictionaryEntryType::kObjects>()) {
return isolate->heap()->true_value();
}
}
......
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