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 "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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. | 361 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. |
362 delete spawn_state_; | 362 delete spawn_state_; |
363 } | 363 } |
364 | 364 |
365 | 365 |
366 void Isolate::SetCurrent(Isolate* current) { | 366 void Isolate::SetCurrent(Isolate* current) { |
367 Isolate* old_current = Current(); | 367 Isolate* old_current = Current(); |
368 if (old_current != NULL) { | 368 if (old_current != NULL) { |
369 old_current->set_thread_state(NULL); | 369 old_current->set_thread_state(NULL); |
370 Profiler::EndExecution(old_current); | 370 Profiler::EndExecution(old_current); |
371 old_current->set_vm_tag(VMTag::kIdleTagId); | |
371 } | 372 } |
372 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); | 373 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); |
373 if (current != NULL) { | 374 if (current != NULL) { |
375 current->set_vm_tag(VMTag::kVMTagId); | |
374 ASSERT(current->thread_state() == NULL); | 376 ASSERT(current->thread_state() == NULL); |
375 InterruptableThreadState* thread_state = | 377 InterruptableThreadState* thread_state = |
376 ThreadInterrupter::GetCurrentThreadState(); | 378 ThreadInterrupter::GetCurrentThreadState(); |
377 #if defined(DEBUG) | 379 #if defined(DEBUG) |
378 CheckForDuplicateThreadState(thread_state); | 380 CheckForDuplicateThreadState(thread_state); |
379 #endif | 381 #endif |
380 Profiler::BeginExecution(current); | 382 Profiler::BeginExecution(current); |
381 current->set_thread_state(thread_state); | 383 current->set_thread_state(thread_state); |
382 } | 384 } |
383 } | 385 } |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
916 jsobj.AddProperty("controlPorts", control_ports); | 918 jsobj.AddProperty("controlPorts", control_ports); |
917 jsobj.AddProperty("pausedOnStart", pause_on_start); | 919 jsobj.AddProperty("pausedOnStart", pause_on_start); |
918 jsobj.AddProperty("pausedOnExit", paused_on_exit); | 920 jsobj.AddProperty("pausedOnExit", paused_on_exit); |
919 jsobj.AddProperty("pauseOnExit", pause_on_exit); | 921 jsobj.AddProperty("pauseOnExit", pause_on_exit); |
920 const Library& lib = | 922 const Library& lib = |
921 Library::Handle(object_store()->root_library()); | 923 Library::Handle(object_store()->root_library()); |
922 jsobj.AddProperty("rootLib", lib); | 924 jsobj.AddProperty("rootLib", lib); |
923 | 925 |
924 timer_list().PrintTimersToJSONProperty(&jsobj); | 926 timer_list().PrintTimersToJSONProperty(&jsobj); |
925 | 927 |
928 if (object_store()->sticky_error() != Object::null()) { | |
929 Error& error = Error::Handle(this, object_store()->sticky_error()); | |
930 ASSERT(!error.IsNull()); | |
931 jsobj.AddProperty("stickyError", error, false); | |
turnidge
2014/03/24 20:22:13
rename to "error"?
Cutch
2014/03/25 14:39:06
Done.
| |
932 } | |
933 | |
926 { | 934 { |
927 JSONObject typeargsRef(&jsobj, "canonicalTypeArguments"); | 935 JSONObject typeargsRef(&jsobj, "canonicalTypeArguments"); |
928 typeargsRef.AddProperty("type", "@TypeArgumentsList"); | 936 typeargsRef.AddProperty("type", "@TypeArgumentsList"); |
929 typeargsRef.AddProperty("id", "typearguments"); | 937 typeargsRef.AddProperty("id", "typearguments"); |
930 typeargsRef.AddProperty("name", "canonical type arguments"); | 938 typeargsRef.AddProperty("name", "canonical type arguments"); |
931 } | 939 } |
932 } | 940 } |
933 | 941 |
934 | 942 |
943 void Isolate::ProfileInterrupt() { | |
944 InterruptableThreadState* state = thread_state(); | |
945 if (state == NULL) { | |
946 // Isolate is not scheduled on a thread. | |
947 ProfileIdle(); | |
948 return; | |
949 } | |
950 ASSERT(state->id != Thread::kInvalidThreadId); | |
951 ThreadInterrupter::InterruptThread(state); | |
952 } | |
953 | |
954 | |
955 void Isolate::ProfileIdle() { | |
956 vm_tag_counters_.Increment(vm_tag()); | |
turnidge
2014/03/24 20:22:13
Is the vm_tag always the kIdleTagId here? Or are
Cutch
2014/03/25 14:39:06
It will always be kIdleTagId or kVMTagId (there is
| |
957 } | |
958 | |
959 | |
935 void Isolate::VisitIsolates(IsolateVisitor* visitor) { | 960 void Isolate::VisitIsolates(IsolateVisitor* visitor) { |
936 if (visitor == NULL) { | 961 if (visitor == NULL) { |
937 return; | 962 return; |
938 } | 963 } |
939 MonitorLocker ml(isolates_list_monitor_); | 964 MonitorLocker ml(isolates_list_monitor_); |
940 Isolate* current = isolates_list_head_; | 965 Isolate* current = isolates_list_head_; |
941 while (current) { | 966 while (current) { |
942 visitor->VisitIsolate(current); | 967 visitor->VisitIsolate(current); |
943 current = current->next_; | 968 current = current->next_; |
944 } | 969 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 return func.raw(); | 1119 return func.raw(); |
1095 } | 1120 } |
1096 | 1121 |
1097 | 1122 |
1098 void IsolateSpawnState::Cleanup() { | 1123 void IsolateSpawnState::Cleanup() { |
1099 SwitchIsolateScope switch_scope(isolate()); | 1124 SwitchIsolateScope switch_scope(isolate()); |
1100 Dart::ShutdownIsolate(); | 1125 Dart::ShutdownIsolate(); |
1101 } | 1126 } |
1102 | 1127 |
1103 } // namespace dart | 1128 } // namespace dart |
OLD | NEW |