| 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 2651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2662 thread->heap_ = heap(); | 2662 thread->heap_ = heap(); |
| 2663 thread->set_os_thread(os_thread); | 2663 thread->set_os_thread(os_thread); |
| 2664 ASSERT(thread->execution_state() == Thread::kThreadInNative); | 2664 ASSERT(thread->execution_state() == Thread::kThreadInNative); |
| 2665 thread->set_execution_state(Thread::kThreadInVM); | 2665 thread->set_execution_state(Thread::kThreadInVM); |
| 2666 thread->set_safepoint_state(0); | 2666 thread->set_safepoint_state(0); |
| 2667 thread->set_vm_tag(VMTag::kVMTagId); | 2667 thread->set_vm_tag(VMTag::kVMTagId); |
| 2668 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2668 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2669 os_thread->set_thread(thread); | 2669 os_thread->set_thread(thread); |
| 2670 if (is_mutator) { | 2670 if (is_mutator) { |
| 2671 mutator_thread_ = thread; | 2671 mutator_thread_ = thread; |
| 2672 if (this != Dart::vm_isolate()) { |
| 2673 mutator_thread_->set_top(heap()->new_space()->top()); |
| 2674 mutator_thread_->set_end(heap()->new_space()->end()); |
| 2675 } |
| 2672 } | 2676 } |
| 2673 Thread::SetCurrent(thread); | 2677 Thread::SetCurrent(thread); |
| 2674 os_thread->EnableThreadInterrupts(); | 2678 os_thread->EnableThreadInterrupts(); |
| 2675 } | 2679 } |
| 2676 return thread; | 2680 return thread; |
| 2677 } | 2681 } |
| 2678 | 2682 |
| 2679 | 2683 |
| 2680 void Isolate::UnscheduleThread(Thread* thread, | 2684 void Isolate::UnscheduleThread(Thread* thread, |
| 2681 bool is_mutator, | 2685 bool is_mutator, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2701 if (!bypass_safepoint) { | 2705 if (!bypass_safepoint) { |
| 2702 // Ensure that the thread reports itself as being at a safepoint. | 2706 // Ensure that the thread reports itself as being at a safepoint. |
| 2703 thread->EnterSafepoint(); | 2707 thread->EnterSafepoint(); |
| 2704 } | 2708 } |
| 2705 OSThread* os_thread = thread->os_thread(); | 2709 OSThread* os_thread = thread->os_thread(); |
| 2706 ASSERT(os_thread != NULL); | 2710 ASSERT(os_thread != NULL); |
| 2707 os_thread->DisableThreadInterrupts(); | 2711 os_thread->DisableThreadInterrupts(); |
| 2708 os_thread->set_thread(NULL); | 2712 os_thread->set_thread(NULL); |
| 2709 OSThread::SetCurrent(os_thread); | 2713 OSThread::SetCurrent(os_thread); |
| 2710 if (is_mutator) { | 2714 if (is_mutator) { |
| 2715 if (this != Dart::vm_isolate()) { |
| 2716 heap()->new_space()->set_top(mutator_thread_->top_); |
| 2717 heap()->new_space()->set_end(mutator_thread_->end_); |
| 2718 } |
| 2719 mutator_thread_->top_ = 0; |
| 2720 mutator_thread_->end_ = 0; |
| 2711 mutator_thread_ = NULL; | 2721 mutator_thread_ = NULL; |
| 2712 } | 2722 } |
| 2713 thread->isolate_ = NULL; | 2723 thread->isolate_ = NULL; |
| 2714 thread->heap_ = NULL; | 2724 thread->heap_ = NULL; |
| 2715 thread->set_os_thread(NULL); | 2725 thread->set_os_thread(NULL); |
| 2716 thread->set_execution_state(Thread::kThreadInNative); | 2726 thread->set_execution_state(Thread::kThreadInNative); |
| 2717 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2727 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
| 2718 thread->clear_pending_functions(); | 2728 thread->clear_pending_functions(); |
| 2719 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2729 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2720 // Return thread structure. | 2730 // Return thread structure. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2948 void IsolateSpawnState::DecrementSpawnCount() { | 2958 void IsolateSpawnState::DecrementSpawnCount() { |
| 2949 ASSERT(spawn_count_monitor_ != NULL); | 2959 ASSERT(spawn_count_monitor_ != NULL); |
| 2950 ASSERT(spawn_count_ != NULL); | 2960 ASSERT(spawn_count_ != NULL); |
| 2951 MonitorLocker ml(spawn_count_monitor_); | 2961 MonitorLocker ml(spawn_count_monitor_); |
| 2952 ASSERT(*spawn_count_ > 0); | 2962 ASSERT(*spawn_count_ > 0); |
| 2953 *spawn_count_ = *spawn_count_ - 1; | 2963 *spawn_count_ = *spawn_count_ - 1; |
| 2954 ml.Notify(); | 2964 ml.Notify(); |
| 2955 } | 2965 } |
| 2956 | 2966 |
| 2957 } // namespace dart | 2967 } // namespace dart |
| OLD | NEW |