Commit b186ca9c authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Move MaxNumberKey and NextEnumerationIndex to the subclasses that use it

Bug: 
Change-Id: Ica3ebd998ad44d24c401cfb74cf5cbe3a6164c47
Reviewed-on: https://chromium-review.googlesource.com/541344
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46099}
parent af1c9e34
...@@ -2106,8 +2106,6 @@ Node* CodeStubAssembler::AllocateNameDictionaryWithCapacity(Node* capacity) { ...@@ -2106,8 +2106,6 @@ Node* CodeStubAssembler::AllocateNameDictionaryWithCapacity(Node* capacity) {
SmiTag(capacity), SKIP_WRITE_BARRIER); SmiTag(capacity), SKIP_WRITE_BARRIER);
// Initialize Dictionary fields. // Initialize Dictionary fields.
Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex);
StoreFixedArrayElement(result, NameDictionary::kMaxNumberKeyIndex, filler,
SKIP_WRITE_BARRIER);
StoreFixedArrayElement(result, NameDictionary::kNextEnumerationIndexIndex, StoreFixedArrayElement(result, NameDictionary::kNextEnumerationIndexIndex,
SmiConstant(PropertyDetails::kInitialIndex), SmiConstant(PropertyDetails::kInitialIndex),
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
......
...@@ -998,7 +998,7 @@ FieldAccess AccessBuilder::ForHashTableBaseCapacity() { ...@@ -998,7 +998,7 @@ FieldAccess AccessBuilder::ForHashTableBaseCapacity() {
FieldAccess AccessBuilder::ForDictionaryMaxNumberKey() { FieldAccess AccessBuilder::ForDictionaryMaxNumberKey() {
FieldAccess access = { FieldAccess access = {
kTaggedBase, kTaggedBase,
FixedArray::OffsetOfElementAt(NameDictionary::kMaxNumberKeyIndex), FixedArray::OffsetOfElementAt(SeededNumberDictionary::kMaxNumberKeyIndex),
MaybeHandle<Name>(), MaybeHandle<Name>(),
MaybeHandle<Map>(), MaybeHandle<Map>(),
Type::Any(), Type::Any(),
......
...@@ -1928,15 +1928,12 @@ Reduction JSBuiltinReducer::ReduceObjectCreate(Node* node) { ...@@ -1928,15 +1928,12 @@ Reduction JSBuiltinReducer::ReduceObjectCreate(Node* node) {
value, jsgraph()->SmiConstant(capacity), effect, control); value, jsgraph()->SmiConstant(capacity), effect, control);
// Initialize Dictionary fields. // Initialize Dictionary fields.
Node* undefined = jsgraph()->UndefinedConstant(); Node* undefined = jsgraph()->UndefinedConstant();
effect = graph()->NewNode(
simplified()->StoreField(AccessBuilder::ForDictionaryMaxNumberKey()),
value, undefined, effect, control);
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->StoreField( simplified()->StoreField(
AccessBuilder::ForDictionaryNextEnumerationIndex()), AccessBuilder::ForDictionaryNextEnumerationIndex()),
value, jsgraph()->SmiConstant(PropertyDetails::kInitialIndex), effect, value, jsgraph()->SmiConstant(PropertyDetails::kInitialIndex), effect,
control); control);
// Initialize hte Properties fields. // Initialize the Properties fields.
for (int index = NameDictionary::kNextEnumerationIndexIndex + 1; for (int index = NameDictionary::kNextEnumerationIndexIndex + 1;
index < length; index++) { index < length; index++) {
effect = graph()->NewNode( effect = graph()->NewNode(
......
...@@ -17479,8 +17479,10 @@ Handle<Derived> Dictionary<Derived, Shape>::New( ...@@ -17479,8 +17479,10 @@ Handle<Derived> Dictionary<Derived, Shape>::New(
Handle<Derived> dict = DerivedHashTable::New(isolate, at_least_space_for, Handle<Derived> dict = DerivedHashTable::New(isolate, at_least_space_for,
capacity_option, pretenure); capacity_option, pretenure);
// Initialize the next enumeration index. if (Shape::kIsEnumerable) {
dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex); // Initialize the next enumeration index.
dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
}
return dict; return dict;
} }
...@@ -17490,8 +17492,10 @@ Handle<Derived> Dictionary<Derived, Shape>::NewEmpty(Isolate* isolate, ...@@ -17490,8 +17492,10 @@ Handle<Derived> Dictionary<Derived, Shape>::NewEmpty(Isolate* isolate,
Handle<Derived> dict = DerivedHashTable::New(isolate, 1, pretenure); Handle<Derived> dict = DerivedHashTable::New(isolate, 1, pretenure);
// Attempt to add one element to the empty dictionary must cause reallocation. // Attempt to add one element to the empty dictionary must cause reallocation.
DCHECK(!dict->HasSufficientCapacityToAdd(1)); DCHECK(!dict->HasSufficientCapacityToAdd(1));
// Initialize the next enumeration index. if (Shape::kIsEnumerable) {
dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex); // Initialize the next enumeration index.
dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
}
return dict; return dict;
} }
......
...@@ -61,6 +61,9 @@ class Dictionary : public HashTable<Derived, Shape> { ...@@ -61,6 +61,9 @@ class Dictionary : public HashTable<Derived, Shape> {
return DerivedHashTable::Shrink(dictionary); return DerivedHashTable::Shrink(dictionary);
} }
int NextEnumerationIndex() { UNREACHABLE(); }
void SetNextEnumerationIndex(int index) { UNREACHABLE(); }
int NumberOfEnumerableProperties(); int NumberOfEnumerableProperties();
// Return the key indices sorted by its enumeration index. // Return the key indices sorted by its enumeration index.
...@@ -77,16 +80,6 @@ class Dictionary : public HashTable<Derived, Shape> { ...@@ -77,16 +80,6 @@ class Dictionary : public HashTable<Derived, Shape> {
Handle<FixedArray> storage, KeyCollectionMode mode, Handle<FixedArray> storage, KeyCollectionMode mode,
KeyAccumulator* accumulator); KeyAccumulator* accumulator);
// Accessors for next enumeration index.
void SetNextEnumerationIndex(int index) {
DCHECK(index != 0);
this->set(kNextEnumerationIndexIndex, Smi::FromInt(index));
}
int NextEnumerationIndex() {
return Smi::cast(this->get(kNextEnumerationIndexIndex))->value();
}
// Creates a new dictionary. // Creates a new dictionary.
MUST_USE_RESULT static Handle<Derived> New( MUST_USE_RESULT static Handle<Derived> New(
Isolate* isolate, int at_least_space_for, Isolate* isolate, int at_least_space_for,
...@@ -122,9 +115,6 @@ class Dictionary : public HashTable<Derived, Shape> { ...@@ -122,9 +115,6 @@ class Dictionary : public HashTable<Derived, Shape> {
PropertyDetails details, PropertyDetails details,
int* entry_out = nullptr); int* entry_out = nullptr);
static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex;
static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
static const bool kIsEnumerable = Shape::kIsEnumerable; static const bool kIsEnumerable = Shape::kIsEnumerable;
protected: protected:
...@@ -169,7 +159,7 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> { ...@@ -169,7 +159,7 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
static inline uint32_t Hash(Handle<Name> key); static inline uint32_t Hash(Handle<Name> key);
static inline uint32_t HashForObject(Object* object); static inline uint32_t HashForObject(Object* object);
static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key); static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key);
static const int kPrefixSize = 2; static const int kPrefixSize = 1;
static const int kEntrySize = 3; static const int kEntrySize = 3;
static const int kEntryValueIndex = 1; static const int kEntryValueIndex = 1;
static const int kEntryDetailsIndex = 2; static const int kEntryDetailsIndex = 2;
...@@ -177,13 +167,29 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> { ...@@ -177,13 +167,29 @@ class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
static const bool kNeedsHoleCheck = false; static const bool kNeedsHoleCheck = false;
}; };
class NameDictionary : public Dictionary<NameDictionary, NameDictionaryShape> { template <typename Derived, typename Shape>
typedef Dictionary<NameDictionary, NameDictionaryShape> DerivedDictionary; class BaseNameDictionary : public Dictionary<Derived, Shape> {
public:
static const int kNextEnumerationIndexIndex =
HashTableBase::kPrefixStartIndex;
static const int kEntryValueIndex = 1;
// Accessors for next enumeration index.
void SetNextEnumerationIndex(int index) {
DCHECK_NE(0, index);
this->set(kNextEnumerationIndexIndex, Smi::FromInt(index));
}
int NextEnumerationIndex() {
return Smi::cast(this->get(kNextEnumerationIndexIndex))->value();
}
};
class NameDictionary
: public BaseNameDictionary<NameDictionary, NameDictionaryShape> {
public: public:
DECLARE_CAST(NameDictionary) DECLARE_CAST(NameDictionary)
static const int kEntryValueIndex = 1;
static const int kEntryDetailsIndex = 2; static const int kEntryDetailsIndex = 2;
static const int kInitialCapacity = 2; static const int kInitialCapacity = 2;
}; };
...@@ -208,7 +214,7 @@ class GlobalDictionaryShape : public NameDictionaryShape { ...@@ -208,7 +214,7 @@ class GlobalDictionaryShape : public NameDictionaryShape {
}; };
class GlobalDictionary class GlobalDictionary
: public Dictionary<GlobalDictionary, GlobalDictionaryShape> { : public BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape> {
public: public:
DECLARE_CAST(GlobalDictionary) DECLARE_CAST(GlobalDictionary)
...@@ -225,7 +231,7 @@ class NumberDictionaryShape : public BaseDictionaryShape<uint32_t> { ...@@ -225,7 +231,7 @@ class NumberDictionaryShape : public BaseDictionaryShape<uint32_t> {
class SeededNumberDictionaryShape : public NumberDictionaryShape { class SeededNumberDictionaryShape : public NumberDictionaryShape {
public: public:
static const bool UsesSeed = true; static const bool UsesSeed = true;
static const int kPrefixSize = 2; static const int kPrefixSize = 1;
static const int kEntrySize = 3; static const int kEntrySize = 3;
static inline uint32_t SeededHash(uint32_t key, uint32_t seed); static inline uint32_t SeededHash(uint32_t key, uint32_t seed);
...@@ -275,6 +281,7 @@ class SeededNumberDictionary ...@@ -275,6 +281,7 @@ class SeededNumberDictionary
Handle<Object> value, PropertyDetails details, Handle<Object> value, PropertyDetails details,
Handle<JSObject> dictionary_holder); Handle<JSObject> dictionary_holder);
static const int kMaxNumberKeyIndex = kPrefixStartIndex;
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,
......
...@@ -296,18 +296,18 @@ KNOWN_OBJECTS = { ...@@ -296,18 +296,18 @@ KNOWN_OBJECTS = {
("OLD_SPACE", 0x02811): "UndefinedCell", ("OLD_SPACE", 0x02811): "UndefinedCell",
("OLD_SPACE", 0x02821): "EmptySloppyArgumentsElements", ("OLD_SPACE", 0x02821): "EmptySloppyArgumentsElements",
("OLD_SPACE", 0x02841): "EmptySlowElementDictionary", ("OLD_SPACE", 0x02841): "EmptySlowElementDictionary",
("OLD_SPACE", 0x02891): "EmptyPropertyCell", ("OLD_SPACE", 0x02889): "EmptyPropertyCell",
("OLD_SPACE", 0x028b1): "EmptyWeakCell", ("OLD_SPACE", 0x028a9): "EmptyWeakCell",
("OLD_SPACE", 0x028c9): "ArrayProtector", ("OLD_SPACE", 0x028c1): "ArrayProtector",
("OLD_SPACE", 0x028e9): "IsConcatSpreadableProtector", ("OLD_SPACE", 0x028e1): "IsConcatSpreadableProtector",
("OLD_SPACE", 0x028f9): "SpeciesProtector", ("OLD_SPACE", 0x028f1): "SpeciesProtector",
("OLD_SPACE", 0x02909): "StringLengthProtector", ("OLD_SPACE", 0x02901): "StringLengthProtector",
("OLD_SPACE", 0x02929): "FastArrayIterationProtector", ("OLD_SPACE", 0x02921): "FastArrayIterationProtector",
("OLD_SPACE", 0x02939): "ArrayIteratorProtector", ("OLD_SPACE", 0x02931): "ArrayIteratorProtector",
("OLD_SPACE", 0x02959): "ArrayBufferNeuteringProtector", ("OLD_SPACE", 0x02951): "ArrayBufferNeuteringProtector",
("OLD_SPACE", 0x02979): "InfinityValue", ("OLD_SPACE", 0x02971): "InfinityValue",
("OLD_SPACE", 0x02989): "MinusZeroValue", ("OLD_SPACE", 0x02981): "MinusZeroValue",
("OLD_SPACE", 0x02999): "MinusInfinityValue", ("OLD_SPACE", 0x02991): "MinusInfinityValue",
} }
# List of known V8 Frame Markers. # List of known V8 Frame Markers.
......
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