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

Unified Diff: runtime/vm/gc_marker.cc

Issue 9655011: Implement prologue weak persistent handles. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: final revision Created 8 years, 9 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/gc_marker.h ('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 ced90782cc17a87231264fef650d7f106a86398d..ff9998f34e1ba7b29a46159ca72dc1c9f1d2a1b9 100644
--- a/runtime/vm/gc_marker.cc
+++ b/runtime/vm/gc_marker.cc
@@ -205,11 +205,11 @@ class MarkingWeakVisitor : public HandleVisitor {
}
void VisitHandle(uword addr) {
- WeakPersistentHandle* handle =
- reinterpret_cast<WeakPersistentHandle*>(addr);
+ FinalizablePersistentHandle* handle =
+ reinterpret_cast<FinalizablePersistentHandle*>(addr);
RawObject* raw_obj = handle->raw();
if (IsUnreachable(raw_obj)) {
- WeakPersistentHandle::Finalize(handle);
+ FinalizablePersistentHandle::Finalize(handle);
}
}
@@ -218,28 +218,38 @@ class MarkingWeakVisitor : public HandleVisitor {
};
-void GCMarker::Prologue(Isolate* isolate) {
- // Always invoke the prologue callbacks.
- isolate->gc_prologue_callbacks().Invoke();
+void GCMarker::Prologue(Isolate* isolate, bool invoke_api_callbacks) {
+ if (invoke_api_callbacks) {
+ isolate->gc_prologue_callbacks().Invoke();
+ }
}
-void GCMarker::Epilogue(Isolate* isolate) {
- // Always invoke the epilogue callbacks.
- isolate->gc_epilogue_callbacks().Invoke();
+void GCMarker::Epilogue(Isolate* isolate, bool invoke_api_callbacks) {
+ if (invoke_api_callbacks) {
+ isolate->gc_epilogue_callbacks().Invoke();
+ }
}
-void GCMarker::IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor) {
+void GCMarker::IterateRoots(Isolate* isolate,
+ ObjectPointerVisitor* visitor,
+ bool visit_prologue_weak_persistent_handles) {
isolate->VisitObjectPointers(visitor,
+ visit_prologue_weak_persistent_handles,
StackFrameIterator::kDontValidateFrames);
heap_->IterateNewPointers(visitor);
heap_->IterateCodePointers(visitor);
}
-void GCMarker::IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor) {
- isolate->VisitWeakPersistentHandles(visitor);
+void GCMarker::IterateWeakRoots(Isolate* isolate,
+ HandleVisitor* visitor,
+ bool visit_prologue_weak_persistent_handles) {
+ ApiState* state = isolate->api_state();
+ ASSERT(state != NULL);
+ isolate->VisitWeakPersistentHandles(visitor,
+ visit_prologue_weak_persistent_handles);
}
@@ -304,16 +314,18 @@ void GCMarker::DrainMarkingStack(Isolate* isolate,
}
-void GCMarker::MarkObjects(Isolate* isolate, PageSpace* page_space) {
+void GCMarker::MarkObjects(Isolate* isolate,
+ PageSpace* page_space,
+ bool invoke_api_callbacks) {
MarkingStack marking_stack;
- Prologue(isolate);
+ Prologue(isolate, invoke_api_callbacks);
MarkingVisitor mark(heap_, page_space, &marking_stack);
- IterateRoots(isolate, &mark);
+ IterateRoots(isolate, &mark, !invoke_api_callbacks);
DrainMarkingStack(isolate, &mark);
IterateWeakReferences(isolate, &mark);
MarkingWeakVisitor mark_weak;
- IterateWeakRoots(isolate, &mark_weak);
- Epilogue(isolate);
+ IterateWeakRoots(isolate, &mark_weak, invoke_api_callbacks);
+ Epilogue(isolate, invoke_api_callbacks);
}
} // namespace dart
« no previous file with comments | « runtime/vm/gc_marker.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698