33 34 class ObjArrayKlass : public ArrayKlass { 35 friend class VMStructs; 36 friend class JVMCIVMStructs; 37 38 public: 39 static const KlassID ID = ObjArrayKlassID; 40 41 private: 42 // If you add a new field that points to any metaspace object, you 43 // must add this field to ObjArrayKlass::metaspace_pointers_do(). 44 Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass) 45 46 // Constructor 47 ObjArrayKlass(int n, Klass* element_klass, Symbol* name); 48 static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS); 49 public: 50 // For dummy objects 51 ObjArrayKlass() {} 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 // Dispatched operation 61 bool can_be_primary_super_slow() const; 62 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots, 63 Array<InstanceKlass*>* transitive_interfaces); 64 DEBUG_ONLY(bool is_objArray_klass_slow() const { return true; }) 65 int oop_size(oop obj) const; 66 67 // Allocation 68 static Klass* allocate_objArray_klass(ClassLoaderData* loader_data, 69 int n, Klass* element_klass, TRAPS); 70 71 objArrayOop allocate(int length, TRAPS); 72 oop multi_allocate(int rank, jint* sizes, TRAPS); 73 74 // Copying 75 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 76 77 // Compute protection domain 78 oop protection_domain() const { return bottom_klass()->protection_domain(); } 79 80 virtual void metaspace_pointers_do(MetaspaceClosure* iter); 81 82 private: 83 // Either oop or narrowOop depending on UseCompressedOops. 84 // must be called from within ObjArrayKlass.cpp 85 void do_copy(arrayOop s, size_t src_offset, 86 arrayOop d, size_t dst_offset, 87 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. 93 virtual Klass* array_klass_impl(bool or_null, TRAPS); 94 95 public: 96 97 static ObjArrayKlass* cast(Klass* k) { 98 return const_cast<ObjArrayKlass*>(cast(const_cast<const Klass*>(k))); 99 } 100 101 static const ObjArrayKlass* cast(const Klass* k) { 102 assert(k->is_objArray_klass(), "cast to ObjArrayKlass"); 103 return static_cast<const ObjArrayKlass*>(k); 104 } 105 106 // Sizing 107 static int header_size() { return sizeof(ObjArrayKlass)/wordSize; } 108 int size() const { return ArrayKlass::static_size(header_size()); } 109 110 // Initialization (virtual from Klass) 111 void initialize(TRAPS); 112 113 // Oop fields (and metadata) iterators | 33 34 class ObjArrayKlass : public ArrayKlass { 35 friend class VMStructs; 36 friend class JVMCIVMStructs; 37 38 public: 39 static const KlassID ID = ObjArrayKlassID; 40 41 private: 42 // If you add a new field that points to any metaspace object, you 43 // must add this field to ObjArrayKlass::metaspace_pointers_do(). 44 Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass) 45 46 // Constructor 47 ObjArrayKlass(int n, Klass* element_klass, Symbol* name); 48 static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS); 49 public: 50 // For dummy objects 51 ObjArrayKlass() {} 52 53 // if ObjArrayKlass is used to represent an LWorld "Q-type" value type array, the only thing we can give null-free (i.e. not flattened) 54 // ArrayStorageProperties::empty meaning nothing special, array of references (possibly even to value types) 55 ArrayStorageProperties storage_properties(); 56 57 Klass* bottom_klass() const { return _bottom_klass; } 58 void set_bottom_klass(Klass* k) { _bottom_klass = k; } 59 Klass** bottom_klass_addr() { return &_bottom_klass; } 60 61 ModuleEntry* module() const; 62 PackageEntry* package() const; 63 64 // Dispatched operation 65 bool can_be_primary_super_slow() const; 66 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots, 67 Array<InstanceKlass*>* transitive_interfaces); 68 DEBUG_ONLY(bool is_objArray_klass_slow() const { return true; }) 69 int oop_size(oop obj) const; 70 71 // Allocation 72 static Klass* allocate_objArray_klass(ArrayStorageProperties storage_props, 73 int n, Klass* element_klass, TRAPS); 74 75 objArrayOop allocate(int length, TRAPS); 76 oop multi_allocate(int rank, jint* sizes, TRAPS); 77 78 // Copying 79 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 80 81 // Compute protection domain 82 oop protection_domain() const { return bottom_klass()->protection_domain(); } 83 84 virtual void metaspace_pointers_do(MetaspaceClosure* iter); 85 86 private: 87 // Either oop or narrowOop depending on UseCompressedOops. 88 // must be called from within ObjArrayKlass.cpp 89 void do_copy(arrayOop s, size_t src_offset, 90 arrayOop d, size_t dst_offset, 91 int length, TRAPS); 92 protected: 93 // Returns the ObjArrayKlass for n'th dimension. 94 virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int n, TRAPS); 95 96 // Returns the array class with this class as element type. 97 virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS); 98 99 public: 100 101 static ObjArrayKlass* cast(Klass* k) { 102 return const_cast<ObjArrayKlass*>(cast(const_cast<const Klass*>(k))); 103 } 104 105 static const ObjArrayKlass* cast(const Klass* k) { 106 assert(k->is_objArray_klass(), "cast to ObjArrayKlass"); 107 return static_cast<const ObjArrayKlass*>(k); 108 } 109 110 // Sizing 111 static int header_size() { return sizeof(ObjArrayKlass)/wordSize; } 112 int size() const { return ArrayKlass::static_size(header_size()); } 113 114 // Initialization (virtual from Klass) 115 void initialize(TRAPS); 116 117 // Oop fields (and metadata) iterators |