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

Unified Diff: runtime/vm/thread.cc

Issue 1393013005: Fix GC problem with vm_handles in thread (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add comment Created 5 years, 2 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/thread.h ('k') | runtime/vm/thread_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread.cc
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
index 9f08a73e107e21bae928e2c1fd2cd879346c8885..56c25af41b5d8144a628c5dd909f72cf0e734876 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -223,6 +223,11 @@ void Thread::ExitIsolate() {
Thread* thread = Thread::Current();
// TODO(koda): Audit callers; they should know whether they're in an isolate.
if (thread == NULL || thread->isolate() == NULL) return;
+#if defined(DEBUG)
+ ASSERT(!thread->IsAnyReusableHandleScopeActive());
+#endif // DEBUG
+ // Clear since GC will not visit the thread once it is unscheduled.
+ thread->ClearReusableHandles();
Isolate* isolate = thread->isolate();
Profiler::EndExecution(isolate);
thread->Unschedule();
@@ -237,9 +242,6 @@ void Thread::ExitIsolate() {
thread->isolate_ = NULL;
ASSERT(Isolate::Current() == NULL);
thread->heap_ = NULL;
-#if defined(DEBUG)
- ASSERT(!thread->IsAnyReusableHandleScopeActive());
-#endif // DEBUG
}
@@ -348,6 +350,14 @@ C* Thread::AllocateReusableHandle() {
}
+void Thread::ClearReusableHandles() {
+#define CLEAR_REUSABLE_HANDLE(object) \
+ *object##_handle_ = object::null();
+ REUSABLE_HANDLE_LIST(CLEAR_REUSABLE_HANDLE)
+#undef CLEAR_REUSABLE_HANDLE
+}
+
+
void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor) {
ASSERT(visitor != NULL);
« no previous file with comments | « runtime/vm/thread.h ('k') | runtime/vm/thread_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698