[cleanup] Make Heap::InToSpace static
Like Heap::InFromSpace, it doesn't use any members, so should be made static. Also clean up call sites to not call via a heap pointer. Change-Id: If55484ddac51351d789c73093f1f7ebf1c568bea Reviewed-on: https://chromium-review.googlesource.com/1088618 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#53842}
This commit is contained in:
parent
7f2fc562dd
commit
25cd2453d4
@ -360,17 +360,20 @@ bool Heap::InFromSpace(HeapObject* heap_object) {
|
||||
->IsFlagSet(Page::IN_FROM_SPACE);
|
||||
}
|
||||
|
||||
// static
|
||||
bool Heap::InToSpace(Object* object) {
|
||||
DCHECK(!HasWeakHeapObjectTag(object));
|
||||
return object->IsHeapObject() && InToSpace(HeapObject::cast(object));
|
||||
}
|
||||
|
||||
// static
|
||||
bool Heap::InToSpace(MaybeObject* object) {
|
||||
HeapObject* heap_object;
|
||||
return object->ToStrongOrWeakHeapObject(&heap_object) &&
|
||||
InToSpace(heap_object);
|
||||
}
|
||||
|
||||
// static
|
||||
bool Heap::InToSpace(HeapObject* heap_object) {
|
||||
return MemoryChunk::FromHeapObject(heap_object)->IsFlagSet(Page::IN_TO_SPACE);
|
||||
}
|
||||
|
@ -1975,16 +1975,14 @@ void Heap::CheckNewSpaceExpansionCriteria() {
|
||||
}
|
||||
|
||||
static bool IsUnscavengedHeapObject(Heap* heap, Object** p) {
|
||||
return heap->InFromSpace(*p) &&
|
||||
return Heap::InFromSpace(*p) &&
|
||||
!HeapObject::cast(*p)->map_word().IsForwardingAddress();
|
||||
}
|
||||
|
||||
class ScavengeWeakObjectRetainer : public WeakObjectRetainer {
|
||||
public:
|
||||
explicit ScavengeWeakObjectRetainer(Heap* heap) : heap_(heap) {}
|
||||
|
||||
virtual Object* RetainAs(Object* object) {
|
||||
if (!heap_->InFromSpace(object)) {
|
||||
if (!Heap::InFromSpace(object)) {
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -1994,9 +1992,6 @@ class ScavengeWeakObjectRetainer : public WeakObjectRetainer {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
Heap* heap_;
|
||||
};
|
||||
|
||||
void Heap::EvacuateYoungGeneration() {
|
||||
@ -2237,7 +2232,7 @@ void Heap::Scavenge() {
|
||||
}
|
||||
}
|
||||
|
||||
ScavengeWeakObjectRetainer weak_object_retainer(this);
|
||||
ScavengeWeakObjectRetainer weak_object_retainer;
|
||||
ProcessYoungWeakReferences(&weak_object_retainer);
|
||||
|
||||
// Set age mark.
|
||||
@ -3812,7 +3807,7 @@ class OldToNewSlotVerifyingVisitor : public SlotVerifyingVisitor {
|
||||
bool ShouldHaveBeenRecorded(HeapObject* host, MaybeObject* target) override {
|
||||
DCHECK_IMPLIES(
|
||||
target->IsStrongOrWeakHeapObject() && heap_->InNewSpace(target),
|
||||
heap_->InToSpace(target));
|
||||
Heap::InToSpace(target));
|
||||
return target->IsStrongOrWeakHeapObject() && heap_->InNewSpace(target) &&
|
||||
!heap_->InNewSpace(host);
|
||||
}
|
||||
|
@ -1368,9 +1368,9 @@ class Heap {
|
||||
static inline bool InFromSpace(Object* object);
|
||||
static inline bool InFromSpace(MaybeObject* object);
|
||||
static inline bool InFromSpace(HeapObject* heap_object);
|
||||
inline bool InToSpace(Object* object);
|
||||
inline bool InToSpace(MaybeObject* object);
|
||||
inline bool InToSpace(HeapObject* heap_object);
|
||||
static inline bool InToSpace(Object* object);
|
||||
static inline bool InToSpace(MaybeObject* object);
|
||||
static inline bool InToSpace(HeapObject* heap_object);
|
||||
|
||||
// Returns whether the object resides in old space.
|
||||
inline bool InOldSpace(Object* object);
|
||||
|
@ -601,7 +601,7 @@ void IncrementalMarking::UpdateMarkingWorklistAfterScavenge() {
|
||||
HeapObject* obj, HeapObject** out) -> bool {
|
||||
DCHECK(obj->IsHeapObject());
|
||||
// Only pointers to from space have to be updated.
|
||||
if (heap_->InFromSpace(obj)) {
|
||||
if (Heap::InFromSpace(obj)) {
|
||||
MapWord map_word = obj->map_word();
|
||||
if (!map_word.IsForwardingAddress()) {
|
||||
// There may be objects on the marking deque that do not exist anymore,
|
||||
@ -615,7 +615,7 @@ void IncrementalMarking::UpdateMarkingWorklistAfterScavenge() {
|
||||
DCHECK_IMPLIES(marking_state()->IsWhite(obj), obj->IsFiller());
|
||||
*out = dest;
|
||||
return true;
|
||||
} else if (heap_->InToSpace(obj)) {
|
||||
} else if (Heap::InToSpace(obj)) {
|
||||
// The object may be on a page that was moved in new space.
|
||||
DCHECK(
|
||||
Page::FromAddress(obj->address())->IsFlagSet(Page::SWEEP_TO_ITERATE));
|
||||
|
@ -300,7 +300,7 @@ class FullEvacuationVerifier : public EvacuationVerifier {
|
||||
if ((*current)->IsHeapObject()) {
|
||||
HeapObject* object = HeapObject::cast(*current);
|
||||
if (heap()->InNewSpace(object)) {
|
||||
CHECK(heap()->InToSpace(object));
|
||||
CHECK(Heap::InToSpace(object));
|
||||
}
|
||||
CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(object));
|
||||
}
|
||||
@ -311,7 +311,7 @@ class FullEvacuationVerifier : public EvacuationVerifier {
|
||||
HeapObject* object;
|
||||
if ((*current)->ToStrongHeapObject(&object)) {
|
||||
if (heap()->InNewSpace(object)) {
|
||||
CHECK(heap()->InToSpace(object));
|
||||
CHECK(Heap::InToSpace(object));
|
||||
}
|
||||
CHECK(!MarkCompactCollector::IsOnEvacuationCandidate(object));
|
||||
}
|
||||
@ -2859,7 +2859,7 @@ class RememberedSetUpdatingItem : public UpdatingItem {
|
||||
if (!(*slot)->ToStrongOrWeakHeapObject(&heap_object)) {
|
||||
return REMOVE_SLOT;
|
||||
}
|
||||
if (heap_->InFromSpace(heap_object)) {
|
||||
if (Heap::InFromSpace(heap_object)) {
|
||||
MapWord map_word = heap_object->map_word();
|
||||
if (map_word.IsForwardingAddress()) {
|
||||
HeapObjectReference::Update(
|
||||
@ -2873,10 +2873,10 @@ class RememberedSetUpdatingItem : public UpdatingItem {
|
||||
// callback in to space, the object is still live.
|
||||
// Unfortunately, we do not know about the slot. It could be in a
|
||||
// just freed free space object.
|
||||
if (heap_->InToSpace(heap_object)) {
|
||||
if (Heap::InToSpace(heap_object)) {
|
||||
return KEEP_SLOT;
|
||||
}
|
||||
} else if (heap_->InToSpace(heap_object)) {
|
||||
} else if (Heap::InToSpace(heap_object)) {
|
||||
// Slots can point to "to" space if the page has been moved, or if the
|
||||
// slot has been recorded multiple times in the remembered set, or
|
||||
// if the slot was already updated during old->old updating.
|
||||
@ -3451,7 +3451,7 @@ class YoungGenerationEvacuationVerifier : public EvacuationVerifier {
|
||||
for (Object** current = start; current < end; current++) {
|
||||
if ((*current)->IsHeapObject()) {
|
||||
HeapObject* object = HeapObject::cast(*current);
|
||||
CHECK_IMPLIES(heap()->InNewSpace(object), heap()->InToSpace(object));
|
||||
CHECK_IMPLIES(heap()->InNewSpace(object), Heap::InToSpace(object));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3459,7 +3459,7 @@ class YoungGenerationEvacuationVerifier : public EvacuationVerifier {
|
||||
for (MaybeObject** current = start; current < end; current++) {
|
||||
HeapObject* object;
|
||||
if ((*current)->ToStrongOrWeakHeapObject(&object)) {
|
||||
CHECK_IMPLIES(heap()->InNewSpace(object), heap()->InToSpace(object));
|
||||
CHECK_IMPLIES(heap()->InNewSpace(object), Heap::InToSpace(object));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3482,7 +3482,7 @@ void SeedGlobalHandles(Heap* heap, GlobalHandles* global_handles,
|
||||
}
|
||||
|
||||
bool IsUnmarkedObjectForYoungGeneration(Heap* heap, Object** p) {
|
||||
DCHECK_IMPLIES(heap->InNewSpace(*p), heap->InToSpace(*p));
|
||||
DCHECK_IMPLIES(heap->InNewSpace(*p), Heap::InToSpace(*p));
|
||||
return heap->InNewSpace(*p) && !heap->minor_mark_compact_collector()
|
||||
->non_atomic_marking_state()
|
||||
->IsGrey(HeapObject::cast(*p));
|
||||
@ -4089,7 +4089,7 @@ class PageMarkingItem : public MarkingItem {
|
||||
if (heap()->InNewSpace(object)) {
|
||||
// Marking happens before flipping the young generation, so the object
|
||||
// has to be in ToSpace.
|
||||
DCHECK(heap()->InToSpace(object));
|
||||
DCHECK(Heap::InToSpace(object));
|
||||
HeapObject* heap_object;
|
||||
bool success = object->ToStrongOrWeakHeapObject(&heap_object);
|
||||
USE(success);
|
||||
|
@ -202,7 +202,7 @@ void Scavenger::EvacuateShortcutCandidate(Map* map, HeapObject** slot,
|
||||
|
||||
void Scavenger::EvacuateObject(HeapObjectReference** slot, Map* map,
|
||||
HeapObject* source) {
|
||||
SLOW_DCHECK(heap_->InFromSpace(source));
|
||||
SLOW_DCHECK(Heap::InFromSpace(source));
|
||||
SLOW_DCHECK(!MapWord::FromMap(map).IsForwardingAddress());
|
||||
int size = source->SizeFromMap(map);
|
||||
// Cannot use ::cast() below because that would add checks in debug mode
|
||||
@ -227,7 +227,7 @@ void Scavenger::EvacuateObject(HeapObjectReference** slot, Map* map,
|
||||
}
|
||||
|
||||
void Scavenger::ScavengeObject(HeapObjectReference** p, HeapObject* object) {
|
||||
DCHECK(heap()->InFromSpace(object));
|
||||
DCHECK(Heap::InFromSpace(object));
|
||||
|
||||
// Synchronized load that consumes the publishing CAS of MigrateObject.
|
||||
MapWord first_word = object->synchronized_map_word();
|
||||
@ -236,7 +236,7 @@ void Scavenger::ScavengeObject(HeapObjectReference** p, HeapObject* object) {
|
||||
// copied.
|
||||
if (first_word.IsForwardingAddress()) {
|
||||
HeapObject* dest = first_word.ToForwardingAddress();
|
||||
DCHECK(heap()->InFromSpace(*p));
|
||||
DCHECK(Heap::InFromSpace(*p));
|
||||
if ((*p)->IsWeakHeapObject()) {
|
||||
*p = HeapObjectReference::Weak(dest);
|
||||
} else {
|
||||
@ -257,7 +257,7 @@ SlotCallbackResult Scavenger::CheckAndScavengeObject(Heap* heap,
|
||||
Address slot_address) {
|
||||
MaybeObject** slot = reinterpret_cast<MaybeObject**>(slot_address);
|
||||
MaybeObject* object = *slot;
|
||||
if (heap->InFromSpace(object)) {
|
||||
if (Heap::InFromSpace(object)) {
|
||||
HeapObject* heap_object;
|
||||
bool success = object->ToStrongOrWeakHeapObject(&heap_object);
|
||||
USE(success);
|
||||
@ -272,10 +272,10 @@ SlotCallbackResult Scavenger::CheckAndScavengeObject(Heap* heap,
|
||||
// Unfortunately, we do not know about the slot. It could be in a
|
||||
// just freed free space object.
|
||||
PageMemoryFence(object);
|
||||
if (heap->InToSpace(object)) {
|
||||
if (Heap::InToSpace(object)) {
|
||||
return KEEP_SLOT;
|
||||
}
|
||||
} else if (heap->InToSpace(object)) {
|
||||
} else if (Heap::InToSpace(object)) {
|
||||
// Already updated slot. This can happen when processing of the work list
|
||||
// is interleaved with processing roots.
|
||||
return KEEP_SLOT;
|
||||
|
@ -52,7 +52,7 @@ class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor {
|
||||
reinterpret_cast<HeapObjectReference**>(slot_address);
|
||||
scavenger_->PageMemoryFence(reinterpret_cast<MaybeObject*>(target));
|
||||
|
||||
if (heap_->InFromSpace(target)) {
|
||||
if (Heap::InFromSpace(target)) {
|
||||
scavenger_->ScavengeObject(slot, target);
|
||||
bool success = (*slot)->ToStrongOrWeakHeapObject(&target);
|
||||
USE(success);
|
||||
@ -61,7 +61,7 @@ class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor {
|
||||
|
||||
if (heap_->InNewSpace(target)) {
|
||||
SLOW_DCHECK(target->IsHeapObject());
|
||||
SLOW_DCHECK(heap_->InToSpace(target));
|
||||
SLOW_DCHECK(Heap::InToSpace(target));
|
||||
RememberedSet<OLD_TO_NEW>::Insert(Page::FromAddress(slot_address),
|
||||
slot_address);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user