author | never |
Mon, 04 Dec 2017 13:13:44 -0800 | |
changeset 48299 | e8f5fc8f5f67 |
parent 47216 | 71c04702a3d5 |
child 48604 | 37a5a1109b93 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39411
diff
changeset
|
2 |
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4493
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4493
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4493
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CODE_DEPENDENCIES_HPP |
26 |
#define SHARE_VM_CODE_DEPENDENCIES_HPP |
|
27 |
||
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
28 |
#include "ci/ciCallSite.hpp" |
7397 | 29 |
#include "ci/ciKlass.hpp" |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
30 |
#include "ci/ciMethodHandle.hpp" |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
31 |
#include "classfile/systemDictionary.hpp" |
7397 | 32 |
#include "code/compressedStream.hpp" |
33 |
#include "code/nmethod.hpp" |
|
29201
fee2bbb2ec1d
8073389: Remove the include of resourceArea.hpp from classFileParser.hpp
stefank
parents:
28514
diff
changeset
|
34 |
#include "memory/resourceArea.hpp" |
7397 | 35 |
#include "utilities/growableArray.hpp" |
22921
ee35d5c0b1dc
8034839: jvm hangs with gc/gctests/LoadUnloadGC test
anoll
parents:
22506
diff
changeset
|
36 |
#include "utilities/hashtable.hpp" |
7397 | 37 |
|
1 | 38 |
//** Dependencies represent assertions (approximate invariants) within |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
39 |
// the runtime system, e.g. class hierarchy changes. An example is an |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
40 |
// assertion that a given method is not overridden; another example is |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
41 |
// that a type has only one concrete subtype. Compiled code which |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
42 |
// relies on such assertions must be discarded if they are overturned |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
43 |
// by changes in the runtime system. We can think of these assertions |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
44 |
// as approximate invariants, because we expect them to be overturned |
1 | 45 |
// very infrequently. We are willing to perform expensive recovery |
46 |
// operations when they are overturned. The benefit, of course, is |
|
47 |
// performing optimistic optimizations (!) on the object code. |
|
48 |
// |
|
49 |
// Changes in the class hierarchy due to dynamic linking or |
|
50 |
// class evolution can violate dependencies. There is enough |
|
51 |
// indexing between classes and nmethods to make dependency |
|
52 |
// checking reasonably efficient. |
|
53 |
||
54 |
class ciEnv; |
|
55 |
class nmethod; |
|
56 |
class OopRecorder; |
|
57 |
class xmlStream; |
|
58 |
class CompileLog; |
|
59 |
class DepChange; |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
60 |
class KlassDepChange; |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
61 |
class CallSiteDepChange; |
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
33611
diff
changeset
|
62 |
class NoSafepointVerifier; |
1 | 63 |
|
64 |
class Dependencies: public ResourceObj { |
|
65 |
public: |
|
66 |
// Note: In the comments on dependency types, most uses of the terms |
|
67 |
// subtype and supertype are used in a "non-strict" or "inclusive" |
|
68 |
// sense, and are starred to remind the reader of this fact. |
|
69 |
// Strict uses of the terms use the word "proper". |
|
70 |
// |
|
71 |
// Specifically, every class is its own subtype* and supertype*. |
|
72 |
// (This trick is easier than continually saying things like "Y is a |
|
73 |
// subtype of X or X itself".) |
|
74 |
// |
|
75 |
// Sometimes we write X > Y to mean X is a proper supertype of Y. |
|
76 |
// The notation X > {Y, Z} means X has proper subtypes Y, Z. |
|
77 |
// The notation X.m > Y means that Y inherits m from X, while |
|
78 |
// X.m > Y.m means Y overrides X.m. A star denotes abstractness, |
|
79 |
// as *I > A, meaning (abstract) interface I is a super type of A, |
|
80 |
// or A.*m > B.m, meaning B.m implements abstract method A.m. |
|
81 |
// |
|
82 |
// In this module, the terms "subtype" and "supertype" refer to |
|
83 |
// Java-level reference type conversions, as detected by |
|
84 |
// "instanceof" and performed by "checkcast" operations. The method |
|
85 |
// Klass::is_subtype_of tests these relations. Note that "subtype" |
|
86 |
// is richer than "subclass" (as tested by Klass::is_subclass_of), |
|
87 |
// since it takes account of relations involving interface and array |
|
88 |
// types. |
|
89 |
// |
|
90 |
// To avoid needless complexity, dependencies involving array types |
|
91 |
// are not accepted. If you need to make an assertion about an |
|
92 |
// array type, make the assertion about its corresponding element |
|
93 |
// types. Any assertion that might change about an array type can |
|
94 |
// be converted to an assertion about its element type. |
|
95 |
// |
|
96 |
// Most dependencies are evaluated over a "context type" CX, which |
|
97 |
// stands for the set Subtypes(CX) of every Java type that is a subtype* |
|
98 |
// of CX. When the system loads a new class or interface N, it is |
|
99 |
// responsible for re-evaluating changed dependencies whose context |
|
100 |
// type now includes N, that is, all super types of N. |
|
101 |
// |
|
102 |
enum DepType { |
|
103 |
end_marker = 0, |
|
104 |
||
105 |
// An 'evol' dependency simply notes that the contents of the |
|
106 |
// method were used. If it evolves (is replaced), the nmethod |
|
107 |
// must be recompiled. No other dependencies are implied. |
|
108 |
evol_method, |
|
109 |
FIRST_TYPE = evol_method, |
|
110 |
||
111 |
// A context type CX is a leaf it if has no proper subtype. |
|
112 |
leaf_type, |
|
113 |
||
114 |
// An abstract class CX has exactly one concrete subtype CC. |
|
115 |
abstract_with_unique_concrete_subtype, |
|
116 |
||
117 |
// The type CX is purely abstract, with no concrete subtype* at all. |
|
118 |
abstract_with_no_concrete_subtype, |
|
119 |
||
120 |
// The concrete CX is free of concrete proper subtypes. |
|
121 |
concrete_with_no_concrete_subtype, |
|
122 |
||
123 |
// Given a method M1 and a context class CX, the set MM(CX, M1) of |
|
124 |
// "concrete matching methods" in CX of M1 is the set of every |
|
125 |
// concrete M2 for which it is possible to create an invokevirtual |
|
126 |
// or invokeinterface call site that can reach either M1 or M2. |
|
127 |
// That is, M1 and M2 share a name, signature, and vtable index. |
|
128 |
// We wish to notice when the set MM(CX, M1) is just {M1}, or |
|
129 |
// perhaps a set of two {M1,M2}, and issue dependencies on this. |
|
130 |
||
131 |
// The set MM(CX, M1) can be computed by starting with any matching |
|
132 |
// concrete M2 that is inherited into CX, and then walking the |
|
133 |
// subtypes* of CX looking for concrete definitions. |
|
134 |
||
135 |
// The parameters to this dependency are the method M1 and the |
|
136 |
// context class CX. M1 must be either inherited in CX or defined |
|
137 |
// in a subtype* of CX. It asserts that MM(CX, M1) is no greater |
|
138 |
// than {M1}. |
|
139 |
unique_concrete_method, // one unique concrete method under CX |
|
140 |
||
141 |
// An "exclusive" assertion concerns two methods or subtypes, and |
|
142 |
// declares that there are at most two (or perhaps later N>2) |
|
143 |
// specific items that jointly satisfy the restriction. |
|
144 |
// We list all items explicitly rather than just giving their |
|
145 |
// count, for robustness in the face of complex schema changes. |
|
146 |
||
147 |
// A context class CX (which may be either abstract or concrete) |
|
148 |
// has two exclusive concrete subtypes* C1, C2 if every concrete |
|
149 |
// subtype* of CX is either C1 or C2. Note that if neither C1 or C2 |
|
150 |
// are equal to CX, then CX itself must be abstract. But it is |
|
151 |
// also possible (for example) that C1 is CX (a concrete class) |
|
152 |
// and C2 is a proper subtype of C1. |
|
153 |
abstract_with_exclusive_concrete_subtypes_2, |
|
154 |
||
155 |
// This dependency asserts that MM(CX, M1) is no greater than {M1,M2}. |
|
156 |
exclusive_concrete_methods_2, |
|
157 |
||
158 |
// This dependency asserts that no instances of class or it's |
|
159 |
// subclasses require finalization registration. |
|
160 |
no_finalizable_subclasses, |
|
161 |
||
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
162 |
// This dependency asserts when the CallSite.target value changed. |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
163 |
call_site_target_value, |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
164 |
|
1 | 165 |
TYPE_LIMIT |
166 |
}; |
|
167 |
enum { |
|
168 |
LG2_TYPE_LIMIT = 4, // assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT)) |
|
169 |
||
170 |
// handy categorizations of dependency types: |
|
39411
9b6627406019
8157758: JDK9 does not compile on Linux with GCC 6.1 because left-shifting a negative number has undefined behavior
kbarrett
parents:
36300
diff
changeset
|
171 |
all_types = ((1 << TYPE_LIMIT) - 1) & ((~0u) << FIRST_TYPE), |
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
172 |
|
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
173 |
non_klass_types = (1 << call_site_target_value), |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
174 |
klass_types = all_types & ~non_klass_types, |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
175 |
|
31037
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
30296
diff
changeset
|
176 |
non_ctxk_types = (1 << evol_method) | (1 << call_site_target_value), |
30296
95baefac8485
8057967: CallSite dependency tracking scales devastatingly poorly
vlivanov
parents:
29201
diff
changeset
|
177 |
implicit_ctxk_types = 0, |
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
178 |
explicit_ctxk_types = all_types & ~(non_ctxk_types | implicit_ctxk_types), |
1 | 179 |
|
180 |
max_arg_count = 3, // current maximum number of arguments (incl. ctxk) |
|
181 |
||
182 |
// A "context type" is a class or interface that |
|
183 |
// provides context for evaluating a dependency. |
|
184 |
// When present, it is one of the arguments (dep_context_arg). |
|
185 |
// |
|
186 |
// If a dependency does not have a context type, there is a |
|
187 |
// default context, depending on the type of the dependency. |
|
188 |
// This bit signals that a default context has been compressed away. |
|
189 |
default_context_type_bit = (1<<LG2_TYPE_LIMIT) |
|
190 |
}; |
|
191 |
||
192 |
static const char* dep_name(DepType dept); |
|
193 |
static int dep_args(DepType dept); |
|
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
194 |
|
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
195 |
static bool is_klass_type( DepType dept) { return dept_in_mask(dept, klass_types ); } |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
196 |
|
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
197 |
static bool has_explicit_context_arg(DepType dept) { return dept_in_mask(dept, explicit_ctxk_types); } |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
198 |
static bool has_implicit_context_arg(DepType dept) { return dept_in_mask(dept, implicit_ctxk_types); } |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
199 |
|
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
200 |
static int dep_context_arg(DepType dept) { return has_explicit_context_arg(dept) ? 0 : -1; } |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
201 |
static int dep_implicit_context_arg(DepType dept) { return has_implicit_context_arg(dept) ? 0 : -1; } |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
202 |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
203 |
static void check_valid_dependency_type(DepType dept); |
1 | 204 |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
205 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
206 |
// A Metadata* or object value recorded in an OopRecorder |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
207 |
class DepValue VALUE_OBJ_CLASS_SPEC { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
208 |
private: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
209 |
// Unique identifier of the value within the associated OopRecorder that |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
210 |
// encodes both the category of the value (0: invalid, positive: metadata, negative: object) |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
211 |
// and the index within a category specific array (metadata: index + 1, object: -(index + 1)) |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
212 |
int _id; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
213 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
214 |
public: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
215 |
DepValue() : _id(0) {} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
216 |
DepValue(OopRecorder* rec, Metadata* metadata, DepValue* candidate = NULL) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
217 |
assert(candidate == NULL || candidate->is_metadata(), "oops"); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
218 |
if (candidate != NULL && candidate->as_metadata(rec) == metadata) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
219 |
_id = candidate->_id; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
220 |
} else { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
221 |
_id = rec->find_index(metadata) + 1; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
222 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
223 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
224 |
DepValue(OopRecorder* rec, jobject obj, DepValue* candidate = NULL) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
225 |
assert(candidate == NULL || candidate->is_object(), "oops"); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
226 |
if (candidate != NULL && candidate->as_object(rec) == obj) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
227 |
_id = candidate->_id; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
228 |
} else { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
229 |
_id = -(rec->find_index(obj) + 1); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
230 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
231 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
232 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
233 |
// Used to sort values in ascending order of index() with metadata values preceding object values |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
234 |
int sort_key() const { return -_id; } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
235 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
236 |
bool operator == (const DepValue& other) const { return other._id == _id; } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
237 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
238 |
bool is_valid() const { return _id != 0; } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
239 |
int index() const { assert(is_valid(), "oops"); return _id < 0 ? -(_id + 1) : _id - 1; } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
240 |
bool is_metadata() const { assert(is_valid(), "oops"); return _id > 0; } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
241 |
bool is_object() const { assert(is_valid(), "oops"); return _id < 0; } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
242 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
243 |
Metadata* as_metadata(OopRecorder* rec) const { assert(is_metadata(), "oops"); return rec->metadata_at(index()); } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
244 |
Klass* as_klass(OopRecorder* rec) const { assert(as_metadata(rec)->is_klass(), "oops"); return (Klass*) as_metadata(rec); } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
245 |
Method* as_method(OopRecorder* rec) const { assert(as_metadata(rec)->is_method(), "oops"); return (Method*) as_metadata(rec); } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
246 |
jobject as_object(OopRecorder* rec) const { assert(is_object(), "oops"); return rec->oop_at(index()); } |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
247 |
}; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
248 |
#endif // INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
249 |
|
1 | 250 |
private: |
251 |
// State for writing a new set of dependencies: |
|
252 |
GrowableArray<int>* _dep_seen; // (seen[h->ident] & (1<<dept)) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
253 |
GrowableArray<ciBaseObject*>* _deps[TYPE_LIMIT]; |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
254 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
255 |
bool _using_dep_values; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
256 |
GrowableArray<DepValue>* _dep_values[TYPE_LIMIT]; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
257 |
#endif |
1 | 258 |
|
259 |
static const char* _dep_name[TYPE_LIMIT]; |
|
260 |
static int _dep_args[TYPE_LIMIT]; |
|
261 |
||
262 |
static bool dept_in_mask(DepType dept, int mask) { |
|
263 |
return (int)dept >= 0 && dept < TYPE_LIMIT && ((1<<dept) & mask) != 0; |
|
264 |
} |
|
265 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
266 |
bool note_dep_seen(int dept, ciBaseObject* x) { |
1 | 267 |
assert(dept < BitsPerInt, "oob"); |
268 |
int x_id = x->ident(); |
|
269 |
assert(_dep_seen != NULL, "deps must be writable"); |
|
270 |
int seen = _dep_seen->at_grow(x_id, 0); |
|
271 |
_dep_seen->at_put(x_id, seen | (1<<dept)); |
|
272 |
// return true if we've already seen dept/x |
|
273 |
return (seen & (1<<dept)) != 0; |
|
274 |
} |
|
275 |
||
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
276 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
277 |
bool note_dep_seen(int dept, DepValue x) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
278 |
assert(dept < BitsPerInt, "oops"); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
279 |
// place metadata deps at even indexes, object deps at odd indexes |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
280 |
int x_id = x.is_metadata() ? x.index() * 2 : (x.index() * 2) + 1; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
281 |
assert(_dep_seen != NULL, "deps must be writable"); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
282 |
int seen = _dep_seen->at_grow(x_id, 0); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
283 |
_dep_seen->at_put(x_id, seen | (1<<dept)); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
284 |
// return true if we've already seen dept/x |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
285 |
return (seen & (1<<dept)) != 0; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
286 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
287 |
#endif |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
288 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
289 |
bool maybe_merge_ctxk(GrowableArray<ciBaseObject*>* deps, |
1 | 290 |
int ctxk_i, ciKlass* ctxk); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
291 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
292 |
bool maybe_merge_ctxk(GrowableArray<DepValue>* deps, |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
293 |
int ctxk_i, DepValue ctxk); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
294 |
#endif |
1 | 295 |
|
296 |
void sort_all_deps(); |
|
297 |
size_t estimate_size_in_bytes(); |
|
298 |
||
299 |
// Initialize _deps, etc. |
|
300 |
void initialize(ciEnv* env); |
|
301 |
||
302 |
// State for making a new set of dependencies: |
|
303 |
OopRecorder* _oop_recorder; |
|
304 |
||
305 |
// Logging support |
|
306 |
CompileLog* _log; |
|
307 |
||
308 |
address _content_bytes; // everything but the oop references, encoded |
|
309 |
size_t _size_in_bytes; |
|
310 |
||
311 |
public: |
|
312 |
// Make a new empty dependencies set. |
|
313 |
Dependencies(ciEnv* env) { |
|
314 |
initialize(env); |
|
315 |
} |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
316 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
317 |
Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
318 |
#endif |
1 | 319 |
|
320 |
private: |
|
321 |
// Check for a valid context type. |
|
322 |
// Enforce the restriction against array types. |
|
323 |
static void check_ctxk(ciKlass* ctxk) { |
|
324 |
assert(ctxk->is_instance_klass(), "java types only"); |
|
325 |
} |
|
326 |
static void check_ctxk_concrete(ciKlass* ctxk) { |
|
327 |
assert(is_concrete_klass(ctxk->as_instance_klass()), "must be concrete"); |
|
328 |
} |
|
329 |
static void check_ctxk_abstract(ciKlass* ctxk) { |
|
330 |
check_ctxk(ctxk); |
|
331 |
assert(!is_concrete_klass(ctxk->as_instance_klass()), "must be abstract"); |
|
332 |
} |
|
333 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
334 |
void assert_common_1(DepType dept, ciBaseObject* x); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
335 |
void assert_common_2(DepType dept, ciBaseObject* x0, ciBaseObject* x1); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
336 |
void assert_common_3(DepType dept, ciKlass* ctxk, ciBaseObject* x1, ciBaseObject* x2); |
1 | 337 |
|
338 |
public: |
|
339 |
// Adding assertions to a new dependency set at compile time: |
|
340 |
void assert_evol_method(ciMethod* m); |
|
341 |
void assert_leaf_type(ciKlass* ctxk); |
|
342 |
void assert_abstract_with_unique_concrete_subtype(ciKlass* ctxk, ciKlass* conck); |
|
343 |
void assert_abstract_with_no_concrete_subtype(ciKlass* ctxk); |
|
344 |
void assert_concrete_with_no_concrete_subtype(ciKlass* ctxk); |
|
345 |
void assert_unique_concrete_method(ciKlass* ctxk, ciMethod* uniqm); |
|
346 |
void assert_abstract_with_exclusive_concrete_subtypes(ciKlass* ctxk, ciKlass* k1, ciKlass* k2); |
|
347 |
void assert_exclusive_concrete_methods(ciKlass* ctxk, ciMethod* m1, ciMethod* m2); |
|
348 |
void assert_has_no_finalizable_subclasses(ciKlass* ctxk); |
|
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
349 |
void assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle); |
1 | 350 |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
351 |
#if INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
352 |
private: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
353 |
static void check_ctxk(Klass* ctxk) { |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33160
diff
changeset
|
354 |
assert(ctxk->is_instance_klass(), "java types only"); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
355 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
356 |
static void check_ctxk_abstract(Klass* ctxk) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
357 |
check_ctxk(ctxk); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
358 |
assert(ctxk->is_abstract(), "must be abstract"); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
359 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
360 |
void assert_common_1(DepType dept, DepValue x); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
361 |
void assert_common_2(DepType dept, DepValue x0, DepValue x1); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
362 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
363 |
public: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
364 |
void assert_evol_method(Method* m); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
365 |
void assert_has_no_finalizable_subclasses(Klass* ctxk); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
366 |
void assert_leaf_type(Klass* ctxk); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
367 |
void assert_unique_concrete_method(Klass* ctxk, Method* uniqm); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
368 |
void assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
369 |
void assert_call_site_target_value(oop callSite, oop methodHandle); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
370 |
#endif // INCLUDE_JVMCI |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
371 |
|
1 | 372 |
// Define whether a given method or type is concrete. |
373 |
// These methods define the term "concrete" as used in this module. |
|
374 |
// For this module, an "abstract" class is one which is non-concrete. |
|
375 |
// |
|
376 |
// Future optimizations may allow some classes to remain |
|
377 |
// non-concrete until their first instantiation, and allow some |
|
378 |
// methods to remain non-concrete until their first invocation. |
|
379 |
// In that case, there would be a middle ground between concrete |
|
380 |
// and abstract (as defined by the Java language and VM). |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
381 |
static bool is_concrete_klass(Klass* k); // k is instantiable |
28514 | 382 |
static bool is_concrete_method(Method* m, Klass* k); // m is invocable |
1 | 383 |
static Klass* find_finalizable_subclass(Klass* k); |
384 |
||
385 |
// These versions of the concreteness queries work through the CI. |
|
386 |
// The CI versions are allowed to skew sometimes from the VM |
|
387 |
// (oop-based) versions. The cost of such a difference is a |
|
388 |
// (safely) aborted compilation, or a deoptimization, or a missed |
|
389 |
// optimization opportunity. |
|
390 |
// |
|
391 |
// In order to prevent spurious assertions, query results must |
|
392 |
// remain stable within any single ciEnv instance. (I.e., they must |
|
393 |
// not go back into the VM to get their value; they must cache the |
|
394 |
// bit in the CI, either eagerly or lazily.) |
|
395 |
static bool is_concrete_klass(ciInstanceKlass* k); // k appears instantiable |
|
396 |
static bool has_finalizable_subclass(ciInstanceKlass* k); |
|
397 |
||
398 |
// As a general rule, it is OK to compile under the assumption that |
|
399 |
// a given type or method is concrete, even if it at some future |
|
400 |
// point becomes abstract. So dependency checking is one-sided, in |
|
401 |
// that it permits supposedly concrete classes or methods to turn up |
|
402 |
// as really abstract. (This shouldn't happen, except during class |
|
403 |
// evolution, but that's the logic of the checking.) However, if a |
|
404 |
// supposedly abstract class or method suddenly becomes concrete, a |
|
405 |
// dependency on it must fail. |
|
406 |
||
407 |
// Checking old assertions at run-time (in the VM only): |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
408 |
static Klass* check_evol_method(Method* m); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
409 |
static Klass* check_leaf_type(Klass* ctxk); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
410 |
static Klass* check_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck, |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
411 |
KlassDepChange* changes = NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
412 |
static Klass* check_abstract_with_no_concrete_subtype(Klass* ctxk, |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
413 |
KlassDepChange* changes = NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
414 |
static Klass* check_concrete_with_no_concrete_subtype(Klass* ctxk, |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
415 |
KlassDepChange* changes = NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
416 |
static Klass* check_unique_concrete_method(Klass* ctxk, Method* uniqm, |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
417 |
KlassDepChange* changes = NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
418 |
static Klass* check_abstract_with_exclusive_concrete_subtypes(Klass* ctxk, Klass* k1, Klass* k2, |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
419 |
KlassDepChange* changes = NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
420 |
static Klass* check_exclusive_concrete_methods(Klass* ctxk, Method* m1, Method* m2, |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
421 |
KlassDepChange* changes = NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
422 |
static Klass* check_has_no_finalizable_subclasses(Klass* ctxk, KlassDepChange* changes = NULL); |
31037
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
30296
diff
changeset
|
423 |
static Klass* check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes = NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
424 |
// A returned Klass* is NULL if the dependency assertion is still |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
425 |
// valid. A non-NULL Klass* is a 'witness' to the assertion |
1 | 426 |
// failure, a point in the class hierarchy where the assertion has |
427 |
// been proven false. For example, if check_leaf_type returns |
|
428 |
// non-NULL, the value is a subtype of the supposed leaf type. This |
|
429 |
// witness value may be useful for logging the dependency failure. |
|
430 |
// Note that, when a dependency fails, there may be several possible |
|
431 |
// witnesses to the failure. The value returned from the check_foo |
|
432 |
// method is chosen arbitrarily. |
|
433 |
||
434 |
// The 'changes' value, if non-null, requests a limited spot-check |
|
435 |
// near the indicated recent changes in the class hierarchy. |
|
436 |
// It is used by DepStream::spot_check_dependency_at. |
|
437 |
||
438 |
// Detecting possible new assertions: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
439 |
static Klass* find_unique_concrete_subtype(Klass* ctxk); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
440 |
static Method* find_unique_concrete_method(Klass* ctxk, Method* m); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
441 |
static int find_exclusive_concrete_subtypes(Klass* ctxk, int klen, Klass* k[]); |
1 | 442 |
|
443 |
// Create the encoding which will be stored in an nmethod. |
|
444 |
void encode_content_bytes(); |
|
445 |
||
446 |
address content_bytes() { |
|
447 |
assert(_content_bytes != NULL, "encode it first"); |
|
448 |
return _content_bytes; |
|
449 |
} |
|
450 |
size_t size_in_bytes() { |
|
451 |
assert(_content_bytes != NULL, "encode it first"); |
|
452 |
return _size_in_bytes; |
|
453 |
} |
|
454 |
||
455 |
OopRecorder* oop_recorder() { return _oop_recorder; } |
|
456 |
CompileLog* log() { return _log; } |
|
457 |
||
458 |
void copy_to(nmethod* nm); |
|
459 |
||
48299
e8f5fc8f5f67
8191052: [Graal] java/lang/invoke/CallSiteTest.java intermittently fails with "Failed dependency of type call_site_target_value" when running with Graal as JIT
never
parents:
47216
diff
changeset
|
460 |
DepType validate_dependencies(CompileTask* task, bool counter_changed, char** failure_detail = NULL); |
e8f5fc8f5f67
8191052: [Graal] java/lang/invoke/CallSiteTest.java intermittently fails with "Failed dependency of type call_site_target_value" when running with Graal as JIT
never
parents:
47216
diff
changeset
|
461 |
|
1 | 462 |
void log_all_dependencies(); |
25936
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
463 |
|
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
464 |
void log_dependency(DepType dept, GrowableArray<ciBaseObject*>* args) { |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
465 |
ResourceMark rm; |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
466 |
int argslen = args->length(); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
467 |
write_dependency_to(log(), dept, args); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
468 |
guarantee(argslen == args->length(), |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
469 |
"args array cannot grow inside nested ResoureMark scope"); |
1 | 470 |
} |
25936
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
471 |
|
1 | 472 |
void log_dependency(DepType dept, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
473 |
ciBaseObject* x0, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
474 |
ciBaseObject* x1 = NULL, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
475 |
ciBaseObject* x2 = NULL) { |
25936
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
476 |
if (log() == NULL) { |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
477 |
return; |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
478 |
} |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
479 |
ResourceMark rm; |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
480 |
GrowableArray<ciBaseObject*>* ciargs = |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
481 |
new GrowableArray<ciBaseObject*>(dep_args(dept)); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
482 |
assert (x0 != NULL, "no log x0"); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
483 |
ciargs->push(x0); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
484 |
|
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
485 |
if (x1 != NULL) { |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
486 |
ciargs->push(x1); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
487 |
} |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
488 |
if (x2 != NULL) { |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
489 |
ciargs->push(x2); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
490 |
} |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
491 |
assert(ciargs->length() == dep_args(dept), ""); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
492 |
log_dependency(dept, ciargs); |
1 | 493 |
} |
494 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
495 |
class DepArgument : public ResourceObj { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
496 |
private: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
497 |
bool _is_oop; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
498 |
bool _valid; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
499 |
void* _value; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
500 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
501 |
DepArgument() : _is_oop(false), _value(NULL), _valid(false) {} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
502 |
DepArgument(oop v): _is_oop(true), _value(v), _valid(true) {} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
503 |
DepArgument(Metadata* v): _is_oop(false), _value(v), _valid(true) {} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
504 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
505 |
bool is_null() const { return _value == NULL; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
506 |
bool is_oop() const { return _is_oop; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
507 |
bool is_metadata() const { return !_is_oop; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
508 |
bool is_klass() const { return is_metadata() && metadata_value()->is_klass(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
509 |
bool is_method() const { return is_metadata() && metadata_value()->is_method(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
510 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
511 |
oop oop_value() const { assert(_is_oop && _valid, "must be"); return (oop) _value; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
512 |
Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
513 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
514 |
|
1 | 515 |
static void print_dependency(DepType dept, |
25936
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
516 |
GrowableArray<DepArgument>* args, |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
517 |
Klass* witness = NULL, outputStream* st = tty); |
1 | 518 |
|
519 |
private: |
|
520 |
// helper for encoding common context types as zero: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
521 |
static ciKlass* ctxk_encoded_as_null(DepType dept, ciBaseObject* x); |
1 | 522 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
523 |
static Klass* ctxk_encoded_as_null(DepType dept, Metadata* x); |
1 | 524 |
|
25936
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
525 |
static void write_dependency_to(CompileLog* log, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
526 |
DepType dept, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
527 |
GrowableArray<ciBaseObject*>* args, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
528 |
Klass* witness = NULL); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
529 |
static void write_dependency_to(CompileLog* log, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
530 |
DepType dept, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
531 |
GrowableArray<DepArgument>* args, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
532 |
Klass* witness = NULL); |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
533 |
static void write_dependency_to(xmlStream* xtty, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
534 |
DepType dept, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
535 |
GrowableArray<DepArgument>* args, |
9b693ed74c13
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
morris
parents:
23187
diff
changeset
|
536 |
Klass* witness = NULL); |
1 | 537 |
public: |
538 |
// Use this to iterate over an nmethod's dependency set. |
|
539 |
// Works on new and old dependency sets. |
|
540 |
// Usage: |
|
541 |
// |
|
542 |
// ; |
|
543 |
// Dependencies::DepType dept; |
|
544 |
// for (Dependencies::DepStream deps(nm); deps.next(); ) { |
|
545 |
// ... |
|
546 |
// } |
|
547 |
// |
|
548 |
// The caller must be in the VM, since oops are not wrapped in handles. |
|
549 |
class DepStream { |
|
550 |
private: |
|
551 |
nmethod* _code; // null if in a compiler thread |
|
552 |
Dependencies* _deps; // null if not in a compiler thread |
|
553 |
CompressedReadStream _bytes; |
|
554 |
#ifdef ASSERT |
|
555 |
size_t _byte_limit; |
|
556 |
#endif |
|
557 |
||
558 |
// iteration variables: |
|
559 |
DepType _type; |
|
560 |
int _xi[max_arg_count+1]; |
|
561 |
||
562 |
void initial_asserts(size_t byte_limit) NOT_DEBUG({}); |
|
563 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
564 |
inline Metadata* recorded_metadata_at(int i); |
1 | 565 |
inline oop recorded_oop_at(int i); |
566 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
567 |
Klass* check_klass_dependency(KlassDepChange* changes); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
568 |
Klass* check_call_site_dependency(CallSiteDepChange* changes); |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
569 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
570 |
void trace_and_log_witness(Klass* witness); |
1 | 571 |
|
572 |
public: |
|
573 |
DepStream(Dependencies* deps) |
|
574 |
: _deps(deps), |
|
575 |
_code(NULL), |
|
576 |
_bytes(deps->content_bytes()) |
|
577 |
{ |
|
578 |
initial_asserts(deps->size_in_bytes()); |
|
579 |
} |
|
580 |
DepStream(nmethod* code) |
|
581 |
: _deps(NULL), |
|
582 |
_code(code), |
|
583 |
_bytes(code->dependencies_begin()) |
|
584 |
{ |
|
585 |
initial_asserts(code->dependencies_size()); |
|
586 |
} |
|
587 |
||
588 |
bool next(); |
|
589 |
||
590 |
DepType type() { return _type; } |
|
31037
01a5c5fa5681
8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents:
30296
diff
changeset
|
591 |
bool is_oop_argument(int i) { return type() == call_site_target_value; } |
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
592 |
uintptr_t get_identifier(int i); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
593 |
|
1 | 594 |
int argument_count() { return dep_args(type()); } |
595 |
int argument_index(int i) { assert(0 <= i && i < argument_count(), "oob"); |
|
596 |
return _xi[i]; } |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
597 |
Metadata* argument(int i); // => recorded_oop_at(argument_index(i)) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
598 |
oop argument_oop(int i); // => recorded_oop_at(argument_index(i)) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
599 |
Klass* context_type(); |
1 | 600 |
|
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
601 |
bool is_klass_type() { return Dependencies::is_klass_type(type()); } |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10265
diff
changeset
|
602 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
603 |
Method* method_argument(int i) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
604 |
Metadata* x = argument(i); |
1 | 605 |
assert(x->is_method(), "type"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
606 |
return (Method*) x; |
1 | 607 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
608 |
Klass* type_argument(int i) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
609 |
Metadata* x = argument(i); |
1 | 610 |
assert(x->is_klass(), "type"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
611 |
return (Klass*) x; |
1 | 612 |
} |
613 |
||
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
614 |
// The point of the whole exercise: Is this dep still OK? |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
615 |
Klass* check_dependency() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
616 |
Klass* result = check_klass_dependency(NULL); |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
617 |
if (result != NULL) return result; |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
618 |
return check_call_site_dependency(NULL); |
1 | 619 |
} |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
620 |
|
1 | 621 |
// A lighter version: Checks only around recent changes in a class |
622 |
// hierarchy. (See Universe::flush_dependents_on.) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
623 |
Klass* spot_check_dependency_at(DepChange& changes); |
1 | 624 |
|
625 |
// Log the current dependency to xtty or compilation log. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
626 |
void log_dependency(Klass* witness = NULL); |
1 | 627 |
|
628 |
// Print the current dependency to tty. |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31037
diff
changeset
|
629 |
void print_dependency(Klass* witness = NULL, bool verbose = false, outputStream* st = tty); |
1 | 630 |
}; |
631 |
friend class Dependencies::DepStream; |
|
632 |
||
633 |
static void print_statistics() PRODUCT_RETURN; |
|
634 |
}; |
|
635 |
||
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
636 |
|
23187
0f438571f278
8035946: Use ResourceHashtable for dependency checking
anoll
parents:
22921
diff
changeset
|
637 |
class DependencySignature : public ResourceObj { |
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
638 |
private: |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
639 |
int _args_count; |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
640 |
uintptr_t _argument_hash[Dependencies::max_arg_count]; |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
641 |
Dependencies::DepType _type; |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
642 |
|
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
643 |
public: |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
644 |
DependencySignature(Dependencies::DepStream& dep) { |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
645 |
_args_count = dep.argument_count(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
646 |
_type = dep.type(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
647 |
for (int i = 0; i < _args_count; i++) { |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
648 |
_argument_hash[i] = dep.get_identifier(i); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
649 |
} |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
650 |
} |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
651 |
|
23187
0f438571f278
8035946: Use ResourceHashtable for dependency checking
anoll
parents:
22921
diff
changeset
|
652 |
static bool equals(DependencySignature const& s1, DependencySignature const& s2); |
0f438571f278
8035946: Use ResourceHashtable for dependency checking
anoll
parents:
22921
diff
changeset
|
653 |
static unsigned hash (DependencySignature const& s1) { return s1.arg(0) >> 2; } |
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
654 |
|
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
655 |
int args_count() const { return _args_count; } |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
656 |
uintptr_t arg(int idx) const { return _argument_hash[idx]; } |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
657 |
Dependencies::DepType type() const { return _type; } |
23187
0f438571f278
8035946: Use ResourceHashtable for dependency checking
anoll
parents:
22921
diff
changeset
|
658 |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
659 |
}; |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
660 |
|
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
13728
diff
changeset
|
661 |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
662 |
// Every particular DepChange is a sub-class of this class. |
1 | 663 |
class DepChange : public StackObj { |
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
1
diff
changeset
|
664 |
public: |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
665 |
// What kind of DepChange is this? |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
666 |
virtual bool is_klass_change() const { return false; } |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
667 |
virtual bool is_call_site_change() const { return false; } |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
668 |
|
36300
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
669 |
virtual void mark_for_deoptimization(nmethod* nm) = 0; |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
670 |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
671 |
// Subclass casting with assertions. |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
672 |
KlassDepChange* as_klass_change() { |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
673 |
assert(is_klass_change(), "bad cast"); |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
674 |
return (KlassDepChange*) this; |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
675 |
} |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
676 |
CallSiteDepChange* as_call_site_change() { |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
677 |
assert(is_call_site_change(), "bad cast"); |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
678 |
return (CallSiteDepChange*) this; |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
679 |
} |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
680 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
681 |
void print(); |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
682 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
683 |
public: |
1 | 684 |
enum ChangeType { |
685 |
NO_CHANGE = 0, // an uninvolved klass |
|
686 |
Change_new_type, // a newly loaded type |
|
687 |
Change_new_sub, // a super with a new subtype |
|
688 |
Change_new_impl, // an interface with a new implementation |
|
689 |
CHANGE_LIMIT, |
|
690 |
Start_Klass = CHANGE_LIMIT // internal indicator for ContextStream |
|
691 |
}; |
|
692 |
||
693 |
// Usage: |
|
694 |
// for (DepChange::ContextStream str(changes); str.next(); ) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
695 |
// Klass* k = str.klass(); |
1 | 696 |
// switch (str.change_type()) { |
697 |
// ... |
|
698 |
// } |
|
699 |
// } |
|
700 |
class ContextStream : public StackObj { |
|
701 |
private: |
|
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
1
diff
changeset
|
702 |
DepChange& _changes; |
1 | 703 |
friend class DepChange; |
704 |
||
705 |
// iteration variables: |
|
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
1
diff
changeset
|
706 |
ChangeType _change_type; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
707 |
Klass* _klass; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
708 |
Array<Klass*>* _ti_base; // i.e., transitive_interfaces |
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
1
diff
changeset
|
709 |
int _ti_index; |
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
1
diff
changeset
|
710 |
int _ti_limit; |
1 | 711 |
|
712 |
// start at the beginning: |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
713 |
void start(); |
1 | 714 |
|
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
1
diff
changeset
|
715 |
public: |
1 | 716 |
ContextStream(DepChange& changes) |
717 |
: _changes(changes) |
|
718 |
{ start(); } |
|
719 |
||
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
33611
diff
changeset
|
720 |
ContextStream(DepChange& changes, NoSafepointVerifier& nsv) |
1 | 721 |
: _changes(changes) |
722 |
// the nsv argument makes it safe to hold oops like _klass |
|
723 |
{ start(); } |
|
724 |
||
725 |
bool next(); |
|
726 |
||
4493
9204129f065e
6843629: Make current hotspot build part of jdk5 control build
phh
parents:
1
diff
changeset
|
727 |
ChangeType change_type() { return _change_type; } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
728 |
Klass* klass() { return _klass; } |
1 | 729 |
}; |
730 |
friend class DepChange::ContextStream; |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
731 |
}; |
1 | 732 |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
733 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
734 |
// A class hierarchy change coming through the VM (under the Compile_lock). |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
735 |
// The change is structured as a single new type with any number of supers |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
736 |
// and implemented interface types. Other than the new type, any of the |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
737 |
// super types can be context types for a relevant dependency, which the |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
738 |
// new type could invalidate. |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
739 |
class KlassDepChange : public DepChange { |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
740 |
private: |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
741 |
// each change set is rooted in exactly one new type (at present): |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39411
diff
changeset
|
742 |
Klass* _new_type; |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
743 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
744 |
void initialize(); |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
745 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
746 |
public: |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
747 |
// notes the new type, marks it and all its super-types |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39411
diff
changeset
|
748 |
KlassDepChange(Klass* new_type) |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
749 |
: _new_type(new_type) |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
750 |
{ |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
751 |
initialize(); |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
752 |
} |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
753 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
754 |
// cleans up the marks |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
755 |
~KlassDepChange(); |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
756 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
757 |
// What kind of DepChange is this? |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
758 |
virtual bool is_klass_change() const { return true; } |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
759 |
|
36300
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
760 |
virtual void mark_for_deoptimization(nmethod* nm) { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
761 |
nm->mark_for_deoptimization(/*inc_recompile_counts=*/true); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
762 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
763 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39411
diff
changeset
|
764 |
Klass* new_type() { return _new_type; } |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
765 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
766 |
// involves_context(k) is true if k is new_type or any of the super types |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10503
diff
changeset
|
767 |
bool involves_context(Klass* k); |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
768 |
}; |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
769 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
770 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
771 |
// A CallSite has changed its target. |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
772 |
class CallSiteDepChange : public DepChange { |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
773 |
private: |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
774 |
Handle _call_site; |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
775 |
Handle _method_handle; |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
776 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
777 |
public: |
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
33611
diff
changeset
|
778 |
CallSiteDepChange(Handle call_site, Handle method_handle); |
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
779 |
|
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
780 |
// What kind of DepChange is this? |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
781 |
virtual bool is_call_site_change() const { return true; } |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
782 |
|
36300
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
783 |
virtual void mark_for_deoptimization(nmethod* nm) { |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
784 |
nm->mark_for_deoptimization(/*inc_recompile_counts=*/false); |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
785 |
} |
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35499
diff
changeset
|
786 |
|
10265
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
787 |
oop call_site() const { return _call_site(); } |
4c869854aebd
7071653: JSR 292: call site change notification should be pushed not pulled
twisti
parents:
7397
diff
changeset
|
788 |
oop method_handle() const { return _method_handle(); } |
1 | 789 |
}; |
7397 | 790 |
|
791 |
#endif // SHARE_VM_CODE_DEPENDENCIES_HPP |