[cleanup] Drop ObjectSlot::Relaxed_Load(int, ...)

and Relaxed_Store(int, ...) by migrating the only call site
to using slot increment/decrement instead of offset calculations.
Also use SlotBase::location() more consistently.

Bug: v8:8238
Change-Id: I3099884a2a9e05041114205e7fb81691261afe19
Reviewed-on: https://chromium-review.googlesource.com/c/1349731
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57852}
This commit is contained in:
Jakob Kummerow 2018-11-23 18:35:58 -08:00 committed by Commit Bot
parent 3896c04767
commit fe0d26534c
3 changed files with 21 additions and 36 deletions

View File

@ -1429,11 +1429,18 @@ void Heap::MoveElements(FixedArray array, int dst_index, int src_index, int len,
if (FLAG_concurrent_marking && incremental_marking()->IsMarking()) {
if (dst < src) {
for (int i = 0; i < len; i++) {
dst.Relaxed_Store(i, src.Relaxed_Load(i));
dst.Relaxed_Store(src.Relaxed_Load());
++dst;
++src;
}
} else {
for (int i = len - 1; i >= 0; i--) {
dst.Relaxed_Store(i, src.Relaxed_Load(i));
// Copy backwards.
dst += len - 1;
src += len - 1;
for (int i = 0; i < len; i++) {
dst.Relaxed_Store(src.Relaxed_Load());
--dst;
--src;
}
}
} else {

View File

@ -18,34 +18,20 @@ namespace internal {
ObjectSlot::ObjectSlot(ObjectPtr* object)
: SlotBase(reinterpret_cast<Address>(&object->ptr_)) {}
void ObjectSlot::store(Object* value) {
*reinterpret_cast<Address*>(address()) = value->ptr();
}
void ObjectSlot::store(Object* value) { *location() = value->ptr(); }
ObjectPtr ObjectSlot::Acquire_Load() const {
return ObjectPtr(base::AsAtomicWord::Acquire_Load(location()));
}
Object* ObjectSlot::Relaxed_Load() const {
Address object_ptr = base::AsAtomicWord::Relaxed_Load(location());
return reinterpret_cast<Object*>(object_ptr);
}
Object* ObjectSlot::Relaxed_Load(int offset) const {
Address object_ptr = base::AsAtomicWord::Relaxed_Load(
reinterpret_cast<Address*>(address() + offset * kPointerSize));
return reinterpret_cast<Object*>(object_ptr);
ObjectPtr ObjectSlot::Relaxed_Load() const {
return ObjectPtr(base::AsAtomicWord::Relaxed_Load(location()));
}
void ObjectSlot::Relaxed_Store(ObjectPtr value) const {
base::AsAtomicWord::Relaxed_Store(location(), value->ptr());
}
void ObjectSlot::Relaxed_Store(int offset, Object* value) const {
Address* addr = reinterpret_cast<Address*>(address() + offset * kPointerSize);
base::AsAtomicWord::Relaxed_Store(addr, value->ptr());
}
void ObjectSlot::Release_Store(ObjectPtr value) const {
base::AsAtomicWord::Release_Store(location(), value->ptr());
}
@ -57,17 +43,12 @@ ObjectPtr ObjectSlot::Release_CompareAndSwap(ObjectPtr old,
return ObjectPtr(result);
}
MaybeObject MaybeObjectSlot::operator*() {
return MaybeObject(*reinterpret_cast<Address*>(address()));
}
MaybeObject MaybeObjectSlot::operator*() { return MaybeObject(*location()); }
void MaybeObjectSlot::store(MaybeObject value) {
*reinterpret_cast<Address*>(address()) = value.ptr();
}
void MaybeObjectSlot::store(MaybeObject value) { *location() = value.ptr(); }
MaybeObject MaybeObjectSlot::Relaxed_Load() const {
Address object_ptr = base::AsAtomicWord::Relaxed_Load(location());
return MaybeObject(object_ptr);
return MaybeObject(base::AsAtomicWord::Relaxed_Load(location()));
}
void MaybeObjectSlot::Release_CompareAndSwap(MaybeObject old,
@ -77,10 +58,10 @@ void MaybeObjectSlot::Release_CompareAndSwap(MaybeObject old,
}
HeapObjectReference HeapObjectSlot::operator*() {
return HeapObjectReference(*reinterpret_cast<Address*>(address()));
return HeapObjectReference(*location());
}
void HeapObjectSlot::store(HeapObjectReference value) {
*reinterpret_cast<Address*>(address()) = value.ptr();
*location() = value.ptr();
}
} // namespace internal

View File

@ -101,10 +101,8 @@ class ObjectSlot : public SlotBase<ObjectSlot, kTaggedSize> {
inline void store(Object* value);
inline ObjectPtr Acquire_Load() const;
inline Object* Relaxed_Load() const;
inline Object* Relaxed_Load(int offset) const;
inline ObjectPtr Relaxed_Load() const;
inline void Relaxed_Store(ObjectPtr value) const;
inline void Relaxed_Store(int offset, Object* value) const;
inline void Release_Store(ObjectPtr value) const;
inline ObjectPtr Release_CompareAndSwap(ObjectPtr old,
ObjectPtr target) const;
@ -148,9 +146,8 @@ class HeapObjectSlot : public SlotBase<HeapObjectSlot, kTaggedSize> {
inline void store(HeapObjectReference value);
HeapObject* ToHeapObject() {
DCHECK((*reinterpret_cast<Address*>(address()) & kHeapObjectTagMask) ==
kHeapObjectTag);
return *reinterpret_cast<HeapObject**>(address());
DCHECK((*location() & kHeapObjectTagMask) == kHeapObjectTag);
return reinterpret_cast<HeapObject*>(*location());
}
void StoreHeapObject(HeapObject* value) {