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