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

Unified Diff: runtime/vm/gc_marker.cc

Issue 2012973002: Background finalization. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | « runtime/vm/dart_api_state.cc ('k') | runtime/vm/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/gc_marker.cc
diff --git a/runtime/vm/gc_marker.cc b/runtime/vm/gc_marker.cc
index 069f34175990a492b4c75280f2062e1e58ad0153..0b302cec79fb011d8c5dfc97364e0fdbf52646e5 100644
--- a/runtime/vm/gc_marker.cc
+++ b/runtime/vm/gc_marker.cc
@@ -422,19 +422,21 @@ static bool IsUnreachable(const RawObject* raw_obj) {
class MarkingWeakVisitor : public HandleVisitor {
public:
- MarkingWeakVisitor() : HandleVisitor(Thread::Current()) {
- }
+ MarkingWeakVisitor(Thread* thread, FinalizationQueue* queue) :
+ HandleVisitor(thread), queue_(queue) { }
void VisitHandle(uword addr) {
FinalizablePersistentHandle* handle =
reinterpret_cast<FinalizablePersistentHandle*>(addr);
RawObject* raw_obj = handle->raw();
if (IsUnreachable(raw_obj)) {
- handle->UpdateUnreachable(thread()->isolate());
+ handle->UpdateUnreachable(thread()->isolate(), queue_);
}
}
private:
+ FinalizationQueue* queue_;
+
DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor);
};
@@ -668,8 +670,14 @@ void GCMarker::MarkObjects(Isolate* isolate,
mark.DrainMarkingStack();
{
TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing");
- MarkingWeakVisitor mark_weak;
+ FinalizationQueue* queue = new FinalizationQueue();
+ MarkingWeakVisitor mark_weak(thread, queue);
IterateWeakRoots(isolate, &mark_weak);
+ if (queue->length() > 0) {
+ Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue));
+ } else {
+ delete queue;
+ }
}
// All marking done; detach code, etc.
FinalizeResultsFrom(&mark);
@@ -693,8 +701,14 @@ void GCMarker::MarkObjects(Isolate* isolate,
// Phase 2: Weak processing on main thread.
{
TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing");
- MarkingWeakVisitor mark_weak;
+ FinalizationQueue* queue = new FinalizationQueue();
+ MarkingWeakVisitor mark_weak(thread, queue);
IterateWeakRoots(isolate, &mark_weak);
+ if (queue->length() > 0) {
+ Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue));
+ } else {
+ delete queue;
+ }
}
barrier.Sync();
« no previous file with comments | « runtime/vm/dart_api_state.cc ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698