Chromium Code Reviews| 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 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 return true; | 877 return true; |
| 878 } | 878 } |
| 879 | 879 |
| 880 | 880 |
| 881 char* Isolate::DoStacktraceInterrupt(Dart_IsolateInterruptCallback cb) { | 881 char* Isolate::DoStacktraceInterrupt(Dart_IsolateInterruptCallback cb) { |
| 882 ASSERT(stacktrace_ == NULL); | 882 ASSERT(stacktrace_ == NULL); |
| 883 SetVmStatsCallback(cb); | 883 SetVmStatsCallback(cb); |
| 884 if (status_sync == NULL) { | 884 if (status_sync == NULL) { |
| 885 status_sync = new Monitor(); | 885 status_sync = new Monitor(); |
| 886 } | 886 } |
| 887 bool is_main_isolate = (strstr(name(), "$main-") != NULL); | |
| 887 ScheduleInterrupts(Isolate::kVmStatusInterrupt); | 888 ScheduleInterrupts(Isolate::kVmStatusInterrupt); |
| 888 { | 889 { |
| 889 MonitorLocker ml(status_sync); | 890 MonitorLocker ml(status_sync); |
| 890 if (stacktrace_ == NULL) { // It may already be available. | 891 if (stacktrace_ == NULL) { // It may already be available. |
| 891 ml.Wait(); | 892 if (is_main_isolate) { |
| 893 // Main isolate may have finished, but waiting for other isolates | |
| 894 // to finish. If so, it won't respond to interrupts. | |
| 895 ml.Wait(500); | |
|
Ivan Posva
2013/04/12 14:37:36
This is quite unfortunate. There must be a way to
| |
| 896 } else { | |
| 897 ml.Wait(); | |
| 898 } | |
| 892 } | 899 } |
| 893 } | 900 } |
| 894 SetVmStatsCallback(NULL); | 901 SetVmStatsCallback(NULL); |
| 895 ASSERT(stacktrace_ != NULL); | |
| 896 // result is freed by VmStats::WebServer(). | |
| 897 char* result = stacktrace_; | 902 char* result = stacktrace_; |
| 898 stacktrace_ = NULL; | 903 stacktrace_ = NULL; |
| 904 if (is_main_isolate && result == NULL) { | |
|
Ivan Posva
2013/04/12 14:37:36
Why do we only care about the main isolate here? A
Tom Ball
2013/04/16 18:11:02
Replaced main-only test, with test for whether iso
| |
| 905 // Return empty stack. | |
| 906 TextBuffer buffer(256); | |
| 907 buffer.Printf("{ \"handle\": \"0x%"Px64"\", \"stacktrace\": []}", | |
| 908 reinterpret_cast<int64_t>(this)); | |
| 909 | |
| 910 result = strndup(buffer.buf(), buffer.length()); | |
| 911 } | |
| 912 ASSERT(result != NULL); | |
| 913 // result is freed by VmStats::WebServer(). | |
| 899 return result; | 914 return result; |
| 900 } | 915 } |
| 901 | 916 |
| 902 | 917 |
| 903 char* Isolate::GetStatusStacktrace() { | 918 char* Isolate::GetStatusStacktrace() { |
| 904 return DoStacktraceInterrupt(&FetchStacktrace); | 919 return DoStacktraceInterrupt(&FetchStacktrace); |
| 905 } | 920 } |
| 906 | 921 |
| 907 char* Isolate::GetStatusStackFrame(intptr_t index) { | 922 char* Isolate::GetStatusStackFrame(intptr_t index) { |
| 908 ASSERT(index >= 0); | 923 ASSERT(index >= 0); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1066 return func.raw(); | 1081 return func.raw(); |
| 1067 } | 1082 } |
| 1068 | 1083 |
| 1069 | 1084 |
| 1070 void IsolateSpawnState::Cleanup() { | 1085 void IsolateSpawnState::Cleanup() { |
| 1071 SwitchIsolateScope switch_scope(isolate()); | 1086 SwitchIsolateScope switch_scope(isolate()); |
| 1072 Dart::ShutdownIsolate(); | 1087 Dart::ShutdownIsolate(); |
| 1073 } | 1088 } |
| 1074 | 1089 |
| 1075 } // namespace dart | 1090 } // namespace dart |
| OLD | NEW |