summaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/heap-object.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/heap-object.h')
-rw-r--r--deps/v8/src/objects/heap-object.h58
1 files changed, 32 insertions, 26 deletions
diff --git a/deps/v8/src/objects/heap-object.h b/deps/v8/src/objects/heap-object.h
index 9ca51bdda1..ad5475c9e8 100644
--- a/deps/v8/src/objects/heap-object.h
+++ b/deps/v8/src/objects/heap-object.h
@@ -9,6 +9,7 @@
#include "src/roots/roots.h"
#include "src/objects/objects.h"
+#include "src/objects/tagged-field.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@@ -22,27 +23,30 @@ class Heap;
// objects.
class HeapObject : public Object {
public:
- bool is_null() const { return ptr() == kNullAddress; }
+ bool is_null() const {
+ return static_cast<Tagged_t>(ptr()) == static_cast<Tagged_t>(kNullAddress);
+ }
// [map]: Contains a map which contains the object's reflective
// information.
- inline Map map() const;
+ DECL_GETTER(map, Map)
inline void set_map(Map value);
- inline MapWordSlot map_slot() const;
+ inline ObjectSlot map_slot() const;
// The no-write-barrier version. This is OK if the object is white and in
// new space, or if the value is an immortal immutable object, like the maps
// of primitive (non-JS) objects like strings, heap numbers etc.
inline void set_map_no_write_barrier(Map value);
- // Get the map using acquire load.
- inline Map synchronized_map() const;
- inline MapWord synchronized_map_word() const;
-
- // Set the map using release store
+ // Access the map using acquire load and release store.
+ DECL_GETTER(synchronized_map, Map)
inline void synchronized_set_map(Map value);
- inline void synchronized_set_map_word(MapWord map_word);
+
+ // Compare-and-swaps map word using release store, returns true if the map
+ // word was actually swapped.
+ inline bool synchronized_compare_and_swap_map_word(MapWord old_map_word,
+ MapWord new_map_word);
// Initialize the map immediately after the object is allocated.
// Do not use this outside Heap.
@@ -51,18 +55,29 @@ class HeapObject : public Object {
// During garbage collection, the map word of a heap object does not
// necessarily contain a map pointer.
- inline MapWord map_word() const;
+ DECL_GETTER(map_word, MapWord)
inline void set_map_word(MapWord map_word);
+ // Access the map word using acquire load and release store.
+ DECL_GETTER(synchronized_map_word, MapWord)
+ inline void synchronized_set_map_word(MapWord map_word);
+
// TODO(v8:7464): Once RO_SPACE is shared between isolates, this method can be
// removed as ReadOnlyRoots will be accessible from a global variable. For now
// this method exists to help remove GetIsolate/GetHeap from HeapObject, in a
// way that doesn't require passing Isolate/Heap down huge call chains or to
// places where it might not be safe to access it.
inline ReadOnlyRoots GetReadOnlyRoots() const;
+ // This version is intended to be used for the isolate values produced by
+ // i::GetIsolateForPtrCompr(HeapObject) function which may return nullptr.
+ inline ReadOnlyRoots GetReadOnlyRoots(Isolate* isolate) const;
-#define IS_TYPE_FUNCTION_DECL(Type) V8_INLINE bool Is##Type() const;
+#define IS_TYPE_FUNCTION_DECL(Type) \
+ V8_INLINE bool Is##Type() const; \
+ V8_INLINE bool Is##Type(Isolate* isolate) const;
HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL)
+ IS_TYPE_FUNCTION_DECL(HashTableBase)
+ IS_TYPE_FUNCTION_DECL(SmallOrderedHashTable)
#undef IS_TYPE_FUNCTION_DECL
bool IsExternal(Isolate* isolate) const;
@@ -74,13 +89,12 @@ class HeapObject : public Object {
V8_INLINE bool Is##Type(ReadOnlyRoots roots) const; \
V8_INLINE bool Is##Type() const;
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
+ IS_TYPE_FUNCTION_DECL(NullOrUndefined, /* unused */)
#undef IS_TYPE_FUNCTION_DECL
- V8_INLINE bool IsNullOrUndefined(Isolate* isolate) const;
- V8_INLINE bool IsNullOrUndefined(ReadOnlyRoots roots) const;
- V8_INLINE bool IsNullOrUndefined() const;
-
-#define DECL_STRUCT_PREDICATE(NAME, Name, name) V8_INLINE bool Is##Name() const;
+#define DECL_STRUCT_PREDICATE(NAME, Name, name) \
+ V8_INLINE bool Is##Name() const; \
+ V8_INLINE bool Is##Name(Isolate* isolate) const;
STRUCT_LIST(DECL_STRUCT_PREDICATE)
#undef DECL_STRUCT_PREDICATE
@@ -189,6 +203,8 @@ class HeapObject : public Object {
STATIC_ASSERT(kMapOffset == Internals::kHeapObjectMapOffset);
+ using MapField = TaggedField<MapWord, HeapObject::kMapOffset>;
+
inline Address GetFieldAddress(int field_offset) const;
protected:
@@ -203,16 +219,6 @@ class HeapObject : public Object {
OBJECT_CONSTRUCTORS_IMPL(HeapObject, Object)
CAST_ACCESSOR(HeapObject)
-// Helper class for objects that can never be in RO space.
-class NeverReadOnlySpaceObject {
- public:
- // The Heap the object was allocated in. Used also to access Isolate.
- static inline Heap* GetHeap(const HeapObject object);
-
- // Convenience method to get current isolate.
- static inline Isolate* GetIsolate(const HeapObject object);
-};
-
} // namespace internal
} // namespace v8