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 2640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2651 // Now get a free Thread structure. | 2651 // Now get a free Thread structure. |
2652 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); | 2652 thread = thread_registry()->GetFreeThreadLocked(this, is_mutator); |
2653 ASSERT(thread != NULL); | 2653 ASSERT(thread != NULL); |
2654 | 2654 |
2655 thread->ResetHighWatermark(); | 2655 thread->ResetHighWatermark(); |
2656 | 2656 |
2657 // Set up other values and set the TLS value. | 2657 // Set up other values and set the TLS value. |
2658 thread->isolate_ = this; | 2658 thread->isolate_ = this; |
2659 ASSERT(heap() != NULL); | 2659 ASSERT(heap() != NULL); |
2660 thread->heap_ = heap(); | 2660 thread->heap_ = heap(); |
2661 | |
2661 thread->set_os_thread(os_thread); | 2662 thread->set_os_thread(os_thread); |
2662 ASSERT(thread->execution_state() == Thread::kThreadInNative); | 2663 ASSERT(thread->execution_state() == Thread::kThreadInNative); |
2663 thread->set_execution_state(Thread::kThreadInVM); | 2664 thread->set_execution_state(Thread::kThreadInVM); |
2664 thread->set_safepoint_state(0); | 2665 thread->set_safepoint_state(0); |
2665 thread->set_vm_tag(VMTag::kVMTagId); | 2666 thread->set_vm_tag(VMTag::kVMTagId); |
2666 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2667 ASSERT(thread->no_safepoint_scope_depth() == 0); |
2667 os_thread->set_thread(thread); | 2668 os_thread->set_thread(thread); |
2668 if (is_mutator) { | 2669 if (is_mutator) { |
2669 mutator_thread_ = thread; | 2670 mutator_thread_ = thread; |
rmacnak
2017/07/05 17:39:52
// Grab an allocation area.
danunez
2017/07/05 18:12:55
Done.
| |
2671 if (this != Dart::vm_isolate()) { | |
rmacnak
2017/07/05 17:39:52
Is there a property of the heap we can check inste
danunez
2017/07/05 18:12:55
That should work. I'll give it a shot.
| |
2672 mutator_thread_->top_ = *(heap()->new_space()->TopAddress()); | |
rmacnak
2017/07/05 17:39:52
*top_address() -> top()
danunez
2017/07/05 18:12:55
Done.
| |
2673 mutator_thread_->end_ = *(heap()->new_space()->EndAddress()); | |
2674 } | |
2670 } | 2675 } |
2671 Thread::SetCurrent(thread); | 2676 Thread::SetCurrent(thread); |
2672 os_thread->EnableThreadInterrupts(); | 2677 os_thread->EnableThreadInterrupts(); |
2673 } | 2678 } |
2674 return thread; | 2679 return thread; |
2675 } | 2680 } |
2676 | 2681 |
2677 | 2682 |
2678 void Isolate::UnscheduleThread(Thread* thread, | 2683 void Isolate::UnscheduleThread(Thread* thread, |
2679 bool is_mutator, | 2684 bool is_mutator, |
(...skipping 19 matching lines...) Expand all Loading... | |
2699 if (!bypass_safepoint) { | 2704 if (!bypass_safepoint) { |
2700 // Ensure that the thread reports itself as being at a safepoint. | 2705 // Ensure that the thread reports itself as being at a safepoint. |
2701 thread->EnterSafepoint(); | 2706 thread->EnterSafepoint(); |
2702 } | 2707 } |
2703 OSThread* os_thread = thread->os_thread(); | 2708 OSThread* os_thread = thread->os_thread(); |
2704 ASSERT(os_thread != NULL); | 2709 ASSERT(os_thread != NULL); |
2705 os_thread->DisableThreadInterrupts(); | 2710 os_thread->DisableThreadInterrupts(); |
2706 os_thread->set_thread(NULL); | 2711 os_thread->set_thread(NULL); |
2707 OSThread::SetCurrent(os_thread); | 2712 OSThread::SetCurrent(os_thread); |
2708 if (is_mutator) { | 2713 if (is_mutator) { |
2714 if (this != Dart::vm_isolate()) { | |
rmacnak
2017/07/05 17:39:52
// Release allocation area.
danunez
2017/07/05 18:12:55
Done.
| |
2715 *(heap()->new_space()->TopAddress()) = mutator_thread_->top_; | |
rmacnak
2017/07/05 17:39:52
*top_address() -> set_top()
danunez
2017/07/05 18:12:55
Done.
| |
2716 *(heap()->new_space()->EndAddress()) = mutator_thread_->end_; | |
2717 } | |
2718 mutator_thread_->top_ = 0; | |
2719 mutator_thread_->end_ = 0; | |
2709 mutator_thread_ = NULL; | 2720 mutator_thread_ = NULL; |
2710 } | 2721 } |
2711 thread->isolate_ = NULL; | 2722 thread->isolate_ = NULL; |
2712 thread->heap_ = NULL; | 2723 thread->heap_ = NULL; |
2713 thread->set_os_thread(NULL); | 2724 thread->set_os_thread(NULL); |
2714 thread->set_execution_state(Thread::kThreadInNative); | 2725 thread->set_execution_state(Thread::kThreadInNative); |
2715 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2726 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
2716 thread->clear_pending_functions(); | 2727 thread->clear_pending_functions(); |
2717 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2728 ASSERT(thread->no_safepoint_scope_depth() == 0); |
2718 // Return thread structure. | 2729 // Return thread structure. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2946 void IsolateSpawnState::DecrementSpawnCount() { | 2957 void IsolateSpawnState::DecrementSpawnCount() { |
2947 ASSERT(spawn_count_monitor_ != NULL); | 2958 ASSERT(spawn_count_monitor_ != NULL); |
2948 ASSERT(spawn_count_ != NULL); | 2959 ASSERT(spawn_count_ != NULL); |
2949 MonitorLocker ml(spawn_count_monitor_); | 2960 MonitorLocker ml(spawn_count_monitor_); |
2950 ASSERT(*spawn_count_ > 0); | 2961 ASSERT(*spawn_count_ > 0); |
2951 *spawn_count_ = *spawn_count_ - 1; | 2962 *spawn_count_ = *spawn_count_ - 1; |
2952 ml.Notify(); | 2963 ml.Notify(); |
2953 } | 2964 } |
2954 | 2965 |
2955 } // namespace dart | 2966 } // namespace dart |
OLD | NEW |