Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: src/heap/concurrent-marking.cc

Issue 2855003004: [heap] Use shared markbits in the concurrent marker. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/heap/objects-visiting.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/concurrent-marking.cc
diff --git a/src/heap/concurrent-marking.cc b/src/heap/concurrent-marking.cc
index 618cb1139b1b7db55090c85f77b83aaba779c9d9..2e91ae368f958edec45f6577b2fdfa2fc5d0c1c8 100644
--- a/src/heap/concurrent-marking.cc
+++ b/src/heap/concurrent-marking.cc
@@ -30,6 +30,11 @@ class ConcurrentMarkingVisitor final
explicit ConcurrentMarkingVisitor(ConcurrentMarkingDeque* deque)
: deque_(deque) {}
+ bool ShouldVisit(HeapObject* object) override {
+ return ObjectMarking::GreyToBlack<MarkBit::AccessMode::ATOMIC>(
+ object, marking_state(object));
+ }
+
void VisitPointers(HeapObject* host, Object** start, Object** end) override {
for (Object** p = start; p < end; p++) {
if (!(*p)->IsHeapObject()) continue;
@@ -68,7 +73,7 @@ class ConcurrentMarkingVisitor final
// ===========================================================================
int VisitCode(Map* map, Code* object) override {
- // TODO(ulan): push the object to the bail-out deque.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
@@ -77,58 +82,65 @@ class ConcurrentMarkingVisitor final
// ===========================================================================
int VisitBytecodeArray(Map* map, BytecodeArray* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
int VisitJSFunction(Map* map, JSFunction* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
int VisitMap(Map* map, Map* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
int VisitNativeContext(Map* map, Context* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
int VisitSharedFunctionInfo(Map* map, SharedFunctionInfo* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
int VisitTransitionArray(Map* map, TransitionArray* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
int VisitWeakCell(Map* map, WeakCell* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
int VisitJSWeakCollection(Map* map, JSWeakCollection* object) override {
- // TODO(ulan): implement iteration of strong fields and push the object to
- // the bailout deque.
+ // TODO(ulan): implement iteration of strong fields.
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kBailout);
return 0;
}
- void MarkObject(HeapObject* obj) {
- deque_->Push(obj, MarkingThread::kConcurrent, TargetDeque::kShared);
+ void MarkObject(HeapObject* object) {
+ if (ObjectMarking::WhiteToGrey<MarkBit::AccessMode::ATOMIC>(
+ object, marking_state(object))) {
+ deque_->Push(object, MarkingThread::kConcurrent, TargetDeque::kShared);
+ }
}
private:
+ MarkingState marking_state(HeapObject* object) const {
+ return MarkingState::Internal(object);
+ }
+
ConcurrentMarkingDeque* deque_;
};
@@ -175,7 +187,7 @@ void ConcurrentMarking::Run() {
TimedScope scope(&time_ms);
HeapObject* object;
while ((object = deque_->Pop(MarkingThread::kConcurrent)) != nullptr) {
- bytes_marked += visitor_->IterateBody(object);
+ bytes_marked += visitor_->Visit(object);
}
}
if (FLAG_trace_concurrent_marking) {
« no previous file with comments | « src/flag-definitions.h ('k') | src/heap/objects-visiting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698