22 * 23 */ 24 25 #ifndef SHARE_VM_OOPS_OBJARRAYKLASS_HPP 26 #define SHARE_VM_OOPS_OBJARRAYKLASS_HPP 27 28 #include "classfile/classLoaderData.hpp" 29 #include "oops/arrayKlass.hpp" 30 #include "utilities/macros.hpp" 31 32 // ObjArrayKlass is the klass for objArrays 33 34 class ObjArrayKlass : public ArrayKlass { 35 friend class VMStructs; 36 friend class JVMCIVMStructs; 37 private: 38 Klass* _element_klass; // The klass of the elements of this array type 39 Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass) 40 41 // Constructor 42 ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name); 43 static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS); 44 public: 45 // For dummy objects 46 ObjArrayKlass() {} 47 48 // Instance variables 49 Klass* element_klass() const { return _element_klass; } 50 void set_element_klass(Klass* k) { _element_klass = k; } 51 Klass** element_klass_addr() { return &_element_klass; } 52 53 Klass* bottom_klass() const { return _bottom_klass; } 54 void set_bottom_klass(Klass* k) { _bottom_klass = k; } 55 Klass** bottom_klass_addr() { return &_bottom_klass; } 56 57 ModuleEntry* module() const; 58 PackageEntry* package() const; 59 60 // Compiler/Interpreter offset 61 static ByteSize element_klass_offset() { return in_ByteSize(offset_of(ObjArrayKlass, _element_klass)); } 62 63 // Dispatched operation 64 bool can_be_primary_super_slow() const; 65 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots); 66 bool compute_is_subtype_of(Klass* k); 67 DEBUG_ONLY(bool is_objArray_klass_slow() const { return true; }) 68 int oop_size(oop obj) const; 69 70 // Allocation 71 static Klass* allocate_objArray_klass(ClassLoaderData* loader_data, 72 int n, KlassHandle element_klass, TRAPS); 73 74 objArrayOop allocate(int length, TRAPS); 75 oop multi_allocate(int rank, jint* sizes, TRAPS); 76 77 // Copying 78 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 79 80 // Compute protection domain 81 oop protection_domain() const { return bottom_klass()->protection_domain(); } 82 83 private: 84 // Either oop or narrowOop depending on UseCompressedOops. 85 // must be called from within ObjArrayKlass.cpp 86 template <class T> void do_copy(arrayOop s, T* src, arrayOop d, 87 T* dst, int length, TRAPS); 88 protected: 89 // Returns the ObjArrayKlass for n'th dimension. 90 virtual Klass* array_klass_impl(bool or_null, int n, TRAPS); 91 92 // Returns the array class with this class as element type. | 22 * 23 */ 24 25 #ifndef SHARE_VM_OOPS_OBJARRAYKLASS_HPP 26 #define SHARE_VM_OOPS_OBJARRAYKLASS_HPP 27 28 #include "classfile/classLoaderData.hpp" 29 #include "oops/arrayKlass.hpp" 30 #include "utilities/macros.hpp" 31 32 // ObjArrayKlass is the klass for objArrays 33 34 class ObjArrayKlass : public ArrayKlass { 35 friend class VMStructs; 36 friend class JVMCIVMStructs; 37 private: 38 Klass* _element_klass; // The klass of the elements of this array type 39 Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass) 40 41 // Constructor 42 ObjArrayKlass(int n, Klass* element_klass, Symbol* name); 43 static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS); 44 public: 45 // For dummy objects 46 ObjArrayKlass() {} 47 48 // Instance variables 49 Klass* element_klass() const { return _element_klass; } 50 void set_element_klass(Klass* k) { _element_klass = k; } 51 Klass** element_klass_addr() { return &_element_klass; } 52 53 Klass* bottom_klass() const { return _bottom_klass; } 54 void set_bottom_klass(Klass* k) { _bottom_klass = k; } 55 Klass** bottom_klass_addr() { return &_bottom_klass; } 56 57 ModuleEntry* module() const; 58 PackageEntry* package() const; 59 60 // Compiler/Interpreter offset 61 static ByteSize element_klass_offset() { return in_ByteSize(offset_of(ObjArrayKlass, _element_klass)); } 62 63 // Dispatched operation 64 bool can_be_primary_super_slow() const; 65 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots); 66 bool compute_is_subtype_of(Klass* k); 67 DEBUG_ONLY(bool is_objArray_klass_slow() const { return true; }) 68 int oop_size(oop obj) const; 69 70 // Allocation 71 static Klass* allocate_objArray_klass(ClassLoaderData* loader_data, 72 int n, Klass* element_klass, TRAPS); 73 74 objArrayOop allocate(int length, TRAPS); 75 oop multi_allocate(int rank, jint* sizes, TRAPS); 76 77 // Copying 78 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 79 80 // Compute protection domain 81 oop protection_domain() const { return bottom_klass()->protection_domain(); } 82 83 private: 84 // Either oop or narrowOop depending on UseCompressedOops. 85 // must be called from within ObjArrayKlass.cpp 86 template <class T> void do_copy(arrayOop s, T* src, arrayOop d, 87 T* dst, int length, TRAPS); 88 protected: 89 // Returns the ObjArrayKlass for n'th dimension. 90 virtual Klass* array_klass_impl(bool or_null, int n, TRAPS); 91 92 // Returns the array class with this class as element type. |