aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/hash-table.h
diff options
context:
space:
mode:
authorRefael Ackermann <refack@gmail.com>2019-05-28 08:46:21 -0400
committerRefael Ackermann <refack@gmail.com>2019-06-01 09:55:12 -0400
commited74896b1fae1c163b3906163f3bf46326618ddb (patch)
tree7fb05c5a19808e0c5cd95837528e9005999cf540 /deps/v8/src/objects/hash-table.h
parent2a850cd0664a4eee51f44d0bb8c2f7a3fe444154 (diff)
downloadandroid-node-v8-ed74896b1fae1c163b3906163f3bf46326618ddb.tar.gz
android-node-v8-ed74896b1fae1c163b3906163f3bf46326618ddb.tar.bz2
android-node-v8-ed74896b1fae1c163b3906163f3bf46326618ddb.zip
deps: update V8 to 7.5.288.22
PR-URL: https://github.com/nodejs/node/pull/27375 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'deps/v8/src/objects/hash-table.h')
-rw-r--r--deps/v8/src/objects/hash-table.h63
1 files changed, 52 insertions, 11 deletions
diff --git a/deps/v8/src/objects/hash-table.h b/deps/v8/src/objects/hash-table.h
index 15ad1d8538..0c83d01b42 100644
--- a/deps/v8/src/objects/hash-table.h
+++ b/deps/v8/src/objects/hash-table.h
@@ -6,6 +6,8 @@
#define V8_OBJECTS_HASH_TABLE_H_
#include "src/base/compiler-specific.h"
+#include "src/base/export-template.h"
+#include "src/base/macros.h"
#include "src/globals.h"
#include "src/objects/fixed-array.h"
#include "src/objects/smi.h"
@@ -56,7 +58,7 @@ namespace internal {
template <typename KeyT>
class BaseShape {
public:
- typedef KeyT Key;
+ using Key = KeyT;
static inline RootIndex GetMapRootIndex();
static const bool kNeedsHoleCheck = true;
static Object Unwrap(Object key) { return key; }
@@ -130,15 +132,16 @@ class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) {
};
template <typename Derived, typename Shape>
-class HashTable : public HashTableBase {
+class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
+ : public HashTableBase {
public:
- typedef Shape ShapeT;
- typedef typename Shape::Key Key;
+ using ShapeT = Shape;
+ using Key = typename Shape::Key;
// Returns a new HashTable object.
V8_WARN_UNUSED_RESULT static Handle<Derived> New(
Isolate* isolate, int at_least_space_for,
- PretenureFlag pretenure = NOT_TENURED,
+ AllocationType allocation = AllocationType::kYoung,
MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY);
// Garbage collection support.
@@ -183,10 +186,20 @@ class HashTable : public HashTableBase {
return (entry * kEntrySize) + kElementsStartIndex;
}
+ // Returns the index for an entry (of the key)
+ static constexpr inline int IndexToEntry(int index) {
+ return (index - kElementsStartIndex) / kEntrySize;
+ }
+
+ // Returns the index for a slot address in the object.
+ static constexpr inline int SlotToIndex(Address object, Address slot) {
+ return static_cast<int>((slot - object - kHeaderSize) / kTaggedSize);
+ }
+
// Ensure enough space for n additional elements.
V8_WARN_UNUSED_RESULT static Handle<Derived> EnsureCapacity(
Isolate* isolate, Handle<Derived> table, int n,
- PretenureFlag pretenure = NOT_TENURED);
+ AllocationType allocation = AllocationType::kYoung);
// Returns true if this table has sufficient capacity for adding n elements.
bool HasSufficientCapacityToAdd(int number_of_additional_elements);
@@ -195,7 +208,7 @@ class HashTable : public HashTableBase {
friend class ObjectHashTable;
V8_WARN_UNUSED_RESULT static Handle<Derived> NewInternal(
- Isolate* isolate, int capacity, PretenureFlag pretenure);
+ Isolate* isolate, int capacity, AllocationType allocation);
// Find the entry at which to insert element with the given key that
// has the given hash value.
@@ -205,6 +218,9 @@ class HashTable : public HashTableBase {
V8_WARN_UNUSED_RESULT static Handle<Derived> Shrink(
Isolate* isolate, Handle<Derived> table, int additionalCapacity = 0);
+ inline void set_key(int index, Object value);
+ inline void set_key(int index, Object value, WriteBarrierMode mode);
+
private:
// Ensure that kMaxRegularCapacity yields a non-large object dictionary.
STATIC_ASSERT(EntryToIndex(kMaxRegularCapacity) < kMaxRegularLength);
@@ -274,7 +290,8 @@ class ObjectHashTableShape : public BaseShape<Handle<Object>> {
};
template <typename Derived, typename Shape>
-class ObjectHashTableBase : public HashTable<Derived, Shape> {
+class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) ObjectHashTableBase
+ : public HashTable<Derived, Shape> {
public:
// Looks up the value associated with the given key. The hole value is
// returned in case the key is not present.
@@ -315,9 +332,16 @@ class ObjectHashTableBase : public HashTable<Derived, Shape> {
OBJECT_CONSTRUCTORS(ObjectHashTableBase, HashTable<Derived, Shape>);
};
+class ObjectHashTable;
+
+extern template class EXPORT_TEMPLATE_DECLARE(
+ V8_EXPORT_PRIVATE) HashTable<ObjectHashTable, ObjectHashTableShape>;
+extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
+ ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape>;
+
// ObjectHashTable maps keys that are arbitrary objects to object values by
// using the identity hash of the key for hashing purposes.
-class ObjectHashTable
+class V8_EXPORT_PRIVATE ObjectHashTable
: public ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape> {
public:
DECL_CAST(ObjectHashTable)
@@ -333,19 +357,31 @@ class EphemeronHashTableShape : public ObjectHashTableShape {
static inline RootIndex GetMapRootIndex();
};
+class EphemeronHashTable;
+
+extern template class EXPORT_TEMPLATE_DECLARE(
+ V8_EXPORT_PRIVATE) HashTable<EphemeronHashTable, EphemeronHashTableShape>;
+extern template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
+ ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape>;
+
// EphemeronHashTable is similar to ObjectHashTable but gets special treatment
// by the GC. The GC treats its entries as ephemerons: both key and value are
// weak references, however if the key is strongly reachable its corresponding
// value is also kept alive.
-class EphemeronHashTable
+class V8_EXPORT_PRIVATE EphemeronHashTable
: public ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape> {
public:
DECL_CAST(EphemeronHashTable)
DECL_PRINTER(EphemeronHashTable)
+ class BodyDescriptor;
protected:
friend class MarkCompactCollector;
friend class ScavengerCollector;
+ friend class HashTable<EphemeronHashTable, EphemeronHashTableShape>;
+ friend class ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape>;
+ inline void set_key(int index, Object value);
+ inline void set_key(int index, Object value, WriteBarrierMode mode);
OBJECT_CONSTRUCTORS(
EphemeronHashTable,
@@ -358,7 +394,12 @@ class ObjectHashSetShape : public ObjectHashTableShape {
static const int kEntrySize = 1;
};
-class ObjectHashSet : public HashTable<ObjectHashSet, ObjectHashSetShape> {
+class ObjectHashSet;
+extern template class EXPORT_TEMPLATE_DECLARE(
+ V8_EXPORT_PRIVATE) HashTable<ObjectHashSet, ObjectHashSetShape>;
+
+class V8_EXPORT_PRIVATE ObjectHashSet
+ : public HashTable<ObjectHashSet, ObjectHashSetShape> {
public:
static Handle<ObjectHashSet> Add(Isolate* isolate, Handle<ObjectHashSet> set,
Handle<Object> key);