Commit 933bb6e5 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr] Use TaggedField<> in READ/WRITE macros

... instead of [Maybe]ObjectSlot.

Bug: v8:9353
Change-Id: I9747da70895e459882a83d06cc20a13b8519e500
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1678196Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62380}
parent e62c8282
...@@ -254,35 +254,30 @@ ...@@ -254,35 +254,30 @@
#define FIELD_ADDR(p, offset) ((p).ptr() + offset - kHeapObjectTag) #define FIELD_ADDR(p, offset) ((p).ptr() + offset - kHeapObjectTag)
#define READ_FIELD(p, offset) (*ObjectSlot(FIELD_ADDR(p, offset))) #define READ_FIELD(p, offset) TaggedField<Object>::load(p, offset)
#define READ_WEAK_FIELD(p, offset) (*MaybeObjectSlot(FIELD_ADDR(p, offset))) #define READ_WEAK_FIELD(p, offset) TaggedField<MaybeObject>::load(p, offset)
#define ACQUIRE_READ_FIELD(p, offset) \ #define ACQUIRE_READ_FIELD(p, offset) \
ObjectSlot(FIELD_ADDR(p, offset)).Acquire_Load() TaggedField<Object>::Acquire_Load(p, offset)
#define RELAXED_READ_FIELD(p, offset) \ #define RELAXED_READ_FIELD(p, offset) \
ObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Load() TaggedField<Object>::Relaxed_Load(p, offset)
#define RELAXED_READ_WEAK_FIELD(p, offset) \ #define RELAXED_READ_WEAK_FIELD(p, offset) \
MaybeObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Load() TaggedField<MaybeObject>::Relaxed_Load(p, offset)
#ifdef V8_CONCURRENT_MARKING
#define WRITE_FIELD(p, offset, value) \ #define WRITE_FIELD(p, offset, value) \
ObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Store(value) TaggedField<Object>::store(p, offset, value)
#else
#define WRITE_FIELD(p, offset, value) \
ObjectSlot(FIELD_ADDR(p, offset)).store(value)
#endif
#define RELEASE_WRITE_FIELD(p, offset, value) \ #define RELEASE_WRITE_FIELD(p, offset, value) \
ObjectSlot(FIELD_ADDR(p, offset)).Release_Store(value) TaggedField<Object>::Release_Store(p, offset, value)
#define RELAXED_WRITE_FIELD(p, offset, value) \ #define RELAXED_WRITE_FIELD(p, offset, value) \
ObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Store(value) TaggedField<Object>::Relaxed_Store(p, offset, value)
#define RELAXED_WRITE_WEAK_FIELD(p, offset, value) \ #define RELAXED_WRITE_WEAK_FIELD(p, offset, value) \
MaybeObjectSlot(FIELD_ADDR(p, offset)).Relaxed_Store(value) TaggedField<MaybeObject>::Relaxed_Store(p, offset, value)
#define WRITE_BARRIER(object, offset, value) \ #define WRITE_BARRIER(object, offset, value) \
do { \ do { \
......
...@@ -118,16 +118,16 @@ void TaggedField<T, kFieldOffset>::Relaxed_Store(HeapObject host, int offset, ...@@ -118,16 +118,16 @@ void TaggedField<T, kFieldOffset>::Relaxed_Store(HeapObject host, int offset,
// static // static
template <typename T, int kFieldOffset> template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::Acquire_Load(HeapObject host) { T TaggedField<T, kFieldOffset>::Acquire_Load(HeapObject host, int offset) {
AtomicTagged_t value = AsAtomicTagged::Acquire_Load(location(host)); AtomicTagged_t value = AsAtomicTagged::Acquire_Load(location(host, offset));
return T(tagged_to_full(host.ptr(), value)); return T(tagged_to_full(host.ptr(), value));
} }
// static // static
template <typename T, int kFieldOffset> template <typename T, int kFieldOffset>
T TaggedField<T, kFieldOffset>::Acquire_Load(Isolate* isolate, T TaggedField<T, kFieldOffset>::Acquire_Load(Isolate* isolate, HeapObject host,
HeapObject host) { int offset) {
AtomicTagged_t value = AsAtomicTagged::Acquire_Load(location(host)); AtomicTagged_t value = AsAtomicTagged::Acquire_Load(location(host, offset));
return T(tagged_to_full(isolate, value)); return T(tagged_to_full(isolate, value));
} }
...@@ -137,6 +137,14 @@ void TaggedField<T, kFieldOffset>::Release_Store(HeapObject host, T value) { ...@@ -137,6 +137,14 @@ void TaggedField<T, kFieldOffset>::Release_Store(HeapObject host, T value) {
AsAtomicTagged::Release_Store(location(host), full_to_tagged(value.ptr())); AsAtomicTagged::Release_Store(location(host), full_to_tagged(value.ptr()));
} }
// static
template <typename T, int kFieldOffset>
void TaggedField<T, kFieldOffset>::Release_Store(HeapObject host, int offset,
T value) {
AsAtomicTagged::Release_Store(location(host, offset),
full_to_tagged(value.ptr()));
}
// static // static
template <typename T, int kFieldOffset> template <typename T, int kFieldOffset>
Tagged_t TaggedField<T, kFieldOffset>::Release_CompareAndSwap(HeapObject host, Tagged_t TaggedField<T, kFieldOffset>::Release_CompareAndSwap(HeapObject host,
......
...@@ -18,7 +18,7 @@ namespace internal { ...@@ -18,7 +18,7 @@ namespace internal {
// For full-pointer mode this type adds no overhead but when pointer // For full-pointer mode this type adds no overhead but when pointer
// compression is enabled such class allows us to use proper decompression // compression is enabled such class allows us to use proper decompression
// function depending on the field type. // function depending on the field type.
template <typename T, int kFieldOffset> template <typename T, int kFieldOffset = 0>
class TaggedField : public AllStatic { class TaggedField : public AllStatic {
public: public:
static_assert(std::is_base_of<Object, T>::value || static_assert(std::is_base_of<Object, T>::value ||
...@@ -50,10 +50,12 @@ class TaggedField : public AllStatic { ...@@ -50,10 +50,12 @@ class TaggedField : public AllStatic {
static inline void Relaxed_Store(HeapObject host, T value); static inline void Relaxed_Store(HeapObject host, T value);
static inline void Relaxed_Store(HeapObject host, int offset, T value); static inline void Relaxed_Store(HeapObject host, int offset, T value);
static inline T Acquire_Load(HeapObject host); static inline T Acquire_Load(HeapObject host, int offset = 0);
static inline T Acquire_Load(Isolate* isolate, HeapObject host); static inline T Acquire_Load(Isolate* isolate, HeapObject host,
int offset = 0);
static inline void Release_Store(HeapObject host, T value); static inline void Release_Store(HeapObject host, T value);
static inline void Release_Store(HeapObject host, int offset, T value);
static inline Tagged_t Release_CompareAndSwap(HeapObject host, T old, static inline Tagged_t Release_CompareAndSwap(HeapObject host, T old,
T value); T value);
......
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