diff options
| author | 2015-11-13 10:42:08 -0800 | |
|---|---|---|
| committer | 2015-11-16 15:05:36 -0800 | |
| commit | 4b00d3415beb7a816a3b5948f43f3b2e4b856ea8 (patch) | |
| tree | a54f8c2704fbe9b9ffebdc0f1984a777beb80ac0 /runtime/mirror/array-inl.h | |
| parent | 991842a5273d20695dd5f35eb9a9e28c386c5b4b (diff) | |
Refactor some patching logic
Reduce duplication since app images in-place relocation will require
this code also.
Bug: 22858531
Change-Id: Ibb901b67267e27ef3bc2a0baff77189d4dcd018a
Diffstat (limited to 'runtime/mirror/array-inl.h')
| -rw-r--r-- | runtime/mirror/array-inl.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h index ec7d758ebb..b6f424b3a4 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -394,6 +394,19 @@ inline void PointerArray::SetElementPtrSize(uint32_t idx, T element, size_t ptr_ } } +template <typename Visitor> +inline void PointerArray::Fixup(mirror::PointerArray* dest, + size_t pointer_size, + const Visitor& visitor) { + for (size_t i = 0, count = GetLength(); i < count; ++i) { + void* ptr = GetElementPtrSize<void*>(i, pointer_size); + void* new_ptr = visitor(ptr); + if (ptr != new_ptr) { + dest->SetElementPtrSize<false, true>(i, new_ptr, pointer_size); + } + } +} + } // namespace mirror } // namespace art |