comparison src/share/vm/ci/ciKlass.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 1d1603768966
children e522a00b91aa 6171eb9da4fd
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
28 #include "ci/ciUtilities.hpp" 28 #include "ci/ciUtilities.hpp"
29 #include "oops/oop.inline.hpp" 29 #include "oops/oop.inline.hpp"
30 30
31 // ciKlass 31 // ciKlass
32 // 32 //
33 // This class represents a klassOop in the HotSpot virtual 33 // This class represents a Klass* in the HotSpot virtual
34 // machine. 34 // machine.
35 35
36 // ------------------------------------------------------------------ 36 // ------------------------------------------------------------------
37 // ciKlass::ciKlass 37 // ciKlass::ciKlass
38 ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { 38 ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) {
39 assert(get_oop()->is_klass(), "wrong type"); 39 assert(get_Klass()->is_klass(), "wrong type");
40 Klass* k = get_Klass(); 40 Klass* k = get_Klass();
41 _layout_helper = k->layout_helper(); 41 _layout_helper = k->layout_helper();
42 Symbol* klass_name = k->name(); 42 Symbol* klass_name = k->name();
43 assert(klass_name != NULL, "wrong ciKlass constructor"); 43 assert(klass_name != NULL, "wrong ciKlass constructor");
44 _name = CURRENT_ENV->get_symbol(klass_name); 44 _name = CURRENT_ENV->get_symbol(klass_name);
47 // ------------------------------------------------------------------ 47 // ------------------------------------------------------------------
48 // ciKlass::ciKlass 48 // ciKlass::ciKlass
49 // 49 //
50 // Nameless klass variant. 50 // Nameless klass variant.
51 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) { 51 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) {
52 assert(get_oop()->is_klass(), "wrong type"); 52 assert(get_Klass()->is_klass(), "wrong type");
53 _name = name; 53 _name = name;
54 _layout_helper = Klass::_lh_neutral_value; 54 _layout_helper = Klass::_lh_neutral_value;
55 } 55 }
56 56
57 // ------------------------------------------------------------------ 57 // ------------------------------------------------------------------
58 // ciKlass::ciKlass 58 // ciKlass::ciKlass
59 // 59 //
60 // Unloaded klass variant. 60 // Unloaded klass variant.
61 ciKlass::ciKlass(ciSymbol* name, ciKlass* klass) : ciType(klass) { 61 ciKlass::ciKlass(ciSymbol* name, BasicType bt) : ciType(bt) {
62 _name = name; 62 _name = name;
63 _layout_helper = Klass::_lh_neutral_value; 63 _layout_helper = Klass::_lh_neutral_value;
64 } 64 }
65 65
66 // ------------------------------------------------------------------ 66 // ------------------------------------------------------------------
67 // ciKlass::is_subtype_of 67 // ciKlass::is_subtype_of
68 bool ciKlass::is_subtype_of(ciKlass* that) { 68 bool ciKlass::is_subtype_of(ciKlass* that) {
69 assert(is_loaded() && that->is_loaded(), "must be loaded"); 69 assert(is_loaded() && that->is_loaded(), "must be loaded");
70 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
71 // Check to see if the klasses are identical. 70 // Check to see if the klasses are identical.
72 if (this == that) { 71 if (this == that) {
73 return true; 72 return true;
74 } 73 }
75 74
76 VM_ENTRY_MARK; 75 VM_ENTRY_MARK;
77 Klass* this_klass = get_Klass(); 76 Klass* this_klass = get_Klass();
78 klassOop that_klass = that->get_klassOop(); 77 Klass* that_klass = that->get_Klass();
79 bool result = this_klass->is_subtype_of(that_klass); 78 bool result = this_klass->is_subtype_of(that_klass);
80 79
81 return result; 80 return result;
82 } 81 }
83 82
84 // ------------------------------------------------------------------ 83 // ------------------------------------------------------------------
85 // ciKlass::is_subclass_of 84 // ciKlass::is_subclass_of
86 bool ciKlass::is_subclass_of(ciKlass* that) { 85 bool ciKlass::is_subclass_of(ciKlass* that) {
87 assert(is_loaded() && that->is_loaded(), "must be loaded"); 86 assert(is_loaded() && that->is_loaded(), "must be loaded");
88 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
89 // Check to see if the klasses are identical. 87 // Check to see if the klasses are identical.
90 88
91 VM_ENTRY_MARK; 89 VM_ENTRY_MARK;
92 Klass* this_klass = get_Klass(); 90 Klass* this_klass = get_Klass();
93 klassOop that_klass = that->get_klassOop(); 91 Klass* that_klass = that->get_Klass();
94 bool result = this_klass->is_subclass_of(that_klass); 92 bool result = this_klass->is_subclass_of(that_klass);
95 93
96 return result; 94 return result;
97 } 95 }
98 96
99 // ------------------------------------------------------------------ 97 // ------------------------------------------------------------------
100 // ciKlass::super_depth 98 // ciKlass::super_depth
101 juint ciKlass::super_depth() { 99 juint ciKlass::super_depth() {
102 assert(is_loaded(), "must be loaded"); 100 assert(is_loaded(), "must be loaded");
103 assert(is_java_klass(), "must be java klasses");
104 101
105 VM_ENTRY_MARK; 102 VM_ENTRY_MARK;
106 Klass* this_klass = get_Klass(); 103 Klass* this_klass = get_Klass();
107 return this_klass->super_depth(); 104 return this_klass->super_depth();
108 } 105 }
109 106
110 // ------------------------------------------------------------------ 107 // ------------------------------------------------------------------
111 // ciKlass::super_check_offset 108 // ciKlass::super_check_offset
112 juint ciKlass::super_check_offset() { 109 juint ciKlass::super_check_offset() {
113 assert(is_loaded(), "must be loaded"); 110 assert(is_loaded(), "must be loaded");
114 assert(is_java_klass(), "must be java klasses");
115 111
116 VM_ENTRY_MARK; 112 VM_ENTRY_MARK;
117 Klass* this_klass = get_Klass(); 113 Klass* this_klass = get_Klass();
118 return this_klass->super_check_offset(); 114 return this_klass->super_check_offset();
119 } 115 }
120 116
121 // ------------------------------------------------------------------ 117 // ------------------------------------------------------------------
122 // ciKlass::super_of_depth 118 // ciKlass::super_of_depth
123 ciKlass* ciKlass::super_of_depth(juint i) { 119 ciKlass* ciKlass::super_of_depth(juint i) {
124 assert(is_loaded(), "must be loaded"); 120 assert(is_loaded(), "must be loaded");
125 assert(is_java_klass(), "must be java klasses"); 121
126 122 VM_ENTRY_MARK;
127 VM_ENTRY_MARK; 123 Klass* this_klass = get_Klass();
128 Klass* this_klass = get_Klass(); 124 Klass* super = this_klass->primary_super_of_depth(i);
129 klassOop super = this_klass->primary_super_of_depth(i); 125 return (super != NULL) ? CURRENT_THREAD_ENV->get_klass(super) : NULL;
130 return (super != NULL) ? CURRENT_THREAD_ENV->get_object(super)->as_klass() : NULL;
131 } 126 }
132 127
133 // ------------------------------------------------------------------ 128 // ------------------------------------------------------------------
134 // ciKlass::can_be_primary_super 129 // ciKlass::can_be_primary_super
135 bool ciKlass::can_be_primary_super() { 130 bool ciKlass::can_be_primary_super() {
136 assert(is_loaded(), "must be loaded"); 131 assert(is_loaded(), "must be loaded");
137 assert(is_java_klass(), "must be java klasses");
138 132
139 VM_ENTRY_MARK; 133 VM_ENTRY_MARK;
140 Klass* this_klass = get_Klass(); 134 Klass* this_klass = get_Klass();
141 return this_klass->can_be_primary_super(); 135 return this_klass->can_be_primary_super();
142 } 136 }
154 // computation or possibly if most of the superklasses have already 148 // computation or possibly if most of the superklasses have already
155 // been created as ciObjects anyway. Something to think about... 149 // been created as ciObjects anyway. Something to think about...
156 ciKlass* 150 ciKlass*
157 ciKlass::least_common_ancestor(ciKlass* that) { 151 ciKlass::least_common_ancestor(ciKlass* that) {
158 assert(is_loaded() && that->is_loaded(), "must be loaded"); 152 assert(is_loaded() && that->is_loaded(), "must be loaded");
159 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
160 // Check to see if the klasses are identical. 153 // Check to see if the klasses are identical.
161 if (this == that) { 154 if (this == that) {
162 return this; 155 return this;
163 } 156 }
164 157
176 return this; 169 return this;
177 } 170 }
178 171
179 // Create the ciInstanceKlass for the lca. 172 // Create the ciInstanceKlass for the lca.
180 ciKlass* result = 173 ciKlass* result =
181 CURRENT_THREAD_ENV->get_object(lca->as_klassOop())->as_klass(); 174 CURRENT_THREAD_ENV->get_klass(lca);
182 175
183 return result; 176 return result;
184 } 177 }
185 178
186 // ------------------------------------------------------------------ 179 // ------------------------------------------------------------------
202 ciInstance* ciKlass::java_mirror() { 195 ciInstance* ciKlass::java_mirror() {
203 GUARDED_VM_ENTRY( 196 GUARDED_VM_ENTRY(
204 if (!is_loaded()) 197 if (!is_loaded())
205 return ciEnv::current()->get_unloaded_klass_mirror(this); 198 return ciEnv::current()->get_unloaded_klass_mirror(this);
206 oop java_mirror = get_Klass()->java_mirror(); 199 oop java_mirror = get_Klass()->java_mirror();
207 return CURRENT_ENV->get_object(java_mirror)->as_instance(); 200 return CURRENT_ENV->get_instance(java_mirror);
208 ) 201 )
209 } 202 }
210 203
211 // ------------------------------------------------------------------ 204 // ------------------------------------------------------------------
212 // ciKlass::modifier_flags 205 // ciKlass::modifier_flags