src/share/vm/oops/objArrayKlass.hpp

Thu, 04 Apr 2019 17:56:29 +0800

author
aoqi
date
Thu, 04 Apr 2019 17:56:29 +0800
changeset 9572
624a0741915c
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_OOPS_OBJARRAYKLASS_HPP
aoqi@0 26 #define SHARE_VM_OOPS_OBJARRAYKLASS_HPP
aoqi@0 27
aoqi@0 28 #include "classfile/classLoaderData.hpp"
aoqi@0 29 #include "memory/specialized_oop_closures.hpp"
aoqi@0 30 #include "oops/arrayKlass.hpp"
aoqi@0 31 #include "utilities/macros.hpp"
aoqi@0 32
aoqi@0 33 // ObjArrayKlass is the klass for objArrays
aoqi@0 34
aoqi@0 35 class ObjArrayKlass : public ArrayKlass {
aoqi@0 36 friend class VMStructs;
aoqi@0 37 private:
aoqi@0 38 Klass* _element_klass; // The klass of the elements of this array type
aoqi@0 39 Klass* _bottom_klass; // The one-dimensional type (InstanceKlass or TypeArrayKlass)
aoqi@0 40
aoqi@0 41 // Constructor
aoqi@0 42 ObjArrayKlass(int n, KlassHandle element_klass, Symbol* name);
aoqi@0 43 static ObjArrayKlass* allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS);
aoqi@0 44 public:
aoqi@0 45 // For dummy objects
aoqi@0 46 ObjArrayKlass() {}
aoqi@0 47
aoqi@0 48 // Instance variables
aoqi@0 49 Klass* element_klass() const { return _element_klass; }
aoqi@0 50 void set_element_klass(Klass* k) { _element_klass = k; }
aoqi@0 51 Klass** element_klass_addr() { return &_element_klass; }
aoqi@0 52
aoqi@0 53 Klass* bottom_klass() const { return _bottom_klass; }
aoqi@0 54 void set_bottom_klass(Klass* k) { _bottom_klass = k; }
aoqi@0 55 Klass** bottom_klass_addr() { return &_bottom_klass; }
aoqi@0 56
aoqi@0 57 // Compiler/Interpreter offset
aoqi@0 58 static ByteSize element_klass_offset() { return in_ByteSize(offset_of(ObjArrayKlass, _element_klass)); }
aoqi@0 59
aoqi@0 60 // Dispatched operation
aoqi@0 61 bool can_be_primary_super_slow() const;
aoqi@0 62 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
aoqi@0 63 bool compute_is_subtype_of(Klass* k);
aoqi@0 64 bool oop_is_objArray_slow() const { return true; }
aoqi@0 65 int oop_size(oop obj) const;
aoqi@0 66
aoqi@0 67 // Allocation
aoqi@0 68 static Klass* allocate_objArray_klass(ClassLoaderData* loader_data,
aoqi@0 69 int n, KlassHandle element_klass, TRAPS);
aoqi@0 70
aoqi@0 71 objArrayOop allocate(int length, TRAPS);
aoqi@0 72 oop multi_allocate(int rank, jint* sizes, TRAPS);
aoqi@0 73
aoqi@0 74 // Copying
aoqi@0 75 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
aoqi@0 76
aoqi@0 77 // Compute protection domain
aoqi@0 78 oop protection_domain() const { return bottom_klass()->protection_domain(); }
aoqi@0 79
aoqi@0 80 private:
aoqi@0 81 // Either oop or narrowOop depending on UseCompressedOops.
aoqi@0 82 // must be called from within ObjArrayKlass.cpp
aoqi@0 83 template <class T> void do_copy(arrayOop s, T* src, arrayOop d,
aoqi@0 84 T* dst, int length, TRAPS);
aoqi@0 85 protected:
aoqi@0 86 // Returns the ObjArrayKlass for n'th dimension.
aoqi@0 87 virtual Klass* array_klass_impl(bool or_null, int n, TRAPS);
aoqi@0 88
aoqi@0 89 // Returns the array class with this class as element type.
aoqi@0 90 virtual Klass* array_klass_impl(bool or_null, TRAPS);
aoqi@0 91
aoqi@0 92 public:
aoqi@0 93 // Casting from Klass*
aoqi@0 94 static ObjArrayKlass* cast(Klass* k) {
aoqi@0 95 assert(k->oop_is_objArray(), "cast to ObjArrayKlass");
aoqi@0 96 return (ObjArrayKlass*) k;
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 // Sizing
aoqi@0 100 static int header_size() { return sizeof(ObjArrayKlass)/HeapWordSize; }
aoqi@0 101 int size() const { return ArrayKlass::static_size(header_size()); }
aoqi@0 102
aoqi@0 103 // Initialization (virtual from Klass)
aoqi@0 104 void initialize(TRAPS);
aoqi@0 105
aoqi@0 106 // Garbage collection
aoqi@0 107 void oop_follow_contents(oop obj);
aoqi@0 108 inline void oop_follow_contents(oop obj, int index);
aoqi@0 109 template <class T> inline void objarray_follow_contents(oop obj, int index);
aoqi@0 110
aoqi@0 111 int oop_adjust_pointers(oop obj);
aoqi@0 112
aoqi@0 113 // Parallel Scavenge and Parallel Old
aoqi@0 114 PARALLEL_GC_DECLS
aoqi@0 115 #if INCLUDE_ALL_GCS
aoqi@0 116 inline void oop_follow_contents(ParCompactionManager* cm, oop obj, int index);
aoqi@0 117 template <class T> inline void
aoqi@0 118 objarray_follow_contents(ParCompactionManager* cm, oop obj, int index);
aoqi@0 119 #endif // INCLUDE_ALL_GCS
aoqi@0 120
aoqi@0 121 // Iterators
aoqi@0 122 int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
aoqi@0 123 return oop_oop_iterate_v(obj, blk);
aoqi@0 124 }
aoqi@0 125 int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {
aoqi@0 126 return oop_oop_iterate_v_m(obj, blk, mr);
aoqi@0 127 }
aoqi@0 128 #define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
aoqi@0 129 int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \
aoqi@0 130 int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, \
aoqi@0 131 MemRegion mr); \
aoqi@0 132 int oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* blk, \
aoqi@0 133 int start, int end);
aoqi@0 134
aoqi@0 135 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
aoqi@0 136 ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
aoqi@0 137
aoqi@0 138 // JVM support
aoqi@0 139 jint compute_modifier_flags(TRAPS) const;
aoqi@0 140
aoqi@0 141 public:
aoqi@0 142 // Printing
aoqi@0 143 void print_on(outputStream* st) const;
aoqi@0 144 void print_value_on(outputStream* st) const;
aoqi@0 145
aoqi@0 146 void oop_print_value_on(oop obj, outputStream* st);
aoqi@0 147 #ifndef PRODUCT
aoqi@0 148 void oop_print_on (oop obj, outputStream* st);
aoqi@0 149 #endif //PRODUCT
aoqi@0 150
aoqi@0 151 const char* internal_name() const;
aoqi@0 152
aoqi@0 153 // Verification
aoqi@0 154 void verify_on(outputStream* st);
aoqi@0 155
aoqi@0 156 void oop_verify_on(oop obj, outputStream* st);
aoqi@0 157 };
aoqi@0 158
aoqi@0 159 #endif // SHARE_VM_OOPS_OBJARRAYKLASS_HPP

mercurial