annotate src/share/vm/code/dependencies.hpp @ 3018:5857923e563c

Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Sat, 18 Jun 2011 19:13:55 +0200
parents f95d63e2154a
children fdb992d83a87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1123
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1123
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: 1123
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_CODE_DEPENDENCIES_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CODE_DEPENDENCIES_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "ci/ciKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "code/compressedStream.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "code/nmethod.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "utilities/growableArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 //** Dependencies represent assertions (approximate invariants) within
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // the class hierarchy. An example is an assertion that a given
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // method is not overridden; another example is that a type has only
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // one concrete subtype. Compiled code which relies on such
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // assertions must be discarded if they are overturned by changes in
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // the class hierarchy. We can think of these assertions as
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // approximate invariants, because we expect them to be overturned
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // very infrequently. We are willing to perform expensive recovery
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // operations when they are overturned. The benefit, of course, is
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // performing optimistic optimizations (!) on the object code.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 //
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Changes in the class hierarchy due to dynamic linking or
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // class evolution can violate dependencies. There is enough
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // indexing between classes and nmethods to make dependency
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // checking reasonably efficient.
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class ciEnv;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 class nmethod;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 class OopRecorder;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 class xmlStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 class CompileLog;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 class DepChange;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 class No_Safepoint_Verifier;
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 class Dependencies: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Note: In the comments on dependency types, most uses of the terms
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // subtype and supertype are used in a "non-strict" or "inclusive"
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // sense, and are starred to remind the reader of this fact.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Strict uses of the terms use the word "proper".
a61af66fc99e Initial load
duke
parents:
diff changeset
63 //
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Specifically, every class is its own subtype* and supertype*.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // (This trick is easier than continually saying things like "Y is a
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // subtype of X or X itself".)
a61af66fc99e Initial load
duke
parents:
diff changeset
67 //
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Sometimes we write X > Y to mean X is a proper supertype of Y.
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // The notation X > {Y, Z} means X has proper subtypes Y, Z.
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // The notation X.m > Y means that Y inherits m from X, while
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // X.m > Y.m means Y overrides X.m. A star denotes abstractness,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // as *I > A, meaning (abstract) interface I is a super type of A,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // or A.*m > B.m, meaning B.m implements abstract method A.m.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 //
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // In this module, the terms "subtype" and "supertype" refer to
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Java-level reference type conversions, as detected by
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // "instanceof" and performed by "checkcast" operations. The method
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Klass::is_subtype_of tests these relations. Note that "subtype"
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // is richer than "subclass" (as tested by Klass::is_subclass_of),
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // since it takes account of relations involving interface and array
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // types.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 //
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // To avoid needless complexity, dependencies involving array types
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // are not accepted. If you need to make an assertion about an
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // array type, make the assertion about its corresponding element
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // types. Any assertion that might change about an array type can
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // be converted to an assertion about its element type.
a61af66fc99e Initial load
duke
parents:
diff changeset
88 //
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Most dependencies are evaluated over a "context type" CX, which
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // stands for the set Subtypes(CX) of every Java type that is a subtype*
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // of CX. When the system loads a new class or interface N, it is
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // responsible for re-evaluating changed dependencies whose context
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // type now includes N, that is, all super types of N.
a61af66fc99e Initial load
duke
parents:
diff changeset
94 //
a61af66fc99e Initial load
duke
parents:
diff changeset
95 enum DepType {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 end_marker = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // An 'evol' dependency simply notes that the contents of the
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // method were used. If it evolves (is replaced), the nmethod
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // must be recompiled. No other dependencies are implied.
a61af66fc99e Initial load
duke
parents:
diff changeset
101 evol_method,
a61af66fc99e Initial load
duke
parents:
diff changeset
102 FIRST_TYPE = evol_method,
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // A context type CX is a leaf it if has no proper subtype.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 leaf_type,
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // An abstract class CX has exactly one concrete subtype CC.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 abstract_with_unique_concrete_subtype,
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // The type CX is purely abstract, with no concrete subtype* at all.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 abstract_with_no_concrete_subtype,
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // The concrete CX is free of concrete proper subtypes.
a61af66fc99e Initial load
duke
parents:
diff changeset
114 concrete_with_no_concrete_subtype,
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Given a method M1 and a context class CX, the set MM(CX, M1) of
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // "concrete matching methods" in CX of M1 is the set of every
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // concrete M2 for which it is possible to create an invokevirtual
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // or invokeinterface call site that can reach either M1 or M2.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // That is, M1 and M2 share a name, signature, and vtable index.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // We wish to notice when the set MM(CX, M1) is just {M1}, or
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // perhaps a set of two {M1,M2}, and issue dependencies on this.
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // The set MM(CX, M1) can be computed by starting with any matching
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // concrete M2 that is inherited into CX, and then walking the
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // subtypes* of CX looking for concrete definitions.
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // The parameters to this dependency are the method M1 and the
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // context class CX. M1 must be either inherited in CX or defined
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // in a subtype* of CX. It asserts that MM(CX, M1) is no greater
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // than {M1}.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 unique_concrete_method, // one unique concrete method under CX
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // An "exclusive" assertion concerns two methods or subtypes, and
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // declares that there are at most two (or perhaps later N>2)
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // specific items that jointly satisfy the restriction.
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // We list all items explicitly rather than just giving their
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // count, for robustness in the face of complex schema changes.
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // A context class CX (which may be either abstract or concrete)
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // has two exclusive concrete subtypes* C1, C2 if every concrete
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // subtype* of CX is either C1 or C2. Note that if neither C1 or C2
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // are equal to CX, then CX itself must be abstract. But it is
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // also possible (for example) that C1 is CX (a concrete class)
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // and C2 is a proper subtype of C1.
a61af66fc99e Initial load
duke
parents:
diff changeset
146 abstract_with_exclusive_concrete_subtypes_2,
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // This dependency asserts that MM(CX, M1) is no greater than {M1,M2}.
a61af66fc99e Initial load
duke
parents:
diff changeset
149 exclusive_concrete_methods_2,
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // This dependency asserts that no instances of class or it's
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // subclasses require finalization registration.
a61af66fc99e Initial load
duke
parents:
diff changeset
153 no_finalizable_subclasses,
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 TYPE_LIMIT
a61af66fc99e Initial load
duke
parents:
diff changeset
156 };
a61af66fc99e Initial load
duke
parents:
diff changeset
157 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 LG2_TYPE_LIMIT = 4, // assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT))
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // handy categorizations of dependency types:
a61af66fc99e Initial load
duke
parents:
diff changeset
161 all_types = ((1<<TYPE_LIMIT)-1) & ((-1)<<FIRST_TYPE),
a61af66fc99e Initial load
duke
parents:
diff changeset
162 non_ctxk_types = (1<<evol_method),
a61af66fc99e Initial load
duke
parents:
diff changeset
163 ctxk_types = all_types & ~non_ctxk_types,
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 max_arg_count = 3, // current maximum number of arguments (incl. ctxk)
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // A "context type" is a class or interface that
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // provides context for evaluating a dependency.
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // When present, it is one of the arguments (dep_context_arg).
a61af66fc99e Initial load
duke
parents:
diff changeset
170 //
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // If a dependency does not have a context type, there is a
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // default context, depending on the type of the dependency.
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // This bit signals that a default context has been compressed away.
a61af66fc99e Initial load
duke
parents:
diff changeset
174 default_context_type_bit = (1<<LG2_TYPE_LIMIT)
a61af66fc99e Initial load
duke
parents:
diff changeset
175 };
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 static const char* dep_name(DepType dept);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 static int dep_args(DepType dept);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 static int dep_context_arg(DepType dept) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 return dept_in_mask(dept, ctxk_types)? 0: -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // State for writing a new set of dependencies:
a61af66fc99e Initial load
duke
parents:
diff changeset
185 GrowableArray<int>* _dep_seen; // (seen[h->ident] & (1<<dept))
a61af66fc99e Initial load
duke
parents:
diff changeset
186 GrowableArray<ciObject*>* _deps[TYPE_LIMIT];
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 static const char* _dep_name[TYPE_LIMIT];
a61af66fc99e Initial load
duke
parents:
diff changeset
189 static int _dep_args[TYPE_LIMIT];
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 static bool dept_in_mask(DepType dept, int mask) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return (int)dept >= 0 && dept < TYPE_LIMIT && ((1<<dept) & mask) != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 bool note_dep_seen(int dept, ciObject* x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 assert(dept < BitsPerInt, "oob");
a61af66fc99e Initial load
duke
parents:
diff changeset
197 int x_id = x->ident();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 assert(_dep_seen != NULL, "deps must be writable");
a61af66fc99e Initial load
duke
parents:
diff changeset
199 int seen = _dep_seen->at_grow(x_id, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 _dep_seen->at_put(x_id, seen | (1<<dept));
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // return true if we've already seen dept/x
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return (seen & (1<<dept)) != 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 bool maybe_merge_ctxk(GrowableArray<ciObject*>* deps,
a61af66fc99e Initial load
duke
parents:
diff changeset
206 int ctxk_i, ciKlass* ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 void sort_all_deps();
a61af66fc99e Initial load
duke
parents:
diff changeset
209 size_t estimate_size_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // Initialize _deps, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
212 void initialize(ciEnv* env);
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // State for making a new set of dependencies:
a61af66fc99e Initial load
duke
parents:
diff changeset
215 OopRecorder* _oop_recorder;
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // Logging support
a61af66fc99e Initial load
duke
parents:
diff changeset
218 CompileLog* _log;
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 address _content_bytes; // everything but the oop references, encoded
a61af66fc99e Initial load
duke
parents:
diff changeset
221 size_t _size_in_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Make a new empty dependencies set.
a61af66fc99e Initial load
duke
parents:
diff changeset
225 Dependencies(ciEnv* env) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 initialize(env);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Check for a valid context type.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Enforce the restriction against array types.
a61af66fc99e Initial load
duke
parents:
diff changeset
232 static void check_ctxk(ciKlass* ctxk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 assert(ctxk->is_instance_klass(), "java types only");
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 static void check_ctxk_concrete(ciKlass* ctxk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 assert(is_concrete_klass(ctxk->as_instance_klass()), "must be concrete");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 static void check_ctxk_abstract(ciKlass* ctxk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 check_ctxk(ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 assert(!is_concrete_klass(ctxk->as_instance_klass()), "must be abstract");
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 void assert_common_1(DepType dept, ciObject* x);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 void assert_common_2(DepType dept, ciKlass* ctxk, ciObject* x);
a61af66fc99e Initial load
duke
parents:
diff changeset
245 void assert_common_3(DepType dept, ciKlass* ctxk, ciObject* x, ciObject* x2);
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // Adding assertions to a new dependency set at compile time:
a61af66fc99e Initial load
duke
parents:
diff changeset
249 void assert_evol_method(ciMethod* m);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 void assert_leaf_type(ciKlass* ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 void assert_abstract_with_unique_concrete_subtype(ciKlass* ctxk, ciKlass* conck);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 void assert_abstract_with_no_concrete_subtype(ciKlass* ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 void assert_concrete_with_no_concrete_subtype(ciKlass* ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 void assert_unique_concrete_method(ciKlass* ctxk, ciMethod* uniqm);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 void assert_abstract_with_exclusive_concrete_subtypes(ciKlass* ctxk, ciKlass* k1, ciKlass* k2);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 void assert_exclusive_concrete_methods(ciKlass* ctxk, ciMethod* m1, ciMethod* m2);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 void assert_has_no_finalizable_subclasses(ciKlass* ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Define whether a given method or type is concrete.
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // These methods define the term "concrete" as used in this module.
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // For this module, an "abstract" class is one which is non-concrete.
a61af66fc99e Initial load
duke
parents:
diff changeset
262 //
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Future optimizations may allow some classes to remain
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // non-concrete until their first instantiation, and allow some
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // methods to remain non-concrete until their first invocation.
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // In that case, there would be a middle ground between concrete
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // and abstract (as defined by the Java language and VM).
a61af66fc99e Initial load
duke
parents:
diff changeset
268 static bool is_concrete_klass(klassOop k); // k is instantiable
a61af66fc99e Initial load
duke
parents:
diff changeset
269 static bool is_concrete_method(methodOop m); // m is invocable
a61af66fc99e Initial load
duke
parents:
diff changeset
270 static Klass* find_finalizable_subclass(Klass* k);
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // These versions of the concreteness queries work through the CI.
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // The CI versions are allowed to skew sometimes from the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // (oop-based) versions. The cost of such a difference is a
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // (safely) aborted compilation, or a deoptimization, or a missed
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // optimization opportunity.
a61af66fc99e Initial load
duke
parents:
diff changeset
277 //
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // In order to prevent spurious assertions, query results must
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // remain stable within any single ciEnv instance. (I.e., they must
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // not go back into the VM to get their value; they must cache the
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // bit in the CI, either eagerly or lazily.)
a61af66fc99e Initial load
duke
parents:
diff changeset
282 static bool is_concrete_klass(ciInstanceKlass* k); // k appears instantiable
a61af66fc99e Initial load
duke
parents:
diff changeset
283 static bool is_concrete_method(ciMethod* m); // m appears invocable
a61af66fc99e Initial load
duke
parents:
diff changeset
284 static bool has_finalizable_subclass(ciInstanceKlass* k);
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // As a general rule, it is OK to compile under the assumption that
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // a given type or method is concrete, even if it at some future
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // point becomes abstract. So dependency checking is one-sided, in
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // that it permits supposedly concrete classes or methods to turn up
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // as really abstract. (This shouldn't happen, except during class
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // evolution, but that's the logic of the checking.) However, if a
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // supposedly abstract class or method suddenly becomes concrete, a
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // dependency on it must fail.
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // Checking old assertions at run-time (in the VM only):
a61af66fc99e Initial load
duke
parents:
diff changeset
296 static klassOop check_evol_method(methodOop m);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 static klassOop check_leaf_type(klassOop ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 static klassOop check_abstract_with_unique_concrete_subtype(klassOop ctxk, klassOop conck,
a61af66fc99e Initial load
duke
parents:
diff changeset
299 DepChange* changes = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 static klassOop check_abstract_with_no_concrete_subtype(klassOop ctxk,
a61af66fc99e Initial load
duke
parents:
diff changeset
301 DepChange* changes = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 static klassOop check_concrete_with_no_concrete_subtype(klassOop ctxk,
a61af66fc99e Initial load
duke
parents:
diff changeset
303 DepChange* changes = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 static klassOop check_unique_concrete_method(klassOop ctxk, methodOop uniqm,
a61af66fc99e Initial load
duke
parents:
diff changeset
305 DepChange* changes = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 static klassOop check_abstract_with_exclusive_concrete_subtypes(klassOop ctxk, klassOop k1, klassOop k2,
a61af66fc99e Initial load
duke
parents:
diff changeset
307 DepChange* changes = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 static klassOop check_exclusive_concrete_methods(klassOop ctxk, methodOop m1, methodOop m2,
a61af66fc99e Initial load
duke
parents:
diff changeset
309 DepChange* changes = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 static klassOop check_has_no_finalizable_subclasses(klassOop ctxk,
a61af66fc99e Initial load
duke
parents:
diff changeset
311 DepChange* changes = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // A returned klassOop is NULL if the dependency assertion is still
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // valid. A non-NULL klassOop is a 'witness' to the assertion
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // failure, a point in the class hierarchy where the assertion has
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // been proven false. For example, if check_leaf_type returns
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // non-NULL, the value is a subtype of the supposed leaf type. This
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // witness value may be useful for logging the dependency failure.
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // Note that, when a dependency fails, there may be several possible
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // witnesses to the failure. The value returned from the check_foo
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // method is chosen arbitrarily.
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // The 'changes' value, if non-null, requests a limited spot-check
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // near the indicated recent changes in the class hierarchy.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // It is used by DepStream::spot_check_dependency_at.
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // Detecting possible new assertions:
a61af66fc99e Initial load
duke
parents:
diff changeset
327 static klassOop find_unique_concrete_subtype(klassOop ctxk);
a61af66fc99e Initial load
duke
parents:
diff changeset
328 static methodOop find_unique_concrete_method(klassOop ctxk, methodOop m);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 static int find_exclusive_concrete_subtypes(klassOop ctxk, int klen, klassOop k[]);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 static int find_exclusive_concrete_methods(klassOop ctxk, int mlen, methodOop m[]);
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // Create the encoding which will be stored in an nmethod.
a61af66fc99e Initial load
duke
parents:
diff changeset
333 void encode_content_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 address content_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 assert(_content_bytes != NULL, "encode it first");
a61af66fc99e Initial load
duke
parents:
diff changeset
337 return _content_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 size_t size_in_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 assert(_content_bytes != NULL, "encode it first");
a61af66fc99e Initial load
duke
parents:
diff changeset
341 return _size_in_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
342 }
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 OopRecorder* oop_recorder() { return _oop_recorder; }
a61af66fc99e Initial load
duke
parents:
diff changeset
345 CompileLog* log() { return _log; }
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 void copy_to(nmethod* nm);
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 void log_all_dependencies();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 void log_dependency(DepType dept, int nargs, ciObject* args[]) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 write_dependency_to(log(), dept, nargs, args);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 void log_dependency(DepType dept,
a61af66fc99e Initial load
duke
parents:
diff changeset
354 ciObject* x0,
a61af66fc99e Initial load
duke
parents:
diff changeset
355 ciObject* x1 = NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
356 ciObject* x2 = NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
357 if (log() == NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 ciObject* args[max_arg_count];
a61af66fc99e Initial load
duke
parents:
diff changeset
359 args[0] = x0;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 args[1] = x1;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 args[2] = x2;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 assert(2 < max_arg_count, "");
a61af66fc99e Initial load
duke
parents:
diff changeset
363 log_dependency(dept, dep_args(dept), args);
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 static void write_dependency_to(CompileLog* log,
a61af66fc99e Initial load
duke
parents:
diff changeset
367 DepType dept,
a61af66fc99e Initial load
duke
parents:
diff changeset
368 int nargs, ciObject* args[],
a61af66fc99e Initial load
duke
parents:
diff changeset
369 klassOop witness = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 static void write_dependency_to(CompileLog* log,
a61af66fc99e Initial load
duke
parents:
diff changeset
371 DepType dept,
a61af66fc99e Initial load
duke
parents:
diff changeset
372 int nargs, oop args[],
a61af66fc99e Initial load
duke
parents:
diff changeset
373 klassOop witness = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
374 static void write_dependency_to(xmlStream* xtty,
a61af66fc99e Initial load
duke
parents:
diff changeset
375 DepType dept,
a61af66fc99e Initial load
duke
parents:
diff changeset
376 int nargs, oop args[],
a61af66fc99e Initial load
duke
parents:
diff changeset
377 klassOop witness = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
378 static void print_dependency(DepType dept,
a61af66fc99e Initial load
duke
parents:
diff changeset
379 int nargs, oop args[],
a61af66fc99e Initial load
duke
parents:
diff changeset
380 klassOop witness = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // helper for encoding common context types as zero:
a61af66fc99e Initial load
duke
parents:
diff changeset
384 static ciKlass* ctxk_encoded_as_null(DepType dept, ciObject* x);
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 static klassOop ctxk_encoded_as_null(DepType dept, oop x);
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // Use this to iterate over an nmethod's dependency set.
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // Works on new and old dependency sets.
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // Usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
392 //
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // ;
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // Dependencies::DepType dept;
a61af66fc99e Initial load
duke
parents:
diff changeset
395 // for (Dependencies::DepStream deps(nm); deps.next(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
397 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 //
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // The caller must be in the VM, since oops are not wrapped in handles.
a61af66fc99e Initial load
duke
parents:
diff changeset
400 class DepStream {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
402 nmethod* _code; // null if in a compiler thread
a61af66fc99e Initial load
duke
parents:
diff changeset
403 Dependencies* _deps; // null if not in a compiler thread
a61af66fc99e Initial load
duke
parents:
diff changeset
404 CompressedReadStream _bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
405 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
406 size_t _byte_limit;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // iteration variables:
a61af66fc99e Initial load
duke
parents:
diff changeset
410 DepType _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
411 int _xi[max_arg_count+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 void initial_asserts(size_t byte_limit) NOT_DEBUG({});
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 inline oop recorded_oop_at(int i);
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // => _code? _code->oop_at(i): *_deps->_oop_recorder->handle_at(i)
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 klassOop check_dependency_impl(DepChange* changes);
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
421 DepStream(Dependencies* deps)
a61af66fc99e Initial load
duke
parents:
diff changeset
422 : _deps(deps),
a61af66fc99e Initial load
duke
parents:
diff changeset
423 _code(NULL),
a61af66fc99e Initial load
duke
parents:
diff changeset
424 _bytes(deps->content_bytes())
a61af66fc99e Initial load
duke
parents:
diff changeset
425 {
a61af66fc99e Initial load
duke
parents:
diff changeset
426 initial_asserts(deps->size_in_bytes());
a61af66fc99e Initial load
duke
parents:
diff changeset
427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
428 DepStream(nmethod* code)
a61af66fc99e Initial load
duke
parents:
diff changeset
429 : _deps(NULL),
a61af66fc99e Initial load
duke
parents:
diff changeset
430 _code(code),
a61af66fc99e Initial load
duke
parents:
diff changeset
431 _bytes(code->dependencies_begin())
a61af66fc99e Initial load
duke
parents:
diff changeset
432 {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 initial_asserts(code->dependencies_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 bool next();
a61af66fc99e Initial load
duke
parents:
diff changeset
437
a61af66fc99e Initial load
duke
parents:
diff changeset
438 DepType type() { return _type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
439 int argument_count() { return dep_args(type()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
440 int argument_index(int i) { assert(0 <= i && i < argument_count(), "oob");
a61af66fc99e Initial load
duke
parents:
diff changeset
441 return _xi[i]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
442 oop argument(int i); // => recorded_oop_at(argument_index(i))
a61af66fc99e Initial load
duke
parents:
diff changeset
443 klassOop context_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 methodOop method_argument(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 oop x = argument(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 assert(x->is_method(), "type");
a61af66fc99e Initial load
duke
parents:
diff changeset
448 return (methodOop) x;
a61af66fc99e Initial load
duke
parents:
diff changeset
449 }
a61af66fc99e Initial load
duke
parents:
diff changeset
450 klassOop type_argument(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 oop x = argument(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 assert(x->is_klass(), "type");
a61af66fc99e Initial load
duke
parents:
diff changeset
453 return (klassOop) x;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
455
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // The point of the whole exercise: Is this dep is still OK?
a61af66fc99e Initial load
duke
parents:
diff changeset
457 klassOop check_dependency() {
a61af66fc99e Initial load
duke
parents:
diff changeset
458 return check_dependency_impl(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460 // A lighter version: Checks only around recent changes in a class
a61af66fc99e Initial load
duke
parents:
diff changeset
461 // hierarchy. (See Universe::flush_dependents_on.)
a61af66fc99e Initial load
duke
parents:
diff changeset
462 klassOop spot_check_dependency_at(DepChange& changes);
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Log the current dependency to xtty or compilation log.
a61af66fc99e Initial load
duke
parents:
diff changeset
465 void log_dependency(klassOop witness = NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
466
a61af66fc99e Initial load
duke
parents:
diff changeset
467 // Print the current dependency to tty.
a61af66fc99e Initial load
duke
parents:
diff changeset
468 void print_dependency(klassOop witness = NULL, bool verbose = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
469 };
a61af66fc99e Initial load
duke
parents:
diff changeset
470 friend class Dependencies::DepStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 static void print_statistics() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
473 };
a61af66fc99e Initial load
duke
parents:
diff changeset
474
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // A class hierarchy change coming through the VM (under the Compile_lock).
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // The change is structured as a single new type with any number of supers
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // and implemented interface types. Other than the new type, any of the
a61af66fc99e Initial load
duke
parents:
diff changeset
478 // super types can be context types for a relevant dependency, which the
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // new type could invalidate.
a61af66fc99e Initial load
duke
parents:
diff changeset
480 class DepChange : public StackObj {
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
481 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
482 enum ChangeType {
a61af66fc99e Initial load
duke
parents:
diff changeset
483 NO_CHANGE = 0, // an uninvolved klass
a61af66fc99e Initial load
duke
parents:
diff changeset
484 Change_new_type, // a newly loaded type
a61af66fc99e Initial load
duke
parents:
diff changeset
485 Change_new_sub, // a super with a new subtype
a61af66fc99e Initial load
duke
parents:
diff changeset
486 Change_new_impl, // an interface with a new implementation
a61af66fc99e Initial load
duke
parents:
diff changeset
487 CHANGE_LIMIT,
a61af66fc99e Initial load
duke
parents:
diff changeset
488 Start_Klass = CHANGE_LIMIT // internal indicator for ContextStream
a61af66fc99e Initial load
duke
parents:
diff changeset
489 };
a61af66fc99e Initial load
duke
parents:
diff changeset
490
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
491 private:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
492 // each change set is rooted in exactly one new type (at present):
a61af66fc99e Initial load
duke
parents:
diff changeset
493 KlassHandle _new_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // notes the new type, marks it and all its super-types
a61af66fc99e Initial load
duke
parents:
diff changeset
499 DepChange(KlassHandle new_type)
a61af66fc99e Initial load
duke
parents:
diff changeset
500 : _new_type(new_type)
a61af66fc99e Initial load
duke
parents:
diff changeset
501 {
a61af66fc99e Initial load
duke
parents:
diff changeset
502 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // cleans up the marks
a61af66fc99e Initial load
duke
parents:
diff changeset
506 ~DepChange();
a61af66fc99e Initial load
duke
parents:
diff changeset
507
a61af66fc99e Initial load
duke
parents:
diff changeset
508 klassOop new_type() { return _new_type(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
509
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // involves_context(k) is true if k is new_type or any of the super types
a61af66fc99e Initial load
duke
parents:
diff changeset
511 bool involves_context(klassOop k);
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // Usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // for (DepChange::ContextStream str(changes); str.next(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // klassOop k = str.klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // switch (str.change_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
520 class ContextStream : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
521 private:
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
522 DepChange& _changes;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
523 friend class DepChange;
a61af66fc99e Initial load
duke
parents:
diff changeset
524
a61af66fc99e Initial load
duke
parents:
diff changeset
525 // iteration variables:
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
526 ChangeType _change_type;
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
527 klassOop _klass;
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
528 objArrayOop _ti_base; // i.e., transitive_interfaces
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
529 int _ti_index;
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
530 int _ti_limit;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 // start at the beginning:
a61af66fc99e Initial load
duke
parents:
diff changeset
533 void start() {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 klassOop new_type = _changes.new_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
535 _change_type = (new_type == NULL ? NO_CHANGE: Start_Klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
536 _klass = new_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
537 _ti_base = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
538 _ti_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
539 _ti_limit = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
542 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
543 ContextStream(DepChange& changes)
a61af66fc99e Initial load
duke
parents:
diff changeset
544 : _changes(changes)
a61af66fc99e Initial load
duke
parents:
diff changeset
545 { start(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547 ContextStream(DepChange& changes, No_Safepoint_Verifier& nsv)
a61af66fc99e Initial load
duke
parents:
diff changeset
548 : _changes(changes)
a61af66fc99e Initial load
duke
parents:
diff changeset
549 // the nsv argument makes it safe to hold oops like _klass
a61af66fc99e Initial load
duke
parents:
diff changeset
550 { start(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
551
a61af66fc99e Initial load
duke
parents:
diff changeset
552 bool next();
a61af66fc99e Initial load
duke
parents:
diff changeset
553
1123
167c2986d91b 6843629: Make current hotspot build part of jdk5 control build
phh
parents: 0
diff changeset
554 ChangeType change_type() { return _change_type; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
555 klassOop klass() { return _klass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
556 };
a61af66fc99e Initial load
duke
parents:
diff changeset
557 friend class DepChange::ContextStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
560 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
561
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
562 #endif // SHARE_VM_CODE_DEPENDENCIES_HPP