Commit 269eaa82 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[runtime] Simplify signatures of keys-related dict methods

Bug: 
Change-Id: I252a293cfb6c7cce41d4c585078d78609f4419b7
Reviewed-on: https://chromium-review.googlesource.com/543035
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46123}
parent e6c2df47
...@@ -16289,30 +16289,28 @@ template int ...@@ -16289,30 +16289,28 @@ template int
Dictionary<NameDictionary, NameDictionaryShape>::NumberOfEnumerableProperties(); Dictionary<NameDictionary, NameDictionaryShape>::NumberOfEnumerableProperties();
template void template void
Dictionary<GlobalDictionary, GlobalDictionaryShape>::CopyEnumKeysTo( BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>::CopyEnumKeysTo(
Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape>> dictionary, Handle<GlobalDictionary> dictionary, Handle<FixedArray> storage,
Handle<FixedArray> storage, KeyCollectionMode mode, KeyCollectionMode mode, KeyAccumulator* accumulator);
KeyAccumulator* accumulator);
template void Dictionary<NameDictionary, NameDictionaryShape>::CopyEnumKeysTo( template void
Handle<Dictionary<NameDictionary, NameDictionaryShape>> dictionary, BaseNameDictionary<NameDictionary, NameDictionaryShape>::CopyEnumKeysTo(
Handle<FixedArray> storage, KeyCollectionMode mode, Handle<NameDictionary> dictionary, Handle<FixedArray> storage,
KeyAccumulator* accumulator); KeyCollectionMode mode, KeyAccumulator* accumulator);
template Handle<FixedArray> template Handle<FixedArray>
Dictionary<GlobalDictionary, GlobalDictionaryShape>::IterationIndices( BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>::IterationIndices(
Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape>> dictionary); Handle<GlobalDictionary> dictionary);
template void template void
Dictionary<GlobalDictionary, GlobalDictionaryShape>::CollectKeysTo( BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>::CollectKeysTo(
Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape>> dictionary, Handle<GlobalDictionary> dictionary, KeyAccumulator* keys);
KeyAccumulator* keys);
template Handle<FixedArray> template Handle<FixedArray>
Dictionary<NameDictionary, NameDictionaryShape>::IterationIndices( BaseNameDictionary<NameDictionary, NameDictionaryShape>::IterationIndices(
Handle<Dictionary<NameDictionary, NameDictionaryShape>> dictionary); Handle<NameDictionary> dictionary);
template void Dictionary<NameDictionary, NameDictionaryShape>::CollectKeysTo( template void
Handle<Dictionary<NameDictionary, NameDictionaryShape>> dictionary, BaseNameDictionary<NameDictionary, NameDictionaryShape>::CollectKeysTo(
KeyAccumulator* keys); Handle<NameDictionary> dictionary, KeyAccumulator* keys);
template int template int
Dictionary<SeededNumberDictionary, Dictionary<SeededNumberDictionary,
...@@ -17515,7 +17513,7 @@ Handle<Derived> Dictionary<Derived, Shape>::EnsureCapacity( ...@@ -17515,7 +17513,7 @@ Handle<Derived> Dictionary<Derived, Shape>::EnsureCapacity(
// If not, we generate new indices for the properties. // If not, we generate new indices for the properties.
int length = dictionary->NumberOfElements(); int length = dictionary->NumberOfElements();
Handle<FixedArray> iteration_order = IterationIndices(dictionary); Handle<FixedArray> iteration_order = Derived::IterationIndices(dictionary);
DCHECK_EQ(length, iteration_order->length()); DCHECK_EQ(length, iteration_order->length());
// Iterate over the dictionary using the enumeration order and update // Iterate over the dictionary using the enumeration order and update
...@@ -17701,8 +17699,8 @@ struct EnumIndexComparator { ...@@ -17701,8 +17699,8 @@ struct EnumIndexComparator {
}; };
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
void Dictionary<Derived, Shape>::CopyEnumKeysTo( void BaseNameDictionary<Derived, Shape>::CopyEnumKeysTo(
Handle<Dictionary<Derived, Shape>> dictionary, Handle<FixedArray> storage, Handle<Derived> dictionary, Handle<FixedArray> storage,
KeyCollectionMode mode, KeyAccumulator* accumulator) { KeyCollectionMode mode, KeyAccumulator* accumulator) {
DCHECK_IMPLIES(mode != KeyCollectionMode::kOwnOnly, accumulator != nullptr); DCHECK_IMPLIES(mode != KeyCollectionMode::kOwnOnly, accumulator != nullptr);
Isolate* isolate = dictionary->GetIsolate(); Isolate* isolate = dictionary->GetIsolate();
...@@ -17735,9 +17733,9 @@ void Dictionary<Derived, Shape>::CopyEnumKeysTo( ...@@ -17735,9 +17733,9 @@ void Dictionary<Derived, Shape>::CopyEnumKeysTo(
CHECK_EQ(length, properties); CHECK_EQ(length, properties);
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Dictionary<Derived, Shape>* raw_dictionary = *dictionary; Derived* raw_dictionary = *dictionary;
FixedArray* raw_storage = *storage; FixedArray* raw_storage = *storage;
EnumIndexComparator<Derived> cmp(static_cast<Derived*>(*dictionary)); EnumIndexComparator<Derived> cmp(raw_dictionary);
// Use AtomicElement wrapper to ensure that std::sort uses atomic load and // Use AtomicElement wrapper to ensure that std::sort uses atomic load and
// store operations that are safe for concurrent marking. // store operations that are safe for concurrent marking.
base::AtomicElement<Smi*>* start = base::AtomicElement<Smi*>* start =
...@@ -17751,8 +17749,8 @@ void Dictionary<Derived, Shape>::CopyEnumKeysTo( ...@@ -17751,8 +17749,8 @@ void Dictionary<Derived, Shape>::CopyEnumKeysTo(
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
Handle<FixedArray> Dictionary<Derived, Shape>::IterationIndices( Handle<FixedArray> BaseNameDictionary<Derived, Shape>::IterationIndices(
Handle<Dictionary<Derived, Shape>> dictionary) { Handle<Derived> dictionary) {
Isolate* isolate = dictionary->GetIsolate(); Isolate* isolate = dictionary->GetIsolate();
int capacity = dictionary->Capacity(); int capacity = dictionary->Capacity();
int length = dictionary->NumberOfElements(); int length = dictionary->NumberOfElements();
...@@ -17760,17 +17758,17 @@ Handle<FixedArray> Dictionary<Derived, Shape>::IterationIndices( ...@@ -17760,17 +17758,17 @@ Handle<FixedArray> Dictionary<Derived, Shape>::IterationIndices(
int array_size = 0; int array_size = 0;
{ {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Dictionary<Derived, Shape>* raw_dict = *dictionary; Derived* raw_dictionary = *dictionary;
for (int i = 0; i < capacity; i++) { for (int i = 0; i < capacity; i++) {
Object* k = raw_dict->KeyAt(i); Object* k = raw_dictionary->KeyAt(i);
if (!raw_dict->IsKey(isolate, k)) continue; if (!raw_dictionary->IsKey(isolate, k)) continue;
if (raw_dict->IsDeleted(i)) continue; if (raw_dictionary->IsDeleted(i)) continue;
array->set(array_size++, Smi::FromInt(i)); array->set(array_size++, Smi::FromInt(i));
} }
DCHECK_EQ(array_size, length); DCHECK_EQ(array_size, length);
EnumIndexComparator<Derived> cmp(static_cast<Derived*>(raw_dict)); EnumIndexComparator<Derived> cmp(raw_dictionary);
// Use AtomicElement wrapper to ensure that std::sort uses atomic load and // Use AtomicElement wrapper to ensure that std::sort uses atomic load and
// store operations that are safe for concurrent marking. // store operations that are safe for concurrent marking.
base::AtomicElement<Smi*>* start = base::AtomicElement<Smi*>* start =
...@@ -17783,8 +17781,8 @@ Handle<FixedArray> Dictionary<Derived, Shape>::IterationIndices( ...@@ -17783,8 +17781,8 @@ Handle<FixedArray> Dictionary<Derived, Shape>::IterationIndices(
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
void Dictionary<Derived, Shape>::CollectKeysTo( void BaseNameDictionary<Derived, Shape>::CollectKeysTo(
Handle<Dictionary<Derived, Shape>> dictionary, KeyAccumulator* keys) { Handle<Derived> dictionary, KeyAccumulator* keys) {
Isolate* isolate = keys->isolate(); Isolate* isolate = keys->isolate();
int capacity = dictionary->Capacity(); int capacity = dictionary->Capacity();
Handle<FixedArray> array = Handle<FixedArray> array =
...@@ -17793,19 +17791,19 @@ void Dictionary<Derived, Shape>::CollectKeysTo( ...@@ -17793,19 +17791,19 @@ void Dictionary<Derived, Shape>::CollectKeysTo(
PropertyFilter filter = keys->filter(); PropertyFilter filter = keys->filter();
{ {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Dictionary<Derived, Shape>* raw_dict = *dictionary; Derived* raw_dictionary = *dictionary;
for (int i = 0; i < capacity; i++) { for (int i = 0; i < capacity; i++) {
Object* k = raw_dict->KeyAt(i); Object* k = raw_dictionary->KeyAt(i);
if (!raw_dict->IsKey(isolate, k) || k->FilterKey(filter)) continue; if (!raw_dictionary->IsKey(isolate, k) || k->FilterKey(filter)) continue;
if (raw_dict->IsDeleted(i)) continue; if (raw_dictionary->IsDeleted(i)) continue;
PropertyDetails details = raw_dict->DetailsAt(i); PropertyDetails details = raw_dictionary->DetailsAt(i);
if ((details.attributes() & filter) != 0) { if ((details.attributes() & filter) != 0) {
keys->AddShadowingKey(k); keys->AddShadowingKey(k);
continue; continue;
} }
if (filter & ONLY_ALL_CAN_READ) { if (filter & ONLY_ALL_CAN_READ) {
if (details.kind() != kAccessor) continue; if (details.kind() != kAccessor) continue;
Object* accessors = raw_dict->ValueAt(i); Object* accessors = raw_dictionary->ValueAt(i);
if (accessors->IsPropertyCell()) { if (accessors->IsPropertyCell()) {
accessors = PropertyCell::cast(accessors)->value(); accessors = PropertyCell::cast(accessors)->value();
} }
...@@ -17815,7 +17813,7 @@ void Dictionary<Derived, Shape>::CollectKeysTo( ...@@ -17815,7 +17813,7 @@ void Dictionary<Derived, Shape>::CollectKeysTo(
array->set(array_size++, Smi::FromInt(i)); array->set(array_size++, Smi::FromInt(i));
} }
EnumIndexComparator<Derived> cmp(static_cast<Derived*>(raw_dict)); EnumIndexComparator<Derived> cmp(raw_dictionary);
// Use AtomicElement wrapper to ensure that std::sort uses atomic load and // Use AtomicElement wrapper to ensure that std::sort uses atomic load and
// store operations that are safe for concurrent marking. // store operations that are safe for concurrent marking.
base::AtomicElement<Smi*>* start = base::AtomicElement<Smi*>* start =
......
...@@ -64,23 +64,12 @@ class Dictionary : public HashTable<Derived, Shape> { ...@@ -64,23 +64,12 @@ class Dictionary : public HashTable<Derived, Shape> {
int NextEnumerationIndex() { UNREACHABLE(); } int NextEnumerationIndex() { UNREACHABLE(); }
void SetNextEnumerationIndex(int index) { UNREACHABLE(); } void SetNextEnumerationIndex(int index) { UNREACHABLE(); }
static Handle<FixedArray> IterationIndices(Handle<Derived> dictionary) {
UNREACHABLE();
}
int NumberOfEnumerableProperties(); int NumberOfEnumerableProperties();
// Return the key indices sorted by its enumeration index.
static Handle<FixedArray> IterationIndices(
Handle<Dictionary<Derived, Shape>> dictionary);
// Collect the keys into the given KeyAccumulator, in ascending chronological
// order of property creation.
static void CollectKeysTo(Handle<Dictionary<Derived, Shape>> dictionary,
KeyAccumulator* keys);
// Copies enumerable keys to preallocated fixed array.
static void CopyEnumKeysTo(Handle<Dictionary<Derived, Shape>> dictionary,
Handle<FixedArray> storage, KeyCollectionMode mode,
KeyAccumulator* accumulator);
// 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,
...@@ -184,6 +173,18 @@ class BaseNameDictionary : public Dictionary<Derived, Shape> { ...@@ -184,6 +173,18 @@ class BaseNameDictionary : public Dictionary<Derived, Shape> {
int NextEnumerationIndex() { int NextEnumerationIndex() {
return Smi::cast(this->get(kNextEnumerationIndexIndex))->value(); return Smi::cast(this->get(kNextEnumerationIndexIndex))->value();
} }
// Collect the keys into the given KeyAccumulator, in ascending chronological
// order of property creation.
static void CollectKeysTo(Handle<Derived> dictionary, KeyAccumulator* keys);
// Return the key indices sorted by its enumeration index.
static Handle<FixedArray> IterationIndices(Handle<Derived> dictionary);
// Copies enumerable keys to preallocated fixed array.
static void CopyEnumKeysTo(Handle<Derived> dictionary,
Handle<FixedArray> storage, KeyCollectionMode mode,
KeyAccumulator* accumulator);
}; };
class NameDictionary class NameDictionary
......
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