Wed, 07 Dec 2011 11:35:03 +0100
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
Summary: Moved sizeof(klassOopDesc), changed the return type to ByteSize and removed the _in_bytes suffix.
Reviewed-by: never, bdelsart, coleenp, jrose
duke@435 | 1 | /* |
kvn@2439 | 2 | * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_OOPS_ARRAYKLASS_HPP |
stefank@2314 | 26 | #define SHARE_VM_OOPS_ARRAYKLASS_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/universe.hpp" |
stefank@2314 | 29 | #include "oops/klass.hpp" |
stefank@2314 | 30 | #include "oops/klassOop.hpp" |
stefank@2314 | 31 | #include "oops/klassVtable.hpp" |
stefank@2314 | 32 | |
duke@435 | 33 | // arrayKlass is the abstract baseclass for all array classes |
duke@435 | 34 | |
duke@435 | 35 | class arrayKlass: public Klass { |
duke@435 | 36 | friend class VMStructs; |
duke@435 | 37 | private: |
duke@435 | 38 | int _dimension; // This is n'th-dimensional array. |
kvn@2439 | 39 | volatile klassOop _higher_dimension; // Refers the (n+1)'th-dimensional array (if present). |
kvn@2439 | 40 | volatile klassOop _lower_dimension; // Refers the (n-1)'th-dimensional array (if present). |
duke@435 | 41 | int _vtable_len; // size of vtable for this klass |
duke@435 | 42 | juint _alloc_size; // allocation profiling support |
duke@435 | 43 | oop _component_mirror; // component type, as a java/lang/Class |
duke@435 | 44 | |
duke@435 | 45 | public: |
duke@435 | 46 | // Testing operation |
duke@435 | 47 | bool oop_is_array() const { return true; } |
duke@435 | 48 | |
duke@435 | 49 | // Instance variables |
duke@435 | 50 | int dimension() const { return _dimension; } |
duke@435 | 51 | void set_dimension(int dimension) { _dimension = dimension; } |
duke@435 | 52 | |
duke@435 | 53 | klassOop higher_dimension() const { return _higher_dimension; } |
duke@435 | 54 | void set_higher_dimension(klassOop k) { oop_store_without_check((oop*) &_higher_dimension, (oop) k); } |
duke@435 | 55 | oop* adr_higher_dimension() { return (oop*)&this->_higher_dimension;} |
duke@435 | 56 | |
duke@435 | 57 | klassOop lower_dimension() const { return _lower_dimension; } |
duke@435 | 58 | void set_lower_dimension(klassOop k) { oop_store_without_check((oop*) &_lower_dimension, (oop) k); } |
duke@435 | 59 | oop* adr_lower_dimension() { return (oop*)&this->_lower_dimension;} |
duke@435 | 60 | |
duke@435 | 61 | // Allocation profiling support |
duke@435 | 62 | juint alloc_size() const { return _alloc_size; } |
duke@435 | 63 | void set_alloc_size(juint n) { _alloc_size = n; } |
duke@435 | 64 | |
duke@435 | 65 | // offset of first element, including any padding for the sake of alignment |
duke@435 | 66 | int array_header_in_bytes() const { return layout_helper_header_size(layout_helper()); } |
duke@435 | 67 | int log2_element_size() const { return layout_helper_log2_element_size(layout_helper()); } |
duke@435 | 68 | // type of elements (T_OBJECT for both oop arrays and array-arrays) |
duke@435 | 69 | BasicType element_type() const { return layout_helper_element_type(layout_helper()); } |
duke@435 | 70 | |
duke@435 | 71 | oop component_mirror() const { return _component_mirror; } |
duke@435 | 72 | void set_component_mirror(oop m) { oop_store((oop*) &_component_mirror, m); } |
duke@435 | 73 | oop* adr_component_mirror() { return (oop*)&this->_component_mirror;} |
duke@435 | 74 | |
duke@435 | 75 | // Compiler/Interpreter offset |
stefank@3391 | 76 | static ByteSize component_mirror_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(arrayKlass, _component_mirror)); } |
duke@435 | 77 | |
never@1577 | 78 | virtual klassOop java_super() const;//{ return SystemDictionary::Object_klass(); } |
duke@435 | 79 | |
duke@435 | 80 | // Allocation |
duke@435 | 81 | // Sizes points to the first dimension of the array, subsequent dimensions |
duke@435 | 82 | // are always in higher memory. The callers of these set that up. |
duke@435 | 83 | virtual oop multi_allocate(int rank, jint* sizes, TRAPS); |
duke@435 | 84 | objArrayOop allocate_arrayArray(int n, int length, TRAPS); |
duke@435 | 85 | |
duke@435 | 86 | // Lookup operations |
coleenp@2497 | 87 | methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const; |
duke@435 | 88 | |
duke@435 | 89 | // Casting from klassOop |
duke@435 | 90 | static arrayKlass* cast(klassOop k) { |
duke@435 | 91 | Klass* kp = k->klass_part(); |
duke@435 | 92 | assert(kp->null_vtbl() || kp->oop_is_array(), "cast to arrayKlass"); |
duke@435 | 93 | return (arrayKlass*) kp; |
duke@435 | 94 | } |
duke@435 | 95 | |
duke@435 | 96 | objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS); |
duke@435 | 97 | bool compute_is_subtype_of(klassOop k); |
duke@435 | 98 | |
duke@435 | 99 | // Sizing |
duke@435 | 100 | static int header_size() { return oopDesc::header_size() + sizeof(arrayKlass)/HeapWordSize; } |
duke@435 | 101 | int object_size(int header_size) const; |
duke@435 | 102 | |
duke@435 | 103 | bool object_is_parsable() const { return _vtable_len > 0; } |
duke@435 | 104 | |
duke@435 | 105 | // Java vtable |
duke@435 | 106 | klassVtable* vtable() const; // return new klassVtable |
duke@435 | 107 | int vtable_length() const { return _vtable_len; } |
duke@435 | 108 | static int base_vtable_length() { return Universe::base_vtable_size(); } |
duke@435 | 109 | void set_vtable_length(int len) { assert(len == base_vtable_length(), "bad length"); _vtable_len = len; } |
duke@435 | 110 | protected: |
duke@435 | 111 | inline intptr_t* start_of_vtable() const; |
duke@435 | 112 | |
duke@435 | 113 | public: |
duke@435 | 114 | // Iterators |
duke@435 | 115 | void array_klasses_do(void f(klassOop k)); |
duke@435 | 116 | void with_array_klasses_do(void f(klassOop k)); |
duke@435 | 117 | |
duke@435 | 118 | // Shared creation method |
duke@435 | 119 | static arrayKlassHandle base_create_array_klass( |
duke@435 | 120 | const Klass_vtbl& vtbl, |
duke@435 | 121 | int header_size, KlassHandle klass, |
duke@435 | 122 | TRAPS); |
duke@435 | 123 | // Return a handle. |
duke@435 | 124 | static void complete_create_array_klass(arrayKlassHandle k, KlassHandle super_klass, TRAPS); |
duke@435 | 125 | |
bobv@2036 | 126 | // jvm support |
bobv@2036 | 127 | jint compute_modifier_flags(TRAPS) const; |
duke@435 | 128 | |
bobv@2036 | 129 | // JVMTI support |
bobv@2036 | 130 | jint jvmti_class_status() const; |
duke@435 | 131 | |
duke@435 | 132 | // Printing |
duke@435 | 133 | void oop_print_on(oop obj, outputStream* st); |
bobv@2036 | 134 | |
duke@435 | 135 | // Verification |
duke@435 | 136 | void oop_verify_on(oop obj, outputStream* st); |
duke@435 | 137 | }; |
stefank@2314 | 138 | |
stefank@2314 | 139 | #endif // SHARE_VM_OOPS_ARRAYKLASS_HPP |