annotate src/share/vm/ci/ciInstanceKlass.cpp @ 44:52fed2ec0afb

6667620: (Escape Analysis) fix deoptimization for scalar replaced objects Summary: Deoptimization code for reallocation and relocking scalar replaced objects has to be fixed. Reviewed-by: rasbold, never
author kvn
date Tue, 11 Mar 2008 11:25:13 -0700
parents a61af66fc99e
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_ciInstanceKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // ciInstanceKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
29 //
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // This class represents a klassOop in the HotSpot virtual machine
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // whose Klass part in an instanceKlass.
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ciInstanceKlass::ciInstanceKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Loaded instance klass.
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
37 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
38 ciKlass(h_k), _non_static_fields(NULL)
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
39 {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 assert(get_Klass()->oop_is_instance(), "wrong type");
a61af66fc99e Initial load
duke
parents:
diff changeset
41 instanceKlass* ik = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 AccessFlags access_flags = ik->access_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _flags = ciFlags(access_flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 _has_finalizer = access_flags.has_finalizer();
a61af66fc99e Initial load
duke
parents:
diff changeset
46 _has_subklass = ik->subklass() != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _is_initialized = ik->is_initialized();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Next line must follow and use the result of the previous line:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 _is_linked = _is_initialized || ik->is_linked();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _nonstatic_field_size = ik->nonstatic_field_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _nof_implementors = ik->nof_implementors();
a61af66fc99e Initial load
duke
parents:
diff changeset
54 for (int i = 0; i < implementors_limit; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 _implementors[i] = NULL; // we will fill these lazily
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 Thread *thread = Thread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 if (ciObjectFactory::is_initialized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _loader = JNIHandles::make_local(thread, ik->class_loader());
a61af66fc99e Initial load
duke
parents:
diff changeset
61 _protection_domain = JNIHandles::make_local(thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
62 ik->protection_domain());
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _is_shared = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 Handle h_loader(thread, ik->class_loader());
a61af66fc99e Initial load
duke
parents:
diff changeset
66 Handle h_protection_domain(thread, ik->protection_domain());
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _loader = JNIHandles::make_global(h_loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _protection_domain = JNIHandles::make_global(h_protection_domain);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _is_shared = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Lazy fields get filled in only upon request.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _super = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _java_mirror = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 if (h_k() != SystemDictionary::object_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 java_mirror();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 //compute_nonstatic_fields(); // done outside of constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _field_cache = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Version for unloaded classes:
a61af66fc99e Initial load
duke
parents:
diff changeset
88 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 jobject loader, jobject protection_domain)
a61af66fc99e Initial load
duke
parents:
diff changeset
90 : ciKlass(name, ciInstanceKlassKlass::make())
a61af66fc99e Initial load
duke
parents:
diff changeset
91 {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 assert(name->byte_at(0) != '[', "not an instance klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 _is_initialized = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _is_linked = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _nonstatic_field_size = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _nonstatic_fields = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 _nof_implementors = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _loader = loader;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 _protection_domain = protection_domain;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _is_shared = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _super = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _java_mirror = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _field_cache = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // ciInstanceKlass::compute_shared_is_initialized
a61af66fc99e Initial load
duke
parents:
diff changeset
110 bool ciInstanceKlass::compute_shared_is_initialized() {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 GUARDED_VM_ENTRY(
a61af66fc99e Initial load
duke
parents:
diff changeset
112 instanceKlass* ik = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 _is_initialized = ik->is_initialized();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return _is_initialized;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 )
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // ciInstanceKlass::compute_shared_is_linked
a61af66fc99e Initial load
duke
parents:
diff changeset
120 bool ciInstanceKlass::compute_shared_is_linked() {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 GUARDED_VM_ENTRY(
a61af66fc99e Initial load
duke
parents:
diff changeset
122 instanceKlass* ik = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
123 _is_linked = ik->is_linked();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return _is_linked;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 )
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // ciInstanceKlass::compute_shared_has_subklass
a61af66fc99e Initial load
duke
parents:
diff changeset
130 bool ciInstanceKlass::compute_shared_has_subklass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 GUARDED_VM_ENTRY(
a61af66fc99e Initial load
duke
parents:
diff changeset
132 instanceKlass* ik = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 _has_subklass = ik->subklass() != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return _has_subklass;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 )
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // ciInstanceKlass::compute_shared_nof_implementors
a61af66fc99e Initial load
duke
parents:
diff changeset
140 int ciInstanceKlass::compute_shared_nof_implementors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // We requery this property, since it is a very old ciObject.
a61af66fc99e Initial load
duke
parents:
diff changeset
142 GUARDED_VM_ENTRY(
a61af66fc99e Initial load
duke
parents:
diff changeset
143 instanceKlass* ik = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 _nof_implementors = ik->nof_implementors();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return _nof_implementors;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 )
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // ciInstanceKlass::loader
a61af66fc99e Initial load
duke
parents:
diff changeset
151 oop ciInstanceKlass::loader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 ASSERT_IN_VM;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return JNIHandles::resolve(_loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // ciInstanceKlass::loader_handle
a61af66fc99e Initial load
duke
parents:
diff changeset
158 jobject ciInstanceKlass::loader_handle() {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return _loader;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // ciInstanceKlass::protection_domain
a61af66fc99e Initial load
duke
parents:
diff changeset
164 oop ciInstanceKlass::protection_domain() {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 ASSERT_IN_VM;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return JNIHandles::resolve(_protection_domain);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // ciInstanceKlass::protection_domain_handle
a61af66fc99e Initial load
duke
parents:
diff changeset
171 jobject ciInstanceKlass::protection_domain_handle() {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return _protection_domain;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // ciInstanceKlass::field_cache
a61af66fc99e Initial load
duke
parents:
diff changeset
177 //
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Get the field cache associated with this klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
179 ciConstantPoolCache* ciInstanceKlass::field_cache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 if (is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (_field_cache == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 assert(!is_java_lang_Object(), "Object has no fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
185 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 _field_cache = new (arena) ciConstantPoolCache(arena, 5);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 return _field_cache;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // ciInstanceKlass::get_canonical_holder
a61af66fc99e Initial load
duke
parents:
diff changeset
193 //
a61af66fc99e Initial load
duke
parents:
diff changeset
194 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if (!(offset >= 0 && offset < layout_helper())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 tty->print("*** get_canonical_holder(%d) on ", offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
198 this->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 tty->print_cr(" ***");
a61af66fc99e Initial load
duke
parents:
diff changeset
200 };
a61af66fc99e Initial load
duke
parents:
diff changeset
201 assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
a61af66fc99e Initial load
duke
parents:
diff changeset
202 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (offset < (instanceOopDesc::header_size() * wordSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // All header offsets belong properly to java/lang/Object.
a61af66fc99e Initial load
duke
parents:
diff changeset
206 return CURRENT_ENV->Object_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 ciInstanceKlass* self = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
210 for (;;) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 assert(self->is_loaded(), "must be loaded to have size");
a61af66fc99e Initial load
duke
parents:
diff changeset
212 ciInstanceKlass* super = self->super();
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (super == NULL || !super->contains_field_offset(offset)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return self;
a61af66fc99e Initial load
duke
parents:
diff changeset
215 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 self = super; // return super->get_canonical_holder(offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // ciInstanceKlass::is_java_lang_Object
a61af66fc99e Initial load
duke
parents:
diff changeset
223 //
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Is this klass java.lang.Object?
a61af66fc99e Initial load
duke
parents:
diff changeset
225 bool ciInstanceKlass::is_java_lang_Object() {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return equals(CURRENT_ENV->Object_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // ciInstanceKlass::uses_default_loader
a61af66fc99e Initial load
duke
parents:
diff changeset
231 bool ciInstanceKlass::uses_default_loader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 return loader() == NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // ciInstanceKlass::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
238 //
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
240 void ciInstanceKlass::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 ciKlass::print_impl(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 GUARDED_VM_ENTRY(st->print(" loader=0x%x", (address)loader());)
a61af66fc99e Initial load
duke
parents:
diff changeset
243 if (is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=",
a61af66fc99e Initial load
duke
parents:
diff changeset
245 bool_to_str(is_initialized()),
a61af66fc99e Initial load
duke
parents:
diff changeset
246 bool_to_str(has_finalizer()),
a61af66fc99e Initial load
duke
parents:
diff changeset
247 bool_to_str(has_subklass()),
a61af66fc99e Initial load
duke
parents:
diff changeset
248 layout_helper());
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 _flags.print_klass_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if (_super) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 st->print(" super=");
a61af66fc99e Initial load
duke
parents:
diff changeset
254 _super->print_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (_java_mirror) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 st->print(" mirror=PRESENT");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 st->print(" loaded=false");
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // ciInstanceKlass::super
a61af66fc99e Initial load
duke
parents:
diff changeset
266 //
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // Get the superklass of this klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
268 ciInstanceKlass* ciInstanceKlass::super() {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 assert(is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (_super == NULL && !is_java_lang_Object()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 GUARDED_VM_ENTRY(
a61af66fc99e Initial load
duke
parents:
diff changeset
272 klassOop super_klass = get_instanceKlass()->super();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 _super = CURRENT_ENV->get_object(super_klass)->as_instance_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
274 )
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 return _super;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // ciInstanceKlass::java_mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
281 //
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // Get the instance of java.lang.Class corresponding to this klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
283 ciInstance* ciInstanceKlass::java_mirror() {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 assert(is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (_java_mirror == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 _java_mirror = ciKlass::java_mirror();
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return _java_mirror;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // ciInstanceKlass::unique_concrete_subklass
a61af66fc99e Initial load
duke
parents:
diff changeset
293 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 if (!is_loaded()) return NULL; // No change if class is not loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
295 if (!is_abstract()) return NULL; // Only applies to abstract classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
296 if (!has_subklass()) return NULL; // Must have at least one subklass.
a61af66fc99e Initial load
duke
parents:
diff changeset
297 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 instanceKlass* ik = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
299 Klass* up = ik->up_cast_abstract();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 assert(up->oop_is_instance(), "must be instanceKlass");
a61af66fc99e Initial load
duke
parents:
diff changeset
301 if (ik == up) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 return CURRENT_THREAD_ENV->get_object(up->as_klassOop())->as_instance_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // ciInstanceKlass::has_finalizable_subclass
a61af66fc99e Initial load
duke
parents:
diff changeset
309 bool ciInstanceKlass::has_finalizable_subclass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 if (!is_loaded()) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
311 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
312 return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // ciInstanceKlass::get_field_by_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
317 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 if (!is_static) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 ciField* field = _nonstatic_fields->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
321 int field_off = field->offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 if (field_off == field_offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
323 return field;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 if (field_off > field_offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
325 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // could do binary search or check bins, but probably not worth it
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
331 instanceKlass* k = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
332 fieldDescriptor fd;
a61af66fc99e Initial load
duke
parents:
diff changeset
333 if (!k->find_field_from_offset(field_offset, is_static, &fd)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 return field;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
340 // ------------------------------------------------------------------
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
341 // ciInstanceKlass::non_static_fields.
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
342
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
343 class NonStaticFieldFiller: public FieldClosure {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
344 GrowableArray<ciField*>* _arr;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
345 ciEnv* _curEnv;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
346 public:
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
347 NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) :
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
348 _curEnv(curEnv), _arr(arr)
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
349 {}
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
350 void do_field(fieldDescriptor* fd) {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
351 ciField* field = new (_curEnv->arena()) ciField(fd);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
352 _arr->append(field);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
353 }
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
354 };
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
355
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
356 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
357 if (_non_static_fields == NULL) {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
358 VM_ENTRY_MARK;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
359 ciEnv* curEnv = ciEnv::current();
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
360 instanceKlass* ik = get_instanceKlass();
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
361 int max_n_fields = ik->fields()->length()/instanceKlass::next_offset;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
362
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
363 _non_static_fields =
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
364 new (curEnv->arena()) GrowableArray<ciField*>(max_n_fields);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
365 NonStaticFieldFiller filler(curEnv, _non_static_fields);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
366 ik->do_nonstatic_fields(&filler);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
367 }
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
368 return _non_static_fields;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
369 }
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
370
0
a61af66fc99e Initial load
duke
parents:
diff changeset
371 static int sort_field_by_offset(ciField** a, ciField** b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return (*a)->offset_in_bytes() - (*b)->offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // (no worries about 32-bit overflow...)
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // ciInstanceKlass::compute_nonstatic_fields
a61af66fc99e Initial load
duke
parents:
diff changeset
378 int ciInstanceKlass::compute_nonstatic_fields() {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 assert(is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 if (_nonstatic_fields != NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
382 return _nonstatic_fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
383
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // Size in bytes of my fields, including inherited fields.
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // About equal to size_helper() - sizeof(oopDesc).
a61af66fc99e Initial load
duke
parents:
diff changeset
386 int fsize = nonstatic_field_size() * wordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
387 if (fsize == 0) { // easy shortcut
a61af66fc99e Initial load
duke
parents:
diff changeset
388 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
389 _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392 assert(!is_java_lang_Object(), "bootstrap OK");
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 ciInstanceKlass* super = this->super();
a61af66fc99e Initial load
duke
parents:
diff changeset
395 int super_fsize = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
396 int super_flen = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
397 GrowableArray<ciField*>* super_fields = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
398 if (super != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 super_fsize = super->nonstatic_field_size() * wordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
400 super_flen = super->nof_nonstatic_fields();
a61af66fc99e Initial load
duke
parents:
diff changeset
401 super_fields = super->_nonstatic_fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
402 assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // See if I am no larger than my super; if so, I can use his fields.
a61af66fc99e Initial load
duke
parents:
diff changeset
406 if (fsize == super_fsize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 _nonstatic_fields = super_fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
408 return super_fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 GrowableArray<ciField*>* fields = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
412 GUARDED_VM_ENTRY({
a61af66fc99e Initial load
duke
parents:
diff changeset
413 fields = compute_nonstatic_fields_impl(super_fields);
a61af66fc99e Initial load
duke
parents:
diff changeset
414 });
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 if (fields == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 // This can happen if this class (java.lang.Class) has invisible fields.
a61af66fc99e Initial load
duke
parents:
diff changeset
418 _nonstatic_fields = super_fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
419 return super_fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
421
a61af66fc99e Initial load
duke
parents:
diff changeset
422 int flen = fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // Now sort them by offset, ascending.
a61af66fc99e Initial load
duke
parents:
diff changeset
425 // (In principle, they could mix with superclass fields.)
a61af66fc99e Initial load
duke
parents:
diff changeset
426 fields->sort(sort_field_by_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
427 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
428 int last_offset = sizeof(oopDesc);
a61af66fc99e Initial load
duke
parents:
diff changeset
429 for (int i = 0; i < fields->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 ciField* field = fields->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
431 int offset = field->offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
432 int size = (field->_type == NULL) ? oopSize : field->size_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
433 assert(last_offset <= offset, "no field overlap");
a61af66fc99e Initial load
duke
parents:
diff changeset
434 if (last_offset > (int)sizeof(oopDesc))
a61af66fc99e Initial load
duke
parents:
diff changeset
435 assert((offset - last_offset) < BytesPerLong, "no big holes");
a61af66fc99e Initial load
duke
parents:
diff changeset
436 // Note: Two consecutive T_BYTE fields will be separated by wordSize-1
a61af66fc99e Initial load
duke
parents:
diff changeset
437 // padding bytes if one of them is declared by a superclass.
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // This is a minor inefficiency classFileParser.cpp.
a61af66fc99e Initial load
duke
parents:
diff changeset
439 last_offset = offset + size;
a61af66fc99e Initial load
duke
parents:
diff changeset
440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
441 assert(last_offset <= (int)sizeof(oopDesc) + fsize, "no overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
442 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
443
a61af66fc99e Initial load
duke
parents:
diff changeset
444 _nonstatic_fields = fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
445 return flen;
a61af66fc99e Initial load
duke
parents:
diff changeset
446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
447
a61af66fc99e Initial load
duke
parents:
diff changeset
448 GrowableArray<ciField*>*
a61af66fc99e Initial load
duke
parents:
diff changeset
449 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>*
a61af66fc99e Initial load
duke
parents:
diff changeset
450 super_fields) {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 ASSERT_IN_VM;
a61af66fc99e Initial load
duke
parents:
diff changeset
452 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
453 int flen = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 GrowableArray<ciField*>* fields = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 instanceKlass* k = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
456 typeArrayOop fields_array = k->fields();
a61af66fc99e Initial load
duke
parents:
diff changeset
457 for (int pass = 0; pass <= 1; pass++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
458 for (int i = 0, alen = fields_array->length(); i < alen; i += instanceKlass::next_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 fieldDescriptor fd;
a61af66fc99e Initial load
duke
parents:
diff changeset
460 fd.initialize(k->as_klassOop(), i);
a61af66fc99e Initial load
duke
parents:
diff changeset
461 if (fd.is_static()) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
462 if (pass == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
463 flen += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
464 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
465 ciField* field = new (arena) ciField(&fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
466 fields->append(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // Between passes, allocate the array:
a61af66fc99e Initial load
duke
parents:
diff changeset
471 if (pass == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
472 if (flen == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 return NULL; // return nothing if none are locally declared
a61af66fc99e Initial load
duke
parents:
diff changeset
474 }
a61af66fc99e Initial load
duke
parents:
diff changeset
475 if (super_fields != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
476 flen += super_fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 if (super_fields != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 fields->appendAll(super_fields);
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482 }
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484 assert(fields->length() == flen, "sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
485 return fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
486 }
a61af66fc99e Initial load
duke
parents:
diff changeset
487
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
489 // ciInstanceKlass::find_method
a61af66fc99e Initial load
duke
parents:
diff changeset
490 //
a61af66fc99e Initial load
duke
parents:
diff changeset
491 // Find a method in this klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
492 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
a61af66fc99e Initial load
duke
parents:
diff changeset
493 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 instanceKlass* k = get_instanceKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
495 symbolOop name_sym = name->get_symbolOop();
a61af66fc99e Initial load
duke
parents:
diff changeset
496 symbolOop sig_sym= signature->get_symbolOop();
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 methodOop m = k->find_method(name_sym, sig_sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
499 if (m == NULL) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
500
a61af66fc99e Initial load
duke
parents:
diff changeset
501 return CURRENT_THREAD_ENV->get_object(m)->as_method();
a61af66fc99e Initial load
duke
parents:
diff changeset
502 }
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // ciInstanceKlass::is_leaf_type
a61af66fc99e Initial load
duke
parents:
diff changeset
506 bool ciInstanceKlass::is_leaf_type() {
a61af66fc99e Initial load
duke
parents:
diff changeset
507 assert(is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
508 if (is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
509 return is_final(); // approximately correct
a61af66fc99e Initial load
duke
parents:
diff changeset
510 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
511 return !_has_subklass && (_nof_implementors == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
512 }
a61af66fc99e Initial load
duke
parents:
diff changeset
513 }
a61af66fc99e Initial load
duke
parents:
diff changeset
514
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // ciInstanceKlass::implementor
a61af66fc99e Initial load
duke
parents:
diff changeset
517 //
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // Report an implementor of this interface.
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // Returns NULL if exact information is not available.
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // Note that there are various races here, since my copy
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // of _nof_implementors might be out of date with respect
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // to results returned by instanceKlass::implementor.
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // This is OK, since any dependencies we decide to assert
a61af66fc99e Initial load
duke
parents:
diff changeset
524 // will be checked later under the Compile_lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
525 ciInstanceKlass* ciInstanceKlass::implementor(int n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
526 if (n > implementors_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
528 }
a61af66fc99e Initial load
duke
parents:
diff changeset
529 ciInstanceKlass* impl = _implementors[n];
a61af66fc99e Initial load
duke
parents:
diff changeset
530 if (impl == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
531 if (_nof_implementors > implementors_limit) {
a61af66fc99e Initial load
duke
parents:
diff changeset
532 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
533 }
a61af66fc99e Initial load
duke
parents:
diff changeset
534 // Go into the VM to fetch the implementor.
a61af66fc99e Initial load
duke
parents:
diff changeset
535 {
a61af66fc99e Initial load
duke
parents:
diff changeset
536 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
537 klassOop k = get_instanceKlass()->implementor(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
538 if (k != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
539 impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541 }
a61af66fc99e Initial load
duke
parents:
diff changeset
542 // Memoize this result.
a61af66fc99e Initial load
duke
parents:
diff changeset
543 if (!is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
544 _implementors[n] = (impl == NULL)? this: impl;
a61af66fc99e Initial load
duke
parents:
diff changeset
545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
546 } else if (impl == this) {
a61af66fc99e Initial load
duke
parents:
diff changeset
547 impl = NULL; // memoized null result from a VM query
a61af66fc99e Initial load
duke
parents:
diff changeset
548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
549 return impl;
a61af66fc99e Initial load
duke
parents:
diff changeset
550 }