diff options
Diffstat (limited to 'runtime/handle_scope-inl.h')
-rw-r--r-- | runtime/handle_scope-inl.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/handle_scope-inl.h b/runtime/handle_scope-inl.h index 3aa9e5221d..60a82a29ae 100644 --- a/runtime/handle_scope-inl.h +++ b/runtime/handle_scope-inl.h @@ -121,6 +121,15 @@ inline void HandleScope::VisitRoots(Visitor& visitor) { } } +template <typename Visitor> +inline void HandleScope::VisitHandles(Visitor& visitor) { + for (size_t i = 0, count = NumberOfReferences(); i < count; ++i) { + if (GetHandle(i) != nullptr) { + visitor.Visit(GetHandle(i)); + } + } +} + template<size_t kNumReferences> template<class T> inline MutableHandle<T> FixedSizeHandleScope<kNumReferences>::NewHandle(T* object) { return NewHandle(ObjPtr<T>(object)); @@ -179,6 +188,15 @@ inline void BaseHandleScope::VisitRoots(Visitor& visitor) { } } +template <typename Visitor> +inline void BaseHandleScope::VisitHandles(Visitor& visitor) { + if (LIKELY(!IsVariableSized())) { + AsHandleScope()->VisitHandles(visitor); + } else { + AsVariableSized()->VisitHandles(visitor); + } +} + inline VariableSizedHandleScope* BaseHandleScope::AsVariableSized() { DCHECK(IsVariableSized()); return down_cast<VariableSizedHandleScope*>(this); @@ -269,6 +287,15 @@ inline void VariableSizedHandleScope::VisitRoots(Visitor& visitor) { } } +template <typename Visitor> +inline void VariableSizedHandleScope::VisitHandles(Visitor& visitor) { + LocalScopeType* cur = current_scope_; + while (cur != nullptr) { + cur->VisitHandles(visitor); + cur = reinterpret_cast<LocalScopeType*>(cur->GetLink()); + } +} + } // namespace art #endif // ART_RUNTIME_HANDLE_SCOPE_INL_H_ |