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

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

Issue 1053713003: Do not register service isolate descendants with service (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/vm/service_isolate.h ('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) 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const Integer& code_int = Integer::Handle(Integer::New(code)); 142 const Integer& code_int = Integer::Handle(Integer::New(code));
143 list.SetAt(0, code_int); 143 list.SetAt(0, code_int);
144 return list.raw(); 144 return list.raw();
145 } 145 }
146 146
147 147
148 const char* ServiceIsolate::kName = "vm-service"; 148 const char* ServiceIsolate::kName = "vm-service";
149 Isolate* ServiceIsolate::isolate_ = NULL; 149 Isolate* ServiceIsolate::isolate_ = NULL;
150 Dart_Port ServiceIsolate::port_ = ILLEGAL_PORT; 150 Dart_Port ServiceIsolate::port_ = ILLEGAL_PORT;
151 Dart_Port ServiceIsolate::load_port_ = ILLEGAL_PORT; 151 Dart_Port ServiceIsolate::load_port_ = ILLEGAL_PORT;
152 Dart_Port ServiceIsolate::origin_ = ILLEGAL_PORT;
152 Dart_IsolateCreateCallback ServiceIsolate::create_callback_ = NULL; 153 Dart_IsolateCreateCallback ServiceIsolate::create_callback_ = NULL;
153 uint8_t* ServiceIsolate::exit_message_ = NULL; 154 uint8_t* ServiceIsolate::exit_message_ = NULL;
154 intptr_t ServiceIsolate::exit_message_length_ = 0; 155 intptr_t ServiceIsolate::exit_message_length_ = 0;
155 Monitor* ServiceIsolate::monitor_ = NULL; 156 Monitor* ServiceIsolate::monitor_ = NULL;
156 bool ServiceIsolate::initializing_ = true; 157 bool ServiceIsolate::initializing_ = true;
157 bool ServiceIsolate::shutting_down_ = false; 158 bool ServiceIsolate::shutting_down_ = false;
158 159
159 160
160 class RegisterRunningIsolatesVisitor : public IsolateVisitor { 161 class RegisterRunningIsolatesVisitor : public IsolateVisitor {
161 public: 162 public:
(...skipping 11 matching lines...) Expand all
173 // Get function. 174 // Get function.
174 const String& function_name = 175 const String& function_name =
175 String::Handle(String::New("_registerIsolate")); 176 String::Handle(String::New("_registerIsolate"));
176 ASSERT(!function_name.IsNull()); 177 ASSERT(!function_name.IsNull());
177 register_function_ = library.LookupFunctionAllowPrivate(function_name); 178 register_function_ = library.LookupFunctionAllowPrivate(function_name);
178 ASSERT(!register_function_.IsNull()); 179 ASSERT(!register_function_.IsNull());
179 } 180 }
180 181
181 virtual void VisitIsolate(Isolate* isolate) { 182 virtual void VisitIsolate(Isolate* isolate) {
182 ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current())); 183 ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current()));
183 if (ServiceIsolate::IsServiceIsolate(isolate) || 184 if (ServiceIsolate::IsServiceIsolateDescendant(isolate) ||
184 (isolate == Dart::vm_isolate())) { 185 (isolate == Dart::vm_isolate())) {
185 // We do not register the service or vm isolate. 186 // We do not register the service (and descendants) or the vm-isolate.
186 return; 187 return;
187 } 188 }
188 // Setup arguments for call. 189 // Setup arguments for call.
189 Dart_Port port_id = isolate->main_port(); 190 Dart_Port port_id = isolate->main_port();
190 const Integer& port_int = Integer::Handle(Integer::New(port_id)); 191 const Integer& port_int = Integer::Handle(Integer::New(port_id));
191 ASSERT(!port_int.IsNull()); 192 ASSERT(!port_int.IsNull());
192 const SendPort& send_port = SendPort::Handle(SendPort::New(port_id)); 193 const SendPort& send_port = SendPort::Handle(SendPort::New(port_id));
193 const String& name = String::Handle(String::New(isolate->name())); 194 const String& name = String::Handle(String::New(isolate->name()));
194 ASSERT(!name.IsNull()); 195 ASSERT(!name.IsNull());
195 const Array& args = Array::Handle(Array::New(3)); 196 const Array& args = Array::Handle(Array::New(3));
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return (port_ != ILLEGAL_PORT) && (isolate_ != NULL); 371 return (port_ != ILLEGAL_PORT) && (isolate_ != NULL);
371 } 372 }
372 373
373 374
374 bool ServiceIsolate::IsServiceIsolate(Isolate* isolate) { 375 bool ServiceIsolate::IsServiceIsolate(Isolate* isolate) {
375 MonitorLocker ml(monitor_); 376 MonitorLocker ml(monitor_);
376 return isolate == isolate_; 377 return isolate == isolate_;
377 } 378 }
378 379
379 380
381 bool ServiceIsolate::IsServiceIsolateDescendant(Isolate* isolate) {
382 MonitorLocker ml(monitor_);
383 return isolate->origin_id() == origin_;
384 }
385
386
380 Dart_Port ServiceIsolate::Port() { 387 Dart_Port ServiceIsolate::Port() {
381 MonitorLocker ml(monitor_); 388 MonitorLocker ml(monitor_);
382 return port_; 389 return port_;
383 } 390 }
384 391
385 392
386 Dart_Port ServiceIsolate::WaitForLoadPort() { 393 Dart_Port ServiceIsolate::WaitForLoadPort() {
387 MonitorLocker ml(monitor_); 394 MonitorLocker ml(monitor_);
388 395
389 while (initializing_ && (load_port_ == ILLEGAL_PORT)) { 396 while (initializing_ && (load_port_ == ILLEGAL_PORT)) {
390 ml.Wait(); 397 ml.Wait();
391 } 398 }
392 399
393 return load_port_; 400 return load_port_;
394 } 401 }
395 402
396 403
397 Dart_Port ServiceIsolate::LoadPort() { 404 Dart_Port ServiceIsolate::LoadPort() {
398 MonitorLocker ml(monitor_); 405 MonitorLocker ml(monitor_);
399 return load_port_; 406 return load_port_;
400 } 407 }
401 408
402 409
403 bool ServiceIsolate::SendIsolateStartupMessage() { 410 bool ServiceIsolate::SendIsolateStartupMessage() {
404 if (!IsRunning()) { 411 if (!IsRunning()) {
405 return false; 412 return false;
406 } 413 }
407 Isolate* isolate = Isolate::Current(); 414 Isolate* isolate = Isolate::Current();
408 if (IsServiceIsolate(isolate)) { 415 if (IsServiceIsolateDescendant(isolate)) {
409 return false; 416 return false;
410 } 417 }
411 ASSERT(isolate != NULL); 418 ASSERT(isolate != NULL);
412 HANDLESCOPE(isolate); 419 HANDLESCOPE(isolate);
413 const String& name = String::Handle(String::New(isolate->name())); 420 const String& name = String::Handle(String::New(isolate->name()));
414 ASSERT(!name.IsNull()); 421 ASSERT(!name.IsNull());
415 const Array& list = Array::Handle( 422 const Array& list = Array::Handle(
416 MakeServiceControlMessage(Dart_GetMainPortId(), 423 MakeServiceControlMessage(Dart_GetMainPortId(),
417 VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID, 424 VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID,
418 name)); 425 name));
(...skipping 10 matching lines...) Expand all
429 return PortMap::PostMessage( 436 return PortMap::PostMessage(
430 new Message(port_, data, len, Message::kNormalPriority)); 437 new Message(port_, data, len, Message::kNormalPriority));
431 } 438 }
432 439
433 440
434 bool ServiceIsolate::SendIsolateShutdownMessage() { 441 bool ServiceIsolate::SendIsolateShutdownMessage() {
435 if (!IsRunning()) { 442 if (!IsRunning()) {
436 return false; 443 return false;
437 } 444 }
438 Isolate* isolate = Isolate::Current(); 445 Isolate* isolate = Isolate::Current();
439 if (IsServiceIsolate(isolate)) { 446 if (IsServiceIsolateDescendant(isolate)) {
440 return false; 447 return false;
441 } 448 }
442 ASSERT(isolate != NULL); 449 ASSERT(isolate != NULL);
443 HANDLESCOPE(isolate); 450 HANDLESCOPE(isolate);
444 const String& name = String::Handle(String::New(isolate->name())); 451 const String& name = String::Handle(String::New(isolate->name()));
445 ASSERT(!name.IsNull()); 452 ASSERT(!name.IsNull());
446 const Array& list = Array::Handle( 453 const Array& list = Array::Handle(
447 MakeServiceControlMessage(Dart_GetMainPortId(), 454 MakeServiceControlMessage(Dart_GetMainPortId(),
448 VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID, 455 VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID,
449 name)); 456 name));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 MonitorLocker ml(monitor_); 490 MonitorLocker ml(monitor_);
484 port_ = port; 491 port_ = port;
485 } 492 }
486 493
487 494
488 void ServiceIsolate::SetServiceIsolate(Isolate* isolate) { 495 void ServiceIsolate::SetServiceIsolate(Isolate* isolate) {
489 MonitorLocker ml(monitor_); 496 MonitorLocker ml(monitor_);
490 isolate_ = isolate; 497 isolate_ = isolate;
491 if (isolate_ != NULL) { 498 if (isolate_ != NULL) {
492 isolate_->is_service_isolate_ = true; 499 isolate_->is_service_isolate_ = true;
500 origin_ = isolate_->origin_id();
501 } else {
502 origin_ = ILLEGAL_PORT;
493 } 503 }
494 } 504 }
495 505
496 void ServiceIsolate::SetLoadPort(Dart_Port port) { 506 void ServiceIsolate::SetLoadPort(Dart_Port port) {
497 MonitorLocker ml(monitor_); 507 MonitorLocker ml(monitor_);
498 load_port_ = port; 508 load_port_ = port;
499 } 509 }
500 510
501 511
502 void ServiceIsolate::MaybeInjectVMServiceLibrary(Isolate* isolate) { 512 void ServiceIsolate::MaybeInjectVMServiceLibrary(Isolate* isolate) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 return result; 783 return result;
774 } 784 }
775 Dart_Handle source = GetSource(url_string); 785 Dart_Handle source = GetSource(url_string);
776 if (Dart_IsError(source)) { 786 if (Dart_IsError(source)) {
777 return source; 787 return source;
778 } 788 }
779 return Dart_LoadSource(library, url, source, 0, 0); 789 return Dart_LoadSource(library, url, source, 0, 0);
780 } 790 }
781 791
782 } // namespace dart 792 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service_isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698