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 "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
11 #include "vm/compiler_stats.h" | 11 #include "vm/compiler_stats.h" |
12 #include "vm/coverage.h" | 12 #include "vm/coverage.h" |
13 #include "vm/dart_api_state.h" | 13 #include "vm/dart_api_state.h" |
14 #include "vm/dart_entry.h" | 14 #include "vm/dart_entry.h" |
15 #include "vm/debugger.h" | 15 #include "vm/debugger.h" |
16 #include "vm/deopt_instructions.h" | 16 #include "vm/deopt_instructions.h" |
17 #include "vm/heap.h" | 17 #include "vm/heap.h" |
18 #include "vm/lockers.h" | 18 #include "vm/lockers.h" |
19 #include "vm/log.h" | 19 #include "vm/log.h" |
20 #include "vm/message_handler.h" | 20 #include "vm/message_handler.h" |
21 #include "vm/object_id_ring.h" | 21 #include "vm/object_id_ring.h" |
22 #include "vm/object_store.h" | 22 #include "vm/object_store.h" |
23 #include "vm/object.h" | 23 #include "vm/object.h" |
24 #include "vm/os_thread.h" | 24 #include "vm/os_thread.h" |
25 #include "vm/parser.h" | 25 #include "vm/parser.h" |
26 #include "vm/port.h" | 26 #include "vm/port.h" |
27 #include "vm/profiler.h" | 27 #include "vm/profiler.h" |
28 #include "vm/reusable_handles.h" | 28 #include "vm/reusable_handles.h" |
29 #include "vm/service.h" | 29 #include "vm/service.h" |
| 30 #include "vm/service_event.h" |
30 #include "vm/service_isolate.h" | 31 #include "vm/service_isolate.h" |
31 #include "vm/simulator.h" | 32 #include "vm/simulator.h" |
32 #include "vm/stack_frame.h" | 33 #include "vm/stack_frame.h" |
33 #include "vm/stub_code.h" | 34 #include "vm/stub_code.h" |
34 #include "vm/symbols.h" | 35 #include "vm/symbols.h" |
35 #include "vm/tags.h" | 36 #include "vm/tags.h" |
36 #include "vm/thread_interrupter.h" | 37 #include "vm/thread_interrupter.h" |
37 #include "vm/timer.h" | 38 #include "vm/timer.h" |
38 #include "vm/visitor.h" | 39 #include "vm/visitor.h" |
39 | 40 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 108 |
108 | 109 |
109 class IsolateMessageHandler : public MessageHandler { | 110 class IsolateMessageHandler : public MessageHandler { |
110 public: | 111 public: |
111 explicit IsolateMessageHandler(Isolate* isolate); | 112 explicit IsolateMessageHandler(Isolate* isolate); |
112 ~IsolateMessageHandler(); | 113 ~IsolateMessageHandler(); |
113 | 114 |
114 const char* name() const; | 115 const char* name() const; |
115 void MessageNotify(Message::Priority priority); | 116 void MessageNotify(Message::Priority priority); |
116 bool HandleMessage(Message* message); | 117 bool HandleMessage(Message* message); |
| 118 void NotifyPauseOnStart(); |
| 119 void NotifyPauseOnExit(); |
117 | 120 |
118 #if defined(DEBUG) | 121 #if defined(DEBUG) |
119 // Check that it is safe to access this handler. | 122 // Check that it is safe to access this handler. |
120 void CheckAccess(); | 123 void CheckAccess(); |
121 #endif | 124 #endif |
122 bool IsCurrentIsolate() const; | 125 bool IsCurrentIsolate() const; |
123 virtual Isolate* isolate() const { return isolate_; } | 126 virtual Isolate* isolate() const { return isolate_; } |
124 | 127 |
125 private: | 128 private: |
126 // Keep in sync with isolate_patch.dart. | 129 // Keep in sync with isolate_patch.dart. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 success = ProcessUnhandledException(Error::Cast(result)); | 380 success = ProcessUnhandledException(Error::Cast(result)); |
378 } else { | 381 } else { |
379 ASSERT(result.IsNull()); | 382 ASSERT(result.IsNull()); |
380 } | 383 } |
381 } | 384 } |
382 delete message; | 385 delete message; |
383 return success; | 386 return success; |
384 } | 387 } |
385 | 388 |
386 | 389 |
| 390 void IsolateMessageHandler::NotifyPauseOnStart() { |
| 391 StartIsolateScope start_isolate(isolate()); |
| 392 StackZone zone(I); |
| 393 HandleScope handle_scope(I); |
| 394 ServiceEvent pause_event(isolate(), ServiceEvent::kPauseStart); |
| 395 Service::HandleEvent(&pause_event); |
| 396 } |
| 397 |
| 398 |
| 399 void IsolateMessageHandler::NotifyPauseOnExit() { |
| 400 StartIsolateScope start_isolate(isolate()); |
| 401 StackZone zone(I); |
| 402 HandleScope handle_scope(I); |
| 403 ServiceEvent pause_event(isolate(), ServiceEvent::kPauseExit); |
| 404 Service::HandleEvent(&pause_event); |
| 405 } |
| 406 |
| 407 |
387 #if defined(DEBUG) | 408 #if defined(DEBUG) |
388 void IsolateMessageHandler::CheckAccess() { | 409 void IsolateMessageHandler::CheckAccess() { |
389 ASSERT(IsCurrentIsolate()); | 410 ASSERT(IsCurrentIsolate()); |
390 } | 411 } |
391 #endif | 412 #endif |
392 | 413 |
393 | 414 |
394 bool IsolateMessageHandler::IsCurrentIsolate() const { | 415 bool IsolateMessageHandler::IsCurrentIsolate() const { |
395 return (I == Isolate::Current()); | 416 return (I == Isolate::Current()); |
396 } | 417 } |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 func ^= entry.raw(); | 1332 func ^= entry.raw(); |
1312 jsobj.AddProperty("entry", func); | 1333 jsobj.AddProperty("entry", func); |
1313 } | 1334 } |
1314 } | 1335 } |
1315 { | 1336 { |
1316 JSONObject jsheap(&jsobj, "heaps"); | 1337 JSONObject jsheap(&jsobj, "heaps"); |
1317 heap()->PrintToJSONObject(Heap::kNew, &jsheap); | 1338 heap()->PrintToJSONObject(Heap::kNew, &jsheap); |
1318 heap()->PrintToJSONObject(Heap::kOld, &jsheap); | 1339 heap()->PrintToJSONObject(Heap::kOld, &jsheap); |
1319 } | 1340 } |
1320 | 1341 |
1321 // TODO(turnidge): Don't compute a full stack trace every time we | |
1322 // request an isolate's info. | |
1323 DebuggerStackTrace* stack = debugger()->StackTrace(); | |
1324 if (stack->Length() > 0) { | |
1325 JSONObject jsframe(&jsobj, "topFrame"); | |
1326 | |
1327 ActivationFrame* frame = stack->FrameAt(0); | |
1328 frame->PrintToJSONObject(&jsobj); | |
1329 // TODO(turnidge): Implement depth differently -- differentiate | |
1330 // inlined frames. | |
1331 jsobj.AddProperty("depth", (intptr_t)0); | |
1332 } | |
1333 jsobj.AddProperty("livePorts", message_handler()->live_ports()); | 1342 jsobj.AddProperty("livePorts", message_handler()->live_ports()); |
1334 jsobj.AddProperty("pauseOnExit", message_handler()->pause_on_exit()); | 1343 jsobj.AddProperty("pauseOnExit", message_handler()->pause_on_exit()); |
1335 | 1344 |
1336 // TODO(turnidge): Make the debugger support paused_on_start/exit. | |
1337 if (message_handler()->paused_on_start()) { | 1345 if (message_handler()->paused_on_start()) { |
1338 ASSERT(debugger()->PauseEvent() == NULL); | 1346 ASSERT(debugger()->PauseEvent() == NULL); |
1339 DebuggerEvent pauseEvent(this, DebuggerEvent::kIsolateCreated); | 1347 ServiceEvent pause_event(this, ServiceEvent::kPauseStart); |
1340 jsobj.AddProperty("pauseEvent", &pauseEvent); | 1348 jsobj.AddProperty("pauseEvent", &pause_event); |
1341 } else if (message_handler()->paused_on_exit()) { | 1349 } else if (message_handler()->paused_on_exit()) { |
1342 ASSERT(debugger()->PauseEvent() == NULL); | 1350 ASSERT(debugger()->PauseEvent() == NULL); |
1343 DebuggerEvent pauseEvent(this, DebuggerEvent::kIsolateShutdown); | 1351 ServiceEvent pause_event(this, ServiceEvent::kPauseExit); |
1344 jsobj.AddProperty("pauseEvent", &pauseEvent); | 1352 jsobj.AddProperty("pauseEvent", &pause_event); |
1345 } else if (debugger()->PauseEvent() != NULL) { | 1353 } else if (debugger()->PauseEvent() != NULL) { |
1346 jsobj.AddProperty("pauseEvent", debugger()->PauseEvent()); | 1354 ServiceEvent pause_event(debugger()->PauseEvent()); |
| 1355 jsobj.AddProperty("pauseEvent", &pause_event); |
| 1356 } else { |
| 1357 ServiceEvent pause_event(this, ServiceEvent::kResume); |
| 1358 |
| 1359 // TODO(turnidge): Don't compute a full stack trace. |
| 1360 DebuggerStackTrace* stack = debugger()->StackTrace(); |
| 1361 if (stack->Length() > 0) { |
| 1362 pause_event.set_top_frame(stack->FrameAt(0)); |
| 1363 } |
| 1364 jsobj.AddProperty("pauseEvent", &pause_event); |
1347 } | 1365 } |
1348 | 1366 |
1349 const Library& lib = | 1367 const Library& lib = |
1350 Library::Handle(object_store()->root_library()); | 1368 Library::Handle(object_store()->root_library()); |
1351 jsobj.AddProperty("rootLib", lib); | 1369 jsobj.AddProperty("rootLib", lib); |
1352 | 1370 |
1353 timer_list().PrintTimersToJSONProperty(&jsobj); | 1371 timer_list().PrintTimersToJSONProperty(&jsobj); |
1354 { | 1372 { |
1355 JSONObject tagCounters(&jsobj, "tagCounters"); | 1373 JSONObject tagCounters(&jsobj, "tagCounters"); |
1356 vm_tag_counters()->PrintToJSONObject(&tagCounters); | 1374 vm_tag_counters()->PrintToJSONObject(&tagCounters); |
(...skipping 23 matching lines...) Expand all Loading... |
1380 lib ^= libs.At(i); | 1398 lib ^= libs.At(i); |
1381 name = lib.name(); | 1399 name = lib.name(); |
1382 if (name.Equals(Symbols::DartIOLibName())) { | 1400 if (name.Equals(Symbols::DartIOLibName())) { |
1383 is_io_enabled = true; | 1401 is_io_enabled = true; |
1384 } | 1402 } |
1385 ASSERT(!lib.IsNull()); | 1403 ASSERT(!lib.IsNull()); |
1386 lib_array.AddValue(lib); | 1404 lib_array.AddValue(lib); |
1387 } | 1405 } |
1388 } | 1406 } |
1389 { | 1407 { |
| 1408 JSONArray breakpoints(&jsobj, "breakpoints"); |
| 1409 debugger()->PrintBreakpointsToJSONArray(&breakpoints); |
| 1410 } |
| 1411 { |
1390 JSONArray features_array(&jsobj, "features"); | 1412 JSONArray features_array(&jsobj, "features"); |
1391 if (is_io_enabled) { | 1413 if (is_io_enabled) { |
1392 features_array.AddValue("io"); | 1414 features_array.AddValue("io"); |
1393 } | 1415 } |
1394 } | 1416 } |
1395 } | 1417 } |
1396 | 1418 |
1397 | 1419 |
1398 intptr_t Isolate::ProfileInterrupt() { | 1420 intptr_t Isolate::ProfileInterrupt() { |
1399 // Other threads might be modifying these fields. Save them in locals so that | 1421 // Other threads might be modifying these fields. Save them in locals so that |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 serialized_message_, serialized_message_len_); | 1747 serialized_message_, serialized_message_len_); |
1726 } | 1748 } |
1727 | 1749 |
1728 | 1750 |
1729 void IsolateSpawnState::Cleanup() { | 1751 void IsolateSpawnState::Cleanup() { |
1730 SwitchIsolateScope switch_scope(I); | 1752 SwitchIsolateScope switch_scope(I); |
1731 Dart::ShutdownIsolate(); | 1753 Dart::ShutdownIsolate(); |
1732 } | 1754 } |
1733 | 1755 |
1734 } // namespace dart | 1756 } // namespace dart |
OLD | NEW |