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