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

Side by Side Diff: runtime/vm/isolate.cc

Issue 10917126: 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_impl_test.cc ('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
400 void Isolate::Shutdown() { 384 void Isolate::Shutdown() {
401 ASSERT(this == Isolate::Current()); 385 ASSERT(this == Isolate::Current());
402 ASSERT(top_resource() == NULL); 386 ASSERT(top_resource() == NULL);
403 ASSERT((heap_ == NULL) || heap_->Verify()); 387 ASSERT((heap_ == NULL) || heap_->Verify());
404 388
405 // Clean up debugger resources. Shutting down the debugger 389 // Clean up debugger resources. Shutting down the debugger
406 // requires a handle zone. We must set up a temporary zone because 390 // requires a handle zone. We must set up a temporary zone because
407 // Isolate::Shutdown is called without a zone. 391 // Isolate::Shutdown is called without a zone.
408 { 392 {
409 Zone zone(this); 393 Zone zone(this);
410 HandleScope handle_scope(this); 394 HandleScope handle_scope(this);
411 debugger_->Shutdown(); 395 debugger_->Shutdown();
412 } 396 }
413 397
414 // Close all the ports owned by this isolate. 398 // Close all the ports owned by this isolate.
415 PortMap::ClosePorts(message_handler()); 399 PortMap::ClosePorts(message_handler());
416 400
417 // Fail fast if anybody tries to post any more messsages to this isolate. 401 // Fail fast if anybody tries to post any more messsages to this isolate.
418 delete message_handler(); 402 delete message_handler();
419 set_message_handler(NULL); 403 set_message_handler(NULL);
420 404
421 // Finalize any weak persistent handles with a non-null referent.
422 FinalizeWeakPersistentHandlesVisitor visitor;
423 api_state()->weak_persistent_handles().VisitHandles(&visitor);
424
425 // Dump all accumalated timer data for the isolate. 405 // Dump all accumalated timer data for the isolate.
426 timer_list_.ReportTimers(); 406 timer_list_.ReportTimers();
427 if (FLAG_report_usage_count) { 407 if (FLAG_report_usage_count) {
428 PrintInvokedFunctions(); 408 PrintInvokedFunctions();
429 } 409 }
430 CompilerStats::Print(); 410 CompilerStats::Print();
431 if (FLAG_generate_gdb_symbols) { 411 if (FLAG_generate_gdb_symbols) {
432 DebugInfo::UnregisterAllSections(); 412 DebugInfo::UnregisterAllSections();
433 } 413 }
434 if (FLAG_trace_isolates) { 414 if (FLAG_trace_isolates) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 471
492 472
493 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, 473 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor,
494 bool visit_prologue_weak_handles) { 474 bool visit_prologue_weak_handles) {
495 if (api_state() != NULL) { 475 if (api_state() != NULL) {
496 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); 476 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles);
497 } 477 }
498 } 478 }
499 479
500 } // namespace dart 480 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698