From 104883b04617a850adf11f05e57c2fd29e09c83c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 9 Nov 2018 17:12:23 +0000 Subject: Clean up primitive array helpers in Object. Refactor these helpers and avoid read barriers. Remove Class::Is{Int,Long}ArrayClass() and use the Object helpers instead. Remove the AsByteSizedArray() and AsShortSizedArray() helpers that essentially break the type system and rewrite their users, adding appropriate notes. {Float,Double}Array uses in Unsafe would have previously failed a DCHECK(). Test: Additional test in 004-UnsafeTest. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I88b7e3df7de883f64cfc5eb437a40646f2884685 --- runtime/mirror/object.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'runtime/mirror/object.h') diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index 11e8ccadc4..bca7511489 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -21,6 +21,7 @@ #include "base/casts.h" #include "base/enums.h" #include "base/globals.h" +#include "dex/primitive.h" #include "obj_ptr.h" #include "object_reference.h" #include "offsets.h" @@ -198,32 +199,34 @@ class MANAGED LOCKABLE Object { template Array* AsArray() REQUIRES_SHARED(Locks::mutator_lock_); + template + bool IsBooleanArray() REQUIRES_SHARED(Locks::mutator_lock_); template BooleanArray* AsBooleanArray() REQUIRES_SHARED(Locks::mutator_lock_); + template - ByteArray* AsByteArray() REQUIRES_SHARED(Locks::mutator_lock_); + bool IsByteArray() REQUIRES_SHARED(Locks::mutator_lock_); template - ByteArray* AsByteSizedArray() REQUIRES_SHARED(Locks::mutator_lock_); + ByteArray* AsByteArray() REQUIRES_SHARED(Locks::mutator_lock_); + template + bool IsCharArray() REQUIRES_SHARED(Locks::mutator_lock_); template CharArray* AsCharArray() REQUIRES_SHARED(Locks::mutator_lock_); + template - ShortArray* AsShortArray() REQUIRES_SHARED(Locks::mutator_lock_); + bool IsShortArray() REQUIRES_SHARED(Locks::mutator_lock_); template - ShortArray* AsShortSizedArray() REQUIRES_SHARED(Locks::mutator_lock_); + ShortArray* AsShortArray() REQUIRES_SHARED(Locks::mutator_lock_); - template + template bool IsIntArray() REQUIRES_SHARED(Locks::mutator_lock_); - template + template IntArray* AsIntArray() REQUIRES_SHARED(Locks::mutator_lock_); - template + template bool IsLongArray() REQUIRES_SHARED(Locks::mutator_lock_); - template + template LongArray* AsLongArray() REQUIRES_SHARED(Locks::mutator_lock_); template @@ -757,6 +760,9 @@ class MANAGED LOCKABLE Object { size_t num_bytes) REQUIRES_SHARED(Locks::mutator_lock_); + template + bool IsSpecificPrimitiveArray() REQUIRES_SHARED(Locks::mutator_lock_); + static Atomic hash_code_seed; // The Class representing the type of the object. -- cgit v1.2.3-59-g8ed1b