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

Unified Diff: runtime/vm/gc_marker.cc

Issue 9148051: Provide API support for weak handles and post-mortem finalization. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: a better strategy for protected handle checks Created 8 years, 11 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
Index: runtime/vm/gc_marker.cc
diff --git a/runtime/vm/gc_marker.cc b/runtime/vm/gc_marker.cc
index 131273a8147f6b4a5a57c66d326e880d7ceb0bcc..a01b6e8c75827f58135f5e2d348a3e0ca76cb660 100644
--- a/runtime/vm/gc_marker.cc
+++ b/runtime/vm/gc_marker.cc
@@ -5,6 +5,7 @@
#include "vm/gc_marker.h"
#include "vm/allocation.h"
+#include "vm/dart_api_state.h"
#include "vm/isolate.h"
#include "vm/pages.h"
#include "vm/raw_object.h"
@@ -187,18 +188,18 @@ class MarkingVisitor : public ObjectPointerVisitor {
};
-class MarkingWeakVisitor : public ObjectPointerVisitor {
+class MarkingWeakVisitor : public HandleVisitor {
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();
- }
+ void VisitHandle(uword* addr) {
+ WeakPersistentHandle* handle =
+ reinterpret_cast<WeakPersistentHandle*>(addr);
+ RawObject* raw_obj = handle->raw();
+ ASSERT(raw_obj->IsHeapObject());
+ if (!raw_obj->IsMarked() && raw_obj->IsOldObject()) {
+ handle->Finalize();
Anton Muhin 2012/01/12 13:40:26 there might be unpleasant problem: naively impleme
cshapiro 2012/01/12 18:15:38 Correct. There is one case we consider to be safe
Anton Muhin 2012/01/13 14:20:58 Carl, sorry, I wasn't clear enough regarding #2.
cshapiro 2012/01/13 22:56:46 Thanks for the clarification. I discussed your co
}
}
@@ -213,16 +214,15 @@ void GCMarker::Prologue(Isolate* isolate) {
void GCMarker::IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor) {
- isolate->VisitStrongObjectPointers(visitor,
- StackFrameIterator::kDontValidateFrames);
+ isolate->VisitObjectPointers(visitor,
+ StackFrameIterator::kDontValidateFrames);
heap_->IterateNewPointers(visitor);
heap_->IterateCodePointers(visitor);
}
-void GCMarker::IterateWeakRoots(Isolate* isolate,
- ObjectPointerVisitor* visitor) {
- isolate->VisitWeakObjectPointers(visitor);
+void GCMarker::IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor) {
+ isolate->VisitWeakPersistentHandles(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698