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