annotate src/share/vm/oops/instanceMirrorKlass.hpp @ 7745:6dc8db7164d2

Added tag jdk9-b49 for changeset 360cd1fc42f1
author katleman
date Thu, 05 Feb 2015 11:43:29 -0800
parents db9981fd3124
children 30ea4c772cb9
rev   line source
never@2223 1 /*
hseigel@5349 2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
never@2223 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
never@2223 4 *
never@2223 5 * This code is free software; you can redistribute it and/or modify it
never@2223 6 * under the terms of the GNU General Public License version 2 only, as
never@2223 7 * published by the Free Software Foundation.
never@2223 8 *
never@2223 9 * This code is distributed in the hope that it will be useful, but WITHOUT
never@2223 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
never@2223 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
never@2223 12 * version 2 for more details (a copy is included in the LICENSE file that
never@2223 13 * accompanied this code).
never@2223 14 *
never@2223 15 * You should have received a copy of the GNU General Public License version
never@2223 16 * 2 along with this work; if not, write to the Free Software Foundation,
never@2223 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
never@2223 18 *
never@2223 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
never@2223 20 * or visit www.oracle.com if you need additional information or have any
never@2223 21 * questions.
never@2223 22 *
never@2223 23 */
never@2223 24
never@2223 25 #ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
never@2223 26 #define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
never@2223 27
coleenp@3602 28 #include "classfile/systemDictionary.hpp"
never@2223 29 #include "oops/instanceKlass.hpp"
coleenp@3602 30 #include "runtime/handles.hpp"
jprovino@4107 31 #include "utilities/macros.hpp"
never@2223 32
coleenp@3612 33 // An InstanceMirrorKlass is a specialized InstanceKlass for
never@2223 34 // java.lang.Class instances. These instances are special because
never@2223 35 // they contain the static fields of the class in addition to the
never@2223 36 // normal fields of Class. This means they are variable sized
never@2223 37 // instances and need special logic for computing their size and for
never@2223 38 // iteration of their oops.
never@2223 39
never@2223 40
coleenp@3612 41 class InstanceMirrorKlass: public InstanceKlass {
never@2258 42 friend class VMStructs;
coleenp@3602 43 friend class InstanceKlass;
never@2258 44
never@2223 45 private:
never@2223 46 static int _offset_of_static_fields;
never@2223 47
coleenp@3602 48 // Constructor
coleenp@3612 49 InstanceMirrorKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags, bool is_anonymous)
coleenp@3602 50 : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous) {}
coleenp@3602 51
never@2223 52 public:
coleenp@3612 53 InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
never@2223 54 // Type testing
never@2223 55 bool oop_is_instanceMirror() const { return true; }
never@2223 56
coleenp@3602 57 // Casting from Klass*
coleenp@3612 58 static InstanceMirrorKlass* cast(Klass* k) {
coleenp@3612 59 assert(k->oop_is_instanceMirror(), "cast to InstanceMirrorKlass");
coleenp@3612 60 return (InstanceMirrorKlass*) k;
never@2223 61 }
never@2223 62
never@2223 63 // Returns the size of the instance including the extra static fields.
never@2223 64 virtual int oop_size(oop obj) const;
never@2223 65
never@2223 66 // Static field offset is an offset into the Heap, should be converted by
never@2223 67 // based on UseCompressedOop for traversal
never@2223 68 static HeapWord* start_of_static_fields(oop obj) {
hseigel@5349 69 return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());
never@2223 70 }
never@2223 71
never@2223 72 static void init_offset_of_static_fields() {
never@2223 73 // Cache the offset of the static fields in the Class instance
never@2223 74 assert(_offset_of_static_fields == 0, "once");
coleenp@3612 75 _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
never@2223 76 }
never@2223 77
never@2223 78 static int offset_of_static_fields() {
never@2223 79 return _offset_of_static_fields;
never@2223 80 }
never@2223 81
never@2223 82 int compute_static_oop_field_count(oop obj);
never@2223 83
never@2223 84 // Given a Klass return the size of the instance
never@2223 85 int instance_size(KlassHandle k);
never@2223 86
never@2223 87 // allocation
never@2223 88 instanceOop allocate_instance(KlassHandle k, TRAPS);
never@2223 89
never@2223 90 // Garbage collection
never@2223 91 int oop_adjust_pointers(oop obj);
never@2223 92 void oop_follow_contents(oop obj);
never@2223 93
never@2223 94 // Parallel Scavenge and Parallel Old
never@2223 95 PARALLEL_GC_DECLS
never@2223 96
coleenp@3602 97 int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
never@2223 98 return oop_oop_iterate_v(obj, blk);
never@2223 99 }
coleenp@3602 100 int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {
never@2223 101 return oop_oop_iterate_v_m(obj, blk, mr);
never@2223 102 }
never@2223 103
never@2223 104 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
never@2223 105 int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \
never@2223 106 int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
never@2223 107
never@2223 108 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
never@2223 109 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
never@2223 110
jprovino@4107 111 #if INCLUDE_ALL_GCS
never@2223 112 #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
never@2223 113 int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
never@2223 114
never@2223 115 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
never@2223 116 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
jprovino@4107 117 #endif // INCLUDE_ALL_GCS
never@2223 118 };
never@2223 119
never@2223 120 #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP