Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/code/dependencies.hpp
32285 views
1
/*
2
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
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
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_VM_CODE_DEPENDENCIES_HPP
26
#define SHARE_VM_CODE_DEPENDENCIES_HPP
27
28
#include "ci/ciCallSite.hpp"
29
#include "ci/ciKlass.hpp"
30
#include "ci/ciMethodHandle.hpp"
31
#include "classfile/systemDictionary.hpp"
32
#include "code/compressedStream.hpp"
33
#include "code/nmethod.hpp"
34
#include "utilities/growableArray.hpp"
35
36
//** Dependencies represent assertions (approximate invariants) within
37
// the runtime system, e.g. class hierarchy changes. An example is an
38
// assertion that a given method is not overridden; another example is
39
// that a type has only one concrete subtype. Compiled code which
40
// relies on such assertions must be discarded if they are overturned
41
// by changes in the runtime system. We can think of these assertions
42
// as approximate invariants, because we expect them to be overturned
43
// very infrequently. We are willing to perform expensive recovery
44
// operations when they are overturned. The benefit, of course, is
45
// performing optimistic optimizations (!) on the object code.
46
//
47
// Changes in the class hierarchy due to dynamic linking or
48
// class evolution can violate dependencies. There is enough
49
// indexing between classes and nmethods to make dependency
50
// checking reasonably efficient.
51
52
class ciEnv;
53
class nmethod;
54
class OopRecorder;
55
class xmlStream;
56
class CompileLog;
57
class DepChange;
58
class KlassDepChange;
59
class CallSiteDepChange;
60
class No_Safepoint_Verifier;
61
62
class Dependencies: public ResourceObj {
63
public:
64
// Note: In the comments on dependency types, most uses of the terms
65
// subtype and supertype are used in a "non-strict" or "inclusive"
66
// sense, and are starred to remind the reader of this fact.
67
// Strict uses of the terms use the word "proper".
68
//
69
// Specifically, every class is its own subtype* and supertype*.
70
// (This trick is easier than continually saying things like "Y is a
71
// subtype of X or X itself".)
72
//
73
// Sometimes we write X > Y to mean X is a proper supertype of Y.
74
// The notation X > {Y, Z} means X has proper subtypes Y, Z.
75
// The notation X.m > Y means that Y inherits m from X, while
76
// X.m > Y.m means Y overrides X.m. A star denotes abstractness,
77
// as *I > A, meaning (abstract) interface I is a super type of A,
78
// or A.*m > B.m, meaning B.m implements abstract method A.m.
79
//
80
// In this module, the terms "subtype" and "supertype" refer to
81
// Java-level reference type conversions, as detected by
82
// "instanceof" and performed by "checkcast" operations. The method
83
// Klass::is_subtype_of tests these relations. Note that "subtype"
84
// is richer than "subclass" (as tested by Klass::is_subclass_of),
85
// since it takes account of relations involving interface and array
86
// types.
87
//
88
// To avoid needless complexity, dependencies involving array types
89
// are not accepted. If you need to make an assertion about an
90
// array type, make the assertion about its corresponding element
91
// types. Any assertion that might change about an array type can
92
// be converted to an assertion about its element type.
93
//
94
// Most dependencies are evaluated over a "context type" CX, which
95
// stands for the set Subtypes(CX) of every Java type that is a subtype*
96
// of CX. When the system loads a new class or interface N, it is
97
// responsible for re-evaluating changed dependencies whose context
98
// type now includes N, that is, all super types of N.
99
//
100
enum DepType {
101
end_marker = 0,
102
103
// An 'evol' dependency simply notes that the contents of the
104
// method were used. If it evolves (is replaced), the nmethod
105
// must be recompiled. No other dependencies are implied.
106
evol_method,
107
FIRST_TYPE = evol_method,
108
109
// A context type CX is a leaf it if has no proper subtype.
110
leaf_type,
111
112
// An abstract class CX has exactly one concrete subtype CC.
113
abstract_with_unique_concrete_subtype,
114
115
// The type CX is purely abstract, with no concrete subtype* at all.
116
abstract_with_no_concrete_subtype,
117
118
// The concrete CX is free of concrete proper subtypes.
119
concrete_with_no_concrete_subtype,
120
121
// Given a method M1 and a context class CX, the set MM(CX, M1) of
122
// "concrete matching methods" in CX of M1 is the set of every
123
// concrete M2 for which it is possible to create an invokevirtual
124
// or invokeinterface call site that can reach either M1 or M2.
125
// That is, M1 and M2 share a name, signature, and vtable index.
126
// We wish to notice when the set MM(CX, M1) is just {M1}, or
127
// perhaps a set of two {M1,M2}, and issue dependencies on this.
128
129
// The set MM(CX, M1) can be computed by starting with any matching
130
// concrete M2 that is inherited into CX, and then walking the
131
// subtypes* of CX looking for concrete definitions.
132
133
// The parameters to this dependency are the method M1 and the
134
// context class CX. M1 must be either inherited in CX or defined
135
// in a subtype* of CX. It asserts that MM(CX, M1) is no greater
136
// than {M1}.
137
unique_concrete_method, // one unique concrete method under CX
138
139
// An "exclusive" assertion concerns two methods or subtypes, and
140
// declares that there are at most two (or perhaps later N>2)
141
// specific items that jointly satisfy the restriction.
142
// We list all items explicitly rather than just giving their
143
// count, for robustness in the face of complex schema changes.
144
145
// A context class CX (which may be either abstract or concrete)
146
// has two exclusive concrete subtypes* C1, C2 if every concrete
147
// subtype* of CX is either C1 or C2. Note that if neither C1 or C2
148
// are equal to CX, then CX itself must be abstract. But it is
149
// also possible (for example) that C1 is CX (a concrete class)
150
// and C2 is a proper subtype of C1.
151
abstract_with_exclusive_concrete_subtypes_2,
152
153
// This dependency asserts that MM(CX, M1) is no greater than {M1,M2}.
154
exclusive_concrete_methods_2,
155
156
// This dependency asserts that no instances of class or it's
157
// subclasses require finalization registration.
158
no_finalizable_subclasses,
159
160
// This dependency asserts when the CallSite.target value changed.
161
call_site_target_value,
162
163
TYPE_LIMIT
164
};
165
enum {
166
LG2_TYPE_LIMIT = 4, // assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT))
167
168
// handy categorizations of dependency types:
169
all_types = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
170
171
non_klass_types = (1 << call_site_target_value),
172
klass_types = all_types & ~non_klass_types,
173
174
non_ctxk_types = (1 << evol_method),
175
implicit_ctxk_types = (1 << call_site_target_value),
176
explicit_ctxk_types = all_types & ~(non_ctxk_types | implicit_ctxk_types),
177
178
max_arg_count = 3, // current maximum number of arguments (incl. ctxk)
179
180
// A "context type" is a class or interface that
181
// provides context for evaluating a dependency.
182
// When present, it is one of the arguments (dep_context_arg).
183
//
184
// If a dependency does not have a context type, there is a
185
// default context, depending on the type of the dependency.
186
// This bit signals that a default context has been compressed away.
187
default_context_type_bit = (1<<LG2_TYPE_LIMIT)
188
};
189
190
static const char* dep_name(DepType dept);
191
static int dep_args(DepType dept);
192
193
static bool is_klass_type( DepType dept) { return dept_in_mask(dept, klass_types ); }
194
195
static bool has_explicit_context_arg(DepType dept) { return dept_in_mask(dept, explicit_ctxk_types); }
196
static bool has_implicit_context_arg(DepType dept) { return dept_in_mask(dept, implicit_ctxk_types); }
197
198
static int dep_context_arg(DepType dept) { return has_explicit_context_arg(dept) ? 0 : -1; }
199
static int dep_implicit_context_arg(DepType dept) { return has_implicit_context_arg(dept) ? 0 : -1; }
200
201
static void check_valid_dependency_type(DepType dept);
202
203
private:
204
// State for writing a new set of dependencies:
205
GrowableArray<int>* _dep_seen; // (seen[h->ident] & (1<<dept))
206
GrowableArray<ciBaseObject*>* _deps[TYPE_LIMIT];
207
208
static const char* _dep_name[TYPE_LIMIT];
209
static int _dep_args[TYPE_LIMIT];
210
211
static bool dept_in_mask(DepType dept, int mask) {
212
return (int)dept >= 0 && dept < TYPE_LIMIT && ((1<<dept) & mask) != 0;
213
}
214
215
bool note_dep_seen(int dept, ciBaseObject* x) {
216
assert(dept < BitsPerInt, "oob");
217
int x_id = x->ident();
218
assert(_dep_seen != NULL, "deps must be writable");
219
int seen = _dep_seen->at_grow(x_id, 0);
220
_dep_seen->at_put(x_id, seen | (1<<dept));
221
// return true if we've already seen dept/x
222
return (seen & (1<<dept)) != 0;
223
}
224
225
bool maybe_merge_ctxk(GrowableArray<ciBaseObject*>* deps,
226
int ctxk_i, ciKlass* ctxk);
227
228
void sort_all_deps();
229
size_t estimate_size_in_bytes();
230
231
// Initialize _deps, etc.
232
void initialize(ciEnv* env);
233
234
// State for making a new set of dependencies:
235
OopRecorder* _oop_recorder;
236
237
// Logging support
238
CompileLog* _log;
239
240
address _content_bytes; // everything but the oop references, encoded
241
size_t _size_in_bytes;
242
243
public:
244
// Make a new empty dependencies set.
245
Dependencies(ciEnv* env) {
246
initialize(env);
247
}
248
249
private:
250
// Check for a valid context type.
251
// Enforce the restriction against array types.
252
static void check_ctxk(ciKlass* ctxk) {
253
assert(ctxk->is_instance_klass(), "java types only");
254
}
255
static void check_ctxk_concrete(ciKlass* ctxk) {
256
assert(is_concrete_klass(ctxk->as_instance_klass()), "must be concrete");
257
}
258
static void check_ctxk_abstract(ciKlass* ctxk) {
259
check_ctxk(ctxk);
260
assert(!is_concrete_klass(ctxk->as_instance_klass()), "must be abstract");
261
}
262
263
void assert_common_1(DepType dept, ciBaseObject* x);
264
void assert_common_2(DepType dept, ciBaseObject* x0, ciBaseObject* x1);
265
void assert_common_3(DepType dept, ciKlass* ctxk, ciBaseObject* x1, ciBaseObject* x2);
266
267
public:
268
// Adding assertions to a new dependency set at compile time:
269
void assert_evol_method(ciMethod* m);
270
void assert_leaf_type(ciKlass* ctxk);
271
void assert_abstract_with_unique_concrete_subtype(ciKlass* ctxk, ciKlass* conck);
272
void assert_abstract_with_no_concrete_subtype(ciKlass* ctxk);
273
void assert_concrete_with_no_concrete_subtype(ciKlass* ctxk);
274
void assert_unique_concrete_method(ciKlass* ctxk, ciMethod* uniqm);
275
void assert_abstract_with_exclusive_concrete_subtypes(ciKlass* ctxk, ciKlass* k1, ciKlass* k2);
276
void assert_exclusive_concrete_methods(ciKlass* ctxk, ciMethod* m1, ciMethod* m2);
277
void assert_has_no_finalizable_subclasses(ciKlass* ctxk);
278
void assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle);
279
280
// Define whether a given method or type is concrete.
281
// These methods define the term "concrete" as used in this module.
282
// For this module, an "abstract" class is one which is non-concrete.
283
//
284
// Future optimizations may allow some classes to remain
285
// non-concrete until their first instantiation, and allow some
286
// methods to remain non-concrete until their first invocation.
287
// In that case, there would be a middle ground between concrete
288
// and abstract (as defined by the Java language and VM).
289
static bool is_concrete_klass(Klass* k); // k is instantiable
290
static bool is_concrete_method(Method* m, Klass* k); // m is invocable
291
static Klass* find_finalizable_subclass(Klass* k);
292
293
// These versions of the concreteness queries work through the CI.
294
// The CI versions are allowed to skew sometimes from the VM
295
// (oop-based) versions. The cost of such a difference is a
296
// (safely) aborted compilation, or a deoptimization, or a missed
297
// optimization opportunity.
298
//
299
// In order to prevent spurious assertions, query results must
300
// remain stable within any single ciEnv instance. (I.e., they must
301
// not go back into the VM to get their value; they must cache the
302
// bit in the CI, either eagerly or lazily.)
303
static bool is_concrete_klass(ciInstanceKlass* k); // k appears instantiable
304
static bool has_finalizable_subclass(ciInstanceKlass* k);
305
306
// As a general rule, it is OK to compile under the assumption that
307
// a given type or method is concrete, even if it at some future
308
// point becomes abstract. So dependency checking is one-sided, in
309
// that it permits supposedly concrete classes or methods to turn up
310
// as really abstract. (This shouldn't happen, except during class
311
// evolution, but that's the logic of the checking.) However, if a
312
// supposedly abstract class or method suddenly becomes concrete, a
313
// dependency on it must fail.
314
315
// Checking old assertions at run-time (in the VM only):
316
static Klass* check_evol_method(Method* m);
317
static Klass* check_leaf_type(Klass* ctxk);
318
static Klass* check_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck,
319
KlassDepChange* changes = NULL);
320
static Klass* check_abstract_with_no_concrete_subtype(Klass* ctxk,
321
KlassDepChange* changes = NULL);
322
static Klass* check_concrete_with_no_concrete_subtype(Klass* ctxk,
323
KlassDepChange* changes = NULL);
324
static Klass* check_unique_concrete_method(Klass* ctxk, Method* uniqm,
325
KlassDepChange* changes = NULL);
326
static Klass* check_abstract_with_exclusive_concrete_subtypes(Klass* ctxk, Klass* k1, Klass* k2,
327
KlassDepChange* changes = NULL);
328
static Klass* check_exclusive_concrete_methods(Klass* ctxk, Method* m1, Method* m2,
329
KlassDepChange* changes = NULL);
330
static Klass* check_has_no_finalizable_subclasses(Klass* ctxk, KlassDepChange* changes = NULL);
331
static Klass* check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes = NULL);
332
// A returned Klass* is NULL if the dependency assertion is still
333
// valid. A non-NULL Klass* is a 'witness' to the assertion
334
// failure, a point in the class hierarchy where the assertion has
335
// been proven false. For example, if check_leaf_type returns
336
// non-NULL, the value is a subtype of the supposed leaf type. This
337
// witness value may be useful for logging the dependency failure.
338
// Note that, when a dependency fails, there may be several possible
339
// witnesses to the failure. The value returned from the check_foo
340
// method is chosen arbitrarily.
341
342
// The 'changes' value, if non-null, requests a limited spot-check
343
// near the indicated recent changes in the class hierarchy.
344
// It is used by DepStream::spot_check_dependency_at.
345
346
// Detecting possible new assertions:
347
static Klass* find_unique_concrete_subtype(Klass* ctxk);
348
static Method* find_unique_concrete_method(Klass* ctxk, Method* m);
349
static int find_exclusive_concrete_subtypes(Klass* ctxk, int klen, Klass* k[]);
350
351
// Create the encoding which will be stored in an nmethod.
352
void encode_content_bytes();
353
354
address content_bytes() {
355
assert(_content_bytes != NULL, "encode it first");
356
return _content_bytes;
357
}
358
size_t size_in_bytes() {
359
assert(_content_bytes != NULL, "encode it first");
360
return _size_in_bytes;
361
}
362
363
OopRecorder* oop_recorder() { return _oop_recorder; }
364
CompileLog* log() { return _log; }
365
366
void copy_to(nmethod* nm);
367
368
void log_all_dependencies();
369
370
void log_dependency(DepType dept, GrowableArray<ciBaseObject*>* args) {
371
ResourceMark rm;
372
int argslen = args->length();
373
write_dependency_to(log(), dept, args);
374
guarantee(argslen == args->length(),
375
"args array cannot grow inside nested ResoureMark scope");
376
}
377
378
void log_dependency(DepType dept,
379
ciBaseObject* x0,
380
ciBaseObject* x1 = NULL,
381
ciBaseObject* x2 = NULL) {
382
if (log() == NULL) {
383
return;
384
}
385
ResourceMark rm;
386
GrowableArray<ciBaseObject*>* ciargs =
387
new GrowableArray<ciBaseObject*>(dep_args(dept));
388
assert (x0 != NULL, "no log x0");
389
ciargs->push(x0);
390
391
if (x1 != NULL) {
392
ciargs->push(x1);
393
}
394
if (x2 != NULL) {
395
ciargs->push(x2);
396
}
397
assert(ciargs->length() == dep_args(dept), "");
398
log_dependency(dept, ciargs);
399
}
400
401
class DepArgument : public ResourceObj {
402
private:
403
bool _is_oop;
404
bool _valid;
405
void* _value;
406
public:
407
DepArgument() : _is_oop(false), _value(NULL), _valid(false) {}
408
DepArgument(oop v): _is_oop(true), _value(v), _valid(true) {}
409
DepArgument(Metadata* v): _is_oop(false), _value(v), _valid(true) {}
410
411
bool is_null() const { return _value == NULL; }
412
bool is_oop() const { return _is_oop; }
413
bool is_metadata() const { return !_is_oop; }
414
bool is_klass() const { return is_metadata() && metadata_value()->is_klass(); }
415
bool is_method() const { return is_metadata() && metadata_value()->is_method(); }
416
417
oop oop_value() const { assert(_is_oop && _valid, "must be"); return (oop) _value; }
418
Metadata* metadata_value() const { assert(!_is_oop && _valid, "must be"); return (Metadata*) _value; }
419
};
420
421
static void print_dependency(DepType dept,
422
GrowableArray<DepArgument>* args,
423
Klass* witness = NULL);
424
425
private:
426
// helper for encoding common context types as zero:
427
static ciKlass* ctxk_encoded_as_null(DepType dept, ciBaseObject* x);
428
429
static Klass* ctxk_encoded_as_null(DepType dept, Metadata* x);
430
431
static void write_dependency_to(CompileLog* log,
432
DepType dept,
433
GrowableArray<ciBaseObject*>* args,
434
Klass* witness = NULL);
435
static void write_dependency_to(CompileLog* log,
436
DepType dept,
437
GrowableArray<DepArgument>* args,
438
Klass* witness = NULL);
439
static void write_dependency_to(xmlStream* xtty,
440
DepType dept,
441
GrowableArray<DepArgument>* args,
442
Klass* witness = NULL);
443
public:
444
// Use this to iterate over an nmethod's dependency set.
445
// Works on new and old dependency sets.
446
// Usage:
447
//
448
// ;
449
// Dependencies::DepType dept;
450
// for (Dependencies::DepStream deps(nm); deps.next(); ) {
451
// ...
452
// }
453
//
454
// The caller must be in the VM, since oops are not wrapped in handles.
455
class DepStream {
456
private:
457
nmethod* _code; // null if in a compiler thread
458
Dependencies* _deps; // null if not in a compiler thread
459
CompressedReadStream _bytes;
460
#ifdef ASSERT
461
size_t _byte_limit;
462
#endif
463
464
// iteration variables:
465
DepType _type;
466
int _xi[max_arg_count+1];
467
468
void initial_asserts(size_t byte_limit) NOT_DEBUG({});
469
470
inline Metadata* recorded_metadata_at(int i);
471
inline oop recorded_oop_at(int i);
472
473
Klass* check_klass_dependency(KlassDepChange* changes);
474
Klass* check_call_site_dependency(CallSiteDepChange* changes);
475
476
void trace_and_log_witness(Klass* witness);
477
478
public:
479
DepStream(Dependencies* deps)
480
: _deps(deps),
481
_code(NULL),
482
_bytes(deps->content_bytes())
483
{
484
initial_asserts(deps->size_in_bytes());
485
}
486
DepStream(nmethod* code)
487
: _deps(NULL),
488
_code(code),
489
_bytes(code->dependencies_begin())
490
{
491
initial_asserts(code->dependencies_size());
492
}
493
494
bool next();
495
496
DepType type() { return _type; }
497
int argument_count() { return dep_args(type()); }
498
int argument_index(int i) { assert(0 <= i && i < argument_count(), "oob");
499
return _xi[i]; }
500
Metadata* argument(int i); // => recorded_oop_at(argument_index(i))
501
oop argument_oop(int i); // => recorded_oop_at(argument_index(i))
502
Klass* context_type();
503
504
bool is_klass_type() { return Dependencies::is_klass_type(type()); }
505
506
Method* method_argument(int i) {
507
Metadata* x = argument(i);
508
assert(x->is_method(), "type");
509
return (Method*) x;
510
}
511
Klass* type_argument(int i) {
512
Metadata* x = argument(i);
513
assert(x->is_klass(), "type");
514
return (Klass*) x;
515
}
516
517
// The point of the whole exercise: Is this dep still OK?
518
Klass* check_dependency() {
519
Klass* result = check_klass_dependency(NULL);
520
if (result != NULL) return result;
521
return check_call_site_dependency(NULL);
522
}
523
524
// A lighter version: Checks only around recent changes in a class
525
// hierarchy. (See Universe::flush_dependents_on.)
526
Klass* spot_check_dependency_at(DepChange& changes);
527
528
// Log the current dependency to xtty or compilation log.
529
void log_dependency(Klass* witness = NULL);
530
531
// Print the current dependency to tty.
532
void print_dependency(Klass* witness = NULL, bool verbose = false);
533
};
534
friend class Dependencies::DepStream;
535
536
static void print_statistics() PRODUCT_RETURN;
537
};
538
539
540
// Every particular DepChange is a sub-class of this class.
541
class DepChange : public StackObj {
542
public:
543
// What kind of DepChange is this?
544
virtual bool is_klass_change() const { return false; }
545
virtual bool is_call_site_change() const { return false; }
546
547
// Subclass casting with assertions.
548
KlassDepChange* as_klass_change() {
549
assert(is_klass_change(), "bad cast");
550
return (KlassDepChange*) this;
551
}
552
CallSiteDepChange* as_call_site_change() {
553
assert(is_call_site_change(), "bad cast");
554
return (CallSiteDepChange*) this;
555
}
556
557
void print();
558
559
public:
560
enum ChangeType {
561
NO_CHANGE = 0, // an uninvolved klass
562
Change_new_type, // a newly loaded type
563
Change_new_sub, // a super with a new subtype
564
Change_new_impl, // an interface with a new implementation
565
CHANGE_LIMIT,
566
Start_Klass = CHANGE_LIMIT // internal indicator for ContextStream
567
};
568
569
// Usage:
570
// for (DepChange::ContextStream str(changes); str.next(); ) {
571
// Klass* k = str.klass();
572
// switch (str.change_type()) {
573
// ...
574
// }
575
// }
576
class ContextStream : public StackObj {
577
private:
578
DepChange& _changes;
579
friend class DepChange;
580
581
// iteration variables:
582
ChangeType _change_type;
583
Klass* _klass;
584
Array<Klass*>* _ti_base; // i.e., transitive_interfaces
585
int _ti_index;
586
int _ti_limit;
587
588
// start at the beginning:
589
void start();
590
591
public:
592
ContextStream(DepChange& changes)
593
: _changes(changes)
594
{ start(); }
595
596
ContextStream(DepChange& changes, No_Safepoint_Verifier& nsv)
597
: _changes(changes)
598
// the nsv argument makes it safe to hold oops like _klass
599
{ start(); }
600
601
bool next();
602
603
ChangeType change_type() { return _change_type; }
604
Klass* klass() { return _klass; }
605
};
606
friend class DepChange::ContextStream;
607
};
608
609
610
// A class hierarchy change coming through the VM (under the Compile_lock).
611
// The change is structured as a single new type with any number of supers
612
// and implemented interface types. Other than the new type, any of the
613
// super types can be context types for a relevant dependency, which the
614
// new type could invalidate.
615
class KlassDepChange : public DepChange {
616
private:
617
// each change set is rooted in exactly one new type (at present):
618
KlassHandle _new_type;
619
620
void initialize();
621
622
public:
623
// notes the new type, marks it and all its super-types
624
KlassDepChange(KlassHandle new_type)
625
: _new_type(new_type)
626
{
627
initialize();
628
}
629
630
// cleans up the marks
631
~KlassDepChange();
632
633
// What kind of DepChange is this?
634
virtual bool is_klass_change() const { return true; }
635
636
Klass* new_type() { return _new_type(); }
637
638
// involves_context(k) is true if k is new_type or any of the super types
639
bool involves_context(Klass* k);
640
};
641
642
643
// A CallSite has changed its target.
644
class CallSiteDepChange : public DepChange {
645
private:
646
Handle _call_site;
647
Handle _method_handle;
648
649
public:
650
CallSiteDepChange(Handle call_site, Handle method_handle)
651
: _call_site(call_site),
652
_method_handle(method_handle)
653
{
654
assert(_call_site() ->is_a(SystemDictionary::CallSite_klass()), "must be");
655
assert(_method_handle()->is_a(SystemDictionary::MethodHandle_klass()), "must be");
656
}
657
658
// What kind of DepChange is this?
659
virtual bool is_call_site_change() const { return true; }
660
661
oop call_site() const { return _call_site(); }
662
oop method_handle() const { return _method_handle(); }
663
};
664
665
#endif // SHARE_VM_CODE_DEPENDENCIES_HPP
666
667