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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 result->LowLevelShutdown(); | 982 result->LowLevelShutdown(); |
983 Thread::ExitIsolate(); | 983 Thread::ExitIsolate(); |
984 delete result; | 984 delete result; |
985 return NULL; | 985 return NULL; |
986 } | 986 } |
987 | 987 |
988 return result; | 988 return result; |
989 } | 989 } |
990 | 990 |
991 | 991 |
| 992 Thread* Isolate::mutator_thread() const { |
| 993 ASSERT(thread_registry() != NULL); |
| 994 return thread_registry()->mutator_thread(); |
| 995 } |
| 996 |
| 997 |
992 void Isolate::SetupInstructionsSnapshotPage( | 998 void Isolate::SetupInstructionsSnapshotPage( |
993 const uint8_t* instructions_snapshot_buffer) { | 999 const uint8_t* instructions_snapshot_buffer) { |
994 InstructionsSnapshot snapshot(instructions_snapshot_buffer); | 1000 InstructionsSnapshot snapshot(instructions_snapshot_buffer); |
995 #if defined(DEBUG) | 1001 #if defined(DEBUG) |
996 if (FLAG_trace_isolates) { | 1002 if (FLAG_trace_isolates) { |
997 OS::Print("Precompiled instructions are at [0x%" Px ", 0x%" Px ")\n", | 1003 OS::Print("Precompiled instructions are at [0x%" Px ", 0x%" Px ")\n", |
998 reinterpret_cast<uword>(snapshot.instructions_start()), | 1004 reinterpret_cast<uword>(snapshot.instructions_start()), |
999 reinterpret_cast<uword>(snapshot.instructions_start()) + | 1005 reinterpret_cast<uword>(snapshot.instructions_start()) + |
1000 snapshot.instructions_size()); | 1006 snapshot.instructions_size()); |
1001 } | 1007 } |
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 Thread* thread = NULL; | 2584 Thread* thread = NULL; |
2579 OSThread* os_thread = OSThread::Current(); | 2585 OSThread* os_thread = OSThread::Current(); |
2580 if (os_thread != NULL) { | 2586 if (os_thread != NULL) { |
2581 // We are about to associate the thread with an isolate and it would | 2587 // We are about to associate the thread with an isolate and it would |
2582 // not be possible to correctly track no_safepoint_scope_depth for the | 2588 // not be possible to correctly track no_safepoint_scope_depth for the |
2583 // thread in the constructor/destructor of MonitorLocker, | 2589 // thread in the constructor/destructor of MonitorLocker, |
2584 // so we create a MonitorLocker object which does not do any | 2590 // so we create a MonitorLocker object which does not do any |
2585 // no_safepoint_scope_depth increments/decrements. | 2591 // no_safepoint_scope_depth increments/decrements. |
2586 MonitorLocker ml(threads_lock(), false); | 2592 MonitorLocker ml(threads_lock(), false); |
2587 | 2593 |
| 2594 // Check to make sure we don't already have a mutator thread. |
| 2595 if (is_mutator && mutator_thread_ != NULL) { |
| 2596 return NULL; |
| 2597 } |
| 2598 |
2588 // If a safepoint operation is in progress wait for it | 2599 // If a safepoint operation is in progress wait for it |
2589 // to finish before scheduling this thread in. | 2600 // to finish before scheduling this thread in. |
2590 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) { | 2601 while (!bypass_safepoint && safepoint_handler()->SafepointInProgress()) { |
2591 ml.Wait(); | 2602 ml.Wait(); |
2592 } | 2603 } |
2593 | 2604 |
2594 // Now get a free Thread structure. | 2605 // Now get a free Thread structure. |
2595 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); | 2606 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); |
2596 ASSERT(thread != NULL); | 2607 ASSERT(thread != NULL); |
2597 | 2608 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2891 void IsolateSpawnState::DecrementSpawnCount() { | 2902 void IsolateSpawnState::DecrementSpawnCount() { |
2892 ASSERT(spawn_count_monitor_ != NULL); | 2903 ASSERT(spawn_count_monitor_ != NULL); |
2893 ASSERT(spawn_count_ != NULL); | 2904 ASSERT(spawn_count_ != NULL); |
2894 MonitorLocker ml(spawn_count_monitor_); | 2905 MonitorLocker ml(spawn_count_monitor_); |
2895 ASSERT(*spawn_count_ > 0); | 2906 ASSERT(*spawn_count_ > 0); |
2896 *spawn_count_ = *spawn_count_ - 1; | 2907 *spawn_count_ = *spawn_count_ - 1; |
2897 ml.Notify(); | 2908 ml.Notify(); |
2898 } | 2909 } |
2899 | 2910 |
2900 } // namespace dart | 2911 } // namespace dart |
OLD | NEW |