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

Unified Diff: runtime/vm/gc_marker.cc

Issue 8984006: Implement weak persistent handles in the Dart API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 9 years 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
Index: runtime/vm/gc_marker.cc
diff --git a/runtime/vm/gc_marker.cc b/runtime/vm/gc_marker.cc
index 163a6173e2bf7173fc36730224d18ad861f421df..131273a8147f6b4a5a57c66d326e880d7ceb0bcc 100644
--- a/runtime/vm/gc_marker.cc
+++ b/runtime/vm/gc_marker.cc
@@ -187,20 +187,47 @@ class MarkingVisitor : public ObjectPointerVisitor {
};
+class MarkingWeakVisitor : public ObjectPointerVisitor {
+ public:
+ MarkingWeakVisitor() {
+ }
+
+ void VisitPointers(RawObject** first, RawObject** last) {
+ for (RawObject** current = first; current <= last; current++) {
+ RawObject* raw_obj = *current;
+ ASSERT(raw_obj->IsHeapObject());
+ if (!raw_obj->IsMarked() && raw_obj->IsOldObject()) {
+ *current = Object::null();
+ }
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MarkingWeakVisitor);
+};
+
+
void GCMarker::Prologue(Isolate* isolate) {
// Nothing to do at the moment.
}
-void GCMarker::IterateRoots(Isolate* isolate, MarkingVisitor* visitor) {
- isolate->VisitObjectPointers(visitor,
- StackFrameIterator::kDontValidateFrames);
+void GCMarker::IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor) {
+ isolate->VisitStrongObjectPointers(visitor,
+ StackFrameIterator::kDontValidateFrames);
heap_->IterateNewPointers(visitor);
heap_->IterateCodePointers(visitor);
}
-void GCMarker::DrainMarkingStack(Isolate* isolate, MarkingVisitor* visitor) {
+void GCMarker::IterateWeakRoots(Isolate* isolate,
+ ObjectPointerVisitor* visitor) {
+ isolate->VisitWeakObjectPointers(visitor);
+}
+
+
+void GCMarker::DrainMarkingStack(Isolate* isolate,
+ MarkingVisitor* visitor) {
while (!visitor->marking_stack()->IsEmpty()) {
RawObject* raw_obj = visitor->marking_stack()->Pop();
raw_obj->VisitPointers(visitor);
@@ -214,6 +241,8 @@ void GCMarker::MarkObjects(Isolate* isolate, PageSpace* page_space) {
MarkingVisitor mark(heap_, page_space, &marking_stack);
IterateRoots(isolate, &mark);
DrainMarkingStack(isolate, &mark);
+ MarkingWeakVisitor mark_weak;
+ IterateWeakRoots(isolate, &mark_weak);
}
} // namespace dart
« runtime/include/dart_api.h ('K') | « runtime/vm/gc_marker.h ('k') | runtime/vm/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698