OLD | NEW |
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 Loading... |
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 background_compilation_queue_(GrowableObjectArray::null()), | 790 background_compilation_queue_(GrowableObjectArray::null()), |
792 pending_service_extension_calls_(GrowableObjectArray::null()), | 791 pending_service_extension_calls_(GrowableObjectArray::null()), |
793 registered_service_extension_handlers_(GrowableObjectArray::null()), | 792 registered_service_extension_handlers_(GrowableObjectArray::null()), |
794 metrics_list_head_(NULL), | 793 metrics_list_head_(NULL), |
795 compilation_allowed_(true), | 794 compilation_allowed_(true), |
796 all_classes_finalized_(false), | 795 all_classes_finalized_(false), |
797 next_(NULL), | 796 next_(NULL), |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 } | 1705 } |
1707 #endif | 1706 #endif |
1708 | 1707 |
1709 BackgroundCompiler::Stop(background_compiler_); | 1708 BackgroundCompiler::Stop(background_compiler_); |
1710 | 1709 |
1711 // TODO(5411455): For now just make sure there are no current isolates | 1710 // TODO(5411455): For now just make sure there are no current isolates |
1712 // as we are shutting down the isolate. | 1711 // as we are shutting down the isolate. |
1713 Thread::ExitIsolate(); | 1712 Thread::ExitIsolate(); |
1714 // All threads should have exited by now. | 1713 // All threads should have exited by now. |
1715 thread_registry()->CheckNotScheduled(this); | 1714 thread_registry()->CheckNotScheduled(this); |
1716 Profiler::ShutdownProfilingForIsolate(this); | |
1717 } | 1715 } |
1718 | 1716 |
1719 | 1717 |
1720 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1718 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
1721 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; | 1719 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; |
1722 Dart_IsolateUnhandledExceptionCallback | 1720 Dart_IsolateUnhandledExceptionCallback |
1723 Isolate::unhandled_exception_callback_ = NULL; | 1721 Isolate::unhandled_exception_callback_ = NULL; |
1724 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; | 1722 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; |
1725 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; | 1723 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; |
1726 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; | 1724 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 debugger()->PrintBreakpointsToJSONArray(&breakpoints); | 1908 debugger()->PrintBreakpointsToJSONArray(&breakpoints); |
1911 } | 1909 } |
1912 | 1910 |
1913 { | 1911 { |
1914 JSONObject jssettings(&jsobj, "_debuggerSettings"); | 1912 JSONObject jssettings(&jsobj, "_debuggerSettings"); |
1915 debugger()->PrintSettingsToJSONObject(&jssettings); | 1913 debugger()->PrintSettingsToJSONObject(&jssettings); |
1916 } | 1914 } |
1917 } | 1915 } |
1918 | 1916 |
1919 | 1917 |
1920 intptr_t Isolate::ProfileInterrupt() { | |
1921 // Other threads might be modifying these fields. Save them in locals so that | |
1922 // we can at least trust the NULL check. | |
1923 IsolateProfilerData* prof_data = profiler_data(); | |
1924 if (prof_data == NULL) { | |
1925 // Profiler not setup for isolate. | |
1926 return 0; | |
1927 } | |
1928 if (prof_data->blocked()) { | |
1929 // Profiler blocked for this isolate. | |
1930 return 0; | |
1931 } | |
1932 Debugger* debug = debugger(); | |
1933 if ((debug != NULL) && debug->IsPaused()) { | |
1934 // Paused at breakpoint. Don't tick. | |
1935 return 0; | |
1936 } | |
1937 MessageHandler* msg_handler = message_handler(); | |
1938 if ((msg_handler != NULL) && | |
1939 (msg_handler->paused_on_start() || | |
1940 msg_handler->paused_on_exit())) { | |
1941 // Paused at start / exit . Don't tick. | |
1942 return 0; | |
1943 } | |
1944 // Make sure that the isolate's mutator thread does not change behind our | |
1945 // backs. Otherwise we find the entry in the registry and end up reading | |
1946 // the field again. Only by that time it has been reset to NULL because the | |
1947 // thread was in process of exiting the isolate. | |
1948 Thread* mutator = mutator_thread_; | |
1949 if (mutator == NULL) { | |
1950 // No active mutator. | |
1951 ProfileIdle(); | |
1952 return 1; | |
1953 } | |
1954 | |
1955 // TODO(johnmccutchan): Sample all threads, not just the mutator thread. | |
1956 // TODO(johnmccutchan): Keep a global list of threads and use that | |
1957 // instead of Isolate. | |
1958 ThreadRegistry::EntryIterator it(thread_registry()); | |
1959 while (it.HasNext()) { | |
1960 const ThreadRegistry::Entry& entry = it.Next(); | |
1961 if (entry.thread == mutator) { | |
1962 ThreadInterrupter::InterruptThread(mutator); | |
1963 break; | |
1964 } | |
1965 } | |
1966 return 1; | |
1967 } | |
1968 | |
1969 | |
1970 void Isolate::ProfileIdle() { | |
1971 // Currently we are only sampling the mutator thread. | |
1972 vm_tag_counters_.Increment(VMTag::kIdleTagId); | |
1973 } | |
1974 | |
1975 | |
1976 void Isolate::set_tag_table(const GrowableObjectArray& value) { | 1918 void Isolate::set_tag_table(const GrowableObjectArray& value) { |
1977 tag_table_ = value.raw(); | 1919 tag_table_ = value.raw(); |
1978 } | 1920 } |
1979 | 1921 |
1980 | 1922 |
1981 void Isolate::set_current_tag(const UserTag& tag) { | 1923 void Isolate::set_current_tag(const UserTag& tag) { |
1982 uword user_tag = tag.tag(); | 1924 uword user_tag = tag.tag(); |
1983 ASSERT(user_tag < kUwordMax); | 1925 ASSERT(user_tag < kUwordMax); |
1984 set_user_tag(user_tag); | 1926 set_user_tag(user_tag); |
1985 current_tag_ = tag.raw(); | 1927 current_tag_ = tag.raw(); |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2601 serialized_message_, serialized_message_len_); | 2543 serialized_message_, serialized_message_len_); |
2602 } | 2544 } |
2603 | 2545 |
2604 | 2546 |
2605 void IsolateSpawnState::Cleanup() { | 2547 void IsolateSpawnState::Cleanup() { |
2606 SwitchIsolateScope switch_scope(I); | 2548 SwitchIsolateScope switch_scope(I); |
2607 Dart::ShutdownIsolate(); | 2549 Dart::ShutdownIsolate(); |
2608 } | 2550 } |
2609 | 2551 |
2610 } // namespace dart | 2552 } // namespace dart |
OLD | NEW |