| 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 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2556 thread->heap_ = heap(); | 2556 thread->heap_ = heap(); |
| 2557 thread->set_os_thread(os_thread); | 2557 thread->set_os_thread(os_thread); |
| 2558 ASSERT(thread->execution_state() == Thread::kThreadInNative); | 2558 ASSERT(thread->execution_state() == Thread::kThreadInNative); |
| 2559 thread->set_execution_state(Thread::kThreadInVM); | 2559 thread->set_execution_state(Thread::kThreadInVM); |
| 2560 thread->set_safepoint_state(0); | 2560 thread->set_safepoint_state(0); |
| 2561 thread->set_vm_tag(VMTag::kVMTagId); | 2561 thread->set_vm_tag(VMTag::kVMTagId); |
| 2562 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2562 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2563 os_thread->set_thread(thread); | 2563 os_thread->set_thread(thread); |
| 2564 if (is_mutator) { | 2564 if (is_mutator) { |
| 2565 scheduled_mutator_thread_ = thread; | 2565 scheduled_mutator_thread_ = thread; |
| 2566 if (this != Dart::vm_isolate()) { | |
| 2567 scheduled_mutator_thread_->set_top(heap()->new_space()->top()); | |
| 2568 scheduled_mutator_thread_->set_end(heap()->new_space()->end()); | |
| 2569 } | |
| 2570 } | 2566 } |
| 2571 Thread::SetCurrent(thread); | 2567 Thread::SetCurrent(thread); |
| 2572 os_thread->EnableThreadInterrupts(); | 2568 os_thread->EnableThreadInterrupts(); |
| 2573 } | 2569 } |
| 2574 return thread; | 2570 return thread; |
| 2575 } | 2571 } |
| 2576 | 2572 |
| 2577 void Isolate::UnscheduleThread(Thread* thread, | 2573 void Isolate::UnscheduleThread(Thread* thread, |
| 2578 bool is_mutator, | 2574 bool is_mutator, |
| 2579 bool bypass_safepoint) { | 2575 bool bypass_safepoint) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2598 if (!bypass_safepoint) { | 2594 if (!bypass_safepoint) { |
| 2599 // Ensure that the thread reports itself as being at a safepoint. | 2595 // Ensure that the thread reports itself as being at a safepoint. |
| 2600 thread->EnterSafepoint(); | 2596 thread->EnterSafepoint(); |
| 2601 } | 2597 } |
| 2602 OSThread* os_thread = thread->os_thread(); | 2598 OSThread* os_thread = thread->os_thread(); |
| 2603 ASSERT(os_thread != NULL); | 2599 ASSERT(os_thread != NULL); |
| 2604 os_thread->DisableThreadInterrupts(); | 2600 os_thread->DisableThreadInterrupts(); |
| 2605 os_thread->set_thread(NULL); | 2601 os_thread->set_thread(NULL); |
| 2606 OSThread::SetCurrent(os_thread); | 2602 OSThread::SetCurrent(os_thread); |
| 2607 if (is_mutator) { | 2603 if (is_mutator) { |
| 2608 if (this != Dart::vm_isolate()) { | |
| 2609 heap()->new_space()->set_top(scheduled_mutator_thread_->top_); | |
| 2610 heap()->new_space()->set_end(scheduled_mutator_thread_->end_); | |
| 2611 } | |
| 2612 scheduled_mutator_thread_->top_ = 0; | |
| 2613 scheduled_mutator_thread_->end_ = 0; | |
| 2614 scheduled_mutator_thread_ = NULL; | 2604 scheduled_mutator_thread_ = NULL; |
| 2615 } | 2605 } |
| 2616 thread->isolate_ = NULL; | 2606 thread->isolate_ = NULL; |
| 2617 thread->heap_ = NULL; | 2607 thread->heap_ = NULL; |
| 2618 thread->set_os_thread(NULL); | 2608 thread->set_os_thread(NULL); |
| 2619 thread->set_execution_state(Thread::kThreadInNative); | 2609 thread->set_execution_state(Thread::kThreadInNative); |
| 2620 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2610 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
| 2621 thread->clear_pending_functions(); | 2611 thread->clear_pending_functions(); |
| 2622 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2612 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2623 // Return thread structure. | 2613 // Return thread structure. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 void IsolateSpawnState::DecrementSpawnCount() { | 2832 void IsolateSpawnState::DecrementSpawnCount() { |
| 2843 ASSERT(spawn_count_monitor_ != NULL); | 2833 ASSERT(spawn_count_monitor_ != NULL); |
| 2844 ASSERT(spawn_count_ != NULL); | 2834 ASSERT(spawn_count_ != NULL); |
| 2845 MonitorLocker ml(spawn_count_monitor_); | 2835 MonitorLocker ml(spawn_count_monitor_); |
| 2846 ASSERT(*spawn_count_ > 0); | 2836 ASSERT(*spawn_count_ > 0); |
| 2847 *spawn_count_ = *spawn_count_ - 1; | 2837 *spawn_count_ = *spawn_count_ - 1; |
| 2848 ml.Notify(); | 2838 ml.Notify(); |
| 2849 } | 2839 } |
| 2850 | 2840 |
| 2851 } // namespace dart | 2841 } // namespace dart |
| OLD | NEW |