aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/dictionary.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/dictionary.h')
-rw-r--r--deps/v8/src/objects/dictionary.h77
1 files changed, 48 insertions, 29 deletions
diff --git a/deps/v8/src/objects/dictionary.h b/deps/v8/src/objects/dictionary.h
index 6d7ee42eec..1b0c57ec7d 100644
--- a/deps/v8/src/objects/dictionary.h
+++ b/deps/v8/src/objects/dictionary.h
@@ -9,6 +9,7 @@
#include "src/globals.h"
#include "src/objects/hash-table.h"
#include "src/objects/property-array.h"
+#include "src/objects/smi.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@@ -28,23 +29,23 @@ class Dictionary : public HashTable<Derived, Shape> {
public:
typedef typename Shape::Key Key;
// Returns the value at entry.
- Object* ValueAt(int entry) {
+ Object ValueAt(int entry) {
return this->get(DerivedHashTable::EntryToIndex(entry) + 1);
}
// Set the value for entry.
- void ValueAtPut(int entry, Object* value) {
+ void ValueAtPut(int entry, Object value) {
this->set(DerivedHashTable::EntryToIndex(entry) + 1, value);
}
// Returns the property details for the property at entry.
PropertyDetails DetailsAt(int entry) {
- return Shape::DetailsAt(static_cast<Derived*>(this), entry);
+ return Shape::DetailsAt(Derived::cast(*this), entry);
}
// Set the details for entry.
void DetailsAtPut(Isolate* isolate, int entry, PropertyDetails value) {
- Shape::DetailsAtPut(isolate, static_cast<Derived*>(this), entry, value);
+ Shape::DetailsAtPut(isolate, Derived::cast(*this), entry, value);
}
// Delete a property from the dictionary.
@@ -66,11 +67,11 @@ class Dictionary : public HashTable<Derived, Shape> {
void Print(std::ostream& os); // NOLINT
#endif
// Returns the key (slow).
- Object* SlowReverseLookup(Object* value);
+ Object SlowReverseLookup(Object value);
// Sets the entry to (key, value) pair.
inline void ClearEntry(Isolate* isolate, int entry);
- inline void SetEntry(Isolate* isolate, int entry, Object* key, Object* value,
+ inline void SetEntry(Isolate* isolate, int entry, Object key, Object value,
PropertyDetails details);
V8_WARN_UNUSED_RESULT static Handle<Derived> Add(
@@ -84,6 +85,8 @@ class Dictionary : public HashTable<Derived, Shape> {
Key key,
Handle<Object> value,
PropertyDetails details);
+
+ OBJECT_CONSTRUCTORS(Dictionary, HashTable<Derived, Shape>)
};
template <typename Key>
@@ -91,7 +94,7 @@ class BaseDictionaryShape : public BaseShape<Key> {
public:
static const bool kHasDetails = true;
template <typename Dictionary>
- static inline PropertyDetails DetailsAt(Dictionary* dict, int entry) {
+ static inline PropertyDetails DetailsAt(Dictionary dict, int entry) {
STATIC_ASSERT(Dictionary::kEntrySize == 3);
DCHECK_GE(entry, 0); // Not found is -1, which is not caught by get().
return PropertyDetails(Smi::cast(dict->get(
@@ -99,7 +102,7 @@ class BaseDictionaryShape : public BaseShape<Key> {
}
template <typename Dictionary>
- static inline void DetailsAtPut(Isolate* isolate, Dictionary* dict, int entry,
+ static inline void DetailsAtPut(Isolate* isolate, Dictionary dict, int entry,
PropertyDetails value) {
STATIC_ASSERT(Dictionary::kEntrySize == 3);
dict->set(Dictionary::EntryToIndex(entry) + Dictionary::kEntryDetailsIndex,
@@ -109,9 +112,9 @@ class BaseDictionaryShape : public BaseShape<Key> {
class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
public:
- static inline bool IsMatch(Handle<Name> key, Object* other);
+ static inline bool IsMatch(Handle<Name> key, Object other);
static inline uint32_t Hash(Isolate* isolate, Handle<Name> key);
- static inline uint32_t HashForObject(Isolate* isolate, Object* object);
+ static inline uint32_t HashForObject(Isolate* isolate, Object object);
static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key);
static inline RootIndex GetMapRootIndex();
static const int kPrefixSize = 2;
@@ -146,7 +149,7 @@ class BaseNameDictionary : public Dictionary<Derived, Shape> {
}
int Hash() const {
- Object* hash_obj = this->get(kObjectHashIndex);
+ Object hash_obj = this->get(kObjectHashIndex);
int hash = Smi::ToInt(hash_obj);
DCHECK(PropertyArray::HashField::is_valid(hash));
return hash;
@@ -184,6 +187,8 @@ class BaseNameDictionary : public Dictionary<Derived, Shape> {
V8_WARN_UNUSED_RESULT static Handle<Derived> Add(
Isolate* isolate, Handle<Derived> dictionary, Key key,
Handle<Object> value, PropertyDetails details, int* entry_out = nullptr);
+
+ OBJECT_CONSTRUCTORS(BaseNameDictionary, Dictionary<Derived, Shape>)
};
class NameDictionary
@@ -194,28 +199,31 @@ class NameDictionary
static const int kEntryDetailsIndex = 2;
static const int kInitialCapacity = 2;
- inline Name* NameAt(int entry);
+ inline Name NameAt(int entry);
inline void set_hash(int hash);
inline int hash() const;
+
+ OBJECT_CONSTRUCTORS(NameDictionary,
+ BaseNameDictionary<NameDictionary, NameDictionaryShape>)
};
class GlobalDictionaryShape : public NameDictionaryShape {
public:
- static inline bool IsMatch(Handle<Name> key, Object* other);
- static inline uint32_t HashForObject(Isolate* isolate, Object* object);
+ static inline bool IsMatch(Handle<Name> key, Object other);
+ static inline uint32_t HashForObject(Isolate* isolate, Object object);
static const int kEntrySize = 1; // Overrides NameDictionaryShape::kEntrySize
template <typename Dictionary>
- static inline PropertyDetails DetailsAt(Dictionary* dict, int entry);
+ static inline PropertyDetails DetailsAt(Dictionary dict, int entry);
template <typename Dictionary>
- static inline void DetailsAtPut(Isolate* isolate, Dictionary* dict, int entry,
+ static inline void DetailsAtPut(Isolate* isolate, Dictionary dict, int entry,
PropertyDetails value);
- static inline Object* Unwrap(Object* key);
- static inline bool IsKey(ReadOnlyRoots roots, Object* k);
- static inline bool IsLive(ReadOnlyRoots roots, Object* key);
+ static inline Object Unwrap(Object key);
+ static inline bool IsKey(ReadOnlyRoots roots, Object k);
+ static inline bool IsLive(ReadOnlyRoots roots, Object key);
static inline RootIndex GetMapRootIndex();
};
@@ -224,21 +232,25 @@ class GlobalDictionary
public:
DECL_CAST(GlobalDictionary)
- inline Object* ValueAt(int entry);
- inline PropertyCell* CellAt(int entry);
- inline void SetEntry(Isolate* isolate, int entry, Object* key, Object* value,
+ inline Object ValueAt(int entry);
+ inline PropertyCell CellAt(int entry);
+ inline void SetEntry(Isolate* isolate, int entry, Object key, Object value,
PropertyDetails details);
- inline Name* NameAt(int entry);
- inline void ValueAtPut(int entry, Object* value);
+ inline Name NameAt(int entry);
+ inline void ValueAtPut(int entry, Object value);
+
+ OBJECT_CONSTRUCTORS(
+ GlobalDictionary,
+ BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>)
};
class NumberDictionaryBaseShape : public BaseDictionaryShape<uint32_t> {
public:
- static inline bool IsMatch(uint32_t key, Object* other);
+ static inline bool IsMatch(uint32_t key, Object other);
static inline Handle<Object> AsHandle(Isolate* isolate, uint32_t key);
static inline uint32_t Hash(Isolate* isolate, uint32_t key);
- static inline uint32_t HashForObject(Isolate* isolate, Object* object);
+ static inline uint32_t HashForObject(Isolate* isolate, Object object);
};
class NumberDictionaryShape : public NumberDictionaryBaseShape {
@@ -256,12 +268,12 @@ class SimpleNumberDictionaryShape : public NumberDictionaryBaseShape {
static const int kEntrySize = 2;
template <typename Dictionary>
- static inline PropertyDetails DetailsAt(Dictionary* dict, int entry) {
+ static inline PropertyDetails DetailsAt(Dictionary dict, int entry) {
UNREACHABLE();
}
template <typename Dictionary>
- static inline void DetailsAtPut(Isolate* isolate, Dictionary* dict, int entry,
+ static inline void DetailsAtPut(Isolate* isolate, Dictionary dict, int entry,
PropertyDetails value) {
UNREACHABLE();
}
@@ -286,6 +298,10 @@ class SimpleNumberDictionary
Handle<Object> value);
static const int kEntryValueIndex = 1;
+
+ OBJECT_CONSTRUCTORS(
+ SimpleNumberDictionary,
+ Dictionary<SimpleNumberDictionary, SimpleNumberDictionaryShape>)
};
extern template class EXPORT_TEMPLATE_DECLARE(
@@ -317,7 +333,7 @@ class NumberDictionary
bool HasComplexElements();
// Sorting support
- void CopyValuesTo(FixedArray* elements);
+ void CopyValuesTo(FixedArray elements);
// If slow elements are required we will never go back to fast-case
// for the elements kept in this dictionary. We require slow
@@ -343,6 +359,9 @@ class NumberDictionary
// JSObjects prefer dictionary elements if the dictionary saves this much
// memory compared to a fast elements backing store.
static const uint32_t kPreferFastElementsSizeFactor = 3;
+
+ OBJECT_CONSTRUCTORS(NumberDictionary,
+ Dictionary<NumberDictionary, NumberDictionaryShape>)
};
} // namespace internal