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

Unified Diff: runtime/vm/isolate.cc

Issue 10928065: Revert "Revert "Finalize reachable weak persistent handles at isolate shutdown."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 934179687d76401a2fe4d4ebc11843c495cfde19..bd59fb0912a240c3515954ccf6bd5cb740765c51 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -381,6 +381,22 @@ void Isolate::PrintInvokedFunctions() {
}
+class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor {
+ public:
+ FinalizeWeakPersistentHandlesVisitor() {
+ }
+
+ void VisitHandle(uword addr) {
+ FinalizablePersistentHandle* handle =
+ reinterpret_cast<FinalizablePersistentHandle*>(addr);
+ FinalizablePersistentHandle::Finalize(handle);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
+};
+
+
void Isolate::Shutdown() {
ASSERT(this == Isolate::Current());
ASSERT(top_resource() == NULL);
@@ -402,6 +418,10 @@ void Isolate::Shutdown() {
delete message_handler();
set_message_handler(NULL);
+ // Finalize any weak persistent handles with a non-null referent.
+ FinalizeWeakPersistentHandlesVisitor visitor;
+ api_state()->weak_persistent_handles().VisitHandles(&visitor);
+
// Dump all accumalated timer data for the isolate.
timer_list_.ReportTimers();
if (FLAG_report_usage_count) {
« no previous file with comments | « runtime/vm/dart_api_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698