Commit 15dd4caf authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Add helper for visitation using slot snapshot

Change-Id: Ib24a7f2c8c69828c5457595f891dbcb6b2a70296
Reviewed-on: https://chromium-review.googlesource.com/c/1270923Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56499}
parent a9f74f22
...@@ -236,26 +236,17 @@ class ConcurrentMarkingVisitor final ...@@ -236,26 +236,17 @@ class ConcurrentMarkingVisitor final
int VisitConsString(Map* map, ConsString* object) { int VisitConsString(Map* map, ConsString* object) {
int size = ConsString::BodyDescriptor::SizeOf(map, object); int size = ConsString::BodyDescriptor::SizeOf(map, object);
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, size); return VisitWithSnapshot(map, object, size, size);
if (!ShouldVisit(object)) return 0;
VisitPointersInSnapshot(object, snapshot);
return size;
} }
int VisitSlicedString(Map* map, SlicedString* object) { int VisitSlicedString(Map* map, SlicedString* object) {
int size = SlicedString::BodyDescriptor::SizeOf(map, object); int size = SlicedString::BodyDescriptor::SizeOf(map, object);
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, size); return VisitWithSnapshot(map, object, size, size);
if (!ShouldVisit(object)) return 0;
VisitPointersInSnapshot(object, snapshot);
return size;
} }
int VisitThinString(Map* map, ThinString* object) { int VisitThinString(Map* map, ThinString* object) {
int size = ThinString::BodyDescriptor::SizeOf(map, object); int size = ThinString::BodyDescriptor::SizeOf(map, object);
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, size); return VisitWithSnapshot(map, object, size, size);
if (!ShouldVisit(object)) return 0;
VisitPointersInSnapshot(object, snapshot);
return size;
} }
// =========================================================================== // ===========================================================================
...@@ -445,10 +436,7 @@ class ConcurrentMarkingVisitor final ...@@ -445,10 +436,7 @@ class ConcurrentMarkingVisitor final
int used_size = map->UsedInstanceSize(); int used_size = map->UsedInstanceSize();
DCHECK_LE(used_size, size); DCHECK_LE(used_size, size);
DCHECK_GE(used_size, T::kHeaderSize); DCHECK_GE(used_size, T::kHeaderSize);
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, used_size); return VisitWithSnapshot(map, object, used_size, size);
if (!ShouldVisit(object)) return 0;
VisitPointersInSnapshot(object, snapshot);
return size;
} }
template <typename T> template <typename T>
...@@ -478,6 +466,14 @@ class ConcurrentMarkingVisitor final ...@@ -478,6 +466,14 @@ class ConcurrentMarkingVisitor final
return size; return size;
} }
template <typename T>
int VisitWithSnapshot(Map* map, T* object, int used_size, int size) {
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, used_size);
if (!ShouldVisit(object)) return 0;
VisitPointersInSnapshot(object, snapshot);
return size;
}
template <typename T> template <typename T>
const SlotSnapshot& MakeSlotSnapshot(Map* map, T* object, int size) { const SlotSnapshot& MakeSlotSnapshot(Map* map, T* object, int size) {
SlotSnapshottingVisitor visitor(&slot_snapshot_); SlotSnapshottingVisitor visitor(&slot_snapshot_);
......
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