summaryrefslogtreecommitdiff
path: root/runtime/handle_scope-inl.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2023-01-03 14:01:00 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2023-01-28 16:42:34 +0000
commitdf68c0a6f0d36728fa728049e5bcec20de2d0d5e (patch)
treef65b2ffdf3f998dc7980853c71d169cb489289a8 /runtime/handle_scope-inl.h
parent09c218c61ab525b05d7181be92e78d69d035e122 (diff)
Write classes in runtime-generated app image.
Test: 845-data-image Bug: 260557058 Change-Id: I640b78942984ac3d3f8d24abda619d78154acd86
Diffstat (limited to 'runtime/handle_scope-inl.h')
-rw-r--r--runtime/handle_scope-inl.h27
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_