| 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 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2563 thread->heap_ = heap(); | 2563 thread->heap_ = heap(); |
| 2564 thread->set_os_thread(os_thread); | 2564 thread->set_os_thread(os_thread); |
| 2565 ASSERT(thread->execution_state() == Thread::kThreadInNative); | 2565 ASSERT(thread->execution_state() == Thread::kThreadInNative); |
| 2566 thread->set_execution_state(Thread::kThreadInVM); | 2566 thread->set_execution_state(Thread::kThreadInVM); |
| 2567 thread->set_safepoint_state(0); | 2567 thread->set_safepoint_state(0); |
| 2568 thread->set_vm_tag(VMTag::kVMTagId); | 2568 thread->set_vm_tag(VMTag::kVMTagId); |
| 2569 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2569 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2570 os_thread->set_thread(thread); | 2570 os_thread->set_thread(thread); |
| 2571 if (is_mutator) { | 2571 if (is_mutator) { |
| 2572 scheduled_mutator_thread_ = thread; | 2572 scheduled_mutator_thread_ = thread; |
| 2573 if (this != Dart::vm_isolate()) { |
| 2574 scheduled_mutator_thread_->set_top(heap()->new_space()->top()); |
| 2575 scheduled_mutator_thread_->set_end(heap()->new_space()->end()); |
| 2576 } |
| 2573 } | 2577 } |
| 2574 Thread::SetCurrent(thread); | 2578 Thread::SetCurrent(thread); |
| 2575 os_thread->EnableThreadInterrupts(); | 2579 os_thread->EnableThreadInterrupts(); |
| 2576 } | 2580 } |
| 2577 return thread; | 2581 return thread; |
| 2578 } | 2582 } |
| 2579 | 2583 |
| 2580 void Isolate::UnscheduleThread(Thread* thread, | 2584 void Isolate::UnscheduleThread(Thread* thread, |
| 2581 bool is_mutator, | 2585 bool is_mutator, |
| 2582 bool bypass_safepoint) { | 2586 bool bypass_safepoint) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2601 if (!bypass_safepoint) { | 2605 if (!bypass_safepoint) { |
| 2602 // Ensure that the thread reports itself as being at a safepoint. | 2606 // Ensure that the thread reports itself as being at a safepoint. |
| 2603 thread->EnterSafepoint(); | 2607 thread->EnterSafepoint(); |
| 2604 } | 2608 } |
| 2605 OSThread* os_thread = thread->os_thread(); | 2609 OSThread* os_thread = thread->os_thread(); |
| 2606 ASSERT(os_thread != NULL); | 2610 ASSERT(os_thread != NULL); |
| 2607 os_thread->DisableThreadInterrupts(); | 2611 os_thread->DisableThreadInterrupts(); |
| 2608 os_thread->set_thread(NULL); | 2612 os_thread->set_thread(NULL); |
| 2609 OSThread::SetCurrent(os_thread); | 2613 OSThread::SetCurrent(os_thread); |
| 2610 if (is_mutator) { | 2614 if (is_mutator) { |
| 2615 if (this != Dart::vm_isolate()) { |
| 2616 heap()->new_space()->set_top(scheduled_mutator_thread_->top_); |
| 2617 heap()->new_space()->set_end(scheduled_mutator_thread_->end_); |
| 2618 } |
| 2619 scheduled_mutator_thread_->top_ = 0; |
| 2620 scheduled_mutator_thread_->end_ = 0; |
| 2611 scheduled_mutator_thread_ = NULL; | 2621 scheduled_mutator_thread_ = NULL; |
| 2612 } | 2622 } |
| 2613 thread->isolate_ = NULL; | 2623 thread->isolate_ = NULL; |
| 2614 thread->heap_ = NULL; | 2624 thread->heap_ = NULL; |
| 2615 thread->set_os_thread(NULL); | 2625 thread->set_os_thread(NULL); |
| 2616 thread->set_execution_state(Thread::kThreadInNative); | 2626 thread->set_execution_state(Thread::kThreadInNative); |
| 2617 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2627 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
| 2618 thread->clear_pending_functions(); | 2628 thread->clear_pending_functions(); |
| 2619 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2629 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2620 // Return thread structure. | 2630 // Return thread structure. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2839 void IsolateSpawnState::DecrementSpawnCount() { | 2849 void IsolateSpawnState::DecrementSpawnCount() { |
| 2840 ASSERT(spawn_count_monitor_ != NULL); | 2850 ASSERT(spawn_count_monitor_ != NULL); |
| 2841 ASSERT(spawn_count_ != NULL); | 2851 ASSERT(spawn_count_ != NULL); |
| 2842 MonitorLocker ml(spawn_count_monitor_); | 2852 MonitorLocker ml(spawn_count_monitor_); |
| 2843 ASSERT(*spawn_count_ > 0); | 2853 ASSERT(*spawn_count_ > 0); |
| 2844 *spawn_count_ = *spawn_count_ - 1; | 2854 *spawn_count_ = *spawn_count_ - 1; |
| 2845 ml.Notify(); | 2855 ml.Notify(); |
| 2846 } | 2856 } |
| 2847 | 2857 |
| 2848 } // namespace dart | 2858 } // namespace dart |
| OLD | NEW |