src/share/vm/oops/arrayKlass.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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_ARRAYKLASS_HPP
aoqi@0 26 #define SHARE_VM_OOPS_ARRAYKLASS_HPP
aoqi@0 27
aoqi@0 28 #include "memory/universe.hpp"
aoqi@0 29 #include "oops/klass.hpp"
aoqi@0 30
aoqi@0 31 class fieldDescriptor;
aoqi@0 32 class klassVtable;
aoqi@0 33
aoqi@0 34 // ArrayKlass is the abstract baseclass for all array classes
aoqi@0 35
aoqi@0 36 class ArrayKlass: public Klass {
aoqi@0 37 friend class VMStructs;
aoqi@0 38 private:
aoqi@0 39 int _dimension; // This is n'th-dimensional array.
aoqi@0 40 Klass* volatile _higher_dimension; // Refers the (n+1)'th-dimensional array (if present).
aoqi@0 41 Klass* volatile _lower_dimension; // Refers the (n-1)'th-dimensional array (if present).
aoqi@0 42 int _vtable_len; // size of vtable for this klass
aoqi@0 43 oop _component_mirror; // component type, as a java/lang/Class
aoqi@0 44
aoqi@0 45 protected:
aoqi@0 46 // Constructors
aoqi@0 47 // The constructor with the Symbol argument does the real array
aoqi@0 48 // initialization, the other is a dummy
aoqi@0 49 ArrayKlass(Symbol* name);
aoqi@0 50 ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }
aoqi@0 51
aoqi@0 52 public:
aoqi@0 53 // Testing operation
aoqi@0 54 bool oop_is_array_slow() const { return true; }
aoqi@0 55
aoqi@0 56 // Instance variables
aoqi@0 57 int dimension() const { return _dimension; }
aoqi@0 58 void set_dimension(int dimension) { _dimension = dimension; }
aoqi@0 59
aoqi@0 60 Klass* higher_dimension() const { return _higher_dimension; }
aoqi@0 61 void set_higher_dimension(Klass* k) { _higher_dimension = k; }
aoqi@0 62 Klass** adr_higher_dimension() { return (Klass**)&this->_higher_dimension;}
aoqi@0 63
aoqi@0 64 Klass* lower_dimension() const { return _lower_dimension; }
aoqi@0 65 void set_lower_dimension(Klass* k) { _lower_dimension = k; }
aoqi@0 66 Klass** adr_lower_dimension() { return (Klass**)&this->_lower_dimension;}
aoqi@0 67
aoqi@0 68 // offset of first element, including any padding for the sake of alignment
aoqi@0 69 int array_header_in_bytes() const { return layout_helper_header_size(layout_helper()); }
aoqi@0 70 int log2_element_size() const { return layout_helper_log2_element_size(layout_helper()); }
aoqi@0 71 // type of elements (T_OBJECT for both oop arrays and array-arrays)
aoqi@0 72 BasicType element_type() const { return layout_helper_element_type(layout_helper()); }
aoqi@0 73
aoqi@0 74 oop component_mirror() const { return _component_mirror; }
aoqi@0 75 void set_component_mirror(oop m) { klass_oop_store(&_component_mirror, m); }
aoqi@0 76 oop* adr_component_mirror() { return (oop*)&this->_component_mirror;}
aoqi@0 77
aoqi@0 78 // Compiler/Interpreter offset
aoqi@0 79 static ByteSize component_mirror_offset() { return in_ByteSize(offset_of(ArrayKlass, _component_mirror)); }
aoqi@0 80
aoqi@0 81 virtual Klass* java_super() const;//{ return SystemDictionary::Object_klass(); }
aoqi@0 82
aoqi@0 83 // Allocation
aoqi@0 84 // Sizes points to the first dimension of the array, subsequent dimensions
aoqi@0 85 // are always in higher memory. The callers of these set that up.
aoqi@0 86 virtual oop multi_allocate(int rank, jint* sizes, TRAPS);
aoqi@0 87 objArrayOop allocate_arrayArray(int n, int length, TRAPS);
aoqi@0 88
aoqi@0 89 // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
aoqi@0 90 Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
aoqi@0 91
aoqi@0 92 // Lookup operations
aoqi@0 93 Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
aoqi@0 94
aoqi@0 95 // Casting from Klass*
aoqi@0 96 static ArrayKlass* cast(Klass* k) {
aoqi@0 97 assert(k->oop_is_array(), "cast to ArrayKlass");
aoqi@0 98 return (ArrayKlass*) k;
aoqi@0 99 }
aoqi@0 100
aoqi@0 101 GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);
aoqi@0 102 bool compute_is_subtype_of(Klass* k);
aoqi@0 103
aoqi@0 104 // Sizing
aoqi@0 105 static int header_size() { return sizeof(ArrayKlass)/HeapWordSize; }
aoqi@0 106 static int static_size(int header_size);
aoqi@0 107
aoqi@0 108 #if INCLUDE_SERVICES
aoqi@0 109 virtual void collect_statistics(KlassSizeStats *sz) const {
aoqi@0 110 Klass::collect_statistics(sz);
aoqi@0 111 // Do nothing for now, but remember to modify if you add new
aoqi@0 112 // stuff to ArrayKlass.
aoqi@0 113 }
aoqi@0 114 #endif
aoqi@0 115
aoqi@0 116 // Java vtable
aoqi@0 117 klassVtable* vtable() const; // return new klassVtable
aoqi@0 118 int vtable_length() const { return _vtable_len; }
aoqi@0 119 static int base_vtable_length() { return Universe::base_vtable_size(); }
aoqi@0 120 void set_vtable_length(int len) { assert(len == base_vtable_length(), "bad length"); _vtable_len = len; }
aoqi@0 121 protected:
aoqi@0 122 inline intptr_t* start_of_vtable() const;
aoqi@0 123
aoqi@0 124 public:
aoqi@0 125 // Iterators
aoqi@0 126 void array_klasses_do(void f(Klass* k));
aoqi@0 127 void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);
aoqi@0 128
aoqi@0 129 // GC support
aoqi@0 130 virtual void oops_do(OopClosure* cl);
aoqi@0 131
aoqi@0 132 // Return a handle.
aoqi@0 133 static void complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, TRAPS);
aoqi@0 134
aoqi@0 135
aoqi@0 136 // jvm support
aoqi@0 137 jint compute_modifier_flags(TRAPS) const;
aoqi@0 138
aoqi@0 139 // JVMTI support
aoqi@0 140 jint jvmti_class_status() const;
aoqi@0 141
aoqi@0 142 // CDS support - remove and restore oops from metadata. Oops are not shared.
aoqi@0 143 virtual void remove_unshareable_info();
aoqi@0 144 virtual void restore_unshareable_info(TRAPS);
aoqi@0 145
aoqi@0 146 // Printing
aoqi@0 147 void print_on(outputStream* st) const;
aoqi@0 148 void print_value_on(outputStream* st) const;
aoqi@0 149
aoqi@0 150 void oop_print_on(oop obj, outputStream* st);
aoqi@0 151
aoqi@0 152 // Verification
aoqi@0 153 void verify_on(outputStream* st);
aoqi@0 154
aoqi@0 155 void oop_verify_on(oop obj, outputStream* st);
aoqi@0 156 };
aoqi@0 157
aoqi@0 158 #endif // SHARE_VM_OOPS_ARRAYKLASS_HPP

mercurial