OLD | NEW |
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/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/json.h" | 9 #include "platform/json.h" |
10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
11 #include "vm/compiler_stats.h" | 11 #include "vm/compiler_stats.h" |
12 #include "vm/coverage.h" | 12 #include "vm/coverage.h" |
13 #include "vm/dart_api_state.h" | 13 #include "vm/dart_api_state.h" |
14 #include "vm/dart_entry.h" | 14 #include "vm/dart_entry.h" |
15 #include "vm/debugger.h" | 15 #include "vm/debugger.h" |
16 #include "vm/deopt_instructions.h" | 16 #include "vm/deopt_instructions.h" |
17 #include "vm/heap.h" | 17 #include "vm/heap.h" |
18 #include "vm/lockers.h" | 18 #include "vm/lockers.h" |
19 #include "vm/log.h" | 19 #include "vm/log.h" |
20 #include "vm/message_handler.h" | 20 #include "vm/message_handler.h" |
21 #include "vm/object_id_ring.h" | 21 #include "vm/object_id_ring.h" |
22 #include "vm/object_store.h" | 22 #include "vm/object_store.h" |
23 #include "vm/parser.h" | 23 #include "vm/parser.h" |
24 #include "vm/port.h" | 24 #include "vm/port.h" |
25 #include "vm/profiler.h" | 25 #include "vm/profiler.h" |
26 #include "vm/reusable_handles.h" | 26 #include "vm/reusable_handles.h" |
27 #include "vm/service.h" | 27 #include "vm/service.h" |
| 28 #include "vm/service_isolate.h" |
28 #include "vm/simulator.h" | 29 #include "vm/simulator.h" |
29 #include "vm/stack_frame.h" | 30 #include "vm/stack_frame.h" |
30 #include "vm/stub_code.h" | 31 #include "vm/stub_code.h" |
31 #include "vm/symbols.h" | 32 #include "vm/symbols.h" |
32 #include "vm/tags.h" | 33 #include "vm/tags.h" |
33 #include "vm/os_thread.h" | 34 #include "vm/os_thread.h" |
34 #include "vm/thread_interrupter.h" | 35 #include "vm/thread_interrupter.h" |
35 #include "vm/timer.h" | 36 #include "vm/timer.h" |
36 #include "vm/visitor.h" | 37 #include "vm/visitor.h" |
37 | 38 |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 685 |
685 return result; | 686 return result; |
686 } | 687 } |
687 | 688 |
688 | 689 |
689 void Isolate::BuildName(const char* name_prefix) { | 690 void Isolate::BuildName(const char* name_prefix) { |
690 ASSERT(name_ == NULL); | 691 ASSERT(name_ == NULL); |
691 if (name_prefix == NULL) { | 692 if (name_prefix == NULL) { |
692 name_prefix = "isolate"; | 693 name_prefix = "isolate"; |
693 } | 694 } |
694 if (Service::IsServiceIsolateName(name_prefix)) { | 695 if (ServiceIsolate::NameEquals(name_prefix)) { |
695 name_ = strdup(name_prefix); | 696 name_ = strdup(name_prefix); |
696 return; | 697 return; |
697 } | 698 } |
698 const char* kFormat = "%s-%lld"; | 699 const char* kFormat = "%s-%lld"; |
699 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1; | 700 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name_prefix, main_port()) + 1; |
700 name_ = reinterpret_cast<char*>(malloc(len)); | 701 name_ = reinterpret_cast<char*>(malloc(len)); |
701 OS::SNPrint(name_, len, kFormat, name_prefix, main_port()); | 702 OS::SNPrint(name_, len, kFormat, name_prefix, main_port()); |
702 } | 703 } |
703 | 704 |
704 | 705 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 bool Isolate::MakeRunnable() { | 804 bool Isolate::MakeRunnable() { |
804 ASSERT(Isolate::Current() == NULL); | 805 ASSERT(Isolate::Current() == NULL); |
805 MutexLocker ml(mutex_); | 806 MutexLocker ml(mutex_); |
806 // Check if we are in a valid state to make the isolate runnable. | 807 // Check if we are in a valid state to make the isolate runnable. |
807 if (is_runnable_ == true) { | 808 if (is_runnable_ == true) { |
808 return false; // Already runnable. | 809 return false; // Already runnable. |
809 } | 810 } |
810 // Set the isolate as runnable and if we are being spawned schedule | 811 // Set the isolate as runnable and if we are being spawned schedule |
811 // isolate on thread pool for execution. | 812 // isolate on thread pool for execution. |
812 is_runnable_ = true; | 813 is_runnable_ = true; |
813 if (!Service::IsServiceIsolate(this)) { | 814 if (!ServiceIsolate::IsServiceIsolate(this)) { |
814 message_handler()->set_pause_on_start(FLAG_pause_isolates_on_start); | 815 message_handler()->set_pause_on_start(FLAG_pause_isolates_on_start); |
815 message_handler()->set_pause_on_exit(FLAG_pause_isolates_on_exit); | 816 message_handler()->set_pause_on_exit(FLAG_pause_isolates_on_exit); |
816 } | 817 } |
817 IsolateSpawnState* state = spawn_state(); | 818 IsolateSpawnState* state = spawn_state(); |
818 if (state != NULL) { | 819 if (state != NULL) { |
819 ASSERT(this == state->isolate()); | 820 ASSERT(this == state->isolate()); |
820 Run(); | 821 Run(); |
821 } | 822 } |
822 return true; | 823 return true; |
823 } | 824 } |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 serialized_message_, serialized_message_len_); | 1673 serialized_message_, serialized_message_len_); |
1673 } | 1674 } |
1674 | 1675 |
1675 | 1676 |
1676 void IsolateSpawnState::Cleanup() { | 1677 void IsolateSpawnState::Cleanup() { |
1677 SwitchIsolateScope switch_scope(I); | 1678 SwitchIsolateScope switch_scope(I); |
1678 Dart::ShutdownIsolate(); | 1679 Dart::ShutdownIsolate(); |
1679 } | 1680 } |
1680 | 1681 |
1681 } // namespace dart | 1682 } // namespace dart |
OLD | NEW |