Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: runtime/vm/service.cc

Issue 204003002: Support wedging isolates before startup or before exit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/isolate.cc ('K') | « runtime/vm/message_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/coverage.h" 10 #include "vm/coverage.h"
11 #include "vm/cpu.h" 11 #include "vm/cpu.h"
12 #include "vm/dart_api_impl.h" 12 #include "vm/dart_api_impl.h"
13 #include "vm/dart_entry.h" 13 #include "vm/dart_entry.h"
14 #include "vm/debugger.h" 14 #include "vm/debugger.h"
15 #include "vm/isolate.h" 15 #include "vm/isolate.h"
16 #include "vm/message.h" 16 #include "vm/message.h"
17 #include "vm/message_handler.h"
17 #include "vm/native_entry.h" 18 #include "vm/native_entry.h"
18 #include "vm/native_arguments.h" 19 #include "vm/native_arguments.h"
19 #include "vm/object.h" 20 #include "vm/object.h"
20 #include "vm/object_id_ring.h" 21 #include "vm/object_id_ring.h"
21 #include "vm/object_store.h" 22 #include "vm/object_store.h"
22 #include "vm/port.h" 23 #include "vm/port.h"
23 #include "vm/profiler.h" 24 #include "vm/profiler.h"
24 #include "vm/stack_frame.h" 25 #include "vm/stack_frame.h"
25 #include "vm/symbols.h" 26 #include "vm/symbols.h"
26 27
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 Isolate::ServiceCreateCallback(); 256 Isolate::ServiceCreateCallback();
256 if (create_callback == NULL) { 257 if (create_callback == NULL) {
257 return NULL; 258 return NULL;
258 } 259 }
259 Isolate::SetCurrent(NULL); 260 Isolate::SetCurrent(NULL);
260 char* error = NULL; 261 char* error = NULL;
261 Isolate* isolate = reinterpret_cast<Isolate*>( 262 Isolate* isolate = reinterpret_cast<Isolate*>(
262 create_callback(callback_data, &error)); 263 create_callback(callback_data, &error));
263 if (isolate == NULL) { 264 if (isolate == NULL) {
264 return NULL; 265 return NULL;
265 } 266 }
turnidge 2014/03/18 21:45:37 Add comment here.
Cutch 2014/03/18 23:32:33 Done.
267 isolate->message_handler()->set_wedge_on_start(false);
268 isolate->message_handler()->set_wedge_on_exit(false);
266 Isolate::SetCurrent(isolate); 269 Isolate::SetCurrent(isolate);
267 { 270 {
268 // Install the dart:vmservice library. 271 // Install the dart:vmservice library.
269 StackZone zone(isolate); 272 StackZone zone(isolate);
270 HANDLESCOPE(isolate); 273 HANDLESCOPE(isolate);
271 Library& library = 274 Library& library =
272 Library::Handle(isolate, isolate->object_store()->root_library()); 275 Library::Handle(isolate, isolate->object_store()->root_library());
273 // Isolate is empty. 276 // Isolate is empty.
274 ASSERT(library.IsNull()); 277 ASSERT(library.IsNull());
275 // Grab embedder tag handler. 278 // Grab embedder tag handler.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 ASSERT(!name.IsNull()); 362 ASSERT(!name.IsNull());
360 const Array& list = Array::Handle( 363 const Array& list = Array::Handle(
361 MakeServiceControlMessage(Dart_GetMainPortId(), 364 MakeServiceControlMessage(Dart_GetMainPortId(),
362 VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID, 365 VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID,
363 name)); 366 name));
364 ASSERT(!list.IsNull()); 367 ASSERT(!list.IsNull());
365 uint8_t* data = NULL; 368 uint8_t* data = NULL;
366 MessageWriter writer(&data, &allocator); 369 MessageWriter writer(&data, &allocator);
367 writer.WriteMessage(list); 370 writer.WriteMessage(list);
368 intptr_t len = writer.BytesWritten(); 371 intptr_t len = writer.BytesWritten();
372 if (FLAG_trace_service) {
373 OS::Print("Isolate %s %" Pd64 " registered with service \n",
374 name.ToCString(),
375 Dart_GetMainPortId());
376 }
369 return PortMap::PostMessage( 377 return PortMap::PostMessage(
370 new Message(port_, data, len, Message::kNormalPriority)); 378 new Message(port_, data, len, Message::kNormalPriority));
371 } 379 }
372 380
373 381
374 bool Service::SendIsolateShutdownMessage() { 382 bool Service::SendIsolateShutdownMessage() {
375 if (!IsRunning()) { 383 if (!IsRunning()) {
376 return false; 384 return false;
377 } 385 }
378 Isolate* isolate = Isolate::Current(); 386 Isolate* isolate = Isolate::Current();
379 ASSERT(isolate != NULL); 387 ASSERT(isolate != NULL);
380 HANDLESCOPE(isolate); 388 HANDLESCOPE(isolate);
389 const String& name = String::Handle(String::New(isolate->name()));
390 ASSERT(!name.IsNull());
381 const Array& list = Array::Handle( 391 const Array& list = Array::Handle(
382 MakeServiceControlMessage(Dart_GetMainPortId(), 392 MakeServiceControlMessage(Dart_GetMainPortId(),
383 VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID, 393 VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID,
384 String::Handle(String::null()))); 394 name));
385 ASSERT(!list.IsNull()); 395 ASSERT(!list.IsNull());
386 uint8_t* data = NULL; 396 uint8_t* data = NULL;
387 MessageWriter writer(&data, &allocator); 397 MessageWriter writer(&data, &allocator);
388 writer.WriteMessage(list); 398 writer.WriteMessage(list);
389 intptr_t len = writer.BytesWritten(); 399 intptr_t len = writer.BytesWritten();
400 if (FLAG_trace_service) {
401 OS::Print("Isolate %s %" Pd64 " deregistered with service \n",
402 name.ToCString(),
403 Dart_GetMainPortId());
404 }
390 return PortMap::PostMessage( 405 return PortMap::PostMessage(
391 new Message(port_, data, len, Message::kNormalPriority)); 406 new Message(port_, data, len, Message::kNormalPriority));
392 } 407 }
393 408
394 409
395 bool Service::IsRunning() { 410 bool Service::IsRunning() {
396 return port_ != ILLEGAL_PORT; 411 return port_ != ILLEGAL_PORT;
397 } 412 }
398 413
399 414
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 } 1422 }
1408 if (js->num_arguments() != 1) { 1423 if (js->num_arguments() != 1) {
1409 PrintError(js, "Command too long"); 1424 PrintError(js, "Command too long");
1410 return true; 1425 return true;
1411 } 1426 }
1412 isolate->class_table()->AllocationProfilePrintToJSONStream(js); 1427 isolate->class_table()->AllocationProfilePrintToJSONStream(js);
1413 return true; 1428 return true;
1414 } 1429 }
1415 1430
1416 1431
1417 static bool HandleUnpin(Isolate* isolate, JSONStream* js) { 1432 static bool HandleUnpin(Isolate* isolate, JSONStream* js) {
turnidge 2014/03/18 21:45:37 Can we call this resume instead of unpin? That wa
Cutch 2014/03/18 23:32:33 Done.
1418 // TODO(johnmccutchan): What do I respond with?? 1433 // TODO(johnmccutchan): What do I respond with??
1419 isolate->ClosePinPort(); 1434 if (isolate->message_handler()->wedge_on_start()) {
1435 isolate->message_handler()->set_wedge_on_start(false);
1436 return true;
1437 }
1438 if (isolate->message_handler()->wedge_on_exit()) {
1439 isolate->message_handler()->set_wedge_on_exit(false);
1440 return true;
1441 }
1420 return true; 1442 return true;
1421 } 1443 }
1422 1444
1423 1445
1424 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) { 1446 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) {
1425 isolate->heap()->PrintHeapMapToJSONStream(js); 1447 isolate->heap()->PrintHeapMapToJSONStream(js);
1426 return true; 1448 return true;
1427 } 1449 }
1428 1450
1429 1451
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 while (current != NULL) { 1677 while (current != NULL) {
1656 if (strcmp(name, current->name()) == 0) { 1678 if (strcmp(name, current->name()) == 0) {
1657 return current; 1679 return current;
1658 } 1680 }
1659 current = current->next(); 1681 current = current->next();
1660 } 1682 }
1661 return NULL; 1683 return NULL;
1662 } 1684 }
1663 1685
1664 } // namespace dart 1686 } // namespace dart
OLDNEW
« runtime/vm/isolate.cc ('K') | « runtime/vm/message_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698