src/share/vm/oops/instanceMirrorKlass.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) 2011, 2013, 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_INSTANCEMIRRORKLASS_HPP
aoqi@0 26 #define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
aoqi@0 27
aoqi@0 28 #include "classfile/systemDictionary.hpp"
aoqi@0 29 #include "oops/instanceKlass.hpp"
aoqi@0 30 #include "runtime/handles.hpp"
aoqi@0 31 #include "utilities/macros.hpp"
aoqi@0 32
aoqi@0 33 // An InstanceMirrorKlass is a specialized InstanceKlass for
aoqi@0 34 // java.lang.Class instances. These instances are special because
aoqi@0 35 // they contain the static fields of the class in addition to the
aoqi@0 36 // normal fields of Class. This means they are variable sized
aoqi@0 37 // instances and need special logic for computing their size and for
aoqi@0 38 // iteration of their oops.
aoqi@0 39
aoqi@0 40
aoqi@0 41 class InstanceMirrorKlass: public InstanceKlass {
aoqi@0 42 friend class VMStructs;
aoqi@0 43 friend class InstanceKlass;
aoqi@0 44
aoqi@0 45 private:
aoqi@0 46 static int _offset_of_static_fields;
aoqi@0 47
aoqi@0 48 // Constructor
aoqi@0 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)
aoqi@0 50 : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous) {}
aoqi@0 51
aoqi@0 52 public:
aoqi@0 53 InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
aoqi@0 54 // Type testing
aoqi@0 55 bool oop_is_instanceMirror() const { return true; }
aoqi@0 56
aoqi@0 57 // Casting from Klass*
aoqi@0 58 static InstanceMirrorKlass* cast(Klass* k) {
aoqi@0 59 assert(k->oop_is_instanceMirror(), "cast to InstanceMirrorKlass");
aoqi@0 60 return (InstanceMirrorKlass*) k;
aoqi@0 61 }
aoqi@0 62
aoqi@0 63 // Returns the size of the instance including the extra static fields.
aoqi@0 64 virtual int oop_size(oop obj) const;
aoqi@0 65
aoqi@0 66 // Static field offset is an offset into the Heap, should be converted by
aoqi@0 67 // based on UseCompressedOop for traversal
aoqi@0 68 static HeapWord* start_of_static_fields(oop obj) {
aoqi@0 69 return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());
aoqi@0 70 }
aoqi@0 71
aoqi@0 72 static void init_offset_of_static_fields() {
aoqi@0 73 // Cache the offset of the static fields in the Class instance
aoqi@0 74 assert(_offset_of_static_fields == 0, "once");
aoqi@0 75 _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
aoqi@0 76 }
aoqi@0 77
aoqi@0 78 static int offset_of_static_fields() {
aoqi@0 79 return _offset_of_static_fields;
aoqi@0 80 }
aoqi@0 81
aoqi@0 82 int compute_static_oop_field_count(oop obj);
aoqi@0 83
aoqi@0 84 // Given a Klass return the size of the instance
aoqi@0 85 int instance_size(KlassHandle k);
aoqi@0 86
aoqi@0 87 // allocation
aoqi@0 88 instanceOop allocate_instance(KlassHandle k, TRAPS);
aoqi@0 89
aoqi@0 90 // Garbage collection
aoqi@0 91 int oop_adjust_pointers(oop obj);
aoqi@0 92 void oop_follow_contents(oop obj);
aoqi@0 93
aoqi@0 94 // Parallel Scavenge and Parallel Old
aoqi@0 95 PARALLEL_GC_DECLS
aoqi@0 96
aoqi@0 97 int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
aoqi@0 98 return oop_oop_iterate_v(obj, blk);
aoqi@0 99 }
aoqi@0 100 int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {
aoqi@0 101 return oop_oop_iterate_v_m(obj, blk, mr);
aoqi@0 102 }
aoqi@0 103
aoqi@0 104 #define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
aoqi@0 105 int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \
aoqi@0 106 int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
aoqi@0 107
aoqi@0 108 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
aoqi@0 109 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
aoqi@0 110
aoqi@0 111 #if INCLUDE_ALL_GCS
aoqi@0 112 #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
aoqi@0 113 int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
aoqi@0 114
aoqi@0 115 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
aoqi@0 116 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
aoqi@0 117 #endif // INCLUDE_ALL_GCS
aoqi@0 118 };
aoqi@0 119
aoqi@0 120 #endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP

mercurial