Tue, 15 Nov 2011 20:17:33 +0100
7110152: assert(size_in_words <= (julong)max_jint) failed: no overflow
Summary: Reduce what arrayOopDesc::max_array_length() returns to avoid int overflow
Reviewed-by: kvn, dholmes, tonyp
duke@435 | 1 | /* |
never@2658 | 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_KLASS_HPP |
stefank@2314 | 26 | #define SHARE_VM_OOPS_KLASS_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/genOopClosures.hpp" |
stefank@2314 | 29 | #include "memory/iterator.hpp" |
stefank@2314 | 30 | #include "memory/memRegion.hpp" |
stefank@2314 | 31 | #include "memory/specialized_oop_closures.hpp" |
stefank@2314 | 32 | #include "oops/klassOop.hpp" |
stefank@2314 | 33 | #include "oops/klassPS.hpp" |
stefank@2314 | 34 | #include "oops/oop.hpp" |
stefank@2314 | 35 | #include "runtime/orderAccess.hpp" |
stefank@2314 | 36 | #include "utilities/accessFlags.hpp" |
stefank@2314 | 37 | #ifndef SERIALGC |
stefank@2314 | 38 | #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp" |
stefank@2314 | 39 | #include "gc_implementation/g1/g1OopClosures.hpp" |
stefank@2314 | 40 | #include "gc_implementation/parNew/parOopClosures.hpp" |
stefank@2314 | 41 | #endif |
stefank@2314 | 42 | |
duke@435 | 43 | // A Klass is the part of the klassOop that provides: |
duke@435 | 44 | // 1: language level class object (method dictionary etc.) |
duke@435 | 45 | // 2: provide vm dispatch behavior for the object |
duke@435 | 46 | // Both functions are combined into one C++ class. The toplevel class "Klass" |
duke@435 | 47 | // implements purpose 1 whereas all subclasses provide extra virtual functions |
duke@435 | 48 | // for purpose 2. |
duke@435 | 49 | |
duke@435 | 50 | // One reason for the oop/klass dichotomy in the implementation is |
duke@435 | 51 | // that we don't want a C++ vtbl pointer in every object. Thus, |
duke@435 | 52 | // normal oops don't have any virtual functions. Instead, they |
duke@435 | 53 | // forward all "virtual" functions to their klass, which does have |
duke@435 | 54 | // a vtbl and does the C++ dispatch depending on the object's |
duke@435 | 55 | // actual type. (See oop.inline.hpp for some of the forwarding code.) |
duke@435 | 56 | // ALL FUNCTIONS IMPLEMENTING THIS DISPATCH ARE PREFIXED WITH "oop_"! |
duke@435 | 57 | |
duke@435 | 58 | // Klass layout: |
duke@435 | 59 | // [header ] klassOop |
duke@435 | 60 | // [klass pointer ] klassOop |
duke@435 | 61 | // [C++ vtbl ptr ] (contained in Klass_vtbl) |
duke@435 | 62 | // [layout_helper ] |
duke@435 | 63 | // [super_check_offset ] for fast subtype checks |
duke@435 | 64 | // [secondary_super_cache] for fast subtype checks |
duke@435 | 65 | // [secondary_supers ] array of 2ndary supertypes |
duke@435 | 66 | // [primary_supers 0] |
duke@435 | 67 | // [primary_supers 1] |
duke@435 | 68 | // [primary_supers 2] |
duke@435 | 69 | // ... |
duke@435 | 70 | // [primary_supers 7] |
duke@435 | 71 | // [java_mirror ] |
duke@435 | 72 | // [super ] |
duke@435 | 73 | // [name ] |
duke@435 | 74 | // [first subklass] |
duke@435 | 75 | // [next_sibling ] link to chain additional subklasses |
duke@435 | 76 | // [modifier_flags] |
duke@435 | 77 | // [access_flags ] |
duke@435 | 78 | // [verify_count ] - not in product |
duke@435 | 79 | // [alloc_count ] |
duke@435 | 80 | // [last_biased_lock_bulk_revocation_time] (64 bits) |
duke@435 | 81 | // [prototype_header] |
duke@435 | 82 | // [biased_lock_revocation_count] |
duke@435 | 83 | |
duke@435 | 84 | |
duke@435 | 85 | // Forward declarations. |
duke@435 | 86 | class klassVtable; |
duke@435 | 87 | class KlassHandle; |
duke@435 | 88 | class OrderAccess; |
duke@435 | 89 | |
duke@435 | 90 | // Holder (or cage) for the C++ vtable of each kind of Klass. |
duke@435 | 91 | // We want to tightly constrain the location of the C++ vtable in the overall layout. |
duke@435 | 92 | class Klass_vtbl { |
duke@435 | 93 | protected: |
duke@435 | 94 | // The following virtual exists only to force creation of a C++ vtable, |
duke@435 | 95 | // so that this class truly is the location of the vtable of all Klasses. |
duke@435 | 96 | virtual void unused_initial_virtual() { } |
duke@435 | 97 | |
duke@435 | 98 | public: |
duke@435 | 99 | // The following virtual makes Klass_vtbl play a second role as a |
duke@435 | 100 | // factory protocol for subclasses of Klass ("sub-Klasses"). |
duke@435 | 101 | // Here's how it works.... |
duke@435 | 102 | // |
duke@435 | 103 | // This VM uses metaobjects as factories for their instances. |
duke@435 | 104 | // |
duke@435 | 105 | // In order to initialize the C++ vtable of a new instance, its |
duke@435 | 106 | // metaobject is forced to use the C++ placed new operator to |
duke@435 | 107 | // allocate the instance. In a typical C++-based system, each |
duke@435 | 108 | // sub-class would have its own factory routine which |
duke@435 | 109 | // directly uses the placed new operator on the desired class, |
duke@435 | 110 | // and then calls the appropriate chain of C++ constructors. |
duke@435 | 111 | // |
duke@435 | 112 | // However, this system uses shared code to performs the first |
duke@435 | 113 | // allocation and initialization steps for all sub-Klasses. |
duke@435 | 114 | // (See base_create_klass() and base_create_array_klass().) |
duke@435 | 115 | // This does not factor neatly into a hierarchy of C++ constructors. |
duke@435 | 116 | // Each caller of these shared "base_create" routines knows |
duke@435 | 117 | // exactly which sub-Klass it is creating, but the shared routine |
duke@435 | 118 | // does not, even though it must perform the actual allocation. |
duke@435 | 119 | // |
duke@435 | 120 | // Therefore, the caller of the shared "base_create" must wrap |
duke@435 | 121 | // the specific placed new call in a virtual function which |
duke@435 | 122 | // performs the actual allocation and vtable set-up. That |
duke@435 | 123 | // virtual function is here, Klass_vtbl::allocate_permanent. |
duke@435 | 124 | // |
duke@435 | 125 | // The arguments to Universe::allocate_permanent() are passed |
duke@435 | 126 | // straight through the placed new operator, which in turn |
duke@435 | 127 | // obtains them directly from this virtual call. |
duke@435 | 128 | // |
duke@435 | 129 | // This virtual is called on a temporary "example instance" of the |
duke@435 | 130 | // sub-Klass being instantiated, a C++ auto variable. The "real" |
duke@435 | 131 | // instance created by this virtual is on the VM heap, where it is |
duke@435 | 132 | // equipped with a klassOopDesc header. |
duke@435 | 133 | // |
duke@435 | 134 | // It is merely an accident of implementation that we use "example |
duke@435 | 135 | // instances", but that is why the virtual function which implements |
duke@435 | 136 | // each sub-Klass factory happens to be defined by the same sub-Klass |
duke@435 | 137 | // for which it creates instances. |
duke@435 | 138 | // |
duke@435 | 139 | // The vtbl_value() call (see below) is used to strip away the |
duke@435 | 140 | // accidental Klass-ness from an "example instance" and present it as |
duke@435 | 141 | // a factory. Think of each factory object as a mere container of the |
duke@435 | 142 | // C++ vtable for the desired sub-Klass. Since C++ does not allow |
duke@435 | 143 | // direct references to vtables, the factory must also be delegated |
duke@435 | 144 | // the task of allocating the instance, but the essential point is |
duke@435 | 145 | // that the factory knows how to initialize the C++ vtable with the |
duke@435 | 146 | // right pointer value. All other common initializations are handled |
duke@435 | 147 | // by the shared "base_create" subroutines. |
duke@435 | 148 | // |
duke@435 | 149 | virtual void* allocate_permanent(KlassHandle& klass, int size, TRAPS) const = 0; |
duke@435 | 150 | void post_new_init_klass(KlassHandle& klass, klassOop obj, int size) const; |
duke@435 | 151 | |
duke@435 | 152 | // Every subclass on which vtbl_value is called must include this macro. |
duke@435 | 153 | // Delay the installation of the klassKlass pointer until after the |
duke@435 | 154 | // the vtable for a new klass has been installed (after the call to new()). |
ysr@777 | 155 | #define DEFINE_ALLOCATE_PERMANENT(thisKlass) \ |
duke@435 | 156 | void* allocate_permanent(KlassHandle& klass_klass, int size, TRAPS) const { \ |
ysr@777 | 157 | void* result = new(klass_klass, size, THREAD) thisKlass(); \ |
ysr@777 | 158 | if (HAS_PENDING_EXCEPTION) return NULL; \ |
ysr@777 | 159 | klassOop new_klass = ((Klass*) result)->as_klassOop(); \ |
ysr@777 | 160 | OrderAccess::storestore(); \ |
ysr@777 | 161 | post_new_init_klass(klass_klass, new_klass, size); \ |
ysr@777 | 162 | return result; \ |
duke@435 | 163 | } |
duke@435 | 164 | |
duke@435 | 165 | bool null_vtbl() { return *(intptr_t*)this == 0; } |
duke@435 | 166 | |
duke@435 | 167 | protected: |
duke@435 | 168 | void* operator new(size_t ignored, KlassHandle& klass, int size, TRAPS); |
duke@435 | 169 | }; |
duke@435 | 170 | |
duke@435 | 171 | |
duke@435 | 172 | class Klass : public Klass_vtbl { |
duke@435 | 173 | friend class VMStructs; |
duke@435 | 174 | protected: |
duke@435 | 175 | // note: put frequently-used fields together at start of klass structure |
duke@435 | 176 | // for better cache behavior (may not make much of a difference but sure won't hurt) |
duke@435 | 177 | enum { _primary_super_limit = 8 }; |
duke@435 | 178 | |
duke@435 | 179 | // The "layout helper" is a combined descriptor of object layout. |
duke@435 | 180 | // For klasses which are neither instance nor array, the value is zero. |
duke@435 | 181 | // |
duke@435 | 182 | // For instances, layout helper is a positive number, the instance size. |
duke@435 | 183 | // This size is already passed through align_object_size and scaled to bytes. |
duke@435 | 184 | // The low order bit is set if instances of this class cannot be |
duke@435 | 185 | // allocated using the fastpath. |
duke@435 | 186 | // |
duke@435 | 187 | // For arrays, layout helper is a negative number, containing four |
duke@435 | 188 | // distinct bytes, as follows: |
duke@435 | 189 | // MSB:[tag, hsz, ebt, log2(esz)]:LSB |
duke@435 | 190 | // where: |
duke@435 | 191 | // tag is 0x80 if the elements are oops, 0xC0 if non-oops |
duke@435 | 192 | // hsz is array header size in bytes (i.e., offset of first element) |
duke@435 | 193 | // ebt is the BasicType of the elements |
duke@435 | 194 | // esz is the element size in bytes |
duke@435 | 195 | // This packed word is arranged so as to be quickly unpacked by the |
duke@435 | 196 | // various fast paths that use the various subfields. |
duke@435 | 197 | // |
duke@435 | 198 | // The esz bits can be used directly by a SLL instruction, without masking. |
duke@435 | 199 | // |
duke@435 | 200 | // Note that the array-kind tag looks like 0x00 for instance klasses, |
duke@435 | 201 | // since their length in bytes is always less than 24Mb. |
duke@435 | 202 | // |
duke@435 | 203 | // Final note: This comes first, immediately after Klass_vtbl, |
duke@435 | 204 | // because it is frequently queried. |
duke@435 | 205 | jint _layout_helper; |
duke@435 | 206 | |
duke@435 | 207 | // The fields _super_check_offset, _secondary_super_cache, _secondary_supers |
duke@435 | 208 | // and _primary_supers all help make fast subtype checks. See big discussion |
duke@435 | 209 | // in doc/server_compiler/checktype.txt |
duke@435 | 210 | // |
duke@435 | 211 | // Where to look to observe a supertype (it is &_secondary_super_cache for |
duke@435 | 212 | // secondary supers, else is &_primary_supers[depth()]. |
duke@435 | 213 | juint _super_check_offset; |
duke@435 | 214 | |
coleenp@2497 | 215 | // Class name. Instance classes: java/lang/String, etc. Array classes: [I, |
coleenp@2497 | 216 | // [Ljava/lang/String;, etc. Set to zero for all other kinds of classes. |
coleenp@2497 | 217 | Symbol* _name; |
coleenp@2497 | 218 | |
duke@435 | 219 | public: |
duke@435 | 220 | oop* oop_block_beg() const { return adr_secondary_super_cache(); } |
duke@435 | 221 | oop* oop_block_end() const { return adr_next_sibling() + 1; } |
duke@435 | 222 | |
duke@435 | 223 | protected: |
duke@435 | 224 | // |
duke@435 | 225 | // The oop block. All oop fields must be declared here and only oop fields |
duke@435 | 226 | // may be declared here. In addition, the first and last fields in this block |
duke@435 | 227 | // must remain first and last, unless oop_block_beg() and/or oop_block_end() |
duke@435 | 228 | // are updated. Grouping the oop fields in a single block simplifies oop |
duke@435 | 229 | // iteration. |
duke@435 | 230 | // |
duke@435 | 231 | |
duke@435 | 232 | // Cache of last observed secondary supertype |
duke@435 | 233 | klassOop _secondary_super_cache; |
duke@435 | 234 | // Array of all secondary supertypes |
duke@435 | 235 | objArrayOop _secondary_supers; |
duke@435 | 236 | // Ordered list of all primary supertypes |
duke@435 | 237 | klassOop _primary_supers[_primary_super_limit]; |
duke@435 | 238 | // java/lang/Class instance mirroring this class |
duke@435 | 239 | oop _java_mirror; |
duke@435 | 240 | // Superclass |
duke@435 | 241 | klassOop _super; |
duke@435 | 242 | // First subclass (NULL if none); _subklass->next_sibling() is next one |
duke@435 | 243 | klassOop _subklass; |
duke@435 | 244 | // Sibling link (or NULL); links all subklasses of a klass |
duke@435 | 245 | klassOop _next_sibling; |
duke@435 | 246 | |
duke@435 | 247 | // |
duke@435 | 248 | // End of the oop block. |
duke@435 | 249 | // |
duke@435 | 250 | |
duke@435 | 251 | jint _modifier_flags; // Processed access flags, for use by Class.getModifiers. |
duke@435 | 252 | AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here. |
duke@435 | 253 | |
duke@435 | 254 | #ifndef PRODUCT |
duke@435 | 255 | int _verify_count; // to avoid redundant verifies |
duke@435 | 256 | #endif |
duke@435 | 257 | |
duke@435 | 258 | juint _alloc_count; // allocation profiling support - update klass_size_in_bytes() if moved/deleted |
duke@435 | 259 | |
duke@435 | 260 | // Biased locking implementation and statistics |
duke@435 | 261 | // (the 64-bit chunk goes first, to avoid some fragmentation) |
duke@435 | 262 | jlong _last_biased_lock_bulk_revocation_time; |
duke@435 | 263 | markOop _prototype_header; // Used when biased locking is both enabled and disabled for this type |
duke@435 | 264 | jint _biased_lock_revocation_count; |
duke@435 | 265 | |
duke@435 | 266 | public: |
duke@435 | 267 | |
duke@435 | 268 | // returns the enclosing klassOop |
duke@435 | 269 | klassOop as_klassOop() const { |
duke@435 | 270 | // see klassOop.hpp for layout. |
duke@435 | 271 | return (klassOop) (((char*) this) - sizeof(klassOopDesc)); |
duke@435 | 272 | } |
duke@435 | 273 | |
duke@435 | 274 | public: |
duke@435 | 275 | // Allocation |
duke@435 | 276 | const Klass_vtbl& vtbl_value() const { return *this; } // used only on "example instances" |
duke@435 | 277 | static KlassHandle base_create_klass(KlassHandle& klass, int size, const Klass_vtbl& vtbl, TRAPS); |
duke@435 | 278 | static klassOop base_create_klass_oop(KlassHandle& klass, int size, const Klass_vtbl& vtbl, TRAPS); |
duke@435 | 279 | |
duke@435 | 280 | // super |
duke@435 | 281 | klassOop super() const { return _super; } |
duke@435 | 282 | void set_super(klassOop k) { oop_store_without_check((oop*) &_super, (oop) k); } |
duke@435 | 283 | |
duke@435 | 284 | // initializes _super link, _primary_supers & _secondary_supers arrays |
duke@435 | 285 | void initialize_supers(klassOop k, TRAPS); |
duke@435 | 286 | void initialize_supers_impl1(klassOop k); |
duke@435 | 287 | void initialize_supers_impl2(klassOop k); |
duke@435 | 288 | |
duke@435 | 289 | // klass-specific helper for initializing _secondary_supers |
duke@435 | 290 | virtual objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS); |
duke@435 | 291 | |
duke@435 | 292 | // java_super is the Java-level super type as specified by Class.getSuperClass. |
duke@435 | 293 | virtual klassOop java_super() const { return NULL; } |
duke@435 | 294 | |
duke@435 | 295 | juint super_check_offset() const { return _super_check_offset; } |
duke@435 | 296 | void set_super_check_offset(juint o) { _super_check_offset = o; } |
duke@435 | 297 | |
duke@435 | 298 | klassOop secondary_super_cache() const { return _secondary_super_cache; } |
duke@435 | 299 | void set_secondary_super_cache(klassOop k) { oop_store_without_check((oop*) &_secondary_super_cache, (oop) k); } |
duke@435 | 300 | |
duke@435 | 301 | objArrayOop secondary_supers() const { return _secondary_supers; } |
duke@435 | 302 | void set_secondary_supers(objArrayOop k) { oop_store_without_check((oop*) &_secondary_supers, (oop) k); } |
duke@435 | 303 | |
duke@435 | 304 | // Return the element of the _super chain of the given depth. |
duke@435 | 305 | // If there is no such element, return either NULL or this. |
duke@435 | 306 | klassOop primary_super_of_depth(juint i) const { |
duke@435 | 307 | assert(i < primary_super_limit(), "oob"); |
duke@435 | 308 | klassOop super = _primary_supers[i]; |
duke@435 | 309 | assert(super == NULL || super->klass_part()->super_depth() == i, "correct display"); |
duke@435 | 310 | return super; |
duke@435 | 311 | } |
duke@435 | 312 | |
duke@435 | 313 | // Can this klass be a primary super? False for interfaces and arrays of |
duke@435 | 314 | // interfaces. False also for arrays or classes with long super chains. |
duke@435 | 315 | bool can_be_primary_super() const { |
duke@435 | 316 | const juint secondary_offset = secondary_super_cache_offset_in_bytes() + sizeof(oopDesc); |
duke@435 | 317 | return super_check_offset() != secondary_offset; |
duke@435 | 318 | } |
duke@435 | 319 | virtual bool can_be_primary_super_slow() const; |
duke@435 | 320 | |
duke@435 | 321 | // Returns number of primary supers; may be a number in the inclusive range [0, primary_super_limit]. |
duke@435 | 322 | juint super_depth() const { |
duke@435 | 323 | if (!can_be_primary_super()) { |
duke@435 | 324 | return primary_super_limit(); |
duke@435 | 325 | } else { |
duke@435 | 326 | juint d = (super_check_offset() - (primary_supers_offset_in_bytes() + sizeof(oopDesc))) / sizeof(klassOop); |
duke@435 | 327 | assert(d < primary_super_limit(), "oob"); |
duke@435 | 328 | assert(_primary_supers[d] == as_klassOop(), "proper init"); |
duke@435 | 329 | return d; |
duke@435 | 330 | } |
duke@435 | 331 | } |
duke@435 | 332 | |
duke@435 | 333 | // java mirror |
duke@435 | 334 | oop java_mirror() const { return _java_mirror; } |
duke@435 | 335 | void set_java_mirror(oop m) { oop_store((oop*) &_java_mirror, m); } |
duke@435 | 336 | |
duke@435 | 337 | // modifier flags |
duke@435 | 338 | jint modifier_flags() const { return _modifier_flags; } |
duke@435 | 339 | void set_modifier_flags(jint flags) { _modifier_flags = flags; } |
duke@435 | 340 | |
duke@435 | 341 | // size helper |
duke@435 | 342 | int layout_helper() const { return _layout_helper; } |
duke@435 | 343 | void set_layout_helper(int lh) { _layout_helper = lh; } |
duke@435 | 344 | |
duke@435 | 345 | // Note: for instances layout_helper() may include padding. |
duke@435 | 346 | // Use instanceKlass::contains_field_offset to classify field offsets. |
duke@435 | 347 | |
duke@435 | 348 | // sub/superklass links |
duke@435 | 349 | instanceKlass* superklass() const; |
duke@435 | 350 | Klass* subklass() const; |
duke@435 | 351 | Klass* next_sibling() const; |
duke@435 | 352 | void append_to_sibling_list(); // add newly created receiver to superklass' subklass list |
duke@435 | 353 | void remove_from_sibling_list(); // remove receiver from sibling list |
duke@435 | 354 | protected: // internal accessors |
duke@435 | 355 | klassOop subklass_oop() const { return _subklass; } |
duke@435 | 356 | klassOop next_sibling_oop() const { return _next_sibling; } |
duke@435 | 357 | void set_subklass(klassOop s); |
duke@435 | 358 | void set_next_sibling(klassOop s); |
duke@435 | 359 | |
duke@435 | 360 | oop* adr_super() const { return (oop*)&_super; } |
duke@435 | 361 | oop* adr_primary_supers() const { return (oop*)&_primary_supers[0]; } |
duke@435 | 362 | oop* adr_secondary_super_cache() const { return (oop*)&_secondary_super_cache; } |
duke@435 | 363 | oop* adr_secondary_supers()const { return (oop*)&_secondary_supers; } |
duke@435 | 364 | oop* adr_java_mirror() const { return (oop*)&_java_mirror; } |
duke@435 | 365 | oop* adr_subklass() const { return (oop*)&_subklass; } |
duke@435 | 366 | oop* adr_next_sibling() const { return (oop*)&_next_sibling; } |
duke@435 | 367 | |
duke@435 | 368 | public: |
duke@435 | 369 | // Allocation profiling support |
duke@435 | 370 | juint alloc_count() const { return _alloc_count; } |
duke@435 | 371 | void set_alloc_count(juint n) { _alloc_count = n; } |
duke@435 | 372 | virtual juint alloc_size() const = 0; |
duke@435 | 373 | virtual void set_alloc_size(juint n) = 0; |
duke@435 | 374 | |
duke@435 | 375 | // Compiler support |
duke@435 | 376 | static int super_offset_in_bytes() { return offset_of(Klass, _super); } |
duke@435 | 377 | static int super_check_offset_offset_in_bytes() { return offset_of(Klass, _super_check_offset); } |
duke@435 | 378 | static int primary_supers_offset_in_bytes(){ return offset_of(Klass, _primary_supers); } |
duke@435 | 379 | static int secondary_super_cache_offset_in_bytes() { return offset_of(Klass, _secondary_super_cache); } |
duke@435 | 380 | static int secondary_supers_offset_in_bytes() { return offset_of(Klass, _secondary_supers); } |
duke@435 | 381 | static int java_mirror_offset_in_bytes() { return offset_of(Klass, _java_mirror); } |
duke@435 | 382 | static int modifier_flags_offset_in_bytes(){ return offset_of(Klass, _modifier_flags); } |
duke@435 | 383 | static int layout_helper_offset_in_bytes() { return offset_of(Klass, _layout_helper); } |
duke@435 | 384 | static int access_flags_offset_in_bytes() { return offset_of(Klass, _access_flags); } |
duke@435 | 385 | |
duke@435 | 386 | // Unpacking layout_helper: |
duke@435 | 387 | enum { |
duke@435 | 388 | _lh_neutral_value = 0, // neutral non-array non-instance value |
duke@435 | 389 | _lh_instance_slow_path_bit = 0x01, |
duke@435 | 390 | _lh_log2_element_size_shift = BitsPerByte*0, |
duke@435 | 391 | _lh_log2_element_size_mask = BitsPerLong-1, |
duke@435 | 392 | _lh_element_type_shift = BitsPerByte*1, |
duke@435 | 393 | _lh_element_type_mask = right_n_bits(BitsPerByte), // shifted mask |
duke@435 | 394 | _lh_header_size_shift = BitsPerByte*2, |
duke@435 | 395 | _lh_header_size_mask = right_n_bits(BitsPerByte), // shifted mask |
duke@435 | 396 | _lh_array_tag_bits = 2, |
duke@435 | 397 | _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits, |
duke@435 | 398 | _lh_array_tag_type_value = ~0x00, // 0xC0000000 >> 30 |
duke@435 | 399 | _lh_array_tag_obj_value = ~0x01 // 0x80000000 >> 30 |
duke@435 | 400 | }; |
duke@435 | 401 | |
duke@435 | 402 | static int layout_helper_size_in_bytes(jint lh) { |
duke@435 | 403 | assert(lh > (jint)_lh_neutral_value, "must be instance"); |
duke@435 | 404 | return (int) lh & ~_lh_instance_slow_path_bit; |
duke@435 | 405 | } |
duke@435 | 406 | static bool layout_helper_needs_slow_path(jint lh) { |
duke@435 | 407 | assert(lh > (jint)_lh_neutral_value, "must be instance"); |
duke@435 | 408 | return (lh & _lh_instance_slow_path_bit) != 0; |
duke@435 | 409 | } |
duke@435 | 410 | static bool layout_helper_is_instance(jint lh) { |
duke@435 | 411 | return (jint)lh > (jint)_lh_neutral_value; |
duke@435 | 412 | } |
duke@435 | 413 | static bool layout_helper_is_javaArray(jint lh) { |
duke@435 | 414 | return (jint)lh < (jint)_lh_neutral_value; |
duke@435 | 415 | } |
duke@435 | 416 | static bool layout_helper_is_typeArray(jint lh) { |
duke@435 | 417 | // _lh_array_tag_type_value == (lh >> _lh_array_tag_shift); |
duke@435 | 418 | return (juint)lh >= (juint)(_lh_array_tag_type_value << _lh_array_tag_shift); |
duke@435 | 419 | } |
duke@435 | 420 | static bool layout_helper_is_objArray(jint lh) { |
duke@435 | 421 | // _lh_array_tag_obj_value == (lh >> _lh_array_tag_shift); |
duke@435 | 422 | return (jint)lh < (jint)(_lh_array_tag_type_value << _lh_array_tag_shift); |
duke@435 | 423 | } |
duke@435 | 424 | static int layout_helper_header_size(jint lh) { |
duke@435 | 425 | assert(lh < (jint)_lh_neutral_value, "must be array"); |
duke@435 | 426 | int hsize = (lh >> _lh_header_size_shift) & _lh_header_size_mask; |
duke@435 | 427 | assert(hsize > 0 && hsize < (int)sizeof(oopDesc)*3, "sanity"); |
duke@435 | 428 | return hsize; |
duke@435 | 429 | } |
duke@435 | 430 | static BasicType layout_helper_element_type(jint lh) { |
duke@435 | 431 | assert(lh < (jint)_lh_neutral_value, "must be array"); |
duke@435 | 432 | int btvalue = (lh >> _lh_element_type_shift) & _lh_element_type_mask; |
duke@435 | 433 | assert(btvalue >= T_BOOLEAN && btvalue <= T_OBJECT, "sanity"); |
duke@435 | 434 | return (BasicType) btvalue; |
duke@435 | 435 | } |
duke@435 | 436 | static int layout_helper_log2_element_size(jint lh) { |
duke@435 | 437 | assert(lh < (jint)_lh_neutral_value, "must be array"); |
duke@435 | 438 | int l2esz = (lh >> _lh_log2_element_size_shift) & _lh_log2_element_size_mask; |
duke@435 | 439 | assert(l2esz <= LogBitsPerLong, "sanity"); |
duke@435 | 440 | return l2esz; |
duke@435 | 441 | } |
duke@435 | 442 | static jint array_layout_helper(jint tag, int hsize, BasicType etype, int log2_esize) { |
duke@435 | 443 | return (tag << _lh_array_tag_shift) |
duke@435 | 444 | | (hsize << _lh_header_size_shift) |
duke@435 | 445 | | ((int)etype << _lh_element_type_shift) |
duke@435 | 446 | | (log2_esize << _lh_log2_element_size_shift); |
duke@435 | 447 | } |
duke@435 | 448 | static jint instance_layout_helper(jint size, bool slow_path_flag) { |
duke@435 | 449 | return (size << LogHeapWordSize) |
duke@435 | 450 | | (slow_path_flag ? _lh_instance_slow_path_bit : 0); |
duke@435 | 451 | } |
duke@435 | 452 | static int layout_helper_to_size_helper(jint lh) { |
duke@435 | 453 | assert(lh > (jint)_lh_neutral_value, "must be instance"); |
duke@435 | 454 | // Note that the following expression discards _lh_instance_slow_path_bit. |
duke@435 | 455 | return lh >> LogHeapWordSize; |
duke@435 | 456 | } |
duke@435 | 457 | // Out-of-line version computes everything based on the etype: |
duke@435 | 458 | static jint array_layout_helper(BasicType etype); |
duke@435 | 459 | |
duke@435 | 460 | // What is the maximum number of primary superclasses any klass can have? |
duke@435 | 461 | #ifdef PRODUCT |
duke@435 | 462 | static juint primary_super_limit() { return _primary_super_limit; } |
duke@435 | 463 | #else |
duke@435 | 464 | static juint primary_super_limit() { |
duke@435 | 465 | assert(FastSuperclassLimit <= _primary_super_limit, "parameter oob"); |
duke@435 | 466 | return FastSuperclassLimit; |
duke@435 | 467 | } |
duke@435 | 468 | #endif |
duke@435 | 469 | |
duke@435 | 470 | // vtables |
duke@435 | 471 | virtual klassVtable* vtable() const { return NULL; } |
duke@435 | 472 | |
duke@435 | 473 | static int klass_size_in_bytes() { return offset_of(Klass, _alloc_count) + sizeof(juint); } // all "visible" fields |
duke@435 | 474 | |
duke@435 | 475 | // subclass check |
duke@435 | 476 | bool is_subclass_of(klassOop k) const; |
duke@435 | 477 | // subtype check: true if is_subclass_of, or if k is interface and receiver implements it |
duke@435 | 478 | bool is_subtype_of(klassOop k) const { |
duke@435 | 479 | juint off = k->klass_part()->super_check_offset(); |
duke@435 | 480 | klassOop sup = *(klassOop*)( (address)as_klassOop() + off ); |
duke@435 | 481 | const juint secondary_offset = secondary_super_cache_offset_in_bytes() + sizeof(oopDesc); |
duke@435 | 482 | if (sup == k) { |
duke@435 | 483 | return true; |
duke@435 | 484 | } else if (off != secondary_offset) { |
duke@435 | 485 | return false; |
duke@435 | 486 | } else { |
duke@435 | 487 | return search_secondary_supers(k); |
duke@435 | 488 | } |
duke@435 | 489 | } |
duke@435 | 490 | bool search_secondary_supers(klassOop k) const; |
duke@435 | 491 | |
twisti@1040 | 492 | // Find LCA in class hierarchy |
duke@435 | 493 | Klass *LCA( Klass *k ); |
duke@435 | 494 | |
duke@435 | 495 | // Check whether reflection/jni/jvm code is allowed to instantiate this class; |
duke@435 | 496 | // if not, throw either an Error or an Exception. |
duke@435 | 497 | virtual void check_valid_for_instantiation(bool throwError, TRAPS); |
duke@435 | 498 | |
duke@435 | 499 | // Casting |
duke@435 | 500 | static Klass* cast(klassOop k) { |
duke@435 | 501 | assert(k->is_klass(), "cast to Klass"); |
duke@435 | 502 | return k->klass_part(); |
duke@435 | 503 | } |
duke@435 | 504 | |
duke@435 | 505 | // array copying |
duke@435 | 506 | virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); |
duke@435 | 507 | |
duke@435 | 508 | // tells if the class should be initialized |
duke@435 | 509 | virtual bool should_be_initialized() const { return false; } |
duke@435 | 510 | // initializes the klass |
duke@435 | 511 | virtual void initialize(TRAPS); |
duke@435 | 512 | // lookup operation for MethodLookupCache |
duke@435 | 513 | friend class MethodLookupCache; |
coleenp@2497 | 514 | virtual methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const; |
duke@435 | 515 | public: |
coleenp@2497 | 516 | methodOop lookup_method(Symbol* name, Symbol* signature) const { |
duke@435 | 517 | return uncached_lookup_method(name, signature); |
duke@435 | 518 | } |
duke@435 | 519 | |
duke@435 | 520 | // array class with specific rank |
duke@435 | 521 | klassOop array_klass(int rank, TRAPS) { return array_klass_impl(false, rank, THREAD); } |
duke@435 | 522 | |
duke@435 | 523 | // array class with this klass as element type |
duke@435 | 524 | klassOop array_klass(TRAPS) { return array_klass_impl(false, THREAD); } |
duke@435 | 525 | |
duke@435 | 526 | // These will return NULL instead of allocating on the heap: |
duke@435 | 527 | // NB: these can block for a mutex, like other functions with TRAPS arg. |
duke@435 | 528 | klassOop array_klass_or_null(int rank); |
duke@435 | 529 | klassOop array_klass_or_null(); |
duke@435 | 530 | |
duke@435 | 531 | virtual oop protection_domain() { return NULL; } |
duke@435 | 532 | virtual oop class_loader() const { return NULL; } |
duke@435 | 533 | |
duke@435 | 534 | protected: |
duke@435 | 535 | virtual klassOop array_klass_impl(bool or_null, int rank, TRAPS); |
duke@435 | 536 | virtual klassOop array_klass_impl(bool or_null, TRAPS); |
duke@435 | 537 | |
duke@435 | 538 | public: |
duke@435 | 539 | virtual void remove_unshareable_info(); |
coleenp@2497 | 540 | virtual void shared_symbols_iterate(SymbolClosure* closure); |
duke@435 | 541 | |
duke@435 | 542 | protected: |
duke@435 | 543 | // computes the subtype relationship |
duke@435 | 544 | virtual bool compute_is_subtype_of(klassOop k); |
duke@435 | 545 | public: |
duke@435 | 546 | // subclass accessor (here for convenience; undefined for non-klass objects) |
duke@435 | 547 | virtual bool is_leaf_class() const { fatal("not a class"); return false; } |
duke@435 | 548 | public: |
duke@435 | 549 | // ALL FUNCTIONS BELOW THIS POINT ARE DISPATCHED FROM AN OOP |
duke@435 | 550 | // These functions describe behavior for the oop not the KLASS. |
duke@435 | 551 | |
duke@435 | 552 | // actual oop size of obj in memory |
duke@435 | 553 | virtual int oop_size(oop obj) const = 0; |
duke@435 | 554 | |
duke@435 | 555 | // actual oop size of this klass in memory |
duke@435 | 556 | virtual int klass_oop_size() const = 0; |
duke@435 | 557 | |
duke@435 | 558 | // Returns the Java name for a class (Resource allocated) |
duke@435 | 559 | // For arrays, this returns the name of the element with a leading '['. |
duke@435 | 560 | // For classes, this returns the name with the package separators |
duke@435 | 561 | // turned into '.'s. |
duke@435 | 562 | const char* external_name() const; |
duke@435 | 563 | // Returns the name for a class (Resource allocated) as the class |
duke@435 | 564 | // would appear in a signature. |
duke@435 | 565 | // For arrays, this returns the name of the element with a leading '['. |
duke@435 | 566 | // For classes, this returns the name with a leading 'L' and a trailing ';' |
duke@435 | 567 | // and the package separators as '/'. |
jrose@1474 | 568 | virtual const char* signature_name() const; |
duke@435 | 569 | |
duke@435 | 570 | // garbage collection support |
duke@435 | 571 | virtual void oop_follow_contents(oop obj) = 0; |
duke@435 | 572 | virtual int oop_adjust_pointers(oop obj) = 0; |
duke@435 | 573 | |
duke@435 | 574 | // Parallel Scavenge and Parallel Old |
duke@435 | 575 | PARALLEL_GC_DECLS_PV |
duke@435 | 576 | |
duke@435 | 577 | public: |
duke@435 | 578 | // type testing operations |
duke@435 | 579 | virtual bool oop_is_instance_slow() const { return false; } |
never@2658 | 580 | virtual bool oop_is_instanceMirror() const { return false; } |
duke@435 | 581 | virtual bool oop_is_instanceRef() const { return false; } |
duke@435 | 582 | virtual bool oop_is_array() const { return false; } |
duke@435 | 583 | virtual bool oop_is_objArray_slow() const { return false; } |
duke@435 | 584 | virtual bool oop_is_klass() const { return false; } |
duke@435 | 585 | virtual bool oop_is_thread() const { return false; } |
duke@435 | 586 | virtual bool oop_is_method() const { return false; } |
duke@435 | 587 | virtual bool oop_is_constMethod() const { return false; } |
duke@435 | 588 | virtual bool oop_is_methodData() const { return false; } |
duke@435 | 589 | virtual bool oop_is_constantPool() const { return false; } |
duke@435 | 590 | virtual bool oop_is_constantPoolCache() const { return false; } |
duke@435 | 591 | virtual bool oop_is_typeArray_slow() const { return false; } |
duke@435 | 592 | virtual bool oop_is_arrayKlass() const { return false; } |
duke@435 | 593 | virtual bool oop_is_objArrayKlass() const { return false; } |
duke@435 | 594 | virtual bool oop_is_typeArrayKlass() const { return false; } |
duke@435 | 595 | virtual bool oop_is_compiledICHolder() const { return false; } |
duke@435 | 596 | virtual bool oop_is_instanceKlass() const { return false; } |
duke@435 | 597 | |
duke@435 | 598 | bool oop_is_javaArray_slow() const { |
duke@435 | 599 | return oop_is_objArray_slow() || oop_is_typeArray_slow(); |
duke@435 | 600 | } |
duke@435 | 601 | |
duke@435 | 602 | // Fast non-virtual versions, used by oop.inline.hpp and elsewhere: |
duke@435 | 603 | #ifndef ASSERT |
duke@435 | 604 | #define assert_same_query(xval, xcheck) xval |
duke@435 | 605 | #else |
duke@435 | 606 | private: |
duke@435 | 607 | static bool assert_same_query(bool xval, bool xslow) { |
duke@435 | 608 | assert(xval == xslow, "slow and fast queries agree"); |
duke@435 | 609 | return xval; |
duke@435 | 610 | } |
duke@435 | 611 | public: |
duke@435 | 612 | #endif |
duke@435 | 613 | inline bool oop_is_instance() const { return assert_same_query( |
duke@435 | 614 | layout_helper_is_instance(layout_helper()), |
duke@435 | 615 | oop_is_instance_slow()); } |
duke@435 | 616 | inline bool oop_is_javaArray() const { return assert_same_query( |
duke@435 | 617 | layout_helper_is_javaArray(layout_helper()), |
duke@435 | 618 | oop_is_javaArray_slow()); } |
duke@435 | 619 | inline bool oop_is_objArray() const { return assert_same_query( |
duke@435 | 620 | layout_helper_is_objArray(layout_helper()), |
duke@435 | 621 | oop_is_objArray_slow()); } |
duke@435 | 622 | inline bool oop_is_typeArray() const { return assert_same_query( |
duke@435 | 623 | layout_helper_is_typeArray(layout_helper()), |
duke@435 | 624 | oop_is_typeArray_slow()); } |
duke@435 | 625 | #undef assert_same_query |
duke@435 | 626 | |
duke@435 | 627 | // Unless overridden, oop is parsable if it has a klass pointer. |
jmasa@953 | 628 | // Parsability of an object is object specific. |
duke@435 | 629 | virtual bool oop_is_parsable(oop obj) const { return true; } |
duke@435 | 630 | |
jmasa@953 | 631 | // Unless overridden, oop is safe for concurrent GC processing |
jmasa@953 | 632 | // after its allocation is complete. The exception to |
jmasa@953 | 633 | // this is the case where objects are changed after allocation. |
jmasa@953 | 634 | // Class redefinition is one of the known exceptions. During |
jmasa@953 | 635 | // class redefinition, an allocated class can changed in order |
jmasa@953 | 636 | // order to create a merged class (the combiniation of the |
jmasa@953 | 637 | // old class definition that has to be perserved and the new class |
jmasa@953 | 638 | // definition which is being created. |
jmasa@953 | 639 | virtual bool oop_is_conc_safe(oop obj) const { return true; } |
jmasa@953 | 640 | |
duke@435 | 641 | // Access flags |
duke@435 | 642 | AccessFlags access_flags() const { return _access_flags; } |
duke@435 | 643 | void set_access_flags(AccessFlags flags) { _access_flags = flags; } |
duke@435 | 644 | |
duke@435 | 645 | bool is_public() const { return _access_flags.is_public(); } |
duke@435 | 646 | bool is_final() const { return _access_flags.is_final(); } |
duke@435 | 647 | bool is_interface() const { return _access_flags.is_interface(); } |
duke@435 | 648 | bool is_abstract() const { return _access_flags.is_abstract(); } |
duke@435 | 649 | bool is_super() const { return _access_flags.is_super(); } |
duke@435 | 650 | bool is_synthetic() const { return _access_flags.is_synthetic(); } |
duke@435 | 651 | void set_is_synthetic() { _access_flags.set_is_synthetic(); } |
duke@435 | 652 | bool has_finalizer() const { return _access_flags.has_finalizer(); } |
duke@435 | 653 | bool has_final_method() const { return _access_flags.has_final_method(); } |
duke@435 | 654 | void set_has_finalizer() { _access_flags.set_has_finalizer(); } |
duke@435 | 655 | void set_has_final_method() { _access_flags.set_has_final_method(); } |
duke@435 | 656 | bool is_cloneable() const { return _access_flags.is_cloneable(); } |
duke@435 | 657 | void set_is_cloneable() { _access_flags.set_is_cloneable(); } |
duke@435 | 658 | bool has_vanilla_constructor() const { return _access_flags.has_vanilla_constructor(); } |
duke@435 | 659 | void set_has_vanilla_constructor() { _access_flags.set_has_vanilla_constructor(); } |
duke@435 | 660 | bool has_miranda_methods () const { return access_flags().has_miranda_methods(); } |
duke@435 | 661 | void set_has_miranda_methods() { _access_flags.set_has_miranda_methods(); } |
duke@435 | 662 | |
duke@435 | 663 | // Biased locking support |
duke@435 | 664 | // Note: the prototype header is always set up to be at least the |
duke@435 | 665 | // prototype markOop. If biased locking is enabled it may further be |
duke@435 | 666 | // biasable and have an epoch. |
duke@435 | 667 | markOop prototype_header() const { return _prototype_header; } |
duke@435 | 668 | // NOTE: once instances of this klass are floating around in the |
duke@435 | 669 | // system, this header must only be updated at a safepoint. |
duke@435 | 670 | // NOTE 2: currently we only ever set the prototype header to the |
duke@435 | 671 | // biasable prototype for instanceKlasses. There is no technical |
duke@435 | 672 | // reason why it could not be done for arrayKlasses aside from |
duke@435 | 673 | // wanting to reduce the initial scope of this optimization. There |
duke@435 | 674 | // are potential problems in setting the bias pattern for |
duke@435 | 675 | // JVM-internal oops. |
duke@435 | 676 | inline void set_prototype_header(markOop header); |
duke@435 | 677 | static int prototype_header_offset_in_bytes() { return offset_of(Klass, _prototype_header); } |
duke@435 | 678 | |
duke@435 | 679 | int biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; } |
duke@435 | 680 | // Atomically increments biased_lock_revocation_count and returns updated value |
duke@435 | 681 | int atomic_incr_biased_lock_revocation_count(); |
duke@435 | 682 | void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; } |
duke@435 | 683 | jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; } |
duke@435 | 684 | void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; } |
duke@435 | 685 | |
duke@435 | 686 | |
duke@435 | 687 | // garbage collection support |
duke@435 | 688 | virtual void follow_weak_klass_links( |
duke@435 | 689 | BoolObjectClosure* is_alive, OopClosure* keep_alive); |
duke@435 | 690 | |
duke@435 | 691 | // Prefetch within oop iterators. This is a macro because we |
duke@435 | 692 | // can't guarantee that the compiler will inline it. In 64-bit |
duke@435 | 693 | // it generally doesn't. Signature is |
duke@435 | 694 | // |
duke@435 | 695 | // static void prefetch_beyond(oop* const start, |
duke@435 | 696 | // oop* const end, |
duke@435 | 697 | // const intx foffset, |
duke@435 | 698 | // const Prefetch::style pstyle); |
duke@435 | 699 | #define prefetch_beyond(start, end, foffset, pstyle) { \ |
duke@435 | 700 | const intx foffset_ = (foffset); \ |
duke@435 | 701 | const Prefetch::style pstyle_ = (pstyle); \ |
duke@435 | 702 | assert(foffset_ > 0, "prefetch beyond, not behind"); \ |
duke@435 | 703 | if (pstyle_ != Prefetch::do_none) { \ |
duke@435 | 704 | oop* ref = (start); \ |
duke@435 | 705 | if (ref < (end)) { \ |
duke@435 | 706 | switch (pstyle_) { \ |
duke@435 | 707 | case Prefetch::do_read: \ |
duke@435 | 708 | Prefetch::read(*ref, foffset_); \ |
duke@435 | 709 | break; \ |
duke@435 | 710 | case Prefetch::do_write: \ |
duke@435 | 711 | Prefetch::write(*ref, foffset_); \ |
duke@435 | 712 | break; \ |
duke@435 | 713 | default: \ |
duke@435 | 714 | ShouldNotReachHere(); \ |
duke@435 | 715 | break; \ |
duke@435 | 716 | } \ |
duke@435 | 717 | } \ |
duke@435 | 718 | } \ |
duke@435 | 719 | } |
duke@435 | 720 | |
duke@435 | 721 | // iterators |
duke@435 | 722 | virtual int oop_oop_iterate(oop obj, OopClosure* blk) = 0; |
duke@435 | 723 | virtual int oop_oop_iterate_v(oop obj, OopClosure* blk) { |
duke@435 | 724 | return oop_oop_iterate(obj, blk); |
duke@435 | 725 | } |
duke@435 | 726 | |
ysr@777 | 727 | #ifndef SERIALGC |
ysr@777 | 728 | // In case we don't have a specialized backward scanner use forward |
ysr@777 | 729 | // iteration. |
ysr@777 | 730 | virtual int oop_oop_iterate_backwards_v(oop obj, OopClosure* blk) { |
ysr@777 | 731 | return oop_oop_iterate_v(obj, blk); |
ysr@777 | 732 | } |
ysr@777 | 733 | #endif // !SERIALGC |
ysr@777 | 734 | |
duke@435 | 735 | // Iterates "blk" over all the oops in "obj" (of type "this") within "mr". |
duke@435 | 736 | // (I don't see why the _m should be required, but without it the Solaris |
duke@435 | 737 | // C++ gives warning messages about overridings of the "oop_oop_iterate" |
duke@435 | 738 | // defined above "hiding" this virtual function. (DLD, 6/20/00)) */ |
duke@435 | 739 | virtual int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) = 0; |
duke@435 | 740 | virtual int oop_oop_iterate_v_m(oop obj, OopClosure* blk, MemRegion mr) { |
duke@435 | 741 | return oop_oop_iterate_m(obj, blk, mr); |
duke@435 | 742 | } |
duke@435 | 743 | |
duke@435 | 744 | // Versions of the above iterators specialized to particular subtypes |
duke@435 | 745 | // of OopClosure, to avoid closure virtual calls. |
duke@435 | 746 | #define Klass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ |
duke@435 | 747 | virtual int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk) { \ |
duke@435 | 748 | /* Default implementation reverts to general version. */ \ |
duke@435 | 749 | return oop_oop_iterate(obj, blk); \ |
duke@435 | 750 | } \ |
duke@435 | 751 | \ |
duke@435 | 752 | /* Iterates "blk" over all the oops in "obj" (of type "this") within "mr". \ |
duke@435 | 753 | (I don't see why the _m should be required, but without it the Solaris \ |
duke@435 | 754 | C++ gives warning messages about overridings of the "oop_oop_iterate" \ |
duke@435 | 755 | defined above "hiding" this virtual function. (DLD, 6/20/00)) */ \ |
duke@435 | 756 | virtual int oop_oop_iterate##nv_suffix##_m(oop obj, \ |
duke@435 | 757 | OopClosureType* blk, \ |
duke@435 | 758 | MemRegion mr) { \ |
duke@435 | 759 | return oop_oop_iterate_m(obj, blk, mr); \ |
duke@435 | 760 | } |
duke@435 | 761 | |
duke@435 | 762 | SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_DECL) |
ysr@777 | 763 | SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_DECL) |
ysr@777 | 764 | |
ysr@777 | 765 | #ifndef SERIALGC |
ysr@777 | 766 | #define Klass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \ |
ysr@777 | 767 | virtual int oop_oop_iterate_backwards##nv_suffix(oop obj, \ |
ysr@777 | 768 | OopClosureType* blk) { \ |
ysr@777 | 769 | /* Default implementation reverts to general version. */ \ |
ysr@777 | 770 | return oop_oop_iterate_backwards_v(obj, blk); \ |
ysr@777 | 771 | } |
ysr@777 | 772 | |
ysr@777 | 773 | SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_BACKWARDS_DECL) |
ysr@777 | 774 | SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_BACKWARDS_DECL) |
ysr@777 | 775 | #endif // !SERIALGC |
duke@435 | 776 | |
duke@435 | 777 | virtual void array_klasses_do(void f(klassOop k)) {} |
duke@435 | 778 | virtual void with_array_klasses_do(void f(klassOop k)); |
duke@435 | 779 | |
duke@435 | 780 | // Return self, except for abstract classes with exactly 1 |
duke@435 | 781 | // implementor. Then return the 1 concrete implementation. |
duke@435 | 782 | Klass *up_cast_abstract(); |
duke@435 | 783 | |
duke@435 | 784 | // klass name |
coleenp@2497 | 785 | Symbol* name() const { return _name; } |
coleenp@2497 | 786 | void set_name(Symbol* n); |
duke@435 | 787 | |
duke@435 | 788 | friend class klassKlass; |
duke@435 | 789 | |
duke@435 | 790 | public: |
duke@435 | 791 | // jvm support |
duke@435 | 792 | virtual jint compute_modifier_flags(TRAPS) const; |
duke@435 | 793 | |
duke@435 | 794 | // JVMTI support |
duke@435 | 795 | virtual jint jvmti_class_status() const; |
duke@435 | 796 | |
duke@435 | 797 | // Printing |
jrose@1590 | 798 | virtual void oop_print_value_on(oop obj, outputStream* st); |
duke@435 | 799 | virtual void oop_print_on (oop obj, outputStream* st); |
duke@435 | 800 | |
duke@435 | 801 | // Verification |
duke@435 | 802 | virtual const char* internal_name() const = 0; |
duke@435 | 803 | virtual void oop_verify_on(oop obj, outputStream* st); |
duke@435 | 804 | virtual void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty); |
coleenp@548 | 805 | virtual void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty); |
duke@435 | 806 | // tells whether obj is partially constructed (gc during class loading) |
duke@435 | 807 | virtual bool oop_partially_loaded(oop obj) const { return false; } |
duke@435 | 808 | virtual void oop_set_partially_loaded(oop obj) {}; |
duke@435 | 809 | |
duke@435 | 810 | #ifndef PRODUCT |
duke@435 | 811 | void verify_vtable_index(int index); |
duke@435 | 812 | #endif |
duke@435 | 813 | }; |
stefank@2314 | 814 | |
never@2658 | 815 | |
never@2658 | 816 | inline oop klassOopDesc::java_mirror() const { return klass_part()->java_mirror(); } |
never@2658 | 817 | |
never@2658 | 818 | |
stefank@2314 | 819 | #endif // SHARE_VM_OOPS_KLASS_HPP |