| 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 isolate->RemoveTimelineEventRecorder(); | 645 isolate->RemoveTimelineEventRecorder(); |
| 646 | 646 |
| 647 Thread::ExitIsolate(); | 647 Thread::ExitIsolate(); |
| 648 | 648 |
| 649 ServiceIsolate::ConstructExitMessageAndCache(isolate); | 649 ServiceIsolate::ConstructExitMessageAndCache(isolate); |
| 650 | 650 |
| 651 RunMain(isolate); | 651 RunMain(isolate); |
| 652 | 652 |
| 653 ServiceIsolate::FinishedInitializing(); | 653 ServiceIsolate::FinishedInitializing(); |
| 654 | 654 |
| 655 isolate->message_handler()->Run(Dart::thread_pool(), | 655 isolate->message_handler()->Run(NULL, |
| 656 NULL, | |
| 657 ShutdownIsolate, | 656 ShutdownIsolate, |
| 658 reinterpret_cast<uword>(isolate)); | 657 reinterpret_cast<uword>(isolate)); |
| 659 } | 658 } |
| 660 | 659 |
| 661 protected: | 660 protected: |
| 662 static void ShutdownIsolate(uword parameter) { | 661 static void ShutdownIsolate(uword parameter) { |
| 663 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); | 662 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); |
| 664 ASSERT(ServiceIsolate::IsServiceIsolate(isolate)); | 663 ASSERT(ServiceIsolate::IsServiceIsolate(isolate)); |
| 665 { | 664 { |
| 666 // Print the error if there is one. This may execute dart code to | 665 // Print the error if there is one. This may execute dart code to |
| 667 // print the exception object, so we need to use a StartIsolateScope. | 666 // print the exception object, so we need to use a StartIsolateScope. |
| 668 StartIsolateScope start_scope(isolate); | 667 StartIsolateScope start_scope(isolate); |
| 669 StackZone zone(isolate); | 668 StackZone zone(isolate); |
| 670 HandleScope handle_scope(isolate); | 669 HandleScope handle_scope(isolate); |
| 670 |
| 671 ServiceIsolate::KillAllIsolates(); |
| 672 |
| 671 Error& error = Error::Handle(); | 673 Error& error = Error::Handle(); |
| 672 error = isolate->object_store()->sticky_error(); | 674 error = isolate->object_store()->sticky_error(); |
| 673 if (!error.IsNull()) { | 675 if (!error.IsNull()) { |
| 674 OS::PrintErr("vm-service: Error: %s\n", error.ToErrorCString()); | 676 OS::PrintErr("vm-service: Error: %s\n", error.ToErrorCString()); |
| 675 } | 677 } |
| 676 Dart::RunShutdownCallback(); | 678 Dart::RunShutdownCallback(); |
| 677 } | 679 } |
| 678 { | 680 { |
| 679 // Shut the isolate down. | 681 // Shut the isolate down. |
| 680 SwitchIsolateScope switch_scope(isolate); | 682 SwitchIsolateScope switch_scope(isolate); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 }; | 739 }; |
| 738 | 740 |
| 739 | 741 |
| 740 void ServiceIsolate::Run() { | 742 void ServiceIsolate::Run() { |
| 741 ASSERT(monitor_ == NULL); | 743 ASSERT(monitor_ == NULL); |
| 742 monitor_ = new Monitor(); | 744 monitor_ = new Monitor(); |
| 743 ASSERT(monitor_ != NULL); | 745 ASSERT(monitor_ != NULL); |
| 744 // Grab the isolate create callback here to avoid race conditions with tests | 746 // Grab the isolate create callback here to avoid race conditions with tests |
| 745 // that change this after Dart_Initialize returns. | 747 // that change this after Dart_Initialize returns. |
| 746 create_callback_ = Isolate::CreateCallback(); | 748 create_callback_ = Isolate::CreateCallback(); |
| 747 Dart::thread_pool()->Run(new RunServiceTask()); | 749 ThreadPool::Run(new RunServiceTask()); |
| 748 } | 750 } |
| 749 | 751 |
| 750 | 752 |
| 751 void ServiceIsolate::Shutdown() { | 753 void ServiceIsolate::Shutdown() { |
| 752 if (!IsRunning()) { | 754 if (!IsRunning()) { |
| 753 return; | 755 return; |
| 754 } | 756 } |
| 755 { | 757 { |
| 756 MonitorLocker ml(monitor_); | 758 MonitorLocker ml(monitor_); |
| 757 shutting_down_ = true; | 759 shutting_down_ = true; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 if (Dart_IsError(result)) { | 807 if (Dart_IsError(result)) { |
| 806 return result; | 808 return result; |
| 807 } | 809 } |
| 808 Dart_Handle source = GetSource(url_string); | 810 Dart_Handle source = GetSource(url_string); |
| 809 if (Dart_IsError(source)) { | 811 if (Dart_IsError(source)) { |
| 810 return source; | 812 return source; |
| 811 } | 813 } |
| 812 return Dart_LoadSource(library, url, source, 0, 0); | 814 return Dart_LoadSource(library, url, source, 0, 0); |
| 813 } | 815 } |
| 814 | 816 |
| 817 |
| 818 void ServiceIsolate::KillAllIsolates() { |
| 819 Isolate::KillAllIsolates(isolate_); |
| 820 } |
| 821 |
| 815 } // namespace dart | 822 } // namespace dart |
| OLD | NEW |