| 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 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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 MonitorLocker ml(old_space->tasks_lock()); | 1698 MonitorLocker ml(old_space->tasks_lock()); |
| 1700 ASSERT(old_space->tasks() == 0); | 1699 ASSERT(old_space->tasks() == 0); |
| 1701 } | 1700 } |
| 1702 #endif | 1701 #endif |
| 1703 | 1702 |
| 1704 // TODO(5411455): For now just make sure there are no current isolates | 1703 // TODO(5411455): For now just make sure there are no current isolates |
| 1705 // as we are shutting down the isolate. | 1704 // as we are shutting down the isolate. |
| 1706 Thread::ExitIsolate(); | 1705 Thread::ExitIsolate(); |
| 1707 // All threads should have exited by now. | 1706 // All threads should have exited by now. |
| 1708 thread_registry()->CheckNotScheduled(this); | 1707 thread_registry()->CheckNotScheduled(this); |
| 1709 Profiler::ShutdownProfilingForIsolate(this); | |
| 1710 } | 1708 } |
| 1711 | 1709 |
| 1712 | 1710 |
| 1713 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1711 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
| 1714 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; | 1712 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; |
| 1715 Dart_IsolateUnhandledExceptionCallback | 1713 Dart_IsolateUnhandledExceptionCallback |
| 1716 Isolate::unhandled_exception_callback_ = NULL; | 1714 Isolate::unhandled_exception_callback_ = NULL; |
| 1717 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; | 1715 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; |
| 1718 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; | 1716 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; |
| 1719 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; | 1717 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 debugger()->PrintBreakpointsToJSONArray(&breakpoints); | 1902 debugger()->PrintBreakpointsToJSONArray(&breakpoints); |
| 1905 } | 1903 } |
| 1906 | 1904 |
| 1907 { | 1905 { |
| 1908 JSONObject jssettings(&jsobj, "_debuggerSettings"); | 1906 JSONObject jssettings(&jsobj, "_debuggerSettings"); |
| 1909 debugger()->PrintSettingsToJSONObject(&jssettings); | 1907 debugger()->PrintSettingsToJSONObject(&jssettings); |
| 1910 } | 1908 } |
| 1911 } | 1909 } |
| 1912 | 1910 |
| 1913 | 1911 |
| 1914 intptr_t Isolate::ProfileInterrupt() { | |
| 1915 // Other threads might be modifying these fields. Save them in locals so that | |
| 1916 // we can at least trust the NULL check. | |
| 1917 IsolateProfilerData* prof_data = profiler_data(); | |
| 1918 if (prof_data == NULL) { | |
| 1919 // Profiler not setup for isolate. | |
| 1920 return 0; | |
| 1921 } | |
| 1922 if (prof_data->blocked()) { | |
| 1923 // Profiler blocked for this isolate. | |
| 1924 return 0; | |
| 1925 } | |
| 1926 Debugger* debug = debugger(); | |
| 1927 if ((debug != NULL) && debug->IsPaused()) { | |
| 1928 // Paused at breakpoint. Don't tick. | |
| 1929 return 0; | |
| 1930 } | |
| 1931 MessageHandler* msg_handler = message_handler(); | |
| 1932 if ((msg_handler != NULL) && | |
| 1933 (msg_handler->paused_on_start() || | |
| 1934 msg_handler->paused_on_exit())) { | |
| 1935 // Paused at start / exit . Don't tick. | |
| 1936 return 0; | |
| 1937 } | |
| 1938 // Make sure that the isolate's mutator thread does not change behind our | |
| 1939 // backs. Otherwise we find the entry in the registry and end up reading | |
| 1940 // the field again. Only by that time it has been reset to NULL because the | |
| 1941 // thread was in process of exiting the isolate. | |
| 1942 Thread* mutator = mutator_thread_; | |
| 1943 if (mutator == NULL) { | |
| 1944 // No active mutator. | |
| 1945 ProfileIdle(); | |
| 1946 return 1; | |
| 1947 } | |
| 1948 | |
| 1949 // TODO(johnmccutchan): Sample all threads, not just the mutator thread. | |
| 1950 // TODO(johnmccutchan): Keep a global list of threads and use that | |
| 1951 // instead of Isolate. | |
| 1952 ThreadRegistry::EntryIterator it(thread_registry()); | |
| 1953 while (it.HasNext()) { | |
| 1954 const ThreadRegistry::Entry& entry = it.Next(); | |
| 1955 if (entry.thread == mutator) { | |
| 1956 ThreadInterrupter::InterruptThread(mutator); | |
| 1957 break; | |
| 1958 } | |
| 1959 } | |
| 1960 return 1; | |
| 1961 } | |
| 1962 | |
| 1963 | |
| 1964 void Isolate::ProfileIdle() { | |
| 1965 // Currently we are only sampling the mutator thread. | |
| 1966 vm_tag_counters_.Increment(VMTag::kIdleTagId); | |
| 1967 } | |
| 1968 | |
| 1969 | |
| 1970 void Isolate::set_tag_table(const GrowableObjectArray& value) { | 1912 void Isolate::set_tag_table(const GrowableObjectArray& value) { |
| 1971 tag_table_ = value.raw(); | 1913 tag_table_ = value.raw(); |
| 1972 } | 1914 } |
| 1973 | 1915 |
| 1974 | 1916 |
| 1975 void Isolate::set_current_tag(const UserTag& tag) { | 1917 void Isolate::set_current_tag(const UserTag& tag) { |
| 1976 uword user_tag = tag.tag(); | 1918 uword user_tag = tag.tag(); |
| 1977 ASSERT(user_tag < kUwordMax); | 1919 ASSERT(user_tag < kUwordMax); |
| 1978 set_user_tag(user_tag); | 1920 set_user_tag(user_tag); |
| 1979 current_tag_ = tag.raw(); | 1921 current_tag_ = tag.raw(); |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 } | 2527 } |
| 2586 | 2528 |
| 2587 | 2529 |
| 2588 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { | 2530 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { |
| 2589 return DeserializeObject(thread, | 2531 return DeserializeObject(thread, |
| 2590 serialized_message_, serialized_message_len_); | 2532 serialized_message_, serialized_message_len_); |
| 2591 } | 2533 } |
| 2592 | 2534 |
| 2593 | 2535 |
| 2594 } // namespace dart | 2536 } // namespace dart |
| OLD | NEW |