| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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_isolate.h" | 5 #include "vm/service_isolate.h" |
| 6 | 6 |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 Isolate* ServiceIsolate::isolate_ = NULL; | 71 Isolate* ServiceIsolate::isolate_ = NULL; |
| 72 Dart_Port ServiceIsolate::port_ = ILLEGAL_PORT; | 72 Dart_Port ServiceIsolate::port_ = ILLEGAL_PORT; |
| 73 Dart_Port ServiceIsolate::load_port_ = ILLEGAL_PORT; | 73 Dart_Port ServiceIsolate::load_port_ = ILLEGAL_PORT; |
| 74 Dart_Port ServiceIsolate::origin_ = ILLEGAL_PORT; | 74 Dart_Port ServiceIsolate::origin_ = ILLEGAL_PORT; |
| 75 Dart_IsolateCreateCallback ServiceIsolate::create_callback_ = NULL; | 75 Dart_IsolateCreateCallback ServiceIsolate::create_callback_ = NULL; |
| 76 uint8_t* ServiceIsolate::exit_message_ = NULL; | 76 uint8_t* ServiceIsolate::exit_message_ = NULL; |
| 77 intptr_t ServiceIsolate::exit_message_length_ = 0; | 77 intptr_t ServiceIsolate::exit_message_length_ = 0; |
| 78 Monitor* ServiceIsolate::monitor_ = NULL; | 78 Monitor* ServiceIsolate::monitor_ = NULL; |
| 79 bool ServiceIsolate::initializing_ = true; | 79 bool ServiceIsolate::initializing_ = true; |
| 80 bool ServiceIsolate::shutting_down_ = false; | 80 bool ServiceIsolate::shutting_down_ = false; |
| 81 char* ServiceIsolate::server_address_ = NULL; |
| 82 |
| 83 void ServiceIsolate::SetServerAddress(const char* address) { |
| 84 if (server_address_ != NULL) { |
| 85 free(server_address_); |
| 86 server_address_ = NULL; |
| 87 } |
| 88 if (address == NULL) { |
| 89 return; |
| 90 } |
| 91 server_address_ = strdup(address); |
| 92 } |
| 81 | 93 |
| 82 | 94 |
| 83 bool ServiceIsolate::NameEquals(const char* name) { | 95 bool ServiceIsolate::NameEquals(const char* name) { |
| 84 ASSERT(name != NULL); | 96 ASSERT(name != NULL); |
| 85 return strcmp(name, kName) == 0; | 97 return strcmp(name, kName) == 0; |
| 86 } | 98 } |
| 87 | 99 |
| 88 | 100 |
| 89 bool ServiceIsolate::Exists() { | 101 bool ServiceIsolate::Exists() { |
| 90 MonitorLocker ml(monitor_); | 102 MonitorLocker ml(monitor_); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 MonitorLocker ml(monitor_); | 472 MonitorLocker ml(monitor_); |
| 461 shutting_down_ = true; | 473 shutting_down_ = true; |
| 462 } | 474 } |
| 463 SendServiceExitMessage(); | 475 SendServiceExitMessage(); |
| 464 { | 476 { |
| 465 MonitorLocker ml(monitor_); | 477 MonitorLocker ml(monitor_); |
| 466 while (shutting_down_ && (port_ != ILLEGAL_PORT)) { | 478 while (shutting_down_ && (port_ != ILLEGAL_PORT)) { |
| 467 ml.Wait(); | 479 ml.Wait(); |
| 468 } | 480 } |
| 469 } | 481 } |
| 482 if (server_address_ != NULL) { |
| 483 free(server_address_); |
| 484 server_address_ = NULL; |
| 485 } |
| 470 } | 486 } |
| 471 | 487 |
| 472 | 488 |
| 473 void ServiceIsolate::BootVmServiceLibrary() { | 489 void ServiceIsolate::BootVmServiceLibrary() { |
| 474 const Library& vmservice_library = | 490 const Library& vmservice_library = |
| 475 Library::Handle(Library::LookupLibrary(Symbols::DartVMService())); | 491 Library::Handle(Library::LookupLibrary(Symbols::DartVMService())); |
| 476 ASSERT(!vmservice_library.IsNull()); | 492 ASSERT(!vmservice_library.IsNull()); |
| 477 const String& boot_function_name = String::Handle(String::New("boot")); | 493 const String& boot_function_name = String::Handle(String::New("boot")); |
| 478 const Function& boot_function = | 494 const Function& boot_function = |
| 479 Function::Handle( | 495 Function::Handle( |
| 480 vmservice_library.LookupFunctionAllowPrivate(boot_function_name)); | 496 vmservice_library.LookupFunctionAllowPrivate(boot_function_name)); |
| 481 ASSERT(!boot_function.IsNull()); | 497 ASSERT(!boot_function.IsNull()); |
| 482 const Object& result = | 498 const Object& result = |
| 483 Object::Handle( | 499 Object::Handle( |
| 484 DartEntry::InvokeFunction(boot_function, Object::empty_array())); | 500 DartEntry::InvokeFunction(boot_function, Object::empty_array())); |
| 485 ASSERT(!result.IsNull()); | 501 ASSERT(!result.IsNull()); |
| 486 Dart_Port port = ILLEGAL_PORT; | 502 Dart_Port port = ILLEGAL_PORT; |
| 487 if (result.IsReceivePort()) { | 503 if (result.IsReceivePort()) { |
| 488 port = ReceivePort::Cast(result).Id(); | 504 port = ReceivePort::Cast(result).Id(); |
| 489 } | 505 } |
| 490 ASSERT(port != ILLEGAL_PORT); | 506 ASSERT(port != ILLEGAL_PORT); |
| 491 ServiceIsolate::SetServicePort(port); | 507 ServiceIsolate::SetServicePort(port); |
| 492 } | 508 } |
| 493 | 509 |
| 494 } // namespace dart | 510 } // namespace dart |
| OLD | NEW |