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

Side by Side Diff: runtime/bin/vmservice_impl.cc

Issue 22607005: Remove race(s) in vmservice tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « runtime/bin/vmservice_impl.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | 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 "bin/vmservice_impl.h" 5 #include "bin/vmservice_impl.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 printf("VmService has exited with an error:\n%s\n", Dart_GetError(result)); 380 printf("VmService has exited with an error:\n%s\n", Dart_GetError(result));
381 } 381 }
382 382
383 _Stop(); 383 _Stop();
384 384
385 Dart_ExitScope(); 385 Dart_ExitScope();
386 Dart_ExitIsolate(); 386 Dart_ExitIsolate();
387 } 387 }
388 388
389 389
390 static Dart_Handle MakeServiceControlMessage(Dart_Port port) { 390 static Dart_Handle MakeServiceControlMessage(Dart_Port port, intptr_t code) {
391 Dart_Handle list = Dart_NewList(2); 391 Dart_Handle result;
392 Dart_Handle list = Dart_NewList(3);
392 ASSERT(!Dart_IsError(list)); 393 ASSERT(!Dart_IsError(list));
394 Dart_Handle codeHandle = Dart_NewInteger(code);
395 ASSERT(!Dart_IsError(codeHandle));
396 result = Dart_ListSetAt(list, 0, codeHandle);
397 ASSERT(!Dart_IsError(result));
393 Dart_Handle sendPort = Dart_NewSendPort(port); 398 Dart_Handle sendPort = Dart_NewSendPort(port);
394 ASSERT(!Dart_IsError(sendPort)); 399 ASSERT(!Dart_IsError(sendPort));
395 Dart_ListSetAt(list, 1, sendPort); 400 result = Dart_ListSetAt(list, 1, sendPort);
401 ASSERT(!Dart_IsError(result));
396 return list; 402 return list;
397 } 403 }
398 404
399 405
400 bool VmService::SendIsolateStartupMessage(Dart_Port port) { 406 bool VmService::SendIsolateStartupMessage(Dart_Port port, Dart_Handle name) {
401 if (!IsRunning()) { 407 if (!IsRunning()) {
402 return false; 408 return false;
403 } 409 }
404 Dart_Isolate isolate = Dart_CurrentIsolate(); 410 Dart_Isolate isolate = Dart_CurrentIsolate();
405 ASSERT(isolate != NULL); 411 ASSERT(isolate != NULL);
406 ASSERT(Dart_GetMainPortId() == port); 412 ASSERT(Dart_GetMainPortId() == port);
407 Dart_Handle list = MakeServiceControlMessage(port); 413 Dart_Handle list =
408 Dart_ListSetAt(list, 0, 414 MakeServiceControlMessage(port, VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID);
409 Dart_NewInteger(VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID)); 415 ASSERT(!Dart_IsError(list));
416 Dart_Handle result = Dart_ListSetAt(list, 2, name);
417 ASSERT(!Dart_IsError(result));
410 return Dart_Post(port_, list); 418 return Dart_Post(port_, list);
411 } 419 }
412 420
413 421
414 bool VmService::SendIsolateShutdownMessage(Dart_Port port) { 422 bool VmService::SendIsolateShutdownMessage(Dart_Port port) {
415 if (!IsRunning()) { 423 if (!IsRunning()) {
416 return false; 424 return false;
417 } 425 }
418 Dart_Isolate isolate = Dart_CurrentIsolate(); 426 Dart_Isolate isolate = Dart_CurrentIsolate();
419 ASSERT(isolate != NULL); 427 ASSERT(isolate != NULL);
420 ASSERT(Dart_GetMainPortId() == port); 428 ASSERT(Dart_GetMainPortId() == port);
421 Dart_Handle list = MakeServiceControlMessage(port); 429 Dart_Handle list =
422 Dart_ListSetAt(list, 0, 430 MakeServiceControlMessage(port, VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID);
423 Dart_NewInteger(VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID)); 431 ASSERT(!Dart_IsError(list));
424 return Dart_Post(port_, list); 432 return Dart_Post(port_, list);
425 } 433 }
426 434
427 435
428 void VmService::VmServiceShutdownCallback(void* callback_data) { 436 void VmService::VmServiceShutdownCallback(void* callback_data) {
429 ASSERT(Dart_CurrentIsolate() != NULL); 437 ASSERT(Dart_CurrentIsolate() != NULL);
430 Dart_EnterScope(); 438 Dart_EnterScope();
431 VmService::SendIsolateShutdownMessage(Dart_GetMainPortId()); 439 VmService::SendIsolateShutdownMessage(Dart_GetMainPortId());
432 Dart_ExitScope(); 440 Dart_ExitScope();
433 } 441 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 if (!strcmp(function_name, entry.name) && 516 if (!strcmp(function_name, entry.name) &&
509 (num_arguments == entry.num_arguments)) { 517 (num_arguments == entry.num_arguments)) {
510 return entry.function; 518 return entry.function;
511 } 519 }
512 } 520 }
513 return NULL; 521 return NULL;
514 } 522 }
515 523
516 } // namespace bin 524 } // namespace bin
517 } // namespace dart 525 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/vmservice_impl.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698