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

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

Issue 1412733008: Switch profiler from isolates to threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/message_handler.cc » ('j') | 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) 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 "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/json.h" 10 #include "platform/json.h"
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 defer_finalization_count_(0), 777 defer_finalization_count_(0),
778 deopt_context_(NULL), 778 deopt_context_(NULL),
779 compiler_stats_(NULL), 779 compiler_stats_(NULL),
780 is_service_isolate_(false), 780 is_service_isolate_(false),
781 stacktrace_(NULL), 781 stacktrace_(NULL),
782 stack_frame_index_(-1), 782 stack_frame_index_(-1),
783 last_allocationprofile_accumulator_reset_timestamp_(0), 783 last_allocationprofile_accumulator_reset_timestamp_(0),
784 last_allocationprofile_gc_timestamp_(0), 784 last_allocationprofile_gc_timestamp_(0),
785 object_id_ring_(NULL), 785 object_id_ring_(NULL),
786 trace_buffer_(NULL), 786 trace_buffer_(NULL),
787 profiler_data_(NULL),
788 tag_table_(GrowableObjectArray::null()), 787 tag_table_(GrowableObjectArray::null()),
789 deoptimized_code_array_(GrowableObjectArray::null()), 788 deoptimized_code_array_(GrowableObjectArray::null()),
790 background_compiler_(NULL), 789 background_compiler_(NULL),
791 pending_service_extension_calls_(GrowableObjectArray::null()), 790 pending_service_extension_calls_(GrowableObjectArray::null()),
792 registered_service_extension_handlers_(GrowableObjectArray::null()), 791 registered_service_extension_handlers_(GrowableObjectArray::null()),
793 metrics_list_head_(NULL), 792 metrics_list_head_(NULL),
794 compilation_allowed_(true), 793 compilation_allowed_(true),
795 all_classes_finalized_(false), 794 all_classes_finalized_(false),
796 next_(NULL), 795 next_(NULL),
797 pause_loop_monitor_(NULL), 796 pause_loop_monitor_(NULL),
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 MonitorLocker ml(old_space->tasks_lock()); 1708 MonitorLocker ml(old_space->tasks_lock());
1710 ASSERT(old_space->tasks() == 0); 1709 ASSERT(old_space->tasks() == 0);
1711 } 1710 }
1712 #endif 1711 #endif
1713 1712
1714 // TODO(5411455): For now just make sure there are no current isolates 1713 // TODO(5411455): For now just make sure there are no current isolates
1715 // as we are shutting down the isolate. 1714 // as we are shutting down the isolate.
1716 Thread::ExitIsolate(); 1715 Thread::ExitIsolate();
1717 // All threads should have exited by now. 1716 // All threads should have exited by now.
1718 thread_registry()->CheckNotScheduled(this); 1717 thread_registry()->CheckNotScheduled(this);
1719 Profiler::ShutdownProfilingForIsolate(this);
1720 } 1718 }
1721 1719
1722 1720
1723 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; 1721 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL;
1724 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; 1722 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL;
1725 Dart_IsolateUnhandledExceptionCallback 1723 Dart_IsolateUnhandledExceptionCallback
1726 Isolate::unhandled_exception_callback_ = NULL; 1724 Isolate::unhandled_exception_callback_ = NULL;
1727 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; 1725 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL;
1728 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; 1726 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL;
1729 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; 1727 Dart_FileReadCallback Isolate::file_read_callback_ = NULL;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 debugger()->PrintBreakpointsToJSONArray(&breakpoints); 1912 debugger()->PrintBreakpointsToJSONArray(&breakpoints);
1915 } 1913 }
1916 1914
1917 { 1915 {
1918 JSONObject jssettings(&jsobj, "_debuggerSettings"); 1916 JSONObject jssettings(&jsobj, "_debuggerSettings");
1919 debugger()->PrintSettingsToJSONObject(&jssettings); 1917 debugger()->PrintSettingsToJSONObject(&jssettings);
1920 } 1918 }
1921 } 1919 }
1922 1920
1923 1921
1924 intptr_t Isolate::ProfileInterrupt() {
1925 // Other threads might be modifying these fields. Save them in locals so that
1926 // we can at least trust the NULL check.
1927 IsolateProfilerData* prof_data = profiler_data();
1928 if (prof_data == NULL) {
1929 // Profiler not setup for isolate.
1930 return 0;
1931 }
1932 if (prof_data->blocked()) {
1933 // Profiler blocked for this isolate.
1934 return 0;
1935 }
1936 Debugger* debug = debugger();
1937 if ((debug != NULL) && debug->IsPaused()) {
1938 // Paused at breakpoint. Don't tick.
1939 return 0;
1940 }
1941 MessageHandler* msg_handler = message_handler();
1942 if ((msg_handler != NULL) &&
1943 (msg_handler->paused_on_start() ||
1944 msg_handler->paused_on_exit())) {
1945 // Paused at start / exit . Don't tick.
1946 return 0;
1947 }
1948 // Make sure that the isolate's mutator thread does not change behind our
1949 // backs. Otherwise we find the entry in the registry and end up reading
1950 // the field again. Only by that time it has been reset to NULL because the
1951 // thread was in process of exiting the isolate.
1952 Thread* mutator = mutator_thread_;
1953 if (mutator == NULL) {
1954 // No active mutator.
1955 ProfileIdle();
1956 return 1;
1957 }
1958
1959 // TODO(johnmccutchan): Sample all threads, not just the mutator thread.
1960 // TODO(johnmccutchan): Keep a global list of threads and use that
1961 // instead of Isolate.
1962 ThreadRegistry::EntryIterator it(thread_registry());
1963 while (it.HasNext()) {
1964 const ThreadRegistry::Entry& entry = it.Next();
1965 if (entry.thread == mutator) {
1966 ThreadInterrupter::InterruptThread(mutator);
1967 break;
1968 }
1969 }
1970 return 1;
1971 }
1972
1973
1974 void Isolate::ProfileIdle() {
1975 // Currently we are only sampling the mutator thread.
1976 vm_tag_counters_.Increment(VMTag::kIdleTagId);
1977 }
1978
1979
1980 void Isolate::set_tag_table(const GrowableObjectArray& value) { 1922 void Isolate::set_tag_table(const GrowableObjectArray& value) {
1981 tag_table_ = value.raw(); 1923 tag_table_ = value.raw();
1982 } 1924 }
1983 1925
1984 1926
1985 void Isolate::set_current_tag(const UserTag& tag) { 1927 void Isolate::set_current_tag(const UserTag& tag) {
1986 uword user_tag = tag.tag(); 1928 uword user_tag = tag.tag();
1987 ASSERT(user_tag < kUwordMax); 1929 ASSERT(user_tag < kUwordMax);
1988 set_user_tag(user_tag); 1930 set_user_tag(user_tag);
1989 current_tag_ = tag.raw(); 1931 current_tag_ = tag.raw();
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 } 2536 }
2595 2537
2596 2538
2597 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { 2539 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) {
2598 return DeserializeObject(thread, 2540 return DeserializeObject(thread,
2599 serialized_message_, serialized_message_len_); 2541 serialized_message_, serialized_message_len_);
2600 } 2542 }
2601 2543
2602 2544
2603 } // namespace dart 2545 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698