| 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/text_buffer.h" | 10 #include "platform/text_buffer.h" |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 current_tag_(UserTag::null()), | 772 current_tag_(UserTag::null()), |
| 773 default_tag_(UserTag::null()), | 773 default_tag_(UserTag::null()), |
| 774 object_store_(NULL), | 774 object_store_(NULL), |
| 775 class_table_(), | 775 class_table_(), |
| 776 single_step_(false), | 776 single_step_(false), |
| 777 thread_registry_(new ThreadRegistry()), | 777 thread_registry_(new ThreadRegistry()), |
| 778 safepoint_handler_(new SafepointHandler(this)), | 778 safepoint_handler_(new SafepointHandler(this)), |
| 779 message_notify_callback_(NULL), | 779 message_notify_callback_(NULL), |
| 780 name_(NULL), | 780 name_(NULL), |
| 781 debugger_name_(NULL), | 781 debugger_name_(NULL), |
| 782 start_time_(OS::GetCurrentTimeMicros()), | 782 start_time_micros_(OS::GetCurrentMonotonicMicros()), |
| 783 main_port_(0), | 783 main_port_(0), |
| 784 origin_id_(0), | 784 origin_id_(0), |
| 785 pause_capability_(0), | 785 pause_capability_(0), |
| 786 terminate_capability_(0), | 786 terminate_capability_(0), |
| 787 errors_fatal_(true), | 787 errors_fatal_(true), |
| 788 init_callback_data_(NULL), | 788 init_callback_data_(NULL), |
| 789 environment_callback_(NULL), | 789 environment_callback_(NULL), |
| 790 library_tag_handler_(NULL), | 790 library_tag_handler_(NULL), |
| 791 api_state_(NULL), | 791 api_state_(NULL), |
| 792 debugger_(NULL), | 792 debugger_(NULL), |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 } | 1034 } |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 | 1037 |
| 1038 void Isolate::set_debugger_name(const char* name) { | 1038 void Isolate::set_debugger_name(const char* name) { |
| 1039 free(debugger_name_); | 1039 free(debugger_name_); |
| 1040 debugger_name_ = strdup(name); | 1040 debugger_name_ = strdup(name); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 | 1043 |
| 1044 int64_t Isolate::UptimeMicros() const { |
| 1045 return OS::GetCurrentMonotonicMicros() - start_time_micros_; |
| 1046 } |
| 1047 |
| 1048 |
| 1044 bool Isolate::IsPaused() const { | 1049 bool Isolate::IsPaused() const { |
| 1045 return (debugger_ != NULL) && (debugger_->PauseEvent() != NULL); | 1050 return (debugger_ != NULL) && (debugger_->PauseEvent() != NULL); |
| 1046 } | 1051 } |
| 1047 | 1052 |
| 1048 | 1053 |
| 1049 void Isolate::PausePostRequest() { | 1054 void Isolate::PausePostRequest() { |
| 1050 if (!FLAG_support_debugger) { | 1055 if (!FLAG_support_debugger) { |
| 1051 return; | 1056 return; |
| 1052 } | 1057 } |
| 1053 if (debugger_ == NULL) { | 1058 if (debugger_ == NULL) { |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 jsobj.AddFixedServiceId(ISOLATE_SERVICE_ID_FORMAT_STRING, | 1988 jsobj.AddFixedServiceId(ISOLATE_SERVICE_ID_FORMAT_STRING, |
| 1984 static_cast<int64_t>(main_port())); | 1989 static_cast<int64_t>(main_port())); |
| 1985 | 1990 |
| 1986 jsobj.AddProperty("name", debugger_name()); | 1991 jsobj.AddProperty("name", debugger_name()); |
| 1987 jsobj.AddPropertyF("number", "%" Pd64 "", static_cast<int64_t>(main_port())); | 1992 jsobj.AddPropertyF("number", "%" Pd64 "", static_cast<int64_t>(main_port())); |
| 1988 if (ref) { | 1993 if (ref) { |
| 1989 return; | 1994 return; |
| 1990 } | 1995 } |
| 1991 jsobj.AddPropertyF("_originNumber", "%" Pd64 "", | 1996 jsobj.AddPropertyF("_originNumber", "%" Pd64 "", |
| 1992 static_cast<int64_t>(origin_id())); | 1997 static_cast<int64_t>(origin_id())); |
| 1993 int64_t start_time_millis = start_time() / kMicrosecondsPerMillisecond; | 1998 int64_t uptime_millis = UptimeMicros() / kMicrosecondsPerMillisecond; |
| 1994 jsobj.AddPropertyTimeMillis("startTime", start_time_millis); | 1999 int64_t start_time = OS::GetCurrentTimeMillis() - uptime_millis; |
| 2000 jsobj.AddPropertyTimeMillis("startTime", start_time); |
| 1995 { | 2001 { |
| 1996 JSONObject jsheap(&jsobj, "_heaps"); | 2002 JSONObject jsheap(&jsobj, "_heaps"); |
| 1997 heap()->PrintToJSONObject(Heap::kNew, &jsheap); | 2003 heap()->PrintToJSONObject(Heap::kNew, &jsheap); |
| 1998 heap()->PrintToJSONObject(Heap::kOld, &jsheap); | 2004 heap()->PrintToJSONObject(Heap::kOld, &jsheap); |
| 1999 } | 2005 } |
| 2000 | 2006 |
| 2001 jsobj.AddProperty("runnable", is_runnable()); | 2007 jsobj.AddProperty("runnable", is_runnable()); |
| 2002 jsobj.AddProperty("livePorts", message_handler()->live_ports()); | 2008 jsobj.AddProperty("livePorts", message_handler()->live_ports()); |
| 2003 jsobj.AddProperty("pauseOnExit", message_handler()->should_pause_on_exit()); | 2009 jsobj.AddProperty("pauseOnExit", message_handler()->should_pause_on_exit()); |
| 2004 jsobj.AddProperty("_isReloading", IsReloading()); | 2010 jsobj.AddProperty("_isReloading", IsReloading()); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2233 arguments.SetAt(kPendingValuesIndex, parameter_values); | 2239 arguments.SetAt(kPendingValuesIndex, parameter_values); |
| 2234 reply_port ^= calls.At(i + kPendingReplyPortIndex); | 2240 reply_port ^= calls.At(i + kPendingReplyPortIndex); |
| 2235 ASSERT(!reply_port.IsNull()); | 2241 ASSERT(!reply_port.IsNull()); |
| 2236 arguments.SetAt(kPendingReplyPortIndex, reply_port); | 2242 arguments.SetAt(kPendingReplyPortIndex, reply_port); |
| 2237 id ^= calls.At(i + kPendingIdIndex); | 2243 id ^= calls.At(i + kPendingIdIndex); |
| 2238 arguments.SetAt(kPendingIdIndex, id); | 2244 arguments.SetAt(kPendingIdIndex, id); |
| 2239 arguments.SetAt(kPendingEntrySize, Bool::Get(FLAG_trace_service)); | 2245 arguments.SetAt(kPendingEntrySize, Bool::Get(FLAG_trace_service)); |
| 2240 | 2246 |
| 2241 if (FLAG_trace_service) { | 2247 if (FLAG_trace_service) { |
| 2242 OS::Print("[+%" Pd64 "ms] Isolate %s invoking _runExtension for %s\n", | 2248 OS::Print("[+%" Pd64 "ms] Isolate %s invoking _runExtension for %s\n", |
| 2243 Dart::timestamp(), name(), method_name.ToCString()); | 2249 Dart::UptimeMillis(), name(), method_name.ToCString()); |
| 2244 } | 2250 } |
| 2245 result = DartEntry::InvokeFunction(run_extension, arguments); | 2251 result = DartEntry::InvokeFunction(run_extension, arguments); |
| 2246 if (FLAG_trace_service) { | 2252 if (FLAG_trace_service) { |
| 2247 OS::Print("[+%" Pd64 "ms] Isolate %s : _runExtension complete for %s\n", | 2253 OS::Print("[+%" Pd64 "ms] Isolate %s : _runExtension complete for %s\n", |
| 2248 Dart::timestamp(), name(), method_name.ToCString()); | 2254 Dart::UptimeMillis(), name(), method_name.ToCString()); |
| 2249 } | 2255 } |
| 2250 // Propagate the error. | 2256 // Propagate the error. |
| 2251 if (result.IsError()) { | 2257 if (result.IsError()) { |
| 2252 // Remaining service extension calls are dropped. | 2258 // Remaining service extension calls are dropped. |
| 2253 if (!result.IsUnwindError()) { | 2259 if (!result.IsUnwindError()) { |
| 2254 // Send error back over the protocol. | 2260 // Send error back over the protocol. |
| 2255 Service::PostError(method_name, parameter_keys, parameter_values, | 2261 Service::PostError(method_name, parameter_keys, parameter_values, |
| 2256 reply_port, id, Error::Cast(result)); | 2262 reply_port, id, Error::Cast(result)); |
| 2257 } | 2263 } |
| 2258 return result.raw(); | 2264 return result.raw(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2277 | 2283 |
| 2278 | 2284 |
| 2279 void Isolate::AppendServiceExtensionCall(const Instance& closure, | 2285 void Isolate::AppendServiceExtensionCall(const Instance& closure, |
| 2280 const String& method_name, | 2286 const String& method_name, |
| 2281 const Array& parameter_keys, | 2287 const Array& parameter_keys, |
| 2282 const Array& parameter_values, | 2288 const Array& parameter_values, |
| 2283 const Instance& reply_port, | 2289 const Instance& reply_port, |
| 2284 const Instance& id) { | 2290 const Instance& id) { |
| 2285 if (FLAG_trace_service) { | 2291 if (FLAG_trace_service) { |
| 2286 OS::Print("[+%" Pd64 "ms] Isolate %s ENQUEUING request for extension %s\n", | 2292 OS::Print("[+%" Pd64 "ms] Isolate %s ENQUEUING request for extension %s\n", |
| 2287 Dart::timestamp(), name(), method_name.ToCString()); | 2293 Dart::UptimeMillis(), name(), method_name.ToCString()); |
| 2288 } | 2294 } |
| 2289 GrowableObjectArray& calls = | 2295 GrowableObjectArray& calls = |
| 2290 GrowableObjectArray::Handle(pending_service_extension_calls()); | 2296 GrowableObjectArray::Handle(pending_service_extension_calls()); |
| 2291 if (calls.IsNull()) { | 2297 if (calls.IsNull()) { |
| 2292 calls ^= GrowableObjectArray::New(); | 2298 calls ^= GrowableObjectArray::New(); |
| 2293 ASSERT(!calls.IsNull()); | 2299 ASSERT(!calls.IsNull()); |
| 2294 set_pending_service_extension_calls(calls); | 2300 set_pending_service_extension_calls(calls); |
| 2295 } | 2301 } |
| 2296 ASSERT(kPendingHandlerIndex == 0); | 2302 ASSERT(kPendingHandlerIndex == 0); |
| 2297 calls.Add(closure); | 2303 calls.Add(closure); |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 void IsolateSpawnState::DecrementSpawnCount() { | 2948 void IsolateSpawnState::DecrementSpawnCount() { |
| 2943 ASSERT(spawn_count_monitor_ != NULL); | 2949 ASSERT(spawn_count_monitor_ != NULL); |
| 2944 ASSERT(spawn_count_ != NULL); | 2950 ASSERT(spawn_count_ != NULL); |
| 2945 MonitorLocker ml(spawn_count_monitor_); | 2951 MonitorLocker ml(spawn_count_monitor_); |
| 2946 ASSERT(*spawn_count_ > 0); | 2952 ASSERT(*spawn_count_ > 0); |
| 2947 *spawn_count_ = *spawn_count_ - 1; | 2953 *spawn_count_ = *spawn_count_ - 1; |
| 2948 ml.Notify(); | 2954 ml.Notify(); |
| 2949 } | 2955 } |
| 2950 | 2956 |
| 2951 } // namespace dart | 2957 } // namespace dart |
| OLD | NEW |