| 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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 853 |
| 854 | 854 |
| 855 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 855 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
| 856 bool visit_prologue_weak_handles) { | 856 bool visit_prologue_weak_handles) { |
| 857 if (api_state() != NULL) { | 857 if (api_state() != NULL) { |
| 858 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 858 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
| 859 } | 859 } |
| 860 } | 860 } |
| 861 | 861 |
| 862 | 862 |
| 863 void Isolate::PrintToJSONStream(JSONStream* stream) { | 863 void Isolate::PrintToJSONStream(JSONStream* stream, bool ref) { |
| 864 JSONObject jsobj(stream); | 864 JSONObject jsobj(stream); |
| 865 jsobj.AddProperty("type", "Isolate"); | 865 jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate")); |
| 866 jsobj.AddPropertyF("id", "isolates/%" Pd "", | 866 jsobj.AddPropertyF("id", "isolates/%" Pd "", |
| 867 static_cast<intptr_t>(main_port())); | 867 static_cast<intptr_t>(main_port())); |
| 868 jsobj.AddPropertyF("name", "%" Pd "", | 868 jsobj.AddPropertyF("mainPort", "%" Pd "", |
| 869 static_cast<intptr_t>(main_port())); | 869 static_cast<intptr_t>(main_port())); |
| 870 |
| 871 // Assign an isolate name based on the entry function. |
| 870 IsolateSpawnState* state = spawn_state(); | 872 IsolateSpawnState* state = spawn_state(); |
| 873 if (state == NULL) { |
| 874 jsobj.AddPropertyF("name", "root"); |
| 875 } else if (state->class_name() != NULL) { |
| 876 jsobj.AddPropertyF("name", "%s.%s", |
| 877 state->class_name(), |
| 878 state->function_name()); |
| 879 } else { |
| 880 jsobj.AddPropertyF("name", "%s", state->function_name()); |
| 881 } |
| 882 if (ref) { |
| 883 return; |
| 884 } |
| 871 if (state != NULL) { | 885 if (state != NULL) { |
| 872 const Object& entry = Object::Handle(this, state->ResolveFunction()); | 886 const Object& entry = Object::Handle(this, state->ResolveFunction()); |
| 873 if (!entry.IsNull() && entry.IsFunction()) { | 887 if (!entry.IsNull() && entry.IsFunction()) { |
| 874 Function& func = Function::Handle(this); | 888 Function& func = Function::Handle(this); |
| 875 func ^= entry.raw(); | 889 func ^= entry.raw(); |
| 876 jsobj.AddProperty("entry", func); | 890 jsobj.AddProperty("entry", func); |
| 877 } | 891 } |
| 878 } | 892 } |
| 879 { | 893 { |
| 880 JSONObject jsheap(&jsobj, "heap"); | 894 JSONObject jsheap(&jsobj, "heap"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 892 frame->PrintToJSONObject(&jsobj); | 906 frame->PrintToJSONObject(&jsobj); |
| 893 // TODO(turnidge): Implement depth differently -- differentiate | 907 // TODO(turnidge): Implement depth differently -- differentiate |
| 894 // inlined frames. | 908 // inlined frames. |
| 895 jsobj.AddProperty("depth", (intptr_t)0); | 909 jsobj.AddProperty("depth", (intptr_t)0); |
| 896 } | 910 } |
| 897 intptr_t live_ports = message_handler()->live_ports(); | 911 intptr_t live_ports = message_handler()->live_ports(); |
| 898 intptr_t control_ports = message_handler()->control_ports(); | 912 intptr_t control_ports = message_handler()->control_ports(); |
| 899 bool paused_on_exit = message_handler()->paused_on_exit(); | 913 bool paused_on_exit = message_handler()->paused_on_exit(); |
| 900 bool pause_on_start = message_handler()->pause_on_start(); | 914 bool pause_on_start = message_handler()->pause_on_start(); |
| 901 bool pause_on_exit = message_handler()->pause_on_exit(); | 915 bool pause_on_exit = message_handler()->pause_on_exit(); |
| 902 jsobj.AddProperty("live_ports", live_ports); | 916 jsobj.AddProperty("livePorts", live_ports); |
| 903 jsobj.AddProperty("control_ports", control_ports); | 917 jsobj.AddProperty("controlPorts", control_ports); |
| 904 jsobj.AddProperty("paused_on_exit", paused_on_exit); | 918 jsobj.AddProperty("pausedOnStart", pause_on_start); |
| 905 jsobj.AddProperty("paused_on_start", pause_on_start); | 919 jsobj.AddProperty("pausedOnExit", paused_on_exit); |
| 906 jsobj.AddProperty("pause_on_exit", pause_on_exit); | 920 jsobj.AddProperty("pauseOnExit", pause_on_exit); |
| 907 const Library& lib = | 921 const Library& lib = |
| 908 Library::Handle(object_store()->root_library()); | 922 Library::Handle(object_store()->root_library()); |
| 909 jsobj.AddProperty("rootLib", lib); | 923 jsobj.AddProperty("rootLib", lib); |
| 910 | 924 |
| 911 timer_list().PrintTimersToJSONProperty(&jsobj); | 925 timer_list().PrintTimersToJSONProperty(&jsobj); |
| 912 | 926 |
| 913 { | 927 { |
| 914 JSONObject typeargsRef(&jsobj, "canonicalTypeArguments"); | 928 JSONObject typeargsRef(&jsobj, "canonicalTypeArguments"); |
| 915 typeargsRef.AddProperty("type", "@TypeArgumentsList"); | 929 typeargsRef.AddProperty("type", "@TypeArgumentsList"); |
| 916 typeargsRef.AddProperty("id", "typearguments"); | 930 typeargsRef.AddProperty("id", "typearguments"); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 return func.raw(); | 1095 return func.raw(); |
| 1082 } | 1096 } |
| 1083 | 1097 |
| 1084 | 1098 |
| 1085 void IsolateSpawnState::Cleanup() { | 1099 void IsolateSpawnState::Cleanup() { |
| 1086 SwitchIsolateScope switch_scope(isolate()); | 1100 SwitchIsolateScope switch_scope(isolate()); |
| 1087 Dart::ShutdownIsolate(); | 1101 Dart::ShutdownIsolate(); |
| 1088 } | 1102 } |
| 1089 | 1103 |
| 1090 } // namespace dart | 1104 } // namespace dart |
| OLD | NEW |