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