From df68c0a6f0d36728fa728049e5bcec20de2d0d5e Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 3 Jan 2023 14:01:00 +0000 Subject: Write classes in runtime-generated app image. Test: 845-data-image Bug: 260557058 Change-Id: I640b78942984ac3d3f8d24abda619d78154acd86 --- runtime/handle_scope-inl.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'runtime/handle_scope-inl.h') 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 +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 template inline MutableHandle FixedSizeHandleScope::NewHandle(T* object) { return NewHandle(ObjPtr(object)); @@ -179,6 +188,15 @@ inline void BaseHandleScope::VisitRoots(Visitor& visitor) { } } +template +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(this); @@ -269,6 +287,15 @@ inline void VariableSizedHandleScope::VisitRoots(Visitor& visitor) { } } +template +inline void VariableSizedHandleScope::VisitHandles(Visitor& visitor) { + LocalScopeType* cur = current_scope_; + while (cur != nullptr) { + cur->VisitHandles(visitor); + cur = reinterpret_cast(cur->GetLink()); + } +} + } // namespace art #endif // ART_RUNTIME_HANDLE_SCOPE_INL_H_ -- cgit v1.2.3-59-g8ed1b