Commit 432751ae authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[cleanup] Reduce dependents of ordered-hash-table.h to 71.

Together with the previous CL, this is a 10x improvement.


Bug: v8:8834
Change-Id: I89b86ee88c82479997c08b725571369b1bf9d190
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1539592
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60470}
parent 44290e04
......@@ -2350,6 +2350,7 @@ v8_source_set("v8_base") {
"src/objects/js-collator.cc",
"src/objects/js-collator.h",
"src/objects/js-collection-inl.h",
"src/objects/js-collection-iterator.h",
"src/objects/js-collection.h",
"src/objects/js-date-time-format-inl.h",
"src/objects/js-date-time-format.cc",
......
......@@ -12,6 +12,7 @@
#include "src/heap/heap-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-collection.h"
#include "src/objects/ordered-hash-table.h"
#include "torque-generated/builtins-base-from-dsl-gen.h"
#include "torque-generated/builtins-collections-from-dsl-gen.h"
......
......@@ -16,6 +16,7 @@
#include "src/objects/js-collection.h"
#include "src/objects/js-generator.h"
#include "src/objects/module.h"
#include "src/objects/ordered-hash-table.h"
namespace v8 {
namespace internal {
......
......@@ -26,6 +26,7 @@
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-objects.h"
#include "src/objects/ordered-hash-table.h"
#include "src/vector-slot-pair.h"
namespace v8 {
......
......@@ -22,10 +22,10 @@
#include "src/objects/arguments.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/heap-number.h"
#include "src/objects/js-collection-iterator.h"
#include "src/objects/js-generator.h"
#include "src/objects/js-promise.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/ordered-hash-table.h"
namespace v8 {
namespace internal {
......
......@@ -15,6 +15,7 @@
#include "src/elements.h"
#include "src/hash-seed-inl.h"
#include "src/heap/heap.h"
#include "src/objects/ordered-hash-table.h"
// For IncrementalMarking::RecordWriteFromCode. TODO(jkummerow): Drop.
#include "src/heap/heap-inl.h"
#include "src/ic/stub-cache.h"
......
......@@ -15,6 +15,7 @@
#include "src/objects/free-space-inl.h"
#include "src/objects/js-weak-refs-inl.h"
#include "src/objects/oddball.h"
#include "src/objects/ordered-hash-table.h"
#include "src/wasm/wasm-objects.h"
namespace v8 {
......
......@@ -17,6 +17,7 @@
#include "src/objects/js-collection.h"
#include "src/objects/js-weak-refs.h"
#include "src/objects/oddball.h"
#include "src/objects/ordered-hash-table.h"
#include "src/reloc-info.h"
#include "src/transitions.h"
#include "src/wasm/wasm-objects-inl.h"
......
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_JS_COLLECTION_ITERATOR_H_
#define V8_OBJECTS_JS_COLLECTION_ITERATOR_H_
#include "src/globals.h"
#include "src/objects.h"
#include "src/objects/js-objects.h"
#include "src/objects/smi.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
class JSCollectionIterator : public JSObject {
public:
// [table]: the backing hash table mapping keys to values.
DECL_ACCESSORS(table, Object)
// [index]: The index into the data table.
DECL_ACCESSORS(index, Object)
void JSCollectionIteratorPrint(std::ostream& os, const char* name);
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSCOLLECTION_ITERATOR_FIELDS)
OBJECT_CONSTRUCTORS(JSCollectionIterator, JSObject);
};
// OrderedHashTableIterator is an iterator that iterates over the keys and
// values of an OrderedHashTable.
//
// The iterator has a reference to the underlying OrderedHashTable data,
// [table], as well as the current [index] the iterator is at.
//
// When the OrderedHashTable is rehashed it adds a reference from the old table
// to the new table as well as storing enough data about the changes so that the
// iterator [index] can be adjusted accordingly.
//
// When the [Next] result from the iterator is requested, the iterator checks if
// there is a newer table that it needs to transition to.
template <class Derived, class TableType>
class OrderedHashTableIterator : public JSCollectionIterator {
public:
// Whether the iterator has more elements. This needs to be called before
// calling |CurrentKey| and/or |CurrentValue|.
bool HasMore();
// Move the index forward one.
void MoveNext() { set_index(Smi::FromInt(Smi::ToInt(index()) + 1)); }
// Returns the current key of the iterator. This should only be called when
// |HasMore| returns true.
inline Object CurrentKey();
private:
// Transitions the iterator to the non obsolete backing store. This is a NOP
// if the [table] is not obsolete.
void Transition();
OBJECT_CONSTRUCTORS(OrderedHashTableIterator, JSCollectionIterator);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_JS_COLLECTION_ITERATOR_H_
......@@ -6,7 +6,7 @@
#define V8_OBJECTS_JS_COLLECTION_H_
#include "src/objects.h"
#include "src/objects/ordered-hash-table.h"
#include "src/objects/js-collection-iterator.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -14,6 +14,9 @@
namespace v8 {
namespace internal {
class OrderedHashSet;
class OrderedHashMap;
class JSCollection : public JSObject {
public:
// [table]: the backing hash table
......
......@@ -11,6 +11,7 @@
#include "src/objects-inl.h"
#include "src/objects/compressed-slots.h"
#include "src/objects/fixed-array-inl.h"
#include "src/objects/js-collection-iterator.h"
#include "src/objects/slots.h"
// Has to be the last include (doesn't have include guards):
......
......@@ -812,56 +812,6 @@ class SmallOrderedNameDictionary
SmallOrderedHashTable<SmallOrderedNameDictionary>);
};
class JSCollectionIterator : public JSObject {
public:
// [table]: the backing hash table mapping keys to values.
DECL_ACCESSORS(table, Object)
// [index]: The index into the data table.
DECL_ACCESSORS(index, Object)
void JSCollectionIteratorPrint(std::ostream& os, const char* name);
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSCOLLECTION_ITERATOR_FIELDS)
OBJECT_CONSTRUCTORS(JSCollectionIterator, JSObject);
};
// OrderedHashTableIterator is an iterator that iterates over the keys and
// values of an OrderedHashTable.
//
// The iterator has a reference to the underlying OrderedHashTable data,
// [table], as well as the current [index] the iterator is at.
//
// When the OrderedHashTable is rehashed it adds a reference from the old table
// to the new table as well as storing enough data about the changes so that the
// iterator [index] can be adjusted accordingly.
//
// When the [Next] result from the iterator is requested, the iterator checks if
// there is a newer table that it needs to transition to.
template <class Derived, class TableType>
class OrderedHashTableIterator : public JSCollectionIterator {
public:
// Whether the iterator has more elements. This needs to be called before
// calling |CurrentKey| and/or |CurrentValue|.
bool HasMore();
// Move the index forward one.
void MoveNext() { set_index(Smi::FromInt(Smi::ToInt(index()) + 1)); }
// Returns the current key of the iterator. This should only be called when
// |HasMore| returns true.
inline Object CurrentKey();
private:
// Transitions the iterator to the non obsolete backing store. This is a NOP
// if the [table] is not obsolete.
void Transition();
OBJECT_CONSTRUCTORS(OrderedHashTableIterator, JSCollectionIterator);
};
} // namespace internal
} // namespace v8
......
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