OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/thread.h" | 5 #include "vm/thread.h" |
6 | 6 |
7 #include "vm/compiler_stats.h" | 7 #include "vm/compiler_stats.h" |
8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 visitor->VisitPointer(reinterpret_cast<RawObject**>(&sticky_error_)); | 702 visitor->VisitPointer(reinterpret_cast<RawObject**>(&sticky_error_)); |
703 visitor->VisitPointer(reinterpret_cast<RawObject**>(&async_stack_trace_)); | 703 visitor->VisitPointer(reinterpret_cast<RawObject**>(&async_stack_trace_)); |
704 | 704 |
705 // Visit the api local scope as it has all the api local handles. | 705 // Visit the api local scope as it has all the api local handles. |
706 ApiLocalScope* scope = api_top_scope_; | 706 ApiLocalScope* scope = api_top_scope_; |
707 while (scope != NULL) { | 707 while (scope != NULL) { |
708 scope->local_handles()->VisitObjectPointers(visitor); | 708 scope->local_handles()->VisitObjectPointers(visitor); |
709 scope = scope->previous(); | 709 scope = scope->previous(); |
710 } | 710 } |
711 | 711 |
| 712 // The MarkTask, which calls this method, can run on a different thread. We |
| 713 // therefore assume the mutator is at a safepoint and we can iterate it's |
| 714 // stack. |
| 715 // TODO(vm-team): It would be beneficial to be able to ask the mutator thread |
| 716 // whether it is in fact blocked at the moment (at a "safepoint") so we can |
| 717 // safely iterate it's stack. |
| 718 // |
| 719 // Unfortunately we cannot use `this->IsAtSafepoint()` here because that will |
| 720 // return `false` even though the mutator thread is waiting for mark tasks |
| 721 // (which iterate it's stack) to finish. |
| 722 const StackFrameIterator::CrossThreadPolicy cross_thread_policy = |
| 723 StackFrameIterator::kAllowCrossThreadIteration; |
| 724 |
| 725 const StackFrameIterator::ValidationPolicy validation_policy = |
| 726 validate_frames ? StackFrameIterator::kValidateFrames |
| 727 : StackFrameIterator::kDontValidateFrames; |
| 728 |
712 // Iterate over all the stack frames and visit objects on the stack. | 729 // Iterate over all the stack frames and visit objects on the stack. |
713 StackFrameIterator frames_iterator(top_exit_frame_info(), validate_frames); | 730 StackFrameIterator frames_iterator(top_exit_frame_info(), validation_policy, |
| 731 this, cross_thread_policy); |
714 StackFrame* frame = frames_iterator.NextFrame(); | 732 StackFrame* frame = frames_iterator.NextFrame(); |
715 while (frame != NULL) { | 733 while (frame != NULL) { |
716 frame->VisitObjectPointers(visitor); | 734 frame->VisitObjectPointers(visitor); |
717 frame = frames_iterator.NextFrame(); | 735 frame = frames_iterator.NextFrame(); |
718 } | 736 } |
719 } | 737 } |
720 | 738 |
721 | 739 |
722 bool Thread::CanLoadFromThread(const Object& object) { | 740 bool Thread::CanLoadFromThread(const Object& object) { |
723 #define CHECK_OBJECT(type_name, member_name, expr, default_init_value) \ | 741 #define CHECK_OBJECT(type_name, member_name, expr, default_init_value) \ |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 923 |
906 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 924 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
907 if (thread() != NULL) { | 925 if (thread() != NULL) { |
908 OSThread* os_thread = thread()->os_thread(); | 926 OSThread* os_thread = thread()->os_thread(); |
909 ASSERT(os_thread != NULL); | 927 ASSERT(os_thread != NULL); |
910 os_thread->EnableThreadInterrupts(); | 928 os_thread->EnableThreadInterrupts(); |
911 } | 929 } |
912 } | 930 } |
913 | 931 |
914 } // namespace dart | 932 } // namespace dart |
OLD | NEW |