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

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

Issue 109803002: Profiler Take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "platform/json.h" 9 #include "platform/json.h"
10 #include "lib/mirrors.h" 10 #include "lib/mirrors.h"
(...skipping 12 matching lines...) Expand all
23 #include "vm/parser.h" 23 #include "vm/parser.h"
24 #include "vm/port.h" 24 #include "vm/port.h"
25 #include "vm/profiler.h" 25 #include "vm/profiler.h"
26 #include "vm/reusable_handles.h" 26 #include "vm/reusable_handles.h"
27 #include "vm/service.h" 27 #include "vm/service.h"
28 #include "vm/simulator.h" 28 #include "vm/simulator.h"
29 #include "vm/stack_frame.h" 29 #include "vm/stack_frame.h"
30 #include "vm/stub_code.h" 30 #include "vm/stub_code.h"
31 #include "vm/symbols.h" 31 #include "vm/symbols.h"
32 #include "vm/thread.h" 32 #include "vm/thread.h"
33 #include "vm/thread_interrupter.h"
33 #include "vm/timer.h" 34 #include "vm/timer.h"
34 #include "vm/visitor.h" 35 #include "vm/visitor.h"
35 36
36 37
37 namespace dart { 38 namespace dart {
38 39
39 DEFINE_FLAG(bool, report_usage_count, false, 40 DEFINE_FLAG(bool, report_usage_count, false,
40 "Track function usage and report."); 41 "Track function usage and report.");
41 DEFINE_FLAG(bool, trace_isolates, false, 42 DEFINE_FLAG(bool, trace_isolates, false,
42 "Trace isolate creation and shut down."); 43 "Trace isolate creation and shut down.");
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 #endif 333 #endif
333 delete mutex_; 334 delete mutex_;
334 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. 335 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate.
335 delete message_handler_; 336 delete message_handler_;
336 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 337 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate.
337 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. 338 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
338 delete object_histogram_; 339 delete object_histogram_;
339 } 340 }
340 341
341 void Isolate::SetCurrent(Isolate* current) { 342 void Isolate::SetCurrent(Isolate* current) {
342 Isolate* old_isolate = Current(); 343 Isolate* old_current = Current();
343 if (old_isolate != NULL) { 344 if (old_current != current) {
344 ProfilerManager::DescheduleIsolate(old_isolate); 345 Profiler::EndExecution(old_current);
345 } 346 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current));
346 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); 347 Profiler::BeginExecution(current);
347 if (current != NULL) {
348 ProfilerManager::ScheduleIsolate(current);
349 } 348 }
350 } 349 }
351 350
352 351
353 // The single thread local key which stores all the thread local data 352 // The single thread local key which stores all the thread local data
354 // for a thread. Since an Isolate is the central repository for 353 // for a thread. Since an Isolate is the central repository for
355 // storing all isolate specific information a single thread local key 354 // storing all isolate specific information a single thread local key
356 // is sufficient. 355 // is sufficient.
357 ThreadLocalKey Isolate::isolate_key = Thread::kUnsetThreadLocalKey; 356 ThreadLocalKey Isolate::isolate_key = Thread::kUnsetThreadLocalKey;
358 357
359 358
360 void Isolate::InitOnce() { 359 void Isolate::InitOnce() {
361 ASSERT(isolate_key == Thread::kUnsetThreadLocalKey); 360 ASSERT(isolate_key == Thread::kUnsetThreadLocalKey);
362 isolate_key = Thread::CreateThreadLocal(); 361 isolate_key = Thread::CreateThreadLocal();
363 ASSERT(isolate_key != Thread::kUnsetThreadLocalKey); 362 ASSERT(isolate_key != Thread::kUnsetThreadLocalKey);
364 create_callback_ = NULL; 363 create_callback_ = NULL;
365 } 364 }
366 365
367 366
368 Isolate* Isolate::Init(const char* name_prefix) { 367 Isolate* Isolate::Init(const char* name_prefix) {
369 Isolate* result = new Isolate(); 368 Isolate* result = new Isolate();
370 ASSERT(result != NULL); 369 ASSERT(result != NULL);
371 370
372 // Setup for profiling. 371 // Setup for profiling.
373 ProfilerManager::SetupIsolateForProfiling(result); 372 Profiler::InitIsolateForProfiling(result);
374 373
375 // TODO(5411455): For now just set the recently created isolate as 374 // TODO(5411455): For now just set the recently created isolate as
376 // the current isolate. 375 // the current isolate.
377 SetCurrent(result); 376 SetCurrent(result);
378 377
379 // Setup the isolate specific resuable handles. 378 // Setup the isolate specific resuable handles.
380 #define REUSABLE_HANDLE_ALLOCATION(object) \ 379 #define REUSABLE_HANDLE_ALLOCATION(object) \
381 result->object##_handle_ = result->AllocateReusableHandle<object>(); \ 380 result->object##_handle_ = result->AllocateReusableHandle<object>(); \
382 381
383 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION) 382 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION)
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 // Fail fast if anybody tries to post any more messsages to this isolate. 716 // Fail fast if anybody tries to post any more messsages to this isolate.
718 delete message_handler(); 717 delete message_handler();
719 set_message_handler(NULL); 718 set_message_handler(NULL);
720 719
721 // Dump all accumalated timer data for the isolate. 720 // Dump all accumalated timer data for the isolate.
722 timer_list_.ReportTimers(); 721 timer_list_.ReportTimers();
723 if (FLAG_report_usage_count) { 722 if (FLAG_report_usage_count) {
724 PrintInvokedFunctions(); 723 PrintInvokedFunctions();
725 } 724 }
726 725
726 Profiler::WriteTracing(this);
727
727 // Write out the coverage data if collection has been enabled. 728 // Write out the coverage data if collection has been enabled.
728 CodeCoverage::Write(this); 729 CodeCoverage::Write(this);
729 730
730 // Finalize any weak persistent handles with a non-null referent. 731 // Finalize any weak persistent handles with a non-null referent.
731 FinalizeWeakPersistentHandlesVisitor visitor; 732 FinalizeWeakPersistentHandlesVisitor visitor;
732 api_state()->weak_persistent_handles().VisitHandles(&visitor); 733 api_state()->weak_persistent_handles().VisitHandles(&visitor);
733 734
734 CompilerStats::Print(); 735 CompilerStats::Print();
735 if (FLAG_trace_isolates) { 736 if (FLAG_trace_isolates) {
736 heap()->PrintSizes(); 737 heap()->PrintSizes();
737 megamorphic_cache_table()->PrintSizes(); 738 megamorphic_cache_table()->PrintSizes();
738 Symbols::DumpStats(); 739 Symbols::DumpStats();
739 OS::Print("[-] Stopping isolate:\n" 740 OS::Print("[-] Stopping isolate:\n"
740 "\tisolate: %s\n", name()); 741 "\tisolate: %s\n", name());
741 } 742 }
742 } 743 }
743 744
744 // TODO(5411455): For now just make sure there are no current isolates 745 // TODO(5411455): For now just make sure there are no current isolates
745 // as we are shutting down the isolate. 746 // as we are shutting down the isolate.
746 SetCurrent(NULL); 747 SetCurrent(NULL);
747 ProfilerManager::DescheduleIsolate(this); 748 Profiler::ShutdownIsolateForProfiling(this);
748 ProfilerManager::ShutdownIsolateForProfiling(this);
749 } 749 }
750 750
751 751
752 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; 752 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL;
753 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; 753 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL;
754 Dart_IsolateUnhandledExceptionCallback 754 Dart_IsolateUnhandledExceptionCallback
755 Isolate::unhandled_exception_callback_ = NULL; 755 Isolate::unhandled_exception_callback_ = NULL;
756 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; 756 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL;
757 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; 757 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL;
758 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; 758 Dart_FileReadCallback Isolate::file_read_callback_ = NULL;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 return func.raw(); 1120 return func.raw();
1121 } 1121 }
1122 1122
1123 1123
1124 void IsolateSpawnState::Cleanup() { 1124 void IsolateSpawnState::Cleanup() {
1125 SwitchIsolateScope switch_scope(isolate()); 1125 SwitchIsolateScope switch_scope(isolate());
1126 Dart::ShutdownIsolate(); 1126 Dart::ShutdownIsolate();
1127 } 1127 }
1128 1128
1129 } // namespace dart 1129 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698