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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "lib/mirrors.h" 9 #include "lib/mirrors.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 374 }
375 invoked_functions.Sort(MostUsedFunctionFirst); 375 invoked_functions.Sort(MostUsedFunctionFirst);
376 for (int i = 0; i < invoked_functions.length(); i++) { 376 for (int i = 0; i < invoked_functions.length(); i++) {
377 OS::Print("%10"Pd" x %s\n", 377 OS::Print("%10"Pd" x %s\n",
378 invoked_functions[i]->usage_counter(), 378 invoked_functions[i]->usage_counter(),
379 invoked_functions[i]->ToFullyQualifiedCString()); 379 invoked_functions[i]->ToFullyQualifiedCString());
380 } 380 }
381 } 381 }
382 382
383 383
384 class FinalizeWeakPersistentHandlesVisitor : public HandleVisitor {
385 public:
386 FinalizeWeakPersistentHandlesVisitor() {
387 }
388
389 void VisitHandle(uword addr) {
390 FinalizablePersistentHandle* handle =
391 reinterpret_cast<FinalizablePersistentHandle*>(addr);
392 FinalizablePersistentHandle::Finalize(handle);
393 }
394
395 private:
396 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
397 };
398
399
384 void Isolate::Shutdown() { 400 void Isolate::Shutdown() {
385 ASSERT(this == Isolate::Current()); 401 ASSERT(this == Isolate::Current());
386 ASSERT(top_resource() == NULL); 402 ASSERT(top_resource() == NULL);
387 ASSERT((heap_ == NULL) || heap_->Verify()); 403 ASSERT((heap_ == NULL) || heap_->Verify());
388 404
389 // Clean up debugger resources. Shutting down the debugger 405 // Clean up debugger resources. Shutting down the debugger
390 // requires a handle zone. We must set up a temporary zone because 406 // requires a handle zone. We must set up a temporary zone because
391 // Isolate::Shutdown is called without a zone. 407 // Isolate::Shutdown is called without a zone.
392 { 408 {
393 Zone zone(this); 409 Zone zone(this);
394 HandleScope handle_scope(this); 410 HandleScope handle_scope(this);
395 debugger_->Shutdown(); 411 debugger_->Shutdown();
396 } 412 }
397 413
398 // Close all the ports owned by this isolate. 414 // Close all the ports owned by this isolate.
399 PortMap::ClosePorts(message_handler()); 415 PortMap::ClosePorts(message_handler());
400 416
401 // Fail fast if anybody tries to post any more messsages to this isolate. 417 // Fail fast if anybody tries to post any more messsages to this isolate.
402 delete message_handler(); 418 delete message_handler();
403 set_message_handler(NULL); 419 set_message_handler(NULL);
404 420
421 // Finalize any weak persistent handles with a non-null referent.
422 FinalizeWeakPersistentHandlesVisitor visitor;
423 api_state()->weak_persistent_handles().VisitHandles(&visitor);
424
405 // Dump all accumalated timer data for the isolate. 425 // Dump all accumalated timer data for the isolate.
406 timer_list_.ReportTimers(); 426 timer_list_.ReportTimers();
407 if (FLAG_report_usage_count) { 427 if (FLAG_report_usage_count) {
408 PrintInvokedFunctions(); 428 PrintInvokedFunctions();
409 } 429 }
410 CompilerStats::Print(); 430 CompilerStats::Print();
411 if (FLAG_generate_gdb_symbols) { 431 if (FLAG_generate_gdb_symbols) {
412 DebugInfo::UnregisterAllSections(); 432 DebugInfo::UnregisterAllSections();
413 } 433 }
414 if (FLAG_trace_isolates) { 434 if (FLAG_trace_isolates) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 491
472 492
473 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, 493 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor,
474 bool visit_prologue_weak_handles) { 494 bool visit_prologue_weak_handles) {
475 if (api_state() != NULL) { 495 if (api_state() != NULL) {
476 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); 496 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles);
477 } 497 }
478 } 498 }
479 499
480 } // namespace dart 500 } // namespace dart
OLDNEW
« 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