summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorDmitry Petrochenko <dmitry.petrochenko@intel.com>2014-04-18 14:53:09 +0700
committerAndreas Gampe <agampe@google.com>2014-04-24 08:35:30 -0700
commit973cc95da6fb617bab133bd7a693c1cb7eafd393 (patch)
tree34b08f276979f3474b0a53769b2d100866647e91 /runtime
parent96a4f29350bf279d48bff70e21e3264cce216683 (diff)
downloadart-973cc95da6fb617bab133bd7a693c1cb7eafd393.zip
art-973cc95da6fb617bab133bd7a693c1cb7eafd393.tar.gz
art-973cc95da6fb617bab133bd7a693c1cb7eafd393.tar.bz2
ART: Extracts an utility function of the duplicated code
This patch introduces an utility function 'DataOffsetOfType' in 'mirror::Array' class that calculates the data offset at given index in an array of given type. Change-Id: Idb19558653c70a129245f220f0fbb553f898865b Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/mirror/array.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h
index 772d303..a9dcfe6 100644
--- a/runtime/mirror/array.h
+++ b/runtime/mirror/array.h
@@ -68,6 +68,12 @@ class MANAGED Array : public Object {
}
}
+ template<class MirrorType>
+ static int32_t DataOffsetOfType(uint32_t index) {
+ return DataOffset(sizeof(HeapReference<MirrorType>)).Int32Value() +
+ (sizeof(HeapReference<MirrorType>) * index);
+ }
+
void* GetRawData(size_t component_size, int32_t index)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
intptr_t data = reinterpret_cast<intptr_t>(this) + DataOffset(component_size).Int32Value() +