Commit 6fdc3fb0 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by V8 LUCI CQ

[cleanup] Remove synchronized_ from map_word accessors

Continuing the cleanups and using the tags rather than synchronized_
in the name of the accessors.

`map_word` (and its setter) can also be marked explicitly as relaxed to
show that they are atomic accessors.

Bug: v8:7790
Change-Id: I0725054ef37022c777f47660cb11cf839bb7f273
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2897094Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74605}
parent 5258364e
...@@ -806,13 +806,13 @@ void UpdateRetainersMapAfterScavenge( ...@@ -806,13 +806,13 @@ void UpdateRetainersMapAfterScavenge(
HeapObject retainer = pair.second; HeapObject retainer = pair.second;
if (Heap::InFromPage(object)) { if (Heap::InFromPage(object)) {
MapWord map_word = object.map_word(); MapWord map_word = object.map_word(kRelaxedLoad);
if (!map_word.IsForwardingAddress()) continue; if (!map_word.IsForwardingAddress()) continue;
object = map_word.ToForwardingAddress(); object = map_word.ToForwardingAddress();
} }
if (Heap::InFromPage(retainer)) { if (Heap::InFromPage(retainer)) {
MapWord map_word = retainer.map_word(); MapWord map_word = retainer.map_word(kRelaxedLoad);
if (!map_word.IsForwardingAddress()) continue; if (!map_word.IsForwardingAddress()) continue;
retainer = map_word.ToForwardingAddress(); retainer = map_word.ToForwardingAddress();
} }
...@@ -838,7 +838,7 @@ void Heap::UpdateRetainersAfterScavenge() { ...@@ -838,7 +838,7 @@ void Heap::UpdateRetainersAfterScavenge() {
HeapObject object = pair.first; HeapObject object = pair.first;
if (Heap::InFromPage(object)) { if (Heap::InFromPage(object)) {
MapWord map_word = object.map_word(); MapWord map_word = object.map_word(kRelaxedLoad);
if (!map_word.IsForwardingAddress()) continue; if (!map_word.IsForwardingAddress()) continue;
object = map_word.ToForwardingAddress(); object = map_word.ToForwardingAddress();
} }
...@@ -966,7 +966,7 @@ void Heap::MergeAllocationSitePretenuringFeedback( ...@@ -966,7 +966,7 @@ void Heap::MergeAllocationSitePretenuringFeedback(
AllocationSite site; AllocationSite site;
for (auto& site_and_count : local_pretenuring_feedback) { for (auto& site_and_count : local_pretenuring_feedback) {
site = site_and_count.first; site = site_and_count.first;
MapWord map_word = site_and_count.first.map_word(); MapWord map_word = site_and_count.first.map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
site = AllocationSite::cast(map_word.ToForwardingAddress()); site = AllocationSite::cast(map_word.ToForwardingAddress());
} }
...@@ -2640,7 +2640,7 @@ void Heap::UpdateExternalString(String string, size_t old_payload, ...@@ -2640,7 +2640,7 @@ void Heap::UpdateExternalString(String string, size_t old_payload,
String Heap::UpdateYoungReferenceInExternalStringTableEntry(Heap* heap, String Heap::UpdateYoungReferenceInExternalStringTableEntry(Heap* heap,
FullObjectSlot p) { FullObjectSlot p) {
HeapObject obj = HeapObject::cast(*p); HeapObject obj = HeapObject::cast(*p);
MapWord first_word = obj.map_word(); MapWord first_word = obj.map_word(kRelaxedLoad);
String new_string; String new_string;
...@@ -3755,13 +3755,13 @@ void Heap::VerifyObjectLayoutChange(HeapObject object, Map new_map) { ...@@ -3755,13 +3755,13 @@ void Heap::VerifyObjectLayoutChange(HeapObject object, Map new_map) {
// Check that the set of slots before and after the transition match. // Check that the set of slots before and after the transition match.
SlotCollectingVisitor old_visitor; SlotCollectingVisitor old_visitor;
object.IterateFast(&old_visitor); object.IterateFast(&old_visitor);
MapWord old_map_word = object.map_word(); MapWord old_map_word = object.map_word(kRelaxedLoad);
// Temporarily set the new map to iterate new slots. // Temporarily set the new map to iterate new slots.
object.set_map_word(MapWord::FromMap(new_map)); object.set_map_word(MapWord::FromMap(new_map), kRelaxedStore);
SlotCollectingVisitor new_visitor; SlotCollectingVisitor new_visitor;
object.IterateFast(&new_visitor); object.IterateFast(&new_visitor);
// Restore the old map. // Restore the old map.
object.set_map_word(old_map_word); object.set_map_word(old_map_word, kRelaxedStore);
DCHECK_EQ(new_visitor.number_of_slots(), old_visitor.number_of_slots()); DCHECK_EQ(new_visitor.number_of_slots(), old_visitor.number_of_slots());
for (int i = 0; i < new_visitor.number_of_slots(); i++) { for (int i = 0; i < new_visitor.number_of_slots(); i++) {
DCHECK_EQ(new_visitor.slot(i), old_visitor.slot(i)); DCHECK_EQ(new_visitor.slot(i), old_visitor.slot(i));
...@@ -4568,11 +4568,11 @@ class FixStaleLeftTrimmedHandlesVisitor : public RootVisitor { ...@@ -4568,11 +4568,11 @@ class FixStaleLeftTrimmedHandlesVisitor : public RootVisitor {
inline void FixHandle(FullObjectSlot p) { inline void FixHandle(FullObjectSlot p) {
if (!(*p).IsHeapObject()) return; if (!(*p).IsHeapObject()) return;
HeapObject current = HeapObject::cast(*p); HeapObject current = HeapObject::cast(*p);
if (!current.map_word().IsForwardingAddress() && if (!current.map_word(kRelaxedLoad).IsForwardingAddress() &&
current.IsFreeSpaceOrFiller()) { current.IsFreeSpaceOrFiller()) {
#ifdef DEBUG #ifdef DEBUG
// We need to find a FixedArrayBase map after walking the fillers. // We need to find a FixedArrayBase map after walking the fillers.
while (!current.map_word().IsForwardingAddress() && while (!current.map_word(kRelaxedLoad).IsForwardingAddress() &&
current.IsFreeSpaceOrFiller()) { current.IsFreeSpaceOrFiller()) {
Address next = current.ptr(); Address next = current.ptr();
if (current.map() == ReadOnlyRoots(heap_).one_pointer_filler_map()) { if (current.map() == ReadOnlyRoots(heap_).one_pointer_filler_map()) {
...@@ -4585,7 +4585,7 @@ class FixStaleLeftTrimmedHandlesVisitor : public RootVisitor { ...@@ -4585,7 +4585,7 @@ class FixStaleLeftTrimmedHandlesVisitor : public RootVisitor {
} }
current = HeapObject::cast(Object(next)); current = HeapObject::cast(Object(next));
} }
DCHECK(current.map_word().IsForwardingAddress() || DCHECK(current.map_word(kRelaxedLoad).IsForwardingAddress() ||
current.IsFixedArrayBase()); current.IsFixedArrayBase());
#endif // DEBUG #endif // DEBUG
p.store(Smi::zero()); p.store(Smi::zero());
...@@ -6769,7 +6769,7 @@ void Heap::CreateObjectStats() { ...@@ -6769,7 +6769,7 @@ void Heap::CreateObjectStats() {
} }
Map Heap::GcSafeMapOfCodeSpaceObject(HeapObject object) { Map Heap::GcSafeMapOfCodeSpaceObject(HeapObject object) {
MapWord map_word = object.map_word(); MapWord map_word = object.map_word(kRelaxedLoad);
return map_word.IsForwardingAddress() ? map_word.ToForwardingAddress().map() return map_word.IsForwardingAddress() ? map_word.ToForwardingAddress().map()
: map_word.ToMap(); : map_word.ToMap();
} }
......
...@@ -2706,7 +2706,7 @@ class HeapObjectAllocationTracker { ...@@ -2706,7 +2706,7 @@ class HeapObjectAllocationTracker {
template <typename T> template <typename T>
T ForwardingAddress(T heap_obj) { T ForwardingAddress(T heap_obj) {
MapWord map_word = heap_obj.map_word(); MapWord map_word = heap_obj.map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
return T::cast(map_word.ToForwardingAddress()); return T::cast(map_word.ToForwardingAddress());
......
...@@ -447,7 +447,7 @@ void IncrementalMarking::UpdateMarkingWorklistAfterScavenge() { ...@@ -447,7 +447,7 @@ void IncrementalMarking::UpdateMarkingWorklistAfterScavenge() {
DCHECK(obj.IsHeapObject()); DCHECK(obj.IsHeapObject());
// Only pointers to from space have to be updated. // Only pointers to from space have to be updated.
if (Heap::InFromPage(obj)) { if (Heap::InFromPage(obj)) {
MapWord map_word = obj.map_word(); MapWord map_word = obj.map_word(kRelaxedLoad);
if (!map_word.IsForwardingAddress()) { if (!map_word.IsForwardingAddress()) {
// There may be objects on the marking deque that do not exist // There may be objects on the marking deque that do not exist
// anymore, e.g. left trimmed objects or objects from the root set // anymore, e.g. left trimmed objects or objects from the root set
......
...@@ -1347,7 +1347,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor { ...@@ -1347,7 +1347,7 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
if (mode != MigrationMode::kFast) if (mode != MigrationMode::kFast)
base->ExecuteMigrationObservers(dest, src, dst, size); base->ExecuteMigrationObservers(dest, src, dst, size);
} }
src.set_map_word(MapWord::FromForwardingAddress(dst)); src.set_map_word(MapWord::FromForwardingAddress(dst), kRelaxedStore);
} }
EvacuateVisitorBase(Heap* heap, EvacuationAllocator* local_allocator, EvacuateVisitorBase(Heap* heap, EvacuationAllocator* local_allocator,
...@@ -1476,7 +1476,8 @@ class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase { ...@@ -1476,7 +1476,8 @@ class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase {
if (map.visitor_id() == kVisitThinString) { if (map.visitor_id() == kVisitThinString) {
HeapObject actual = ThinString::cast(object).unchecked_actual(); HeapObject actual = ThinString::cast(object).unchecked_actual();
if (MarkCompactCollector::IsOnEvacuationCandidate(actual)) return false; if (MarkCompactCollector::IsOnEvacuationCandidate(actual)) return false;
object.set_map_word(MapWord::FromForwardingAddress(actual)); object.set_map_word(MapWord::FromForwardingAddress(actual),
kRelaxedStore);
return true; return true;
} }
// TODO(mlippautz): Handle ConsString. // TODO(mlippautz): Handle ConsString.
...@@ -1580,7 +1581,7 @@ class EvacuateOldSpaceVisitor final : public EvacuateVisitorBase { ...@@ -1580,7 +1581,7 @@ class EvacuateOldSpaceVisitor final : public EvacuateVisitorBase {
HeapObject target_object; HeapObject target_object;
if (TryEvacuateObject(Page::FromHeapObject(object)->owner_identity(), if (TryEvacuateObject(Page::FromHeapObject(object)->owner_identity(),
object, size, &target_object)) { object, size, &target_object)) {
DCHECK(object.map_word().IsForwardingAddress()); DCHECK(object.map_word(kRelaxedLoad).IsForwardingAddress());
return true; return true;
} }
return false; return false;
...@@ -2714,7 +2715,7 @@ static inline SlotCallbackResult UpdateSlot(TSlot slot, ...@@ -2714,7 +2715,7 @@ static inline SlotCallbackResult UpdateSlot(TSlot slot,
std::is_same<TSlot, OffHeapObjectSlot>::value, std::is_same<TSlot, OffHeapObjectSlot>::value,
"Only [Full|OffHeap]ObjectSlot and [Full]MaybeObjectSlot are " "Only [Full|OffHeap]ObjectSlot and [Full]MaybeObjectSlot are "
"expected here"); "expected here");
MapWord map_word = heap_obj.map_word(); MapWord map_word = heap_obj.map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
DCHECK_IMPLIES(!Heap::InFromPage(heap_obj), DCHECK_IMPLIES(!Heap::InFromPage(heap_obj),
MarkCompactCollector::IsOnEvacuationCandidate(heap_obj) || MarkCompactCollector::IsOnEvacuationCandidate(heap_obj) ||
...@@ -2856,7 +2857,7 @@ class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor { ...@@ -2856,7 +2857,7 @@ class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor {
static String UpdateReferenceInExternalStringTableEntry(Heap* heap, static String UpdateReferenceInExternalStringTableEntry(Heap* heap,
FullObjectSlot p) { FullObjectSlot p) {
MapWord map_word = HeapObject::cast(*p).map_word(); MapWord map_word = HeapObject::cast(*p).map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
String new_string = String::cast(map_word.ToForwardingAddress()); String new_string = String::cast(map_word.ToForwardingAddress());
...@@ -3365,7 +3366,7 @@ class EvacuationWeakObjectRetainer : public WeakObjectRetainer { ...@@ -3365,7 +3366,7 @@ class EvacuationWeakObjectRetainer : public WeakObjectRetainer {
Object RetainAs(Object object) override { Object RetainAs(Object object) override {
if (object.IsHeapObject()) { if (object.IsHeapObject()) {
HeapObject heap_object = HeapObject::cast(object); HeapObject heap_object = HeapObject::cast(object);
MapWord map_word = heap_object.map_word(); MapWord map_word = heap_object.map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
return map_word.ToForwardingAddress(); return map_word.ToForwardingAddress();
} }
...@@ -3696,7 +3697,7 @@ class RememberedSetUpdatingItem : public UpdatingItem { ...@@ -3696,7 +3697,7 @@ class RememberedSetUpdatingItem : public UpdatingItem {
return REMOVE_SLOT; return REMOVE_SLOT;
} }
if (Heap::InFromPage(heap_object)) { if (Heap::InFromPage(heap_object)) {
MapWord map_word = heap_object.map_word(); MapWord map_word = heap_object.map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
HeapObjectReference::Update(THeapObjectSlot(slot), HeapObjectReference::Update(THeapObjectSlot(slot),
map_word.ToForwardingAddress()); map_word.ToForwardingAddress());
...@@ -3930,7 +3931,7 @@ class EphemeronTableUpdatingItem : public UpdatingItem { ...@@ -3930,7 +3931,7 @@ class EphemeronTableUpdatingItem : public UpdatingItem {
it != heap_->ephemeron_remembered_set_.end();) { it != heap_->ephemeron_remembered_set_.end();) {
EphemeronHashTable table = it->first; EphemeronHashTable table = it->first;
auto& indices = it->second; auto& indices = it->second;
if (table.map_word().IsForwardingAddress()) { if (table.map_word(kRelaxedLoad).IsForwardingAddress()) {
// The table has moved, and RecordMigratedSlotVisitor::VisitEphemeron // The table has moved, and RecordMigratedSlotVisitor::VisitEphemeron
// inserts entries for the moved table into ephemeron_remembered_set_. // inserts entries for the moved table into ephemeron_remembered_set_.
it = heap_->ephemeron_remembered_set_.erase(it); it = heap_->ephemeron_remembered_set_.erase(it);
...@@ -3943,7 +3944,7 @@ class EphemeronTableUpdatingItem : public UpdatingItem { ...@@ -3943,7 +3944,7 @@ class EphemeronTableUpdatingItem : public UpdatingItem {
HeapObjectSlot key_slot(table.RawFieldOfElementAt( HeapObjectSlot key_slot(table.RawFieldOfElementAt(
EphemeronHashTable::EntryToIndex(InternalIndex(*iti)))); EphemeronHashTable::EntryToIndex(InternalIndex(*iti))));
HeapObject key = key_slot.ToHeapObject(); HeapObject key = key_slot.ToHeapObject();
MapWord map_word = key.map_word(); MapWord map_word = key.map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
key = map_word.ToForwardingAddress(); key = map_word.ToForwardingAddress();
key_slot.StoreHeapObject(key); key_slot.StoreHeapObject(key);
......
...@@ -76,7 +76,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit(Map map, ...@@ -76,7 +76,7 @@ ResultType HeapVisitor<ResultType, ConcreteVisitor>::Visit(Map map,
template <typename ResultType, typename ConcreteVisitor> template <typename ResultType, typename ConcreteVisitor>
void HeapVisitor<ResultType, ConcreteVisitor>::VisitMapPointer( void HeapVisitor<ResultType, ConcreteVisitor>::VisitMapPointer(
HeapObject host) { HeapObject host) {
DCHECK(!host.map_word().IsForwardingAddress()); DCHECK(!host.map_word(kRelaxedLoad).IsForwardingAddress());
if (!static_cast<ConcreteVisitor*>(this)->ShouldVisitMapPointer()) return; if (!static_cast<ConcreteVisitor*>(this)->ShouldVisitMapPointer()) return;
static_cast<ConcreteVisitor*>(this)->VisitMapPointer(host); static_cast<ConcreteVisitor*>(this)->VisitMapPointer(host);
} }
......
...@@ -119,7 +119,7 @@ void Scavenger::PageMemoryFence(MaybeObject object) { ...@@ -119,7 +119,7 @@ void Scavenger::PageMemoryFence(MaybeObject object) {
bool Scavenger::MigrateObject(Map map, HeapObject source, HeapObject target, bool Scavenger::MigrateObject(Map map, HeapObject source, HeapObject target,
int size) { int size) {
// Copy the content of source to target. // Copy the content of source to target.
target.set_map_word(MapWord::FromMap(map)); target.set_map_word(MapWord::FromMap(map), kRelaxedStore);
heap()->CopyBlock(target.address() + kTaggedSize, heap()->CopyBlock(target.address() + kTaggedSize,
source.address() + kTaggedSize, size - kTaggedSize); source.address() + kTaggedSize, size - kTaggedSize);
...@@ -159,7 +159,7 @@ CopyAndForwardResult Scavenger::SemiSpaceCopyObject( ...@@ -159,7 +159,7 @@ CopyAndForwardResult Scavenger::SemiSpaceCopyObject(
const bool self_success = MigrateObject(map, object, target, object_size); const bool self_success = MigrateObject(map, object, target, object_size);
if (!self_success) { if (!self_success) {
allocator_.FreeLast(NEW_SPACE, target, object_size); allocator_.FreeLast(NEW_SPACE, target, object_size);
MapWord map_word = object.synchronized_map_word(); MapWord map_word = object.map_word(kAcquireLoad);
HeapObjectReference::Update(slot, map_word.ToForwardingAddress()); HeapObjectReference::Update(slot, map_word.ToForwardingAddress());
DCHECK(!Heap::InFromPage(*slot)); DCHECK(!Heap::InFromPage(*slot));
return Heap::InToPage(*slot) return Heap::InToPage(*slot)
...@@ -196,7 +196,7 @@ CopyAndForwardResult Scavenger::PromoteObject(Map map, THeapObjectSlot slot, ...@@ -196,7 +196,7 @@ CopyAndForwardResult Scavenger::PromoteObject(Map map, THeapObjectSlot slot,
const bool self_success = MigrateObject(map, object, target, object_size); const bool self_success = MigrateObject(map, object, target, object_size);
if (!self_success) { if (!self_success) {
allocator_.FreeLast(OLD_SPACE, target, object_size); allocator_.FreeLast(OLD_SPACE, target, object_size);
MapWord map_word = object.synchronized_map_word(); MapWord map_word = object.map_word(kAcquireLoad);
HeapObjectReference::Update(slot, map_word.ToForwardingAddress()); HeapObjectReference::Update(slot, map_word.ToForwardingAddress());
DCHECK(!Heap::InFromPage(*slot)); DCHECK(!Heap::InFromPage(*slot));
return Heap::InToPage(*slot) return Heap::InToPage(*slot)
...@@ -327,24 +327,25 @@ SlotCallbackResult Scavenger::EvacuateShortcutCandidate(Map map, ...@@ -327,24 +327,25 @@ SlotCallbackResult Scavenger::EvacuateShortcutCandidate(Map map,
HeapObjectReference::Update(slot, first); HeapObjectReference::Update(slot, first);
if (!Heap::InYoungGeneration(first)) { if (!Heap::InYoungGeneration(first)) {
object.synchronized_set_map_word(MapWord::FromForwardingAddress(first)); object.set_map_word(MapWord::FromForwardingAddress(first), kReleaseStore);
return REMOVE_SLOT; return REMOVE_SLOT;
} }
MapWord first_word = first.synchronized_map_word(); MapWord first_word = first.map_word(kAcquireLoad);
if (first_word.IsForwardingAddress()) { if (first_word.IsForwardingAddress()) {
HeapObject target = first_word.ToForwardingAddress(); HeapObject target = first_word.ToForwardingAddress();
HeapObjectReference::Update(slot, target); HeapObjectReference::Update(slot, target);
object.synchronized_set_map_word(MapWord::FromForwardingAddress(target)); object.set_map_word(MapWord::FromForwardingAddress(target),
kReleaseStore);
return Heap::InYoungGeneration(target) ? KEEP_SLOT : REMOVE_SLOT; return Heap::InYoungGeneration(target) ? KEEP_SLOT : REMOVE_SLOT;
} }
Map map = first_word.ToMap(); Map map = first_word.ToMap();
SlotCallbackResult result = SlotCallbackResult result =
EvacuateObjectDefault(map, slot, first, first.SizeFromMap(map), EvacuateObjectDefault(map, slot, first, first.SizeFromMap(map),
Map::ObjectFieldsFrom(map.visitor_id())); Map::ObjectFieldsFrom(map.visitor_id()));
object.synchronized_set_map_word( object.set_map_word(MapWord::FromForwardingAddress(slot.ToHeapObject()),
MapWord::FromForwardingAddress(slot.ToHeapObject())); kReleaseStore);
return result; return result;
} }
DCHECK_EQ(ObjectFields::kMaybePointers, DCHECK_EQ(ObjectFields::kMaybePointers,
...@@ -391,7 +392,7 @@ SlotCallbackResult Scavenger::ScavengeObject(THeapObjectSlot p, ...@@ -391,7 +392,7 @@ SlotCallbackResult Scavenger::ScavengeObject(THeapObjectSlot p,
DCHECK(Heap::InFromPage(object)); DCHECK(Heap::InFromPage(object));
// Synchronized load that consumes the publishing CAS of MigrateObject. // Synchronized load that consumes the publishing CAS of MigrateObject.
MapWord first_word = object.synchronized_map_word(); MapWord first_word = object.map_word(kAcquireLoad);
// If the first word is a forwarding address, the object has already been // If the first word is a forwarding address, the object has already been
// copied. // copied.
......
...@@ -130,13 +130,13 @@ namespace { ...@@ -130,13 +130,13 @@ namespace {
V8_INLINE bool IsUnscavengedHeapObject(Heap* heap, Object object) { V8_INLINE bool IsUnscavengedHeapObject(Heap* heap, Object object) {
return Heap::InFromPage(object) && return Heap::InFromPage(object) &&
!HeapObject::cast(object).map_word().IsForwardingAddress(); !HeapObject::cast(object).map_word(kRelaxedLoad).IsForwardingAddress();
} }
// Same as IsUnscavengedHeapObject() above but specialized for HeapObjects. // Same as IsUnscavengedHeapObject() above but specialized for HeapObjects.
V8_INLINE bool IsUnscavengedHeapObject(Heap* heap, HeapObject heap_object) { V8_INLINE bool IsUnscavengedHeapObject(Heap* heap, HeapObject heap_object) {
return Heap::InFromPage(heap_object) && return Heap::InFromPage(heap_object) &&
!heap_object.map_word().IsForwardingAddress(); !heap_object.map_word(kRelaxedLoad).IsForwardingAddress();
} }
bool IsUnscavengedHeapObjectSlot(Heap* heap, FullObjectSlot p) { bool IsUnscavengedHeapObjectSlot(Heap* heap, FullObjectSlot p) {
...@@ -152,7 +152,7 @@ class ScavengeWeakObjectRetainer : public WeakObjectRetainer { ...@@ -152,7 +152,7 @@ class ScavengeWeakObjectRetainer : public WeakObjectRetainer {
return object; return object;
} }
MapWord map_word = HeapObject::cast(object).map_word(); MapWord map_word = HeapObject::cast(object).map_word(kRelaxedLoad);
if (map_word.IsForwardingAddress()) { if (map_word.IsForwardingAddress()) {
return map_word.ToForwardingAddress(); return map_word.ToForwardingAddress();
} }
...@@ -485,7 +485,7 @@ void ScavengerCollector::HandleSurvivingNewLargeObjects() { ...@@ -485,7 +485,7 @@ void ScavengerCollector::HandleSurvivingNewLargeObjects() {
Map map = update_info.second; Map map = update_info.second;
// Order is important here. We have to re-install the map to have access // Order is important here. We have to re-install the map to have access
// to meta-data like size during page promotion. // to meta-data like size during page promotion.
object.set_map_word(MapWord::FromMap(map)); object.set_map_word(MapWord::FromMap(map), kRelaxedStore);
LargePage* page = LargePage::FromHeapObject(object); LargePage* page = LargePage::FromHeapObject(object);
heap_->lo_space()->PromoteNewLargeObject(page); heap_->lo_space()->PromoteNewLargeObject(page);
} }
......
...@@ -58,12 +58,12 @@ class HeapObject : public Object { ...@@ -58,12 +58,12 @@ class HeapObject : public Object {
// During garbage collection, the map word of a heap object does not // During garbage collection, the map word of a heap object does not
// necessarily contain a map pointer. // necessarily contain a map pointer.
DECL_GETTER(map_word, MapWord) DECL_RELAXED_GETTER(map_word, MapWord)
inline void set_map_word(MapWord map_word); inline void set_map_word(MapWord map_word, RelaxedStoreTag);
// Access the map word using acquire load and release store. // Access the map word using acquire load and release store.
DECL_GETTER(synchronized_map_word, MapWord) DECL_ACQUIRE_GETTER(map_word, MapWord)
inline void synchronized_set_map_word(MapWord map_word); inline void set_map_word(MapWord map_word, ReleaseStoreTag);
// This method exists to help remove GetIsolate/GetHeap from HeapObject, in a // 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 // way that doesn't require passing Isolate/Heap down huge call chains or to
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "src/base/memory.h" #include "src/base/memory.h"
#include "src/builtins/builtins.h" #include "src/builtins/builtins.h"
#include "src/common/external-pointer-inl.h" #include "src/common/external-pointer-inl.h"
#include "src/common/globals.h"
#include "src/handles/handles-inl.h" #include "src/handles/handles-inl.h"
#include "src/heap/factory.h" #include "src/heap/factory.h"
#include "src/heap/heap-write-barrier-inl.h" #include "src/heap/heap-write-barrier-inl.h"
...@@ -710,7 +711,9 @@ ReadOnlyRoots HeapObject::GetReadOnlyRoots(PtrComprCageBase cage_base) const { ...@@ -710,7 +711,9 @@ ReadOnlyRoots HeapObject::GetReadOnlyRoots(PtrComprCageBase cage_base) const {
#endif #endif
} }
DEF_GETTER(HeapObject, map, Map) { return map_word(cage_base).ToMap(); } DEF_GETTER(HeapObject, map, Map) {
return map_word(cage_base, kRelaxedLoad).ToMap();
}
void HeapObject::set_map(Map value) { void HeapObject::set_map(Map value) {
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
...@@ -718,7 +721,7 @@ void HeapObject::set_map(Map value) { ...@@ -718,7 +721,7 @@ void HeapObject::set_map(Map value) {
GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value); GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value);
} }
#endif #endif
set_map_word(MapWord::FromMap(value)); set_map_word(MapWord::FromMap(value), kRelaxedStore);
#ifndef V8_DISABLE_WRITE_BARRIERS #ifndef V8_DISABLE_WRITE_BARRIERS
if (!value.is_null()) { if (!value.is_null()) {
// TODO(1600) We are passing kNullAddress as a slot because maps can never // TODO(1600) We are passing kNullAddress as a slot because maps can never
...@@ -729,7 +732,7 @@ void HeapObject::set_map(Map value) { ...@@ -729,7 +732,7 @@ void HeapObject::set_map(Map value) {
} }
DEF_GETTER(HeapObject, synchronized_map, Map) { DEF_GETTER(HeapObject, synchronized_map, Map) {
return synchronized_map_word(cage_base).ToMap(); return map_word(cage_base, kAcquireLoad).ToMap();
} }
void HeapObject::synchronized_set_map(Map value) { void HeapObject::synchronized_set_map(Map value) {
...@@ -738,7 +741,7 @@ void HeapObject::synchronized_set_map(Map value) { ...@@ -738,7 +741,7 @@ void HeapObject::synchronized_set_map(Map value) {
GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value); GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value);
} }
#endif #endif
synchronized_set_map_word(MapWord::FromMap(value)); set_map_word(MapWord::FromMap(value), kReleaseStore);
#ifndef V8_DISABLE_WRITE_BARRIERS #ifndef V8_DISABLE_WRITE_BARRIERS
if (!value.is_null()) { if (!value.is_null()) {
// TODO(1600) We are passing kNullAddress as a slot because maps can never // TODO(1600) We are passing kNullAddress as a slot because maps can never
...@@ -755,12 +758,12 @@ void HeapObject::set_map_no_write_barrier(Map value) { ...@@ -755,12 +758,12 @@ void HeapObject::set_map_no_write_barrier(Map value) {
GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value); GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value);
} }
#endif #endif
set_map_word(MapWord::FromMap(value)); set_map_word(MapWord::FromMap(value), kRelaxedStore);
} }
void HeapObject::set_map_after_allocation(Map value, WriteBarrierMode mode) { void HeapObject::set_map_after_allocation(Map value, WriteBarrierMode mode) {
MapWord mapword = MapWord::FromMap(value); MapWord mapword = MapWord::FromMap(value);
set_map_word(mapword); set_map_word(mapword, kRelaxedStore);
#ifndef V8_DISABLE_WRITE_BARRIERS #ifndef V8_DISABLE_WRITE_BARRIERS
if (mode != SKIP_WRITE_BARRIER) { if (mode != SKIP_WRITE_BARRIER) {
DCHECK(!value.is_null()); DCHECK(!value.is_null());
...@@ -775,19 +778,27 @@ ObjectSlot HeapObject::map_slot() const { ...@@ -775,19 +778,27 @@ ObjectSlot HeapObject::map_slot() const {
return ObjectSlot(MapField::address(*this)); return ObjectSlot(MapField::address(*this));
} }
DEF_GETTER(HeapObject, map_word, MapWord) { MapWord HeapObject::map_word(RelaxedLoadTag tag) const {
PtrComprCageBase cage_base = GetPtrComprCageBase(*this);
return HeapObject::map_word(cage_base, tag);
}
MapWord HeapObject::map_word(PtrComprCageBase cage_base, RelaxedLoadTag) const {
return MapField::Relaxed_Load_Map_Word(cage_base, *this); return MapField::Relaxed_Load_Map_Word(cage_base, *this);
} }
void HeapObject::set_map_word(MapWord map_word) { void HeapObject::set_map_word(MapWord map_word, RelaxedStoreTag) {
MapField::Relaxed_Store_Map_Word(*this, map_word); MapField::Relaxed_Store_Map_Word(*this, map_word);
} }
DEF_GETTER(HeapObject, synchronized_map_word, MapWord) { MapWord HeapObject::map_word(AcquireLoadTag tag) const {
PtrComprCageBase cage_base = GetPtrComprCageBase(*this);
return HeapObject::map_word(cage_base, tag);
}
MapWord HeapObject::map_word(PtrComprCageBase cage_base, AcquireLoadTag) const {
return MapField::Acquire_Load_No_Unpack(cage_base, *this); return MapField::Acquire_Load_No_Unpack(cage_base, *this);
} }
void HeapObject::synchronized_set_map_word(MapWord map_word) { void HeapObject::set_map_word(MapWord map_word, ReleaseStoreTag) {
MapField::Release_Store_Map_Word(*this, map_word); MapField::Release_Store_Map_Word(*this, map_word);
} }
......
...@@ -416,7 +416,7 @@ wasm::StructType* WasmStruct::type(Map map) { ...@@ -416,7 +416,7 @@ wasm::StructType* WasmStruct::type(Map map) {
wasm::StructType* WasmStruct::GcSafeType(Map map) { wasm::StructType* WasmStruct::GcSafeType(Map map) {
DCHECK_EQ(WASM_STRUCT_TYPE, map.instance_type()); DCHECK_EQ(WASM_STRUCT_TYPE, map.instance_type());
HeapObject raw = HeapObject::cast(map.constructor_or_back_pointer()); HeapObject raw = HeapObject::cast(map.constructor_or_back_pointer());
MapWord map_word = raw.map_word(); MapWord map_word = raw.map_word(kRelaxedLoad);
HeapObject forwarded = HeapObject forwarded =
map_word.IsForwardingAddress() ? map_word.ToForwardingAddress() : raw; map_word.IsForwardingAddress() ? map_word.ToForwardingAddress() : raw;
Foreign foreign = Foreign::cast(forwarded); Foreign foreign = Foreign::cast(forwarded);
...@@ -453,7 +453,7 @@ wasm::ArrayType* WasmArray::type(Map map) { ...@@ -453,7 +453,7 @@ wasm::ArrayType* WasmArray::type(Map map) {
wasm::ArrayType* WasmArray::GcSafeType(Map map) { wasm::ArrayType* WasmArray::GcSafeType(Map map) {
DCHECK_EQ(WASM_ARRAY_TYPE, map.instance_type()); DCHECK_EQ(WASM_ARRAY_TYPE, map.instance_type());
HeapObject raw = HeapObject::cast(map.constructor_or_back_pointer()); HeapObject raw = HeapObject::cast(map.constructor_or_back_pointer());
MapWord map_word = raw.map_word(); MapWord map_word = raw.map_word(kRelaxedLoad);
HeapObject forwarded = HeapObject forwarded =
map_word.IsForwardingAddress() ? map_word.ToForwardingAddress() : raw; map_word.IsForwardingAddress() ? map_word.ToForwardingAddress() : raw;
Foreign foreign = Foreign::cast(forwarded); Foreign foreign = Foreign::cast(forwarded);
......
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