diff options
Diffstat (limited to 'runtime/mirror/class.h')
-rw-r--r-- | runtime/mirror/class.h | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index b82a58f4c2..92493bc567 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -35,6 +35,7 @@ namespace art { +class ArtField; struct ClassOffsets; template<class T> class Handle; template<class T> class Handle; @@ -44,7 +45,6 @@ template<size_t kNumReferences> class PACKED(4) StackHandleScope; namespace mirror { -class ArtField; class ArtMethod; class ClassLoader; class DexCache; @@ -420,9 +420,6 @@ class MANAGED Class FINAL : public Object { bool IsThrowableClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> - bool IsArtFieldClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> bool IsArtMethodClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> @@ -823,17 +820,22 @@ class MANAGED Class FINAL : public Object { ALWAYS_INLINE void SetIfTable(IfTable* new_iftable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get instance fields of the class (See also GetSFields). - ObjectArray<ArtField>* GetIFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtField* GetIFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetIFields(ObjectArray<ArtField>* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetIFields(ArtField* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint32_t NumInstanceFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // Unchecked edition has no verification flags. + void SetIFieldsUnchecked(ArtField* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ArtField* GetInstanceField(uint32_t i) // TODO: uint16_t - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + uint32_t NumInstanceFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_instance_fields_)); + } - void SetInstanceField(uint32_t i, ArtField* f) // TODO: uint16_t - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetNumInstanceFields(uint32_t num) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_instance_fields_), num); + } + + ArtField* GetInstanceField(uint32_t i) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of instance fields containing reference types. uint32_t NumReferenceInstanceFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -884,17 +886,23 @@ class MANAGED Class FINAL : public Object { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Gets the static fields of the class. - ObjectArray<ArtField>* GetSFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtField* GetSFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetSFields(ObjectArray<ArtField>* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetSFields(ArtField* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint32_t NumStaticFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // Unchecked edition has no verification flags. + void SetSFieldsUnchecked(ArtField* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // TODO: uint16_t - ArtField* GetStaticField(uint32_t i) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + uint32_t NumStaticFields() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_static_fields_)); + } + + void SetNumStaticFields(uint32_t num) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_static_fields_), num); + } // TODO: uint16_t - void SetStaticField(uint32_t i, ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtField* GetStaticField(uint32_t i) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Find a static or instance field using the JLS resolution order static ArtField* FindField(Thread* self, Handle<Class> klass, const StringPiece& name, @@ -974,6 +982,10 @@ class MANAGED Class FINAL : public Object { static void VisitRoots(RootVisitor* visitor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + template<class Visitor> + // Visit field roots. + void VisitFieldRoots(Visitor& visitor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // When class is verified, set the kAccPreverified flag on each method. void SetPreverifiedFlagOnAllMethods() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -1079,6 +1091,10 @@ class MANAGED Class FINAL : public Object { void CheckObjectAlloc() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // Unchecked editions is for root visiting. + ArtField* GetSFieldsUnchecked() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtField* GetIFieldsUnchecked() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // defining class loader, or NULL for the "bootstrap" system loader HeapReference<ClassLoader> class_loader_; @@ -1096,18 +1112,6 @@ class MANAGED Class FINAL : public Object { // static, private, and <init> methods HeapReference<ObjectArray<ArtMethod>> direct_methods_; - // instance fields - // - // These describe the layout of the contents of an Object. - // Note that only the fields directly declared by this class are - // listed in ifields; fields declared by a superclass are listed in - // the superclass's Class.ifields. - // - // All instance fields that refer to objects are guaranteed to be at - // the beginning of the field list. num_reference_instance_fields_ - // specifies the number of reference fields. - HeapReference<ObjectArray<ArtField>> ifields_; - // The interface table (iftable_) contains pairs of a interface class and an array of the // interface methods. There is one pair per interface supported by this class. That means one // pair for each interface we support directly, indirectly via superclass, or indirectly via a @@ -1124,9 +1128,6 @@ class MANAGED Class FINAL : public Object { // Descriptor for the class such as "java.lang.Class" or "[C". Lazily initialized by ComputeName HeapReference<String> name_; - // Static fields - HeapReference<ObjectArray<ArtField>> sfields_; - // The superclass, or NULL if this is java.lang.Object, an interface or primitive type. HeapReference<Class> super_class_; @@ -1143,8 +1144,22 @@ class MANAGED Class FINAL : public Object { HeapReference<ObjectArray<ArtMethod>> vtable_; // Access flags; low 16 bits are defined by VM spec. + // Note: Shuffled back. uint32_t access_flags_; + // instance fields + // + // These describe the layout of the contents of an Object. + // Note that only the fields directly declared by this class are + // listed in ifields; fields declared by a superclass are listed in + // the superclass's Class.ifields. + // + // ArtField arrays are allocated as an array of fields, and not an array of fields pointers. + uint64_t ifields_; + + // Static fields + uint64_t sfields_; + // Total size of the Class instance; used when allocating storage on gc heap. // See also object_size_. uint32_t class_size_; @@ -1160,12 +1175,18 @@ class MANAGED Class FINAL : public Object { // TODO: really 16bits int32_t dex_type_idx_; + // Number of static fields. + uint32_t num_instance_fields_; + // Number of instance fields that are object refs. uint32_t num_reference_instance_fields_; // Number of static fields that are object refs, uint32_t num_reference_static_fields_; + // Number of static fields. + uint32_t num_static_fields_; + // Total object size; used when allocating storage on gc heap. // (For interfaces and abstract classes this will be zero.) // See also class_size_. |