Mercurial > hg > truffle
annotate src/share/vm/code/dependencies.cpp @ 8600:c423a5fd8ac7
Cull frame states before lowering.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Tue, 02 Apr 2013 11:47:56 +0200 |
parents | c5ff08c22458 |
children | 707b20dd9512 |
rev | line source |
---|---|
0 | 1 /* |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1206
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1206
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:
1206
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "ci/ciArrayKlass.hpp" | |
27 #include "ci/ciEnv.hpp" | |
28 #include "ci/ciKlass.hpp" | |
29 #include "ci/ciMethod.hpp" | |
30 #include "code/dependencies.hpp" | |
31 #include "compiler/compileLog.hpp" | |
32 #include "oops/oop.inline.hpp" | |
7735 | 33 #include "oops/objArrayKlass.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
34 #include "runtime/handles.hpp" |
1972 | 35 #include "runtime/handles.inline.hpp" |
36 #include "utilities/copy.hpp" | |
0 | 37 |
38 | |
39 #ifdef ASSERT | |
40 static bool must_be_in_vm() { | |
41 Thread* thread = Thread::current(); | |
42 if (thread->is_Java_thread()) | |
43 return ((JavaThread*)thread)->thread_state() == _thread_in_vm; | |
44 else | |
45 return true; //something like this: thread->is_VM_thread(); | |
46 } | |
47 #endif //ASSERT | |
48 | |
49 void Dependencies::initialize(ciEnv* env) { | |
50 Arena* arena = env->arena(); | |
51 _oop_recorder = env->oop_recorder(); | |
52 _log = env->log(); | |
53 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0); | |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
54 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
55 _using_dep_values = false; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
56 #endif // GRAAL |
0 | 57 DEBUG_ONLY(_deps[end_marker] = NULL); |
58 for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
59 _deps[i] = new(arena) GrowableArray<ciBaseObject*>(arena, 10, 0, 0); |
0 | 60 } |
61 _content_bytes = NULL; | |
62 _size_in_bytes = (size_t)-1; | |
63 | |
64 assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT), "sanity"); | |
65 } | |
66 | |
67 void Dependencies::assert_evol_method(ciMethod* m) { | |
68 assert_common_1(evol_method, m); | |
69 } | |
70 | |
71 void Dependencies::assert_leaf_type(ciKlass* ctxk) { | |
72 if (ctxk->is_array_klass()) { | |
73 // As a special case, support this assertion on an array type, | |
74 // which reduces to an assertion on its element type. | |
75 // Note that this cannot be done with assertions that | |
76 // relate to concreteness or abstractness. | |
77 ciType* elemt = ctxk->as_array_klass()->base_element_type(); | |
78 if (!elemt->is_instance_klass()) return; // Ex: int[][] | |
79 ctxk = elemt->as_instance_klass(); | |
80 //if (ctxk->is_final()) return; // Ex: String[][] | |
81 } | |
82 check_ctxk(ctxk); | |
83 assert_common_1(leaf_type, ctxk); | |
84 } | |
85 | |
86 void Dependencies::assert_abstract_with_unique_concrete_subtype(ciKlass* ctxk, ciKlass* conck) { | |
87 check_ctxk_abstract(ctxk); | |
88 assert_common_2(abstract_with_unique_concrete_subtype, ctxk, conck); | |
89 } | |
90 | |
91 void Dependencies::assert_abstract_with_no_concrete_subtype(ciKlass* ctxk) { | |
92 check_ctxk_abstract(ctxk); | |
93 assert_common_1(abstract_with_no_concrete_subtype, ctxk); | |
94 } | |
95 | |
96 void Dependencies::assert_concrete_with_no_concrete_subtype(ciKlass* ctxk) { | |
97 check_ctxk_concrete(ctxk); | |
98 assert_common_1(concrete_with_no_concrete_subtype, ctxk); | |
99 } | |
100 | |
101 void Dependencies::assert_unique_concrete_method(ciKlass* ctxk, ciMethod* uniqm) { | |
102 check_ctxk(ctxk); | |
103 assert_common_2(unique_concrete_method, ctxk, uniqm); | |
104 } | |
105 | |
106 void Dependencies::assert_abstract_with_exclusive_concrete_subtypes(ciKlass* ctxk, ciKlass* k1, ciKlass* k2) { | |
107 check_ctxk(ctxk); | |
108 assert_common_3(abstract_with_exclusive_concrete_subtypes_2, ctxk, k1, k2); | |
109 } | |
110 | |
111 void Dependencies::assert_exclusive_concrete_methods(ciKlass* ctxk, ciMethod* m1, ciMethod* m2) { | |
112 check_ctxk(ctxk); | |
113 assert_common_3(exclusive_concrete_methods_2, ctxk, m1, m2); | |
114 } | |
115 | |
116 void Dependencies::assert_has_no_finalizable_subclasses(ciKlass* ctxk) { | |
117 check_ctxk(ctxk); | |
118 assert_common_1(no_finalizable_subclasses, ctxk); | |
119 } | |
120 | |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
121 void Dependencies::assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle) { |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
122 check_ctxk(call_site->klass()); |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
123 assert_common_2(call_site_target_value, call_site, method_handle); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
124 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
125 |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
126 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
127 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
128 Dependencies::Dependencies(Arena* arena, OopRecorder* oop_recorder) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
129 _oop_recorder = oop_recorder; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
130 _log = NULL; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
131 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
132 _using_dep_values = true; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
133 DEBUG_ONLY(_dep_values[end_marker] = NULL); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
134 for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
135 _dep_values[i] = new(arena) GrowableArray<DepValue>(arena, 10, 0, DepValue()); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
136 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
137 _content_bytes = NULL; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
138 _size_in_bytes = (size_t)-1; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
139 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
140 assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT), "sanity"); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
141 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
142 |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
143 void Dependencies::assert_evol_method(Method* m) { |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
144 assert_common_1(evol_method, DepValue(_oop_recorder, m)); |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
145 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
146 |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
147 void Dependencies::assert_leaf_type(Klass* ctxk) { |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
148 if (ctxk->oop_is_array()) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
149 // As a special case, support this assertion on an array type, |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
150 // which reduces to an assertion on its element type. |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
151 // Note that this cannot be done with assertions that |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
152 // relate to concreteness or abstractness. |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
153 BasicType elemt = ArrayKlass::cast(ctxk)->element_type(); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
154 if (is_java_primitive(elemt)) return; // Ex: int[][] |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
155 ctxk = ObjArrayKlass::cast(ctxk)->bottom_klass(); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
156 //if (ctxk->is_final()) return; // Ex: String[][] |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
157 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
158 check_ctxk(ctxk); |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
159 assert_common_1(leaf_type, DepValue(_oop_recorder, ctxk)); |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
160 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
161 |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
162 void Dependencies::assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck) { |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
163 check_ctxk_abstract(ctxk); |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
164 DepValue ctxk_dv(_oop_recorder, ctxk); |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
165 DepValue conck_dv(_oop_recorder, conck, &ctxk_dv); |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
166 assert_common_2(abstract_with_unique_concrete_subtype, ctxk_dv, conck_dv); |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
167 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
168 |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
169 void Dependencies::assert_unique_concrete_method(Klass* ctxk, Method* uniqm) { |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
170 check_ctxk(ctxk); |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
171 assert_common_2(unique_concrete_method, DepValue(_oop_recorder, ctxk), DepValue(_oop_recorder, uniqm)); |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
172 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
173 #endif // GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
174 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
175 |
0 | 176 // Helper function. If we are adding a new dep. under ctxk2, |
177 // try to find an old dep. under a broader* ctxk1. If there is | |
178 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
179 bool Dependencies::maybe_merge_ctxk(GrowableArray<ciBaseObject*>* deps, |
0 | 180 int ctxk_i, ciKlass* ctxk2) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
181 ciKlass* ctxk1 = deps->at(ctxk_i)->as_metadata()->as_klass(); |
0 | 182 if (ctxk2->is_subtype_of(ctxk1)) { |
183 return true; // success, and no need to change | |
184 } else if (ctxk1->is_subtype_of(ctxk2)) { | |
185 // new context class fully subsumes previous one | |
186 deps->at_put(ctxk_i, ctxk2); | |
187 return true; | |
188 } else { | |
189 return false; | |
190 } | |
191 } | |
192 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
193 void Dependencies::assert_common_1(DepType dept, ciBaseObject* x) { |
0 | 194 assert(dep_args(dept) == 1, "sanity"); |
195 log_dependency(dept, x); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
196 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
0 | 197 |
198 // see if the same (or a similar) dep is already recorded | |
199 if (note_dep_seen(dept, x)) { | |
200 assert(deps->find(x) >= 0, "sanity"); | |
201 } else { | |
202 deps->append(x); | |
203 } | |
204 } | |
205 | |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
206 void Dependencies::assert_common_2(DepType dept, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
207 ciBaseObject* x0, ciBaseObject* x1) { |
0 | 208 assert(dep_args(dept) == 2, "sanity"); |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
209 log_dependency(dept, x0, x1); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
210 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
0 | 211 |
212 // see if the same (or a similar) dep is already recorded | |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
213 bool has_ctxk = has_explicit_context_arg(dept); |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
214 if (has_ctxk) { |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
215 assert(dep_context_arg(dept) == 0, "sanity"); |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
216 if (note_dep_seen(dept, x1)) { |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
217 // look in this bucket for redundant assertions |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
218 const int stride = 2; |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
219 for (int i = deps->length(); (i -= stride) >= 0; ) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
220 ciBaseObject* y1 = deps->at(i+1); |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
221 if (x1 == y1) { // same subject; check the context |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
222 if (maybe_merge_ctxk(deps, i+0, x0->as_metadata()->as_klass())) { |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
223 return; |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
224 } |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
225 } |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
226 } |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
227 } |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
228 } else { |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
229 assert(dep_implicit_context_arg(dept) == 0, "sanity"); |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
230 if (note_dep_seen(dept, x0) && note_dep_seen(dept, x1)) { |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
231 // look in this bucket for redundant assertions |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
232 const int stride = 2; |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
233 for (int i = deps->length(); (i -= stride) >= 0; ) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
234 ciBaseObject* y0 = deps->at(i+0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
235 ciBaseObject* y1 = deps->at(i+1); |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
236 if (x0 == y0 && x1 == y1) { |
0 | 237 return; |
238 } | |
239 } | |
240 } | |
241 } | |
242 | |
243 // append the assertion in the correct bucket: | |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
244 deps->append(x0); |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
245 deps->append(x1); |
0 | 246 } |
247 | |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
248 void Dependencies::assert_common_3(DepType dept, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
249 ciKlass* ctxk, ciBaseObject* x, ciBaseObject* x2) { |
0 | 250 assert(dep_context_arg(dept) == 0, "sanity"); |
251 assert(dep_args(dept) == 3, "sanity"); | |
252 log_dependency(dept, ctxk, x, x2); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
253 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
0 | 254 |
255 // try to normalize an unordered pair: | |
256 bool swap = false; | |
257 switch (dept) { | |
258 case abstract_with_exclusive_concrete_subtypes_2: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
259 swap = (x->ident() > x2->ident() && x->as_metadata()->as_klass() != ctxk); |
0 | 260 break; |
261 case exclusive_concrete_methods_2: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
262 swap = (x->ident() > x2->ident() && x->as_metadata()->as_method()->holder() != ctxk); |
0 | 263 break; |
264 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
265 if (swap) { ciBaseObject* t = x; x = x2; x2 = t; } |
0 | 266 |
267 // see if the same (or a similar) dep is already recorded | |
268 if (note_dep_seen(dept, x) && note_dep_seen(dept, x2)) { | |
269 // look in this bucket for redundant assertions | |
270 const int stride = 3; | |
271 for (int i = deps->length(); (i -= stride) >= 0; ) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
272 ciBaseObject* y = deps->at(i+1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
273 ciBaseObject* y2 = deps->at(i+2); |
0 | 274 if (x == y && x2 == y2) { // same subjects; check the context |
275 if (maybe_merge_ctxk(deps, i+0, ctxk)) { | |
276 return; | |
277 } | |
278 } | |
279 } | |
280 } | |
281 // append the assertion in the correct bucket: | |
282 deps->append(ctxk); | |
283 deps->append(x); | |
284 deps->append(x2); | |
285 } | |
286 | |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
287 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
288 bool Dependencies::maybe_merge_ctxk(GrowableArray<DepValue>* deps, |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
289 int ctxk_i, DepValue ctxk2_dv) { |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
290 Klass* ctxk1 = deps->at(ctxk_i).as_klass(_oop_recorder); |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
291 Klass* ctxk2 = ctxk2_dv.as_klass(_oop_recorder); |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
292 if (ctxk2->is_subtype_of(ctxk1)) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
293 return true; // success, and no need to change |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
294 } else if (ctxk1->is_subtype_of(ctxk2)) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
295 // new context class fully subsumes previous one |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
296 deps->at_put(ctxk_i, ctxk2_dv); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
297 return true; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
298 } else { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
299 return false; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
300 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
301 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
302 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
303 void Dependencies::assert_common_1(DepType dept, DepValue x) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
304 assert(dep_args(dept) == 1, "sanity"); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
305 //log_dependency(dept, x); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
306 GrowableArray<DepValue>* deps = _dep_values[dept]; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
307 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
308 // see if the same (or a similar) dep is already recorded |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
309 if (note_dep_seen(dept, x)) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
310 assert(deps->find(x) >= 0, "sanity"); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
311 } else { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
312 deps->append(x); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
313 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
314 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
315 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
316 void Dependencies::assert_common_2(DepType dept, |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
317 DepValue x0, DepValue x1) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
318 assert(dep_args(dept) == 2, "sanity"); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
319 //log_dependency(dept, x0, x1); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
320 GrowableArray<DepValue>* deps = _dep_values[dept]; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
321 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
322 // see if the same (or a similar) dep is already recorded |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
323 bool has_ctxk = has_explicit_context_arg(dept); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
324 if (has_ctxk) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
325 assert(dep_context_arg(dept) == 0, "sanity"); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
326 if (note_dep_seen(dept, x1)) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
327 // look in this bucket for redundant assertions |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
328 const int stride = 2; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
329 for (int i = deps->length(); (i -= stride) >= 0; ) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
330 DepValue y1 = deps->at(i+1); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
331 if (x1 == y1) { // same subject; check the context |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
332 if (maybe_merge_ctxk(deps, i+0, x0)) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
333 return; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
334 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
335 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
336 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
337 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
338 } else { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
339 assert(dep_implicit_context_arg(dept) == 0, "sanity"); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
340 if (note_dep_seen(dept, x0) && note_dep_seen(dept, x1)) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
341 // look in this bucket for redundant assertions |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
342 const int stride = 2; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
343 for (int i = deps->length(); (i -= stride) >= 0; ) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
344 DepValue y0 = deps->at(i+0); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
345 DepValue y1 = deps->at(i+1); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
346 if (x0 == y0 && x1 == y1) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
347 return; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
348 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
349 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
350 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
351 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
352 |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
353 // append the assertion in the correct bucket: |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
354 deps->append(x0); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
355 deps->append(x1); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
356 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
357 #endif // GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
358 |
0 | 359 /// Support for encoding dependencies into an nmethod: |
360 | |
361 void Dependencies::copy_to(nmethod* nm) { | |
362 address beg = nm->dependencies_begin(); | |
363 address end = nm->dependencies_end(); | |
364 guarantee(end - beg >= (ptrdiff_t) size_in_bytes(), "bad sizing"); | |
365 Copy::disjoint_words((HeapWord*) content_bytes(), | |
366 (HeapWord*) beg, | |
367 size_in_bytes() / sizeof(HeapWord)); | |
368 assert(size_in_bytes() % sizeof(HeapWord) == 0, "copy by words"); | |
369 } | |
370 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
371 static int sort_dep(ciBaseObject** p1, ciBaseObject** p2, int narg) { |
0 | 372 for (int i = 0; i < narg; i++) { |
373 int diff = p1[i]->ident() - p2[i]->ident(); | |
374 if (diff != 0) return diff; | |
375 } | |
376 return 0; | |
377 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
378 static int sort_dep_arg_1(ciBaseObject** p1, ciBaseObject** p2) |
0 | 379 { return sort_dep(p1, p2, 1); } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
380 static int sort_dep_arg_2(ciBaseObject** p1, ciBaseObject** p2) |
0 | 381 { return sort_dep(p1, p2, 2); } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
382 static int sort_dep_arg_3(ciBaseObject** p1, ciBaseObject** p2) |
0 | 383 { return sort_dep(p1, p2, 3); } |
384 | |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
385 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
386 // metadata deps are sorted before object deps |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
387 static int sort_dep_value(Dependencies::DepValue* p1, Dependencies::DepValue* p2, int narg) { |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
388 for (int i = 0; i < narg; i++) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
389 int diff = p1[i].sort_key() - p2[i].sort_key(); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
390 if (diff != 0) return diff; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
391 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
392 return 0; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
393 } |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
394 static int sort_dep_value_arg_1(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
395 { return sort_dep_value(p1, p2, 1); } |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
396 static int sort_dep_value_arg_2(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
397 { return sort_dep_value(p1, p2, 2); } |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
398 static int sort_dep_value_arg_3(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
399 { return sort_dep_value(p1, p2, 3); } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
400 #endif // GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
401 |
0 | 402 void Dependencies::sort_all_deps() { |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
403 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
404 if (_using_dep_values) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
405 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
406 DepType dept = (DepType)deptv; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
407 GrowableArray<DepValue>* deps = _dep_values[dept]; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
408 if (deps->length() <= 1) continue; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
409 switch (dep_args(dept)) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
410 case 1: deps->sort(sort_dep_value_arg_1, 1); break; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
411 case 2: deps->sort(sort_dep_value_arg_2, 2); break; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
412 case 3: deps->sort(sort_dep_value_arg_3, 3); break; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
413 default: ShouldNotReachHere(); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
414 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
415 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
416 return; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
417 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
418 #endif // GRAAL |
0 | 419 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
420 DepType dept = (DepType)deptv; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
421 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
0 | 422 if (deps->length() <= 1) continue; |
423 switch (dep_args(dept)) { | |
424 case 1: deps->sort(sort_dep_arg_1, 1); break; | |
425 case 2: deps->sort(sort_dep_arg_2, 2); break; | |
426 case 3: deps->sort(sort_dep_arg_3, 3); break; | |
427 default: ShouldNotReachHere(); | |
428 } | |
429 } | |
430 } | |
431 | |
432 size_t Dependencies::estimate_size_in_bytes() { | |
433 size_t est_size = 100; | |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
434 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
435 if (_using_dep_values) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
436 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
437 DepType dept = (DepType)deptv; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
438 GrowableArray<DepValue>* deps = _dep_values[dept]; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
439 est_size += deps->length() * 2; // tags and argument(s) |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
440 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
441 return est_size; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
442 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
443 #endif // GRAAL |
0 | 444 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
445 DepType dept = (DepType)deptv; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
446 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
0 | 447 est_size += deps->length()*2; // tags and argument(s) |
448 } | |
449 return est_size; | |
450 } | |
451 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
452 ciKlass* Dependencies::ctxk_encoded_as_null(DepType dept, ciBaseObject* x) { |
0 | 453 switch (dept) { |
454 case abstract_with_exclusive_concrete_subtypes_2: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
455 return x->as_metadata()->as_klass(); |
0 | 456 case unique_concrete_method: |
457 case exclusive_concrete_methods_2: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
458 return x->as_metadata()->as_method()->holder(); |
0 | 459 } |
460 return NULL; // let NULL be NULL | |
461 } | |
462 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
463 Klass* Dependencies::ctxk_encoded_as_null(DepType dept, Metadata* x) { |
0 | 464 assert(must_be_in_vm(), "raw oops here"); |
465 switch (dept) { | |
466 case abstract_with_exclusive_concrete_subtypes_2: | |
467 assert(x->is_klass(), "sanity"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
468 return (Klass*) x; |
0 | 469 case unique_concrete_method: |
470 case exclusive_concrete_methods_2: | |
471 assert(x->is_method(), "sanity"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
472 return ((Method*)x)->method_holder(); |
0 | 473 } |
474 return NULL; // let NULL be NULL | |
475 } | |
476 | |
477 void Dependencies::encode_content_bytes() { | |
478 sort_all_deps(); | |
479 | |
480 // cast is safe, no deps can overflow INT_MAX | |
481 CompressedWriteStream bytes((int)estimate_size_in_bytes()); | |
482 | |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
483 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
484 if (_using_dep_values) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
485 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
486 DepType dept = (DepType)deptv; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
487 GrowableArray<DepValue>* deps = _dep_values[dept]; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
488 if (deps->length() == 0) continue; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
489 int stride = dep_args(dept); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
490 int ctxkj = dep_context_arg(dept); // -1 if no context arg |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
491 assert(stride > 0, "sanity"); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
492 for (int i = 0; i < deps->length(); i += stride) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
493 jbyte code_byte = (jbyte)dept; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
494 int skipj = -1; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
495 if (ctxkj >= 0 && ctxkj+1 < stride) { |
7101
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
496 Klass* ctxk = deps->at(i+ctxkj+0).as_klass(_oop_recorder); |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
497 DepValue x = deps->at(i+ctxkj+1); // following argument |
0778b04fc682
better encoding of dependencies during dependency recording by Graal
Doug Simon <doug.simon@oracle.com>
parents:
7094
diff
changeset
|
498 if (ctxk == ctxk_encoded_as_null(dept, x.as_metadata(_oop_recorder))) { |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
499 skipj = ctxkj; // we win: maybe one less oop to keep track of |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
500 code_byte |= default_context_type_bit; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
501 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
502 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
503 bytes.write_byte(code_byte); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
504 for (int j = 0; j < stride; j++) { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
505 if (j == skipj) continue; |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
506 DepValue v = deps->at(i+j); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
507 int idx = v.index(); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
508 bytes.write_int(idx); |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
509 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
510 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
511 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
512 } else { |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
513 #endif // GRAAL |
0 | 514 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
515 DepType dept = (DepType)deptv; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
516 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
0 | 517 if (deps->length() == 0) continue; |
518 int stride = dep_args(dept); | |
519 int ctxkj = dep_context_arg(dept); // -1 if no context arg | |
520 assert(stride > 0, "sanity"); | |
521 for (int i = 0; i < deps->length(); i += stride) { | |
522 jbyte code_byte = (jbyte)dept; | |
523 int skipj = -1; | |
524 if (ctxkj >= 0 && ctxkj+1 < stride) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
525 ciKlass* ctxk = deps->at(i+ctxkj+0)->as_metadata()->as_klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
526 ciBaseObject* x = deps->at(i+ctxkj+1); // following argument |
0 | 527 if (ctxk == ctxk_encoded_as_null(dept, x)) { |
528 skipj = ctxkj; // we win: maybe one less oop to keep track of | |
529 code_byte |= default_context_type_bit; | |
530 } | |
531 } | |
532 bytes.write_byte(code_byte); | |
533 for (int j = 0; j < stride; j++) { | |
534 if (j == skipj) continue; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
535 ciBaseObject* v = deps->at(i+j); |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
536 int idx; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
537 if (v->is_object()) { |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
538 idx = _oop_recorder->find_index(v->as_object()->constant_encoding()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
539 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
540 ciMetadata* meta = v->as_metadata(); |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
541 idx = _oop_recorder->find_index(meta->constant_encoding()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
542 } |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
543 bytes.write_int(idx); |
0 | 544 } |
545 } | |
546 } | |
7094
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
547 #ifdef GRAAL |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
548 } |
eec7173947a1
removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents:
6985
diff
changeset
|
549 #endif // GRAAL |
0 | 550 |
551 // write a sentinel byte to mark the end | |
552 bytes.write_byte(end_marker); | |
553 | |
554 // round it out to a word boundary | |
555 while (bytes.position() % sizeof(HeapWord) != 0) { | |
556 bytes.write_byte(end_marker); | |
557 } | |
558 | |
559 // check whether the dept byte encoding really works | |
560 assert((jbyte)default_context_type_bit != 0, "byte overflow"); | |
561 | |
562 _content_bytes = bytes.buffer(); | |
563 _size_in_bytes = bytes.position(); | |
564 } | |
565 | |
8159
c5ff08c22458
Fix regression in client compiler debug recording.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7735
diff
changeset
|
566 |
0 | 567 const char* Dependencies::_dep_name[TYPE_LIMIT] = { |
568 "end_marker", | |
569 "evol_method", | |
570 "leaf_type", | |
571 "abstract_with_unique_concrete_subtype", | |
572 "abstract_with_no_concrete_subtype", | |
573 "concrete_with_no_concrete_subtype", | |
574 "unique_concrete_method", | |
575 "abstract_with_exclusive_concrete_subtypes_2", | |
576 "exclusive_concrete_methods_2", | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
577 "no_finalizable_subclasses", |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
578 "call_site_target_value" |
0 | 579 }; |
580 | |
581 int Dependencies::_dep_args[TYPE_LIMIT] = { | |
582 -1,// end_marker | |
583 1, // evol_method m | |
584 1, // leaf_type ctxk | |
585 2, // abstract_with_unique_concrete_subtype ctxk, k | |
586 1, // abstract_with_no_concrete_subtype ctxk | |
587 1, // concrete_with_no_concrete_subtype ctxk | |
588 2, // unique_concrete_method ctxk, m | |
589 3, // unique_concrete_subtypes_2 ctxk, k1, k2 | |
590 3, // unique_concrete_methods_2 ctxk, m1, m2 | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
591 1, // no_finalizable_subclasses ctxk |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
592 2 // call_site_target_value call_site, method_handle |
0 | 593 }; |
594 | |
595 const char* Dependencies::dep_name(Dependencies::DepType dept) { | |
596 if (!dept_in_mask(dept, all_types)) return "?bad-dep?"; | |
597 return _dep_name[dept]; | |
598 } | |
599 | |
600 int Dependencies::dep_args(Dependencies::DepType dept) { | |
601 if (!dept_in_mask(dept, all_types)) return -1; | |
602 return _dep_args[dept]; | |
603 } | |
604 | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
605 void Dependencies::check_valid_dependency_type(DepType dept) { |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
606 guarantee(FIRST_TYPE <= dept && dept < TYPE_LIMIT, err_msg("invalid dependency type: %d", (int) dept)); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
607 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
608 |
0 | 609 // for the sake of the compiler log, print out current dependencies: |
610 void Dependencies::log_all_dependencies() { | |
611 if (log() == NULL) return; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
612 ciBaseObject* args[max_arg_count]; |
0 | 613 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
614 DepType dept = (DepType)deptv; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
615 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
0 | 616 if (deps->length() == 0) continue; |
617 int stride = dep_args(dept); | |
618 for (int i = 0; i < deps->length(); i += stride) { | |
619 for (int j = 0; j < stride; j++) { | |
620 // flush out the identities before printing | |
621 args[j] = deps->at(i+j); | |
622 } | |
623 write_dependency_to(log(), dept, stride, args); | |
624 } | |
625 } | |
626 } | |
627 | |
628 void Dependencies::write_dependency_to(CompileLog* log, | |
629 DepType dept, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
630 int nargs, DepArgument args[], |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
631 Klass* witness) { |
0 | 632 if (log == NULL) { |
633 return; | |
634 } | |
635 ciEnv* env = ciEnv::current(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
636 ciBaseObject* ciargs[max_arg_count]; |
0 | 637 assert(nargs <= max_arg_count, "oob"); |
638 for (int j = 0; j < nargs; j++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
639 if (args[j].is_oop()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
640 ciargs[j] = env->get_object(args[j].oop_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
641 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
642 ciargs[j] = env->get_metadata(args[j].metadata_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
643 } |
0 | 644 } |
645 Dependencies::write_dependency_to(log, dept, nargs, ciargs, witness); | |
646 } | |
647 | |
648 void Dependencies::write_dependency_to(CompileLog* log, | |
649 DepType dept, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
650 int nargs, ciBaseObject* args[], |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
651 Klass* witness) { |
0 | 652 if (log == NULL) return; |
653 assert(nargs <= max_arg_count, "oob"); | |
654 int argids[max_arg_count]; | |
655 int ctxkj = dep_context_arg(dept); // -1 if no context arg | |
656 int j; | |
657 for (j = 0; j < nargs; j++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
658 if (args[j]->is_object()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
659 argids[j] = log->identify(args[j]->as_object()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
660 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
661 argids[j] = log->identify(args[j]->as_metadata()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
662 } |
0 | 663 } |
664 if (witness != NULL) { | |
665 log->begin_elem("dependency_failed"); | |
666 } else { | |
667 log->begin_elem("dependency"); | |
668 } | |
669 log->print(" type='%s'", dep_name(dept)); | |
670 if (ctxkj >= 0) { | |
671 log->print(" ctxk='%d'", argids[ctxkj]); | |
672 } | |
673 // write remaining arguments, if any. | |
674 for (j = 0; j < nargs; j++) { | |
675 if (j == ctxkj) continue; // already logged | |
676 if (j == 1) { | |
677 log->print( " x='%d'", argids[j]); | |
678 } else { | |
679 log->print(" x%d='%d'", j, argids[j]); | |
680 } | |
681 } | |
682 if (witness != NULL) { | |
683 log->object("witness", witness); | |
684 log->stamp(); | |
685 } | |
686 log->end_elem(); | |
687 } | |
688 | |
689 void Dependencies::write_dependency_to(xmlStream* xtty, | |
690 DepType dept, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
691 int nargs, DepArgument args[], |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
692 Klass* witness) { |
0 | 693 if (xtty == NULL) return; |
694 ttyLocker ttyl; | |
695 int ctxkj = dep_context_arg(dept); // -1 if no context arg | |
696 if (witness != NULL) { | |
697 xtty->begin_elem("dependency_failed"); | |
698 } else { | |
699 xtty->begin_elem("dependency"); | |
700 } | |
701 xtty->print(" type='%s'", dep_name(dept)); | |
702 if (ctxkj >= 0) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
703 xtty->object("ctxk", args[ctxkj].metadata_value()); |
0 | 704 } |
705 // write remaining arguments, if any. | |
706 for (int j = 0; j < nargs; j++) { | |
707 if (j == ctxkj) continue; // already logged | |
708 if (j == 1) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
709 if (args[j].is_oop()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
710 xtty->object("x", args[j].oop_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
711 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
712 xtty->object("x", args[j].metadata_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
713 } |
0 | 714 } else { |
715 char xn[10]; sprintf(xn, "x%d", j); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
716 if (args[j].is_oop()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
717 xtty->object(xn, args[j].oop_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
718 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
719 xtty->object(xn, args[j].metadata_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
720 } |
0 | 721 } |
722 } | |
723 if (witness != NULL) { | |
724 xtty->object("witness", witness); | |
725 xtty->stamp(); | |
726 } | |
727 xtty->end_elem(); | |
728 } | |
729 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
730 void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
731 Klass* witness) { |
0 | 732 ResourceMark rm; |
733 ttyLocker ttyl; // keep the following output all in one block | |
734 tty->print_cr("%s of type %s", | |
735 (witness == NULL)? "Dependency": "Failed dependency", | |
736 dep_name(dept)); | |
737 // print arguments | |
738 int ctxkj = dep_context_arg(dept); // -1 if no context arg | |
739 for (int j = 0; j < nargs; j++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
740 DepArgument arg = args[j]; |
0 | 741 bool put_star = false; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
742 if (arg.is_null()) continue; |
0 | 743 const char* what; |
744 if (j == ctxkj) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
745 assert(arg.is_metadata(), "must be"); |
0 | 746 what = "context"; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
747 put_star = !Dependencies::is_concrete_klass((Klass*)arg.metadata_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
748 } else if (arg.is_method()) { |
0 | 749 what = "method "; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
750 put_star = !Dependencies::is_concrete_method((Method*)arg.metadata_value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
751 } else if (arg.is_klass()) { |
0 | 752 what = "class "; |
753 } else { | |
754 what = "object "; | |
755 } | |
756 tty->print(" %s = %s", what, (put_star? "*": "")); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
757 if (arg.is_klass()) |
6983 | 758 tty->print("%s", ((Klass*)arg.metadata_value())->external_name()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
759 else if (arg.is_method()) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
760 ((Method*)arg.metadata_value())->print_value(); |
0 | 761 else |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
762 ShouldNotReachHere(); // Provide impl for this type. |
0 | 763 tty->cr(); |
764 } | |
765 if (witness != NULL) { | |
766 bool put_star = !Dependencies::is_concrete_klass(witness); | |
767 tty->print_cr(" witness = %s%s", | |
768 (put_star? "*": ""), | |
6983 | 769 witness->external_name()); |
0 | 770 } |
771 } | |
772 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
773 void Dependencies::DepStream::log_dependency(Klass* witness) { |
0 | 774 if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6940
diff
changeset
|
775 ResourceMark rm; |
0 | 776 int nargs = argument_count(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
777 DepArgument args[max_arg_count]; |
0 | 778 for (int j = 0; j < nargs; j++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
779 if (type() == call_site_target_value) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
780 args[j] = argument_oop(j); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
781 } else { |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
782 args[j] = argument(j); |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
783 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
784 } |
0 | 785 if (_deps != NULL && _deps->log() != NULL) { |
786 Dependencies::write_dependency_to(_deps->log(), | |
787 type(), nargs, args, witness); | |
788 } else { | |
789 Dependencies::write_dependency_to(xtty, | |
790 type(), nargs, args, witness); | |
791 } | |
792 } | |
793 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
794 void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) { |
0 | 795 int nargs = argument_count(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
796 DepArgument args[max_arg_count]; |
0 | 797 for (int j = 0; j < nargs; j++) { |
798 args[j] = argument(j); | |
799 } | |
800 Dependencies::print_dependency(type(), nargs, args, witness); | |
801 if (verbose) { | |
802 if (_code != NULL) { | |
803 tty->print(" code: "); | |
804 _code->print_value_on(tty); | |
805 tty->cr(); | |
806 } | |
807 } | |
808 } | |
809 | |
810 | |
811 /// Dependency stream support (decodes dependencies from an nmethod): | |
812 | |
813 #ifdef ASSERT | |
814 void Dependencies::DepStream::initial_asserts(size_t byte_limit) { | |
815 assert(must_be_in_vm(), "raw oops here"); | |
816 _byte_limit = byte_limit; | |
817 _type = (DepType)(end_marker-1); // defeat "already at end" assert | |
818 assert((_code!=NULL) + (_deps!=NULL) == 1, "one or t'other"); | |
819 } | |
820 #endif //ASSERT | |
821 | |
822 bool Dependencies::DepStream::next() { | |
823 assert(_type != end_marker, "already at end"); | |
824 if (_bytes.position() == 0 && _code != NULL | |
825 && _code->dependencies_size() == 0) { | |
826 // Method has no dependencies at all. | |
827 return false; | |
828 } | |
829 int code_byte = (_bytes.read_byte() & 0xFF); | |
830 if (code_byte == end_marker) { | |
831 DEBUG_ONLY(_type = end_marker); | |
832 return false; | |
833 } else { | |
834 int ctxk_bit = (code_byte & Dependencies::default_context_type_bit); | |
835 code_byte -= ctxk_bit; | |
836 DepType dept = (DepType)code_byte; | |
837 _type = dept; | |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
838 Dependencies::check_valid_dependency_type(dept); |
0 | 839 int stride = _dep_args[dept]; |
840 assert(stride == dep_args(dept), "sanity"); | |
841 int skipj = -1; | |
842 if (ctxk_bit != 0) { | |
843 skipj = 0; // currently the only context argument is at zero | |
844 assert(skipj == dep_context_arg(dept), "zero arg always ctxk"); | |
845 } | |
846 for (int j = 0; j < stride; j++) { | |
847 _xi[j] = (j == skipj)? 0: _bytes.read_int(); | |
848 } | |
849 DEBUG_ONLY(_xi[stride] = -1); // help detect overruns | |
850 return true; | |
851 } | |
852 } | |
853 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
854 inline Metadata* Dependencies::DepStream::recorded_metadata_at(int i) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
855 Metadata* o = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
856 if (_code != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
857 o = _code->metadata_at(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
858 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
859 o = _deps->oop_recorder()->metadata_at(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
860 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
861 assert(o == NULL || o->is_metadata(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
862 err_msg("Should be perm " PTR_FORMAT, o)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
863 return o; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
864 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
865 |
0 | 866 inline oop Dependencies::DepStream::recorded_oop_at(int i) { |
867 return (_code != NULL) | |
868 ? _code->oop_at(i) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
869 : JNIHandles::resolve(_deps->oop_recorder()->oop_at(i)); |
0 | 870 } |
871 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
872 Metadata* Dependencies::DepStream::argument(int i) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
873 Metadata* result = recorded_metadata_at(argument_index(i)); |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
874 |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
875 if (result == NULL) { // Explicit context argument can be compressed |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
876 int ctxkj = dep_context_arg(type()); // -1 if no explicit context arg |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
877 if (ctxkj >= 0 && i == ctxkj && ctxkj+1 < argument_count()) { |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
878 result = ctxk_encoded_as_null(type(), argument(ctxkj+1)); |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
879 } |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
880 } |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
881 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
882 assert(result == NULL || result->is_klass() || result->is_method(), "must be"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
883 return result; |
0 | 884 } |
885 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
886 oop Dependencies::DepStream::argument_oop(int i) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
887 oop result = recorded_oop_at(argument_index(i)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
888 assert(result == NULL || result->is_oop(), "must be"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
889 return result; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
890 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
891 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
892 Klass* Dependencies::DepStream::context_type() { |
0 | 893 assert(must_be_in_vm(), "raw oops here"); |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
894 |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
895 // Most dependencies have an explicit context type argument. |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
896 { |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
897 int ctxkj = dep_context_arg(type()); // -1 if no explicit context arg |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
898 if (ctxkj >= 0) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
899 Metadata* k = argument(ctxkj); |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
900 assert(k != NULL && k->is_klass(), "type check"); |
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
901 return (Klass*)k; |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
902 } |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
903 } |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
904 |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
905 // Some dependencies are using the klass of the first object |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
906 // argument as implicit context type (e.g. call_site_target_value). |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
907 { |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
908 int ctxkj = dep_implicit_context_arg(type()); |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
909 if (ctxkj >= 0) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
910 Klass* k = argument_oop(ctxkj)->klass(); |
6844
9a9b6e05ffb4
8000232: NPG: SIGSEGV in Dependencies::DepStream::check_klass_dependency on solaris-x64
vlivanov
parents:
6740
diff
changeset
|
911 assert(k != NULL && k->is_klass(), "type check"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
912 return (Klass*) k; |
0 | 913 } |
914 } | |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
915 |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
916 // And some dependencies don't have a context type at all, |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
917 // e.g. evol_method. |
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
918 return NULL; |
0 | 919 } |
920 | |
921 /// Checking dependencies: | |
922 | |
923 // This hierarchy walker inspects subtypes of a given type, | |
924 // trying to find a "bad" class which breaks a dependency. | |
925 // Such a class is called a "witness" to the broken dependency. | |
926 // While searching around, we ignore "participants", which | |
927 // are already known to the dependency. | |
928 class ClassHierarchyWalker { | |
929 public: | |
930 enum { PARTICIPANT_LIMIT = 3 }; | |
931 | |
932 private: | |
933 // optional method descriptor to check for: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
934 Symbol* _name; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
935 Symbol* _signature; |
0 | 936 |
937 // special classes which are not allowed to be witnesses: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
938 Klass* _participants[PARTICIPANT_LIMIT+1]; |
0 | 939 int _num_participants; |
940 | |
941 // cache of method lookups | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
942 Method* _found_methods[PARTICIPANT_LIMIT+1]; |
0 | 943 |
944 // if non-zero, tells how many witnesses to convert to participants | |
945 int _record_witnesses; | |
946 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
947 void initialize(Klass* participant) { |
0 | 948 _record_witnesses = 0; |
949 _participants[0] = participant; | |
950 _found_methods[0] = NULL; | |
951 _num_participants = 0; | |
952 if (participant != NULL) { | |
953 // Terminating NULL. | |
954 _participants[1] = NULL; | |
955 _found_methods[1] = NULL; | |
956 _num_participants = 1; | |
957 } | |
958 } | |
959 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
960 void initialize_from_method(Method* m) { |
0 | 961 assert(m != NULL && m->is_method(), "sanity"); |
962 _name = m->name(); | |
963 _signature = m->signature(); | |
964 } | |
965 | |
966 public: | |
967 // The walker is initialized to recognize certain methods and/or types | |
968 // as friendly participants. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
969 ClassHierarchyWalker(Klass* participant, Method* m) { |
0 | 970 initialize_from_method(m); |
971 initialize(participant); | |
972 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
973 ClassHierarchyWalker(Method* m) { |
0 | 974 initialize_from_method(m); |
975 initialize(NULL); | |
976 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
977 ClassHierarchyWalker(Klass* participant = NULL) { |
0 | 978 _name = NULL; |
979 _signature = NULL; | |
980 initialize(participant); | |
981 } | |
982 | |
983 // This is common code for two searches: One for concrete subtypes, | |
984 // the other for concrete method implementations and overrides. | |
985 bool doing_subtype_search() { | |
986 return _name == NULL; | |
987 } | |
988 | |
989 int num_participants() { return _num_participants; } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
990 Klass* participant(int n) { |
0 | 991 assert((uint)n <= (uint)_num_participants, "oob"); |
992 return _participants[n]; | |
993 } | |
994 | |
995 // Note: If n==num_participants, returns NULL. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
996 Method* found_method(int n) { |
0 | 997 assert((uint)n <= (uint)_num_participants, "oob"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
998 Method* fm = _found_methods[n]; |
0 | 999 assert(n == _num_participants || fm != NULL, "proper usage"); |
1000 assert(fm == NULL || fm->method_holder() == _participants[n], "sanity"); | |
1001 return fm; | |
1002 } | |
1003 | |
1004 #ifdef ASSERT | |
1005 // Assert that m is inherited into ctxk, without intervening overrides. | |
1006 // (May return true even if this is not true, in corner cases where we punt.) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1007 bool check_method_context(Klass* ctxk, Method* m) { |
0 | 1008 if (m->method_holder() == ctxk) |
1009 return true; // Quick win. | |
1010 if (m->is_private()) | |
1011 return false; // Quick lose. Should not happen. | |
1012 if (!(m->is_public() || m->is_protected())) | |
1013 // The override story is complex when packages get involved. | |
1014 return true; // Must punt the assertion to true. | |
6983 | 1015 Klass* k = ctxk; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1016 Method* lm = k->lookup_method(m->name(), m->signature()); |
0 | 1017 if (lm == NULL && k->oop_is_instance()) { |
1018 // It might be an abstract interface method, devoid of mirandas. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1019 lm = ((InstanceKlass*)k)->lookup_method_in_all_interfaces(m->name(), |
0 | 1020 m->signature()); |
1021 } | |
1022 if (lm == m) | |
1023 // Method m is inherited into ctxk. | |
1024 return true; | |
1025 if (lm != NULL) { | |
4060 | 1026 if (!(lm->is_public() || lm->is_protected())) { |
0 | 1027 // Method is [package-]private, so the override story is complex. |
1028 return true; // Must punt the assertion to true. | |
4060 | 1029 } |
1030 if (lm->is_static()) { | |
1031 // Static methods don't override non-static so punt | |
1032 return true; | |
1033 } | |
0 | 1034 if ( !Dependencies::is_concrete_method(lm) |
1035 && !Dependencies::is_concrete_method(m) | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
1036 && lm->method_holder()->is_subtype_of(m->method_holder())) |
0 | 1037 // Method m is overridden by lm, but both are non-concrete. |
1038 return true; | |
1039 } | |
1040 ResourceMark rm; | |
1041 tty->print_cr("Dependency method not found in the associated context:"); | |
6983 | 1042 tty->print_cr(" context = %s", ctxk->external_name()); |
0 | 1043 tty->print( " method = "); m->print_short_name(tty); tty->cr(); |
1044 if (lm != NULL) { | |
1045 tty->print( " found = "); lm->print_short_name(tty); tty->cr(); | |
1046 } | |
1047 return false; | |
1048 } | |
1049 #endif | |
1050 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1051 void add_participant(Klass* participant) { |
0 | 1052 assert(_num_participants + _record_witnesses < PARTICIPANT_LIMIT, "oob"); |
1053 int np = _num_participants++; | |
1054 _participants[np] = participant; | |
1055 _participants[np+1] = NULL; | |
1056 _found_methods[np+1] = NULL; | |
1057 } | |
1058 | |
1059 void record_witnesses(int add) { | |
1060 if (add > PARTICIPANT_LIMIT) add = PARTICIPANT_LIMIT; | |
1061 assert(_num_participants + add < PARTICIPANT_LIMIT, "oob"); | |
1062 _record_witnesses = add; | |
1063 } | |
1064 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1065 bool is_witness(Klass* k) { |
0 | 1066 if (doing_subtype_search()) { |
1067 return Dependencies::is_concrete_klass(k); | |
1068 } else { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1069 Method* m = InstanceKlass::cast(k)->find_method(_name, _signature); |
0 | 1070 if (m == NULL || !Dependencies::is_concrete_method(m)) return false; |
1071 _found_methods[_num_participants] = m; | |
1072 // Note: If add_participant(k) is called, | |
1073 // the method m will already be memoized for it. | |
1074 return true; | |
1075 } | |
1076 } | |
1077 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1078 bool is_participant(Klass* k) { |
0 | 1079 if (k == _participants[0]) { |
1080 return true; | |
1081 } else if (_num_participants <= 1) { | |
1082 return false; | |
1083 } else { | |
1084 return in_list(k, &_participants[1]); | |
1085 } | |
1086 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1087 bool ignore_witness(Klass* witness) { |
0 | 1088 if (_record_witnesses == 0) { |
1089 return false; | |
1090 } else { | |
1091 --_record_witnesses; | |
1092 add_participant(witness); | |
1093 return true; | |
1094 } | |
1095 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1096 static bool in_list(Klass* x, Klass** list) { |
0 | 1097 for (int i = 0; ; i++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1098 Klass* y = list[i]; |
0 | 1099 if (y == NULL) break; |
1100 if (y == x) return true; | |
1101 } | |
1102 return false; // not in list | |
1103 } | |
1104 | |
1105 private: | |
1106 // the actual search method: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1107 Klass* find_witness_anywhere(Klass* context_type, |
0 | 1108 bool participants_hide_witnesses, |
1109 bool top_level_call = true); | |
1110 // the spot-checking version: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1111 Klass* find_witness_in(KlassDepChange& changes, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1112 Klass* context_type, |
0 | 1113 bool participants_hide_witnesses); |
1114 public: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1115 Klass* find_witness_subtype(Klass* context_type, KlassDepChange* changes = NULL) { |
0 | 1116 assert(doing_subtype_search(), "must set up a subtype search"); |
1117 // When looking for unexpected concrete types, | |
1118 // do not look beneath expected ones. | |
1119 const bool participants_hide_witnesses = true; | |
1120 // CX > CC > C' is OK, even if C' is new. | |
1121 // CX > { CC, C' } is not OK if C' is new, and C' is the witness. | |
1122 if (changes != NULL) { | |
1123 return find_witness_in(*changes, context_type, participants_hide_witnesses); | |
1124 } else { | |
1125 return find_witness_anywhere(context_type, participants_hide_witnesses); | |
1126 } | |
1127 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1128 Klass* find_witness_definer(Klass* context_type, KlassDepChange* changes = NULL) { |
0 | 1129 assert(!doing_subtype_search(), "must set up a method definer search"); |
1130 // When looking for unexpected concrete methods, | |
1131 // look beneath expected ones, to see if there are overrides. | |
1132 const bool participants_hide_witnesses = true; | |
1133 // CX.m > CC.m > C'.m is not OK, if C'.m is new, and C' is the witness. | |
1134 if (changes != NULL) { | |
1135 return find_witness_in(*changes, context_type, !participants_hide_witnesses); | |
1136 } else { | |
1137 return find_witness_anywhere(context_type, !participants_hide_witnesses); | |
1138 } | |
1139 } | |
1140 }; | |
1141 | |
1142 #ifndef PRODUCT | |
1143 static int deps_find_witness_calls = 0; | |
1144 static int deps_find_witness_steps = 0; | |
1145 static int deps_find_witness_recursions = 0; | |
1146 static int deps_find_witness_singles = 0; | |
1147 static int deps_find_witness_print = 0; // set to -1 to force a final print | |
1148 static bool count_find_witness_calls() { | |
1149 if (TraceDependencies || LogCompilation) { | |
1150 int pcount = deps_find_witness_print + 1; | |
1151 bool final_stats = (pcount == 0); | |
1152 bool initial_call = (pcount == 1); | |
1153 bool occasional_print = ((pcount & ((1<<10) - 1)) == 0); | |
1154 if (pcount < 0) pcount = 1; // crude overflow protection | |
1155 deps_find_witness_print = pcount; | |
1156 if (VerifyDependencies && initial_call) { | |
1157 tty->print_cr("Warning: TraceDependencies results may be inflated by VerifyDependencies"); | |
1158 } | |
1159 if (occasional_print || final_stats) { | |
1160 // Every now and then dump a little info about dependency searching. | |
1161 if (xtty != NULL) { | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1123
diff
changeset
|
1162 ttyLocker ttyl; |
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1123
diff
changeset
|
1163 xtty->elem("deps_find_witness calls='%d' steps='%d' recursions='%d' singles='%d'", |
0 | 1164 deps_find_witness_calls, |
1165 deps_find_witness_steps, | |
1166 deps_find_witness_recursions, | |
1167 deps_find_witness_singles); | |
1168 } | |
1169 if (final_stats || (TraceDependencies && WizardMode)) { | |
1206
87684f1a88b5
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
1123
diff
changeset
|
1170 ttyLocker ttyl; |
0 | 1171 tty->print_cr("Dependency check (find_witness) " |
1172 "calls=%d, steps=%d (avg=%.1f), recursions=%d, singles=%d", | |
1173 deps_find_witness_calls, | |
1174 deps_find_witness_steps, | |
1175 (double)deps_find_witness_steps / deps_find_witness_calls, | |
1176 deps_find_witness_recursions, | |
1177 deps_find_witness_singles); | |
1178 } | |
1179 } | |
1180 return true; | |
1181 } | |
1182 return false; | |
1183 } | |
1184 #else | |
1185 #define count_find_witness_calls() (0) | |
1186 #endif //PRODUCT | |
1187 | |
1188 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1189 Klass* ClassHierarchyWalker::find_witness_in(KlassDepChange& changes, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1190 Klass* context_type, |
0 | 1191 bool participants_hide_witnesses) { |
1192 assert(changes.involves_context(context_type), "irrelevant dependency"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1193 Klass* new_type = changes.new_type(); |
0 | 1194 |
1195 count_find_witness_calls(); | |
1196 NOT_PRODUCT(deps_find_witness_singles++); | |
1197 | |
1198 // Current thread must be in VM (not native mode, as in CI): | |
1199 assert(must_be_in_vm(), "raw oops here"); | |
1200 // Must not move the class hierarchy during this check: | |
1201 assert_locked_or_safepoint(Compile_lock); | |
1202 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1203 int nof_impls = InstanceKlass::cast(context_type)->nof_implementors(); |
30 | 1204 if (nof_impls > 1) { |
1205 // Avoid this case: *I.m > { A.m, C }; B.m > C | |
1206 // %%% Until this is fixed more systematically, bail out. | |
1207 // See corresponding comment in find_witness_anywhere. | |
1208 return context_type; | |
1209 } | |
1210 | |
0 | 1211 assert(!is_participant(new_type), "only old classes are participants"); |
1212 if (participants_hide_witnesses) { | |
1213 // If the new type is a subtype of a participant, we are done. | |
1214 for (int i = 0; i < num_participants(); i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1215 Klass* part = participant(i); |
0 | 1216 if (part == NULL) continue; |
6983 | 1217 assert(changes.involves_context(part) == new_type->is_subtype_of(part), |
0 | 1218 "correct marking of participants, b/c new_type is unique"); |
1219 if (changes.involves_context(part)) { | |
1220 // new guy is protected from this check by previous participant | |
1221 return NULL; | |
1222 } | |
1223 } | |
1224 } | |
1225 | |
1226 if (is_witness(new_type) && | |
1227 !ignore_witness(new_type)) { | |
1228 return new_type; | |
1229 } | |
1230 | |
1231 return NULL; | |
1232 } | |
1233 | |
1234 | |
1235 // Walk hierarchy under a context type, looking for unexpected types. | |
1236 // Do not report participant types, and recursively walk beneath | |
1237 // them only if participants_hide_witnesses is false. | |
1238 // If top_level_call is false, skip testing the context type, | |
1239 // because the caller has already considered it. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1240 Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type, |
0 | 1241 bool participants_hide_witnesses, |
1242 bool top_level_call) { | |
1243 // Current thread must be in VM (not native mode, as in CI): | |
1244 assert(must_be_in_vm(), "raw oops here"); | |
1245 // Must not move the class hierarchy during this check: | |
1246 assert_locked_or_safepoint(Compile_lock); | |
1247 | |
1248 bool do_counts = count_find_witness_calls(); | |
1249 | |
1250 // Check the root of the sub-hierarchy first. | |
1251 if (top_level_call) { | |
1252 if (do_counts) { | |
1253 NOT_PRODUCT(deps_find_witness_calls++); | |
1254 NOT_PRODUCT(deps_find_witness_steps++); | |
1255 } | |
1256 if (is_participant(context_type)) { | |
1257 if (participants_hide_witnesses) return NULL; | |
1258 // else fall through to search loop... | |
1259 } else if (is_witness(context_type) && !ignore_witness(context_type)) { | |
1260 // The context is an abstract class or interface, to start with. | |
1261 return context_type; | |
1262 } | |
1263 } | |
1264 | |
1265 // Now we must check each implementor and each subclass. | |
1266 // Use a short worklist to avoid blowing the stack. | |
1267 // Each worklist entry is a *chain* of subklass siblings to process. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1268 const int CHAINMAX = 100; // >= 1 + InstanceKlass::implementors_limit |
0 | 1269 Klass* chains[CHAINMAX]; |
1270 int chaini = 0; // index into worklist | |
1271 Klass* chain; // scratch variable | |
1272 #define ADD_SUBCLASS_CHAIN(k) { \ | |
1273 assert(chaini < CHAINMAX, "oob"); \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1274 chain = InstanceKlass::cast(k)->subklass(); \ |
0 | 1275 if (chain != NULL) chains[chaini++] = chain; } |
1276 | |
1277 // Look for non-abstract subclasses. | |
1278 // (Note: Interfaces do not have subclasses.) | |
1279 ADD_SUBCLASS_CHAIN(context_type); | |
1280 | |
1281 // If it is an interface, search its direct implementors. | |
1282 // (Their subclasses are additional indirect implementors. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1283 // See InstanceKlass::add_implementor.) |
0 | 1284 // (Note: nof_implementors is always zero for non-interfaces.) |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1285 int nof_impls = InstanceKlass::cast(context_type)->nof_implementors(); |
0 | 1286 if (nof_impls > 1) { |
1287 // Avoid this case: *I.m > { A.m, C }; B.m > C | |
1288 // Here, I.m has 2 concrete implementations, but m appears unique | |
1289 // as A.m, because the search misses B.m when checking C. | |
1290 // The inherited method B.m was getting missed by the walker | |
1291 // when interface 'I' was the starting point. | |
1292 // %%% Until this is fixed more systematically, bail out. | |
1293 // (Old CHA had the same limitation.) | |
1294 return context_type; | |
1295 } | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1296 if (nof_impls > 0) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1297 Klass* impl = InstanceKlass::cast(context_type)->implementor(); |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1298 assert(impl != NULL, "just checking"); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1299 // If impl is the same as the context_type, then more than one |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1300 // implementor has seen. No exact info in this case. |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1301 if (impl == context_type) { |
0 | 1302 return context_type; // report an inexact witness to this sad affair |
1303 } | |
1304 if (do_counts) | |
1305 { NOT_PRODUCT(deps_find_witness_steps++); } | |
1306 if (is_participant(impl)) { | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1307 if (!participants_hide_witnesses) { |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1308 ADD_SUBCLASS_CHAIN(impl); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1309 } |
0 | 1310 } else if (is_witness(impl) && !ignore_witness(impl)) { |
1311 return impl; | |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1312 } else { |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1313 ADD_SUBCLASS_CHAIN(impl); |
0 | 1314 } |
1315 } | |
1316 | |
1317 // Recursively process each non-trivial sibling chain. | |
1318 while (chaini > 0) { | |
1319 Klass* chain = chains[--chaini]; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1320 for (Klass* sub = chain; sub != NULL; sub = sub->next_sibling()) { |
0 | 1321 if (do_counts) { NOT_PRODUCT(deps_find_witness_steps++); } |
1322 if (is_participant(sub)) { | |
1323 if (participants_hide_witnesses) continue; | |
1324 // else fall through to process this guy's subclasses | |
1325 } else if (is_witness(sub) && !ignore_witness(sub)) { | |
1326 return sub; | |
1327 } | |
1328 if (chaini < (VerifyDependencies? 2: CHAINMAX)) { | |
1329 // Fast path. (Partially disabled if VerifyDependencies.) | |
1330 ADD_SUBCLASS_CHAIN(sub); | |
1331 } else { | |
1332 // Worklist overflow. Do a recursive call. Should be rare. | |
1333 // The recursive call will have its own worklist, of course. | |
1334 // (Note that sub has already been tested, so that there is | |
1335 // no need for the recursive call to re-test. That's handy, | |
1336 // since the recursive call sees sub as the context_type.) | |
1337 if (do_counts) { NOT_PRODUCT(deps_find_witness_recursions++); } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1338 Klass* witness = find_witness_anywhere(sub, |
0 | 1339 participants_hide_witnesses, |
1340 /*top_level_call=*/ false); | |
1341 if (witness != NULL) return witness; | |
1342 } | |
1343 } | |
1344 } | |
1345 | |
1346 // No witness found. The dependency remains unbroken. | |
1347 return NULL; | |
1348 #undef ADD_SUBCLASS_CHAIN | |
1349 } | |
1350 | |
1351 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1352 bool Dependencies::is_concrete_klass(Klass* k) { |
6983 | 1353 if (k->is_abstract()) return false; |
0 | 1354 // %%% We could treat classes which are concrete but |
1355 // have not yet been instantiated as virtually abstract. | |
1356 // This would require a deoptimization barrier on first instantiation. | |
1357 //if (k->is_not_instantiated()) return false; | |
1358 return true; | |
1359 } | |
1360 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1361 bool Dependencies::is_concrete_method(Method* m) { |
4060 | 1362 // Statics are irrelevant to virtual call sites. |
1363 if (m->is_static()) return false; | |
1364 | |
1365 // We could also return false if m does not yet appear to be | |
1366 // executed, if the VM version supports this distinction also. | |
6934 | 1367 return !m->is_abstract() && |
1368 !InstanceKlass::cast(m->method_holder())->is_interface(); | |
1369 // TODO: investigate whether default methods should be | |
1370 // considered as "concrete" in this situation. For now they | |
1371 // are not. | |
0 | 1372 } |
1373 | |
1374 | |
1375 Klass* Dependencies::find_finalizable_subclass(Klass* k) { | |
1376 if (k->is_interface()) return NULL; | |
1377 if (k->has_finalizer()) return k; | |
1378 k = k->subklass(); | |
1379 while (k != NULL) { | |
1380 Klass* result = find_finalizable_subclass(k); | |
1381 if (result != NULL) return result; | |
1382 k = k->next_sibling(); | |
1383 } | |
1384 return NULL; | |
1385 } | |
1386 | |
1387 | |
1388 bool Dependencies::is_concrete_klass(ciInstanceKlass* k) { | |
1389 if (k->is_abstract()) return false; | |
4060 | 1390 // We could also return false if k does not yet appear to be |
0 | 1391 // instantiated, if the VM version supports this distinction also. |
1392 //if (k->is_not_instantiated()) return false; | |
1393 return true; | |
1394 } | |
1395 | |
1396 bool Dependencies::is_concrete_method(ciMethod* m) { | |
1397 // Statics are irrelevant to virtual call sites. | |
1398 if (m->is_static()) return false; | |
1399 | |
4060 | 1400 // We could also return false if m does not yet appear to be |
0 | 1401 // executed, if the VM version supports this distinction also. |
1402 return !m->is_abstract(); | |
1403 } | |
1404 | |
1405 | |
1406 bool Dependencies::has_finalizable_subclass(ciInstanceKlass* k) { | |
1407 return k->has_finalizable_subclass(); | |
1408 } | |
1409 | |
1410 | |
1411 // Any use of the contents (bytecodes) of a method must be | |
1412 // marked by an "evol_method" dependency, if those contents | |
1413 // can change. (Note: A method is always dependent on itself.) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1414 Klass* Dependencies::check_evol_method(Method* m) { |
0 | 1415 assert(must_be_in_vm(), "raw oops here"); |
1416 // Did somebody do a JVMTI RedefineClasses while our backs were turned? | |
1417 // Or is there a now a breakpoint? | |
1418 // (Assumes compiled code cannot handle bkpts; change if UseFastBreakpoints.) | |
1419 if (m->is_old() | |
1420 || m->number_of_breakpoints() > 0) { | |
1421 return m->method_holder(); | |
1422 } else { | |
1423 return NULL; | |
1424 } | |
1425 } | |
1426 | |
1427 // This is a strong assertion: It is that the given type | |
1428 // has no subtypes whatever. It is most useful for | |
1429 // optimizing checks on reflected types or on array types. | |
1430 // (Checks on types which are derived from real instances | |
1431 // can be optimized more strongly than this, because we | |
1432 // know that the checked type comes from a concrete type, | |
1433 // and therefore we can disregard abstract types.) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1434 Klass* Dependencies::check_leaf_type(Klass* ctxk) { |
0 | 1435 assert(must_be_in_vm(), "raw oops here"); |
1436 assert_locked_or_safepoint(Compile_lock); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1437 InstanceKlass* ctx = InstanceKlass::cast(ctxk); |
0 | 1438 Klass* sub = ctx->subklass(); |
1439 if (sub != NULL) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1440 return sub; |
0 | 1441 } else if (ctx->nof_implementors() != 0) { |
1442 // if it is an interface, it must be unimplemented | |
1443 // (if it is not an interface, nof_implementors is always zero) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1444 Klass* impl = ctx->implementor(); |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1445 assert(impl != NULL, "must be set"); |
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
4772
diff
changeset
|
1446 return impl; |
0 | 1447 } else { |
1448 return NULL; | |
1449 } | |
1450 } | |
1451 | |
1452 // Test the assertion that conck is the only concrete subtype* of ctxk. | |
1453 // The type conck itself is allowed to have have further concrete subtypes. | |
1454 // This allows the compiler to narrow occurrences of ctxk by conck, | |
1455 // when dealing with the types of actual instances. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1456 Klass* Dependencies::check_abstract_with_unique_concrete_subtype(Klass* ctxk, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1457 Klass* conck, |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1458 KlassDepChange* changes) { |
0 | 1459 ClassHierarchyWalker wf(conck); |
1460 return wf.find_witness_subtype(ctxk, changes); | |
1461 } | |
1462 | |
1463 // If a non-concrete class has no concrete subtypes, it is not (yet) | |
1464 // instantiatable. This can allow the compiler to make some paths go | |
1465 // dead, if they are gated by a test of the type. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1466 Klass* Dependencies::check_abstract_with_no_concrete_subtype(Klass* ctxk, |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1467 KlassDepChange* changes) { |
0 | 1468 // Find any concrete subtype, with no participants: |
1469 ClassHierarchyWalker wf; | |
1470 return wf.find_witness_subtype(ctxk, changes); | |
1471 } | |
1472 | |
1473 | |
1474 // If a concrete class has no concrete subtypes, it can always be | |
1475 // exactly typed. This allows the use of a cheaper type test. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1476 Klass* Dependencies::check_concrete_with_no_concrete_subtype(Klass* ctxk, |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1477 KlassDepChange* changes) { |
0 | 1478 // Find any concrete subtype, with only the ctxk as participant: |
1479 ClassHierarchyWalker wf(ctxk); | |
1480 return wf.find_witness_subtype(ctxk, changes); | |
1481 } | |
1482 | |
1483 | |
1484 // Find the unique concrete proper subtype of ctxk, or NULL if there | |
1485 // is more than one concrete proper subtype. If there are no concrete | |
1486 // proper subtypes, return ctxk itself, whether it is concrete or not. | |
1487 // The returned subtype is allowed to have have further concrete subtypes. | |
1488 // That is, return CC1 for CX > CC1 > CC2, but NULL for CX > { CC1, CC2 }. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1489 Klass* Dependencies::find_unique_concrete_subtype(Klass* ctxk) { |
0 | 1490 ClassHierarchyWalker wf(ctxk); // Ignore ctxk when walking. |
1491 wf.record_witnesses(1); // Record one other witness when walking. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1492 Klass* wit = wf.find_witness_subtype(ctxk); |
0 | 1493 if (wit != NULL) return NULL; // Too many witnesses. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1494 Klass* conck = wf.participant(0); |
0 | 1495 if (conck == NULL) { |
1496 #ifndef PRODUCT | |
1497 // Make sure the dependency mechanism will pass this discovery: | |
1498 if (VerifyDependencies) { | |
1499 // Turn off dependency tracing while actually testing deps. | |
1500 FlagSetting fs(TraceDependencies, false); | |
1501 if (!Dependencies::is_concrete_klass(ctxk)) { | |
1502 guarantee(NULL == | |
1503 (void *)check_abstract_with_no_concrete_subtype(ctxk), | |
1504 "verify dep."); | |
1505 } else { | |
1506 guarantee(NULL == | |
1507 (void *)check_concrete_with_no_concrete_subtype(ctxk), | |
1508 "verify dep."); | |
1509 } | |
1510 } | |
1511 #endif //PRODUCT | |
1512 return ctxk; // Return ctxk as a flag for "no subtypes". | |
1513 } else { | |
1514 #ifndef PRODUCT | |
1515 // Make sure the dependency mechanism will pass this discovery: | |
1516 if (VerifyDependencies) { | |
1517 // Turn off dependency tracing while actually testing deps. | |
1518 FlagSetting fs(TraceDependencies, false); | |
1519 if (!Dependencies::is_concrete_klass(ctxk)) { | |
1520 guarantee(NULL == (void *) | |
1521 check_abstract_with_unique_concrete_subtype(ctxk, conck), | |
1522 "verify dep."); | |
1523 } | |
1524 } | |
1525 #endif //PRODUCT | |
1526 return conck; | |
1527 } | |
1528 } | |
1529 | |
1530 // Test the assertion that the k[12] are the only concrete subtypes of ctxk, | |
1531 // except possibly for further subtypes of k[12] themselves. | |
1532 // The context type must be abstract. The types k1 and k2 are themselves | |
1533 // allowed to have further concrete subtypes. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1534 Klass* Dependencies::check_abstract_with_exclusive_concrete_subtypes( |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1535 Klass* ctxk, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1536 Klass* k1, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1537 Klass* k2, |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1538 KlassDepChange* changes) { |
0 | 1539 ClassHierarchyWalker wf; |
1540 wf.add_participant(k1); | |
1541 wf.add_participant(k2); | |
1542 return wf.find_witness_subtype(ctxk, changes); | |
1543 } | |
1544 | |
1545 // Search ctxk for concrete implementations. If there are klen or fewer, | |
1546 // pack them into the given array and return the number. | |
1547 // Otherwise, return -1, meaning the given array would overflow. | |
1548 // (Note that a return of 0 means there are exactly no concrete subtypes.) | |
1549 // In this search, if ctxk is concrete, it will be reported alone. | |
1550 // For any type CC reported, no proper subtypes of CC will be reported. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1551 int Dependencies::find_exclusive_concrete_subtypes(Klass* ctxk, |
0 | 1552 int klen, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1553 Klass* karray[]) { |
0 | 1554 ClassHierarchyWalker wf; |
1555 wf.record_witnesses(klen); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1556 Klass* wit = wf.find_witness_subtype(ctxk); |
0 | 1557 if (wit != NULL) return -1; // Too many witnesses. |
1558 int num = wf.num_participants(); | |
1559 assert(num <= klen, "oob"); | |
1560 // Pack the result array with the good news. | |
1561 for (int i = 0; i < num; i++) | |
1562 karray[i] = wf.participant(i); | |
1563 #ifndef PRODUCT | |
1564 // Make sure the dependency mechanism will pass this discovery: | |
1565 if (VerifyDependencies) { | |
1566 // Turn off dependency tracing while actually testing deps. | |
1567 FlagSetting fs(TraceDependencies, false); | |
1568 switch (Dependencies::is_concrete_klass(ctxk)? -1: num) { | |
1569 case -1: // ctxk was itself concrete | |
1570 guarantee(num == 1 && karray[0] == ctxk, "verify dep."); | |
1571 break; | |
1572 case 0: | |
1573 guarantee(NULL == (void *)check_abstract_with_no_concrete_subtype(ctxk), | |
1574 "verify dep."); | |
1575 break; | |
1576 case 1: | |
1577 guarantee(NULL == (void *) | |
1578 check_abstract_with_unique_concrete_subtype(ctxk, karray[0]), | |
1579 "verify dep."); | |
1580 break; | |
1581 case 2: | |
1582 guarantee(NULL == (void *) | |
1583 check_abstract_with_exclusive_concrete_subtypes(ctxk, | |
1584 karray[0], | |
1585 karray[1]), | |
1586 "verify dep."); | |
1587 break; | |
1588 default: | |
1589 ShouldNotReachHere(); // klen > 2 yet supported | |
1590 } | |
1591 } | |
1592 #endif //PRODUCT | |
1593 return num; | |
1594 } | |
1595 | |
1596 // If a class (or interface) has a unique concrete method uniqm, return NULL. | |
1597 // Otherwise, return a class that contains an interfering method. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1598 Klass* Dependencies::check_unique_concrete_method(Klass* ctxk, Method* uniqm, |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1599 KlassDepChange* changes) { |
0 | 1600 // Here is a missing optimization: If uniqm->is_final(), |
1601 // we don't really need to search beneath it for overrides. | |
1602 // This is probably not important, since we don't use dependencies | |
1603 // to track final methods. (They can't be "definalized".) | |
1604 ClassHierarchyWalker wf(uniqm->method_holder(), uniqm); | |
1605 return wf.find_witness_definer(ctxk, changes); | |
1606 } | |
1607 | |
1608 // Find the set of all non-abstract methods under ctxk that match m. | |
1609 // (The method m must be defined or inherited in ctxk.) | |
1610 // Include m itself in the set, unless it is abstract. | |
1611 // If this set has exactly one element, return that element. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1612 Method* Dependencies::find_unique_concrete_method(Klass* ctxk, Method* m) { |
0 | 1613 ClassHierarchyWalker wf(m); |
1614 assert(wf.check_method_context(ctxk, m), "proper context"); | |
1615 wf.record_witnesses(1); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1616 Klass* wit = wf.find_witness_definer(ctxk); |
0 | 1617 if (wit != NULL) return NULL; // Too many witnesses. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1618 Method* fm = wf.found_method(0); // Will be NULL if num_parts == 0. |
0 | 1619 if (Dependencies::is_concrete_method(m)) { |
1620 if (fm == NULL) { | |
1621 // It turns out that m was always the only implementation. | |
1622 fm = m; | |
1623 } else if (fm != m) { | |
1624 // Two conflicting implementations after all. | |
1625 // (This can happen if m is inherited into ctxk and fm overrides it.) | |
1626 return NULL; | |
1627 } | |
1628 } | |
1629 #ifndef PRODUCT | |
1630 // Make sure the dependency mechanism will pass this discovery: | |
1631 if (VerifyDependencies && fm != NULL) { | |
1632 guarantee(NULL == (void *)check_unique_concrete_method(ctxk, fm), | |
1633 "verify dep."); | |
1634 } | |
1635 #endif //PRODUCT | |
1636 return fm; | |
1637 } | |
1638 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1639 Klass* Dependencies::check_exclusive_concrete_methods(Klass* ctxk, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1640 Method* m1, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1641 Method* m2, |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1642 KlassDepChange* changes) { |
0 | 1643 ClassHierarchyWalker wf(m1); |
1644 wf.add_participant(m1->method_holder()); | |
1645 wf.add_participant(m2->method_holder()); | |
1646 return wf.find_witness_definer(ctxk, changes); | |
1647 } | |
1648 | |
1649 // Find the set of all non-abstract methods under ctxk that match m[0]. | |
1650 // (The method m[0] must be defined or inherited in ctxk.) | |
1651 // Include m itself in the set, unless it is abstract. | |
1652 // Fill the given array m[0..(mlen-1)] with this set, and return the length. | |
1653 // (The length may be zero if no concrete methods are found anywhere.) | |
1654 // If there are too many concrete methods to fit in marray, return -1. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1655 int Dependencies::find_exclusive_concrete_methods(Klass* ctxk, |
0 | 1656 int mlen, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1657 Method* marray[]) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1658 Method* m0 = marray[0]; |
0 | 1659 ClassHierarchyWalker wf(m0); |
1660 assert(wf.check_method_context(ctxk, m0), "proper context"); | |
1661 wf.record_witnesses(mlen); | |
1662 bool participants_hide_witnesses = true; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1663 Klass* wit = wf.find_witness_definer(ctxk); |
0 | 1664 if (wit != NULL) return -1; // Too many witnesses. |
1665 int num = wf.num_participants(); | |
1666 assert(num <= mlen, "oob"); | |
1667 // Keep track of whether m is also part of the result set. | |
1668 int mfill = 0; | |
1669 assert(marray[mfill] == m0, "sanity"); | |
1670 if (Dependencies::is_concrete_method(m0)) | |
1671 mfill++; // keep m0 as marray[0], the first result | |
1672 for (int i = 0; i < num; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1673 Method* fm = wf.found_method(i); |
0 | 1674 if (fm == m0) continue; // Already put this guy in the list. |
1675 if (mfill == mlen) { | |
1676 return -1; // Oops. Too many methods after all! | |
1677 } | |
1678 marray[mfill++] = fm; | |
1679 } | |
1680 #ifndef PRODUCT | |
1681 // Make sure the dependency mechanism will pass this discovery: | |
1682 if (VerifyDependencies) { | |
1683 // Turn off dependency tracing while actually testing deps. | |
1684 FlagSetting fs(TraceDependencies, false); | |
1685 switch (mfill) { | |
1686 case 1: | |
1687 guarantee(NULL == (void *)check_unique_concrete_method(ctxk, marray[0]), | |
1688 "verify dep."); | |
1689 break; | |
1690 case 2: | |
1691 guarantee(NULL == (void *) | |
1692 check_exclusive_concrete_methods(ctxk, marray[0], marray[1]), | |
1693 "verify dep."); | |
1694 break; | |
1695 default: | |
1696 ShouldNotReachHere(); // mlen > 2 yet supported | |
1697 } | |
1698 } | |
1699 #endif //PRODUCT | |
1700 return mfill; | |
1701 } | |
1702 | |
1703 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1704 Klass* Dependencies::check_has_no_finalizable_subclasses(Klass* ctxk, KlassDepChange* changes) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1705 Klass* search_at = ctxk; |
0 | 1706 if (changes != NULL) |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1707 search_at = changes->new_type(); // just look at the new bit |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1708 return find_finalizable_subclass(search_at); |
0 | 1709 } |
1710 | |
1711 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1712 Klass* Dependencies::check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes) { |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1713 assert(call_site ->is_a(SystemDictionary::CallSite_klass()), "sanity"); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1714 assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "sanity"); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1715 if (changes == NULL) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1716 // Validate all CallSites |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1717 if (java_lang_invoke_CallSite::target(call_site) != method_handle) |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
1718 return call_site->klass(); // assertion failed |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1719 } else { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1720 // Validate the given CallSite |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1721 if (call_site == changes->call_site() && java_lang_invoke_CallSite::target(call_site) != changes->method_handle()) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1722 assert(method_handle != changes->method_handle(), "must be"); |
3894
b27c72d69fd1
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
3852
diff
changeset
|
1723 return call_site->klass(); // assertion failed |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1724 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1725 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1726 return NULL; // assertion still valid |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1727 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1728 |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1729 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1730 void Dependencies::DepStream::trace_and_log_witness(Klass* witness) { |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1731 if (witness != NULL) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1732 if (TraceDependencies) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1733 print_dependency(witness, /*verbose=*/ true); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1734 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1735 // The following is a no-op unless logging is enabled: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1736 log_dependency(witness); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1737 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1738 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1739 |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1740 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1741 Klass* Dependencies::DepStream::check_klass_dependency(KlassDepChange* changes) { |
0 | 1742 assert_locked_or_safepoint(Compile_lock); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1743 Dependencies::check_valid_dependency_type(type()); |
0 | 1744 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1745 Klass* witness = NULL; |
0 | 1746 switch (type()) { |
1747 case evol_method: | |
1748 witness = check_evol_method(method_argument(0)); | |
1749 break; | |
1750 case leaf_type: | |
1751 witness = check_leaf_type(context_type()); | |
1752 break; | |
1753 case abstract_with_unique_concrete_subtype: | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1754 witness = check_abstract_with_unique_concrete_subtype(context_type(), type_argument(1), changes); |
0 | 1755 break; |
1756 case abstract_with_no_concrete_subtype: | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1757 witness = check_abstract_with_no_concrete_subtype(context_type(), changes); |
0 | 1758 break; |
1759 case concrete_with_no_concrete_subtype: | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1760 witness = check_concrete_with_no_concrete_subtype(context_type(), changes); |
0 | 1761 break; |
1762 case unique_concrete_method: | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1763 witness = check_unique_concrete_method(context_type(), method_argument(1), changes); |
0 | 1764 break; |
1765 case abstract_with_exclusive_concrete_subtypes_2: | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1766 witness = check_abstract_with_exclusive_concrete_subtypes(context_type(), type_argument(1), type_argument(2), changes); |
0 | 1767 break; |
1768 case exclusive_concrete_methods_2: | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1769 witness = check_exclusive_concrete_methods(context_type(), method_argument(1), method_argument(2), changes); |
0 | 1770 break; |
1771 case no_finalizable_subclasses: | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1772 witness = check_has_no_finalizable_subclasses(context_type(), changes); |
0 | 1773 break; |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1774 default: |
0 | 1775 witness = NULL; |
1776 break; | |
1777 } | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1778 trace_and_log_witness(witness); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1779 return witness; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1780 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1781 |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1782 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1783 Klass* Dependencies::DepStream::check_call_site_dependency(CallSiteDepChange* changes) { |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1784 assert_locked_or_safepoint(Compile_lock); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1785 Dependencies::check_valid_dependency_type(type()); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1786 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1787 Klass* witness = NULL; |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1788 switch (type()) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1789 case call_site_target_value: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1790 witness = check_call_site_target_value(argument_oop(0), argument_oop(1), changes); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1791 break; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1792 default: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1793 witness = NULL; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1794 break; |
0 | 1795 } |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1796 trace_and_log_witness(witness); |
0 | 1797 return witness; |
1798 } | |
1799 | |
1800 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1801 Klass* Dependencies::DepStream::spot_check_dependency_at(DepChange& changes) { |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1802 // Handle klass dependency |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1803 if (changes.is_klass_change() && changes.as_klass_change()->involves_context(context_type())) |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1804 return check_klass_dependency(changes.as_klass_change()); |
0 | 1805 |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1806 // Handle CallSite dependency |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1807 if (changes.is_call_site_change()) |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1808 return check_call_site_dependency(changes.as_call_site_change()); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1809 |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1810 // irrelevant dependency; skip it |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1811 return NULL; |
0 | 1812 } |
1813 | |
1814 | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1815 void DepChange::print() { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1816 int nsup = 0, nint = 0; |
0 | 1817 for (ContextStream str(*this); str.next(); ) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1818 Klass* k = str.klass(); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1819 switch (str.change_type()) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1820 case Change_new_type: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1821 tty->print_cr(" dependee = %s", InstanceKlass::cast(k)->external_name()); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1822 break; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1823 case Change_new_sub: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1824 if (!WizardMode) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1825 ++nsup; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1826 } else { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1827 tty->print_cr(" context super = %s", InstanceKlass::cast(k)->external_name()); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1828 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1829 break; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1830 case Change_new_impl: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1831 if (!WizardMode) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1832 ++nint; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1833 } else { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1834 tty->print_cr(" context interface = %s", InstanceKlass::cast(k)->external_name()); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1835 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1836 break; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1837 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1838 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1839 if (nsup + nint != 0) { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1840 tty->print_cr(" context supers = %d, interfaces = %d", nsup, nint); |
0 | 1841 } |
1842 } | |
1843 | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1844 void DepChange::ContextStream::start() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1845 Klass* new_type = _changes.is_klass_change() ? _changes.as_klass_change()->new_type() : (Klass*) NULL; |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1846 _change_type = (new_type == NULL ? NO_CHANGE : Start_Klass); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1847 _klass = new_type; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1848 _ti_base = NULL; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1849 _ti_index = 0; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1850 _ti_limit = 0; |
0 | 1851 } |
1852 | |
1853 bool DepChange::ContextStream::next() { | |
1854 switch (_change_type) { | |
1855 case Start_Klass: // initial state; _klass is the new type | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1856 _ti_base = InstanceKlass::cast(_klass)->transitive_interfaces(); |
0 | 1857 _ti_index = 0; |
1858 _change_type = Change_new_type; | |
1859 return true; | |
1860 case Change_new_type: | |
1861 // fall through: | |
1862 _change_type = Change_new_sub; | |
1863 case Change_new_sub: | |
54
d4a0f561287a
6598190: JPRT tests fail when run with -XX:+CheckUnhandledOops
sbohne
parents:
0
diff
changeset
|
1864 // 6598190: brackets workaround Sun Studio C++ compiler bug 6629277 |
d4a0f561287a
6598190: JPRT tests fail when run with -XX:+CheckUnhandledOops
sbohne
parents:
0
diff
changeset
|
1865 { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1866 _klass = InstanceKlass::cast(_klass)->super(); |
54
d4a0f561287a
6598190: JPRT tests fail when run with -XX:+CheckUnhandledOops
sbohne
parents:
0
diff
changeset
|
1867 if (_klass != NULL) { |
d4a0f561287a
6598190: JPRT tests fail when run with -XX:+CheckUnhandledOops
sbohne
parents:
0
diff
changeset
|
1868 return true; |
d4a0f561287a
6598190: JPRT tests fail when run with -XX:+CheckUnhandledOops
sbohne
parents:
0
diff
changeset
|
1869 } |
0 | 1870 } |
1871 // else set up _ti_limit and fall through: | |
1872 _ti_limit = (_ti_base == NULL) ? 0 : _ti_base->length(); | |
1873 _change_type = Change_new_impl; | |
1874 case Change_new_impl: | |
1875 if (_ti_index < _ti_limit) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1876 _klass = _ti_base->at(_ti_index++); |
0 | 1877 return true; |
1878 } | |
1879 // fall through: | |
1880 _change_type = NO_CHANGE; // iterator is exhausted | |
1881 case NO_CHANGE: | |
1882 break; | |
1883 default: | |
1884 ShouldNotReachHere(); | |
1885 } | |
1886 return false; | |
1887 } | |
1888 | |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1889 void KlassDepChange::initialize() { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1890 // entire transaction must be under this lock: |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1891 assert_lock_strong(Compile_lock); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1892 |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1893 // Mark all dependee and all its superclasses |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1894 // Mark transitive interfaces |
0 | 1895 for (ContextStream str(*this); str.next(); ) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1896 Klass* d = str.klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1897 assert(!InstanceKlass::cast(d)->is_marked_dependent(), "checking"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1898 InstanceKlass::cast(d)->set_is_marked_dependent(true); |
0 | 1899 } |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1900 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1901 |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1902 KlassDepChange::~KlassDepChange() { |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1903 // Unmark all dependee and all its superclasses |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1904 // Unmark transitive interfaces |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1905 for (ContextStream str(*this); str.next(); ) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1906 Klass* d = str.klass(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1907 InstanceKlass::cast(d)->set_is_marked_dependent(false); |
0 | 1908 } |
1909 } | |
1910 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1911 bool KlassDepChange::involves_context(Klass* k) { |
6983 | 1912 if (k == NULL || !k->oop_is_instance()) { |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1913 return false; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1914 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5998
diff
changeset
|
1915 InstanceKlass* ik = InstanceKlass::cast(k); |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1916 bool is_contained = ik->is_marked_dependent(); |
6983 | 1917 assert(is_contained == new_type()->is_subtype_of(k), |
3852
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1918 "correct marking of potential context types"); |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1919 return is_contained; |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1920 } |
fdb992d83a87
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
2426
diff
changeset
|
1921 |
0 | 1922 #ifndef PRODUCT |
1923 void Dependencies::print_statistics() { | |
1924 if (deps_find_witness_print != 0) { | |
1925 // Call one final time, to flush out the data. | |
1926 deps_find_witness_print = -1; | |
1927 count_find_witness_calls(); | |
1928 } | |
1929 } | |
1930 #endif |