annotate src/share/vm/ci/ciInstanceKlass.cpp @ 6972:bd7a7ce2e264

6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 12 Nov 2012 14:03:53 -0800
parents da91efe96a93
children 2cb439954abf fcc9e7681d63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
5998
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
26 #include "ci/ciField.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
27 #include "ci/ciInstance.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
28 #include "ci/ciInstanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
29 #include "ci/ciUtilities.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
30 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
31 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
32 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
33 #include "oops/oop.inline.hpp"
3938
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
34 #include "oops/fieldStreams.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1924
diff changeset
35 #include "runtime/fieldDescriptor.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // ciInstanceKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
39 // This class represents a Klass* in the HotSpot virtual machine
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
40 // whose Klass part in an InstanceKlass.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // ciInstanceKlass::ciInstanceKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
44 //
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Loaded instance klass.
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
46 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
47 ciKlass(h_k), _non_static_fields(NULL)
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
48 {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
49 assert(get_Klass()->oop_is_instance(), "wrong type");
2244
4f26f535a225 6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents: 2177
diff changeset
50 assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
51 InstanceKlass* ik = get_instanceKlass();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 AccessFlags access_flags = ik->access_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _flags = ciFlags(access_flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 _has_finalizer = access_flags.has_finalizer();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _has_subklass = ik->subklass() != NULL;
4739
52b5d32fbfaf 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 3938
diff changeset
57 _init_state = ik->init_state();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 _nonstatic_field_size = ik->nonstatic_field_size();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
59 _has_nonstatic_fields = ik->has_nonstatic_fields();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
a61af66fc99e Initial load
duke
parents:
diff changeset
61
5998
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
62 _implementor = NULL; // we will fill these lazily
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 Thread *thread = Thread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 if (ciObjectFactory::is_initialized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _loader = JNIHandles::make_local(thread, ik->class_loader());
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _protection_domain = JNIHandles::make_local(thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
68 ik->protection_domain());
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _is_shared = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 Handle h_loader(thread, ik->class_loader());
a61af66fc99e Initial load
duke
parents:
diff changeset
72 Handle h_protection_domain(thread, ik->protection_domain());
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _loader = JNIHandles::make_global(h_loader);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _protection_domain = JNIHandles::make_global(h_protection_domain);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 _is_shared = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Lazy fields get filled in only upon request.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _super = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _java_mirror = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if (is_shared()) {
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 1138
diff changeset
83 if (h_k() != SystemDictionary::Object_klass()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 super();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //compute_nonstatic_fields(); // done outside of constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _field_cache = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Version for unloaded classes:
a61af66fc99e Initial load
duke
parents:
diff changeset
93 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 jobject loader, jobject protection_domain)
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
95 : ciKlass(name, T_OBJECT)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96 {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 assert(name->byte_at(0) != '[', "not an instance klass");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
98 _init_state = (InstanceKlass::ClassState)0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99 _nonstatic_field_size = -1;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
100 _has_nonstatic_fields = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _nonstatic_fields = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _loader = loader;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _protection_domain = protection_domain;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _is_shared = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _super = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 _java_mirror = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _field_cache = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // ciInstanceKlass::compute_shared_is_initialized
1645
3941674cc7fa 6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents: 1604
diff changeset
114 void ciInstanceKlass::compute_shared_init_state() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 GUARDED_VM_ENTRY(
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
116 InstanceKlass* ik = get_instanceKlass();
4739
52b5d32fbfaf 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 3938
diff changeset
117 _init_state = ik->init_state();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
118 )
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // ciInstanceKlass::compute_shared_has_subklass
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bool ciInstanceKlass::compute_shared_has_subklass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 GUARDED_VM_ENTRY(
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
125 InstanceKlass* ik = get_instanceKlass();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
126 _has_subklass = ik->subklass() != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return _has_subklass;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 )
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // ciInstanceKlass::loader
a61af66fc99e Initial load
duke
parents:
diff changeset
133 oop ciInstanceKlass::loader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 ASSERT_IN_VM;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return JNIHandles::resolve(_loader);
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::loader_handle
a61af66fc99e Initial load
duke
parents:
diff changeset
140 jobject ciInstanceKlass::loader_handle() {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return _loader;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // ciInstanceKlass::protection_domain
a61af66fc99e Initial load
duke
parents:
diff changeset
146 oop ciInstanceKlass::protection_domain() {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 ASSERT_IN_VM;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return JNIHandles::resolve(_protection_domain);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // ciInstanceKlass::protection_domain_handle
a61af66fc99e Initial load
duke
parents:
diff changeset
153 jobject ciInstanceKlass::protection_domain_handle() {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return _protection_domain;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // ciInstanceKlass::field_cache
a61af66fc99e Initial load
duke
parents:
diff changeset
159 //
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Get the field cache associated with this klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 ciConstantPoolCache* ciInstanceKlass::field_cache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (_field_cache == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 assert(!is_java_lang_Object(), "Object has no fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
167 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
168 _field_cache = new (arena) ciConstantPoolCache(arena, 5);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170 return _field_cache;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // ciInstanceKlass::get_canonical_holder
a61af66fc99e Initial load
duke
parents:
diff changeset
175 //
a61af66fc99e Initial load
duke
parents:
diff changeset
176 ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (!(offset >= 0 && offset < layout_helper())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 tty->print("*** get_canonical_holder(%d) on ", offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 this->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
181 tty->print_cr(" ***");
a61af66fc99e Initial load
duke
parents:
diff changeset
182 };
a61af66fc99e Initial load
duke
parents:
diff changeset
183 assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
185
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
186 if (offset < instanceOopDesc::base_offset_in_bytes()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // All header offsets belong properly to java/lang/Object.
a61af66fc99e Initial load
duke
parents:
diff changeset
188 return CURRENT_ENV->Object_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 ciInstanceKlass* self = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 for (;;) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 assert(self->is_loaded(), "must be loaded to have size");
a61af66fc99e Initial load
duke
parents:
diff changeset
194 ciInstanceKlass* super = self->super();
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
195 if (super == NULL || super->nof_nonstatic_fields() == 0 ||
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
196 !super->contains_field_offset(offset)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return self;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 self = super; // return super->get_canonical_holder(offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // ciInstanceKlass::is_java_lang_Object
a61af66fc99e Initial load
duke
parents:
diff changeset
206 //
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // Is this klass java.lang.Object?
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
208 bool ciInstanceKlass::is_java_lang_Object() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return equals(CURRENT_ENV->Object_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // ciInstanceKlass::uses_default_loader
a61af66fc99e Initial load
duke
parents:
diff changeset
214 bool ciInstanceKlass::uses_default_loader() {
1138
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
215 // Note: We do not need to resolve the handle or enter the VM
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
216 // in order to test null-ness.
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
217 return _loader == NULL;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
218 }
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
219
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
220 // ------------------------------------------------------------------
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
221 // ciInstanceKlass::is_in_package
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
222 //
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
223 // Is this klass in the given package?
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
224 bool ciInstanceKlass::is_in_package(const char* packagename, int len) {
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
225 // To avoid class loader mischief, this test always rejects application classes.
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
226 if (!uses_default_loader())
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
227 return false;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
228 GUARDED_VM_ENTRY(
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
229 return is_in_package_impl(packagename, len);
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
230 )
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
231 }
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
232
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
233 bool ciInstanceKlass::is_in_package_impl(const char* packagename, int len) {
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
234 ASSERT_IN_VM;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
235
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
236 // If packagename contains trailing '/' exclude it from the
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
237 // prefix-test since we test for it explicitly.
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
238 if (packagename[len - 1] == '/')
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
239 len--;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
240
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
241 if (!name()->starts_with(packagename, len))
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
242 return false;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
243
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
244 // Test if the class name is something like "java/lang".
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
245 if ((len + 1) > name()->utf8_length())
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
246 return false;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
247
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
248 // Test for trailing '/'
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
249 if ((char) name()->byte_at(len) != '/')
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
250 return false;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
251
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
252 // Make sure it's not actually in a subpackage:
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
253 if (name()->index_of_at(len+1, "/", 1) >= 0)
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
254 return false;
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
255
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1080
diff changeset
256 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // ciInstanceKlass::print_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
261 //
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Implementation of the print method.
a61af66fc99e Initial load
duke
parents:
diff changeset
263 void ciInstanceKlass::print_impl(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 ciKlass::print_impl(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 GUARDED_VM_ENTRY(st->print(" loader=0x%x", (address)loader());)
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 st->print(" loaded=true initialized=%s finalized=%s subklass=%s size=%d flags=",
a61af66fc99e Initial load
duke
parents:
diff changeset
268 bool_to_str(is_initialized()),
a61af66fc99e Initial load
duke
parents:
diff changeset
269 bool_to_str(has_finalizer()),
a61af66fc99e Initial load
duke
parents:
diff changeset
270 bool_to_str(has_subklass()),
a61af66fc99e Initial load
duke
parents:
diff changeset
271 layout_helper());
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 _flags.print_klass_flags();
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 if (_super) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 st->print(" super=");
a61af66fc99e Initial load
duke
parents:
diff changeset
277 _super->print_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 if (_java_mirror) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 st->print(" mirror=PRESENT");
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 st->print(" loaded=false");
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // ciInstanceKlass::super
a61af66fc99e Initial load
duke
parents:
diff changeset
289 //
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // Get the superklass of this klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
291 ciInstanceKlass* ciInstanceKlass::super() {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 assert(is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
293 if (_super == NULL && !is_java_lang_Object()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 GUARDED_VM_ENTRY(
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
295 Klass* super_klass = get_instanceKlass()->super();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
296 _super = CURRENT_ENV->get_instance_klass(super_klass);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
297 )
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return _super;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // ciInstanceKlass::java_mirror
a61af66fc99e Initial load
duke
parents:
diff changeset
304 //
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // Get the instance of java.lang.Class corresponding to this klass.
1604
b918d354830a 6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents: 1602
diff changeset
306 // Cache it on this->_java_mirror.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
307 ciInstance* ciInstanceKlass::java_mirror() {
2376
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2244
diff changeset
308 if (is_shared()) {
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2244
diff changeset
309 return ciKlass::java_mirror();
c7f3d0b4570f 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 2244
diff changeset
310 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
311 if (_java_mirror == NULL) {
1604
b918d354830a 6960865: ldc of unloaded class throws an assert in ciTypeFlow
jrose
parents: 1602
diff changeset
312 _java_mirror = ciKlass::java_mirror();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 return _java_mirror;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // ciInstanceKlass::unique_concrete_subklass
a61af66fc99e Initial load
duke
parents:
diff changeset
319 ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 if (!is_loaded()) return NULL; // No change if class is not loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
321 if (!is_abstract()) return NULL; // Only applies to abstract classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
322 if (!has_subklass()) return NULL; // Must have at least one subklass.
a61af66fc99e Initial load
duke
parents:
diff changeset
323 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
324 InstanceKlass* ik = get_instanceKlass();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
325 Klass* up = ik->up_cast_abstract();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
326 assert(up->oop_is_instance(), "must be InstanceKlass");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
327 if (ik == up) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
330 return CURRENT_THREAD_ENV->get_instance_klass(up);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // ciInstanceKlass::has_finalizable_subclass
a61af66fc99e Initial load
duke
parents:
diff changeset
335 bool ciInstanceKlass::has_finalizable_subclass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 if (!is_loaded()) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
337 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // ciInstanceKlass::get_field_by_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
343 ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 if (!is_static) {
a61af66fc99e Initial load
duke
parents:
diff changeset
345 for (int i = 0, len = nof_nonstatic_fields(); i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 ciField* field = _nonstatic_fields->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 int field_off = field->offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
348 if (field_off == field_offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
349 return field;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 if (field_off > field_offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
351 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // could do binary search or check bins, but probably not worth it
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
357 InstanceKlass* k = get_instanceKlass();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
358 fieldDescriptor fd;
a61af66fc99e Initial load
duke
parents:
diff changeset
359 if (!k->find_field_from_offset(field_offset, is_static, &fd)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 return field;
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
366 // ------------------------------------------------------------------
1080
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
367 // ciInstanceKlass::get_field_by_name
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
368 ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static) {
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
369 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
370 InstanceKlass* k = get_instanceKlass();
1080
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
371 fieldDescriptor fd;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
372 Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd);
1080
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
373 if (def == NULL) {
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
374 return NULL;
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
375 }
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
376 ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd);
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
377 return field;
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
378 }
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
379
7c57aead6d3e 6892658: C2 should optimize some stringbuilder patterns
never
parents: 196
diff changeset
380 // ------------------------------------------------------------------
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
381 // ciInstanceKlass::non_static_fields.
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
382
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
383 class NonStaticFieldFiller: public FieldClosure {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
384 GrowableArray<ciField*>* _arr;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
385 ciEnv* _curEnv;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
386 public:
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
387 NonStaticFieldFiller(ciEnv* curEnv, GrowableArray<ciField*>* arr) :
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
388 _curEnv(curEnv), _arr(arr)
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
389 {}
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
390 void do_field(fieldDescriptor* fd) {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
391 ciField* field = new (_curEnv->arena()) ciField(fd);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
392 _arr->append(field);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
393 }
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
394 };
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
395
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
396 GrowableArray<ciField*>* ciInstanceKlass::non_static_fields() {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
397 if (_non_static_fields == NULL) {
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
398 VM_ENTRY_MARK;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
399 ciEnv* curEnv = ciEnv::current();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
400 InstanceKlass* ik = get_instanceKlass();
3938
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
401 int max_n_fields = ik->java_fields_count();
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
402
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1645
diff changeset
403 Arena* arena = curEnv->arena();
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
404 _non_static_fields =
1685
0e35fa8ebccd 6973963: SEGV in ciBlock::start_bci() with EA
kvn
parents: 1645
diff changeset
405 new (arena) GrowableArray<ciField*>(arena, max_n_fields, 0, NULL);
44
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
406 NonStaticFieldFiller filler(curEnv, _non_static_fields);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
407 ik->do_nonstatic_fields(&filler);
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
408 }
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
409 return _non_static_fields;
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
410 }
52fed2ec0afb 6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents: 0
diff changeset
411
0
a61af66fc99e Initial load
duke
parents:
diff changeset
412 static int sort_field_by_offset(ciField** a, ciField** b) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 return (*a)->offset_in_bytes() - (*b)->offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // (no worries about 32-bit overflow...)
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416
a61af66fc99e Initial load
duke
parents:
diff changeset
417 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // ciInstanceKlass::compute_nonstatic_fields
a61af66fc99e Initial load
duke
parents:
diff changeset
419 int ciInstanceKlass::compute_nonstatic_fields() {
a61af66fc99e Initial load
duke
parents:
diff changeset
420 assert(is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
421
a61af66fc99e Initial load
duke
parents:
diff changeset
422 if (_nonstatic_fields != NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
423 return _nonstatic_fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
424
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
425 if (!has_nonstatic_fields()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
426 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
427 _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
428 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 }
a61af66fc99e Initial load
duke
parents:
diff changeset
430 assert(!is_java_lang_Object(), "bootstrap OK");
a61af66fc99e Initial load
duke
parents:
diff changeset
431
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
432 // Size in bytes of my fields, including inherited fields.
165
437d03ea40b1 6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents: 113
diff changeset
433 int fsize = nonstatic_field_size() * heapOopSize;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
434
0
a61af66fc99e Initial load
duke
parents:
diff changeset
435 ciInstanceKlass* super = this->super();
a61af66fc99e Initial load
duke
parents:
diff changeset
436 GrowableArray<ciField*>* super_fields = NULL;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
437 if (super != NULL && super->has_nonstatic_fields()) {
165
437d03ea40b1 6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents: 113
diff changeset
438 int super_fsize = super->nonstatic_field_size() * heapOopSize;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
439 int super_flen = super->nof_nonstatic_fields();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
440 super_fields = super->_nonstatic_fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
442 // See if I am no larger than my super; if so, I can use his fields.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
443 if (fsize == super_fsize) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
444 _nonstatic_fields = super_fields;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
445 return super_fields->length();
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 44
diff changeset
446 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 GrowableArray<ciField*>* fields = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
450 GUARDED_VM_ENTRY({
a61af66fc99e Initial load
duke
parents:
diff changeset
451 fields = compute_nonstatic_fields_impl(super_fields);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 });
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 if (fields == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // This can happen if this class (java.lang.Class) has invisible fields.
a61af66fc99e Initial load
duke
parents:
diff changeset
456 _nonstatic_fields = super_fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 return super_fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 int flen = fields->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 // Now sort them by offset, ascending.
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // (In principle, they could mix with superclass fields.)
a61af66fc99e Initial load
duke
parents:
diff changeset
464 fields->sort(sort_field_by_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
465 _nonstatic_fields = fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
466 return flen;
a61af66fc99e Initial load
duke
parents:
diff changeset
467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 GrowableArray<ciField*>*
a61af66fc99e Initial load
duke
parents:
diff changeset
470 ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray<ciField*>*
a61af66fc99e Initial load
duke
parents:
diff changeset
471 super_fields) {
a61af66fc99e Initial load
duke
parents:
diff changeset
472 ASSERT_IN_VM;
a61af66fc99e Initial load
duke
parents:
diff changeset
473 Arena* arena = CURRENT_ENV->arena();
a61af66fc99e Initial load
duke
parents:
diff changeset
474 int flen = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 GrowableArray<ciField*>* fields = NULL;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
476 InstanceKlass* k = get_instanceKlass();
3938
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
477 for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
478 if (fs.access_flags().is_static()) continue;
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
479 flen += 1;
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
480 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
481
3938
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
482 // allocate the array:
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
483 if (flen == 0) {
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
484 return NULL; // return nothing if none are locally declared
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
485 }
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
486 if (super_fields != NULL) {
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
487 flen += super_fields->length();
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
488 }
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
489 fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
490 if (super_fields != NULL) {
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
491 fields->appendAll(super_fields);
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
492 }
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
493
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
494 for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
495 if (fs.access_flags().is_static()) continue;
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
496 fieldDescriptor fd;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
497 fd.initialize(k, fs.index());
3938
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
498 ciField* field = new (arena) ciField(&fd);
e6b1331a51d2 7086585: make Java field injection more flexible
never
parents: 2376
diff changeset
499 fields->append(field);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
500 }
a61af66fc99e Initial load
duke
parents:
diff changeset
501 assert(fields->length() == flen, "sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
502 return fields;
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // ciInstanceKlass::find_method
a61af66fc99e Initial load
duke
parents:
diff changeset
507 //
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // Find a method in this klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
509 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
511 InstanceKlass* k = get_instanceKlass();
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
512 Symbol* name_sym = name->get_symbol();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
513 Symbol* sig_sym= signature->get_symbol();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
514
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
515 Method* m = k->find_method(name_sym, sig_sym);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
516 if (m == NULL) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
517
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
518 return CURRENT_THREAD_ENV->get_method(m);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // ciInstanceKlass::is_leaf_type
a61af66fc99e Initial load
duke
parents:
diff changeset
523 bool ciInstanceKlass::is_leaf_type() {
a61af66fc99e Initial load
duke
parents:
diff changeset
524 assert(is_loaded(), "must be loaded");
a61af66fc99e Initial load
duke
parents:
diff changeset
525 if (is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
526 return is_final(); // approximately correct
a61af66fc99e Initial load
duke
parents:
diff changeset
527 } else {
5998
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
528 return !_has_subklass && (nof_implementors() == 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
533 // ciInstanceKlass::implementor
a61af66fc99e Initial load
duke
parents:
diff changeset
534 //
a61af66fc99e Initial load
duke
parents:
diff changeset
535 // Report an implementor of this interface.
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // Note that there are various races here, since my copy
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // of _nof_implementors might be out of date with respect
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
538 // to results returned by InstanceKlass::implementor.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // This is OK, since any dependencies we decide to assert
a61af66fc99e Initial load
duke
parents:
diff changeset
540 // will be checked later under the Compile_lock.
5998
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
541 ciInstanceKlass* ciInstanceKlass::implementor() {
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
542 ciInstanceKlass* impl = _implementor;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
543 if (impl == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
544 // Go into the VM to fetch the implementor.
a61af66fc99e Initial load
duke
parents:
diff changeset
545 {
a61af66fc99e Initial load
duke
parents:
diff changeset
546 VM_ENTRY_MARK;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
547 Klass* k = get_instanceKlass()->implementor();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
548 if (k != NULL) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
549 if (k == get_instanceKlass()) {
5998
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
550 // More than one implementors. Use 'this' in this case.
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
551 impl = this;
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
552 } else {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5998
diff changeset
553 impl = CURRENT_THREAD_ENV->get_instance_klass(k);
5998
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
554 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557 // Memoize this result.
a61af66fc99e Initial load
duke
parents:
diff changeset
558 if (!is_shared()) {
5998
49036505ab5f 7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents: 4739
diff changeset
559 _implementor = impl;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562 return impl;
a61af66fc99e Initial load
duke
parents:
diff changeset
563 }
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
564
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
565 // Utility class for printing of the contents of the static fields for
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
566 // use by compilation replay. It only prints out the information that
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
567 // could be consumed by the compiler, so for primitive types it prints
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
568 // out the actual value. For Strings it's the actual string value.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
569 // For array types it it's first level array size since that's the
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
570 // only value which statically unchangeable. For all other reference
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
571 // types it simply prints out the dynamic type.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
572
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
573 class StaticFinalFieldPrinter : public FieldClosure {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
574 outputStream* _out;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
575 const char* _holder;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
576 public:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
577 StaticFinalFieldPrinter(outputStream* out, const char* holder) :
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
578 _out(out),
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
579 _holder(holder) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
580 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
581 void do_field(fieldDescriptor* fd) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
582 if (fd->is_final() && !fd->has_initial_value()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
583 oop mirror = fd->field_holder()->java_mirror();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
584 _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
585 switch (fd->field_type()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
586 case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
587 case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
588 case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
589 case T_CHAR: _out->print_cr("%d", mirror->char_field(fd->offset())); break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
590 case T_INT: _out->print_cr("%d", mirror->int_field(fd->offset())); break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
591 case T_LONG: _out->print_cr(INT64_FORMAT, mirror->long_field(fd->offset())); break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
592 case T_FLOAT: {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
593 float f = mirror->float_field(fd->offset());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
594 _out->print_cr("%d", *(int*)&f);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
595 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
596 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
597 case T_DOUBLE: {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
598 double d = mirror->double_field(fd->offset());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
599 _out->print_cr(INT64_FORMAT, *(jlong*)&d);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
600 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
601 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
602 case T_ARRAY: {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
603 oop value = mirror->obj_field_acquire(fd->offset());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
604 if (value == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
605 _out->print_cr("null");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
606 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
607 typeArrayOop ta = (typeArrayOop)value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
608 _out->print("%d", ta->length());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
609 if (value->is_objArray()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
610 objArrayOop oa = (objArrayOop)value;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
611 const char* klass_name = value->klass()->name()->as_quoted_ascii();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
612 _out->print(" %s", klass_name);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
613 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
614 _out->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
615 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
616 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
617 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
618 case T_OBJECT: {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
619 oop value = mirror->obj_field_acquire(fd->offset());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
620 if (value == NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
621 _out->print_cr("null");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
622 } else if (value->is_instance()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
623 if (value->is_a(SystemDictionary::String_klass())) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
624 _out->print("\"");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
625 _out->print_raw(java_lang_String::as_quoted_ascii(value));
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
626 _out->print_cr("\"");
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
627 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
628 const char* klass_name = value->klass()->name()->as_quoted_ascii();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
629 _out->print_cr(klass_name);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
630 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
631 } else {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
632 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
633 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
634 break;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
635 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
636 default:
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
637 ShouldNotReachHere();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
638 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
639 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
640 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
641 };
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
642
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
643
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
644 void ciInstanceKlass::dump_replay_data(outputStream* out) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
645 ASSERT_IN_VM;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
646 InstanceKlass* ik = get_instanceKlass();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
647 ConstantPool* cp = ik->constants();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
648
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
649 // Try to record related loaded classes
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
650 Klass* sub = ik->subklass();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
651 while (sub != NULL) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
652 if (sub->oop_is_instance()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
653 out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
654 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
655 sub = sub->next_sibling();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
656 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
657
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
658 // Dump out the state of the constant pool tags. During replay the
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
659 // tags will be validated for things which shouldn't change and
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
660 // classes will be resolved if the tags indicate that they were
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
661 // resolved at compile time.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
662 out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(),
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
663 is_linked(), is_initialized(), cp->length());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
664 for (int index = 1; index < cp->length(); index++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
665 out->print(" %d", cp->tags()->at(index));
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
666 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
667 out->cr();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
668 if (is_initialized()) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
669 // Dump out the static final fields in case the compilation relies
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
670 // on their value for correct replay.
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
671 StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii());
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
672 ik->do_local_static_fields(&sffp);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
673 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6725
diff changeset
674 }