Chromium Code Reviews| 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 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2549 ASSERT(heap() != NULL); | 2549 ASSERT(heap() != NULL); |
| 2550 thread->heap_ = heap(); | 2550 thread->heap_ = heap(); |
| 2551 thread->set_os_thread(os_thread); | 2551 thread->set_os_thread(os_thread); |
| 2552 ASSERT(thread->execution_state() == Thread::kThreadInNative); | 2552 ASSERT(thread->execution_state() == Thread::kThreadInNative); |
| 2553 thread->set_execution_state(Thread::kThreadInVM); | 2553 thread->set_execution_state(Thread::kThreadInVM); |
| 2554 thread->set_safepoint_state(0); | 2554 thread->set_safepoint_state(0); |
| 2555 thread->set_vm_tag(VMTag::kVMTagId); | 2555 thread->set_vm_tag(VMTag::kVMTagId); |
| 2556 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2556 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2557 os_thread->set_thread(thread); | 2557 os_thread->set_thread(thread); |
| 2558 if (is_mutator) { | 2558 if (is_mutator) { |
| 2559 mutator_thread_ = thread; | 2559 mutator_thread_ = thread; |
|
rmacnak
2017/07/25 21:02:45
Consider lazy allocation of the TLAB.
danunez
2017/07/26 20:19:20
Done.
| |
| 2560 if (this != Dart::vm_isolate()) { | 2560 if (Dart::vm_isolate() != NULL && heap() != Dart::vm_isolate()->heap()) { |
| 2561 mutator_thread_->set_top(heap()->new_space()->top()); | 2561 intptr_t tlab_size = heap()->CalculateTLABSize(); |
| 2562 mutator_thread_->set_end(heap()->new_space()->end()); | 2562 uword top = heap()->new_space()->TryAllocateNewTLAB(tlab_size); |
| 2563 ASSERT(top != 0); | |
| 2564 mutator_thread_->set_top(top); | |
| 2565 mutator_thread_->set_end(heap()->new_space()->top()); | |
| 2563 } | 2566 } |
| 2564 } | 2567 } |
| 2565 Thread::SetCurrent(thread); | 2568 Thread::SetCurrent(thread); |
| 2566 os_thread->EnableThreadInterrupts(); | 2569 os_thread->EnableThreadInterrupts(); |
| 2567 } | 2570 } |
| 2568 return thread; | 2571 return thread; |
| 2569 } | 2572 } |
| 2570 | 2573 |
| 2571 void Isolate::UnscheduleThread(Thread* thread, | 2574 void Isolate::UnscheduleThread(Thread* thread, |
| 2572 bool is_mutator, | 2575 bool is_mutator, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2593 // Ensure that the thread reports itself as being at a safepoint. | 2596 // Ensure that the thread reports itself as being at a safepoint. |
| 2594 thread->EnterSafepoint(); | 2597 thread->EnterSafepoint(); |
| 2595 } | 2598 } |
| 2596 OSThread* os_thread = thread->os_thread(); | 2599 OSThread* os_thread = thread->os_thread(); |
| 2597 ASSERT(os_thread != NULL); | 2600 ASSERT(os_thread != NULL); |
| 2598 os_thread->DisableThreadInterrupts(); | 2601 os_thread->DisableThreadInterrupts(); |
| 2599 os_thread->set_thread(NULL); | 2602 os_thread->set_thread(NULL); |
| 2600 OSThread::SetCurrent(os_thread); | 2603 OSThread::SetCurrent(os_thread); |
| 2601 if (is_mutator) { | 2604 if (is_mutator) { |
| 2602 if (this != Dart::vm_isolate()) { | 2605 if (this != Dart::vm_isolate()) { |
| 2603 heap()->new_space()->set_top(mutator_thread_->top_); | 2606 // Ensure the new space is pointing right after the last object allocated. |
| 2604 heap()->new_space()->set_end(mutator_thread_->end_); | 2607 heap()->new_space()->set_top(mutator_thread_->top()); |
| 2605 } | 2608 } |
| 2606 mutator_thread_->top_ = 0; | 2609 mutator_thread_->set_top(0); |
| 2607 mutator_thread_->end_ = 0; | 2610 mutator_thread_->set_end(0); |
| 2608 mutator_thread_ = NULL; | 2611 mutator_thread_ = NULL; |
| 2609 } | 2612 } |
| 2610 thread->isolate_ = NULL; | 2613 thread->isolate_ = NULL; |
| 2611 thread->heap_ = NULL; | 2614 thread->heap_ = NULL; |
| 2612 thread->set_os_thread(NULL); | 2615 thread->set_os_thread(NULL); |
| 2613 thread->set_execution_state(Thread::kThreadInNative); | 2616 thread->set_execution_state(Thread::kThreadInNative); |
| 2614 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); | 2617 thread->set_safepoint_state(Thread::SetAtSafepoint(true, 0)); |
| 2615 thread->clear_pending_functions(); | 2618 thread->clear_pending_functions(); |
| 2616 ASSERT(thread->no_safepoint_scope_depth() == 0); | 2619 ASSERT(thread->no_safepoint_scope_depth() == 0); |
| 2617 // Return thread structure. | 2620 // Return thread structure. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2836 void IsolateSpawnState::DecrementSpawnCount() { | 2839 void IsolateSpawnState::DecrementSpawnCount() { |
| 2837 ASSERT(spawn_count_monitor_ != NULL); | 2840 ASSERT(spawn_count_monitor_ != NULL); |
| 2838 ASSERT(spawn_count_ != NULL); | 2841 ASSERT(spawn_count_ != NULL); |
| 2839 MonitorLocker ml(spawn_count_monitor_); | 2842 MonitorLocker ml(spawn_count_monitor_); |
| 2840 ASSERT(*spawn_count_ > 0); | 2843 ASSERT(*spawn_count_ > 0); |
| 2841 *spawn_count_ = *spawn_count_ - 1; | 2844 *spawn_count_ = *spawn_count_ - 1; |
| 2842 ml.Notify(); | 2845 ml.Notify(); |
| 2843 } | 2846 } |
| 2844 | 2847 |
| 2845 } // namespace dart | 2848 } // namespace dart |
| OLD | NEW |