Skip to content

Commit 55aa122

Browse files
committed
8304059: Use InstanceKlass in dependencies
Reviewed-by: vlivanov, thartmann
1 parent ec1eb00 commit 55aa122

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

src/hotspot/share/code/codeCache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,8 @@ void CodeCache::mark_for_deoptimization(DeoptimizationScope* deopt_scope, KlassD
12551255
// can happen
12561256
NoSafepointVerifier nsv;
12571257
for (DepChange::ContextStream str(changes, nsv); str.next(); ) {
1258-
Klass* d = str.klass();
1259-
InstanceKlass::cast(d)->mark_dependent_nmethods(deopt_scope, changes);
1258+
InstanceKlass* d = str.klass();
1259+
d->mark_dependent_nmethods(deopt_scope, changes);
12601260
}
12611261

12621262
#ifndef PRODUCT

src/hotspot/share/code/dependencies.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ Klass* AbstractClassHierarchyWalker::find_witness(InstanceKlass* context_type, K
11661166
return nullptr; // no implementors
11671167
} else if (nof_impls == 1) { // unique implementor
11681168
assert(context_type != context_type->implementor(), "not unique");
1169-
context_type = InstanceKlass::cast(context_type->implementor());
1169+
context_type = context_type->implementor();
11701170
} else { // nof_impls >= 2
11711171
// Avoid this case: *I.m > { A.m, C }; B.m > C
11721172
// Here, I.m has 2 concrete implementations, but m appears unique
@@ -1597,10 +1597,9 @@ bool Dependencies::verify_method_context(InstanceKlass* ctxk, Method* m) {
15971597
return true; // Must punt the assertion to true.
15981598
}
15991599
Method* lm = ctxk->lookup_method(m->name(), m->signature());
1600-
if (lm == nullptr && ctxk->is_instance_klass()) {
1600+
if (lm == nullptr) {
16011601
// It might be an interface method
1602-
lm = InstanceKlass::cast(ctxk)->lookup_method_in_ordered_interfaces(m->name(),
1603-
m->signature());
1602+
lm = ctxk->lookup_method_in_ordered_interfaces(m->name(), m->signature());
16041603
}
16051604
if (lm == m) {
16061605
// Method m is inherited into ctxk.
@@ -2174,7 +2173,7 @@ Klass* Dependencies::DepStream::spot_check_dependency_at(DepChange& changes) {
21742173
void DepChange::print() {
21752174
int nsup = 0, nint = 0;
21762175
for (ContextStream str(*this); str.next(); ) {
2177-
Klass* k = str.klass();
2176+
InstanceKlass* k = str.klass();
21782177
switch (str.change_type()) {
21792178
case Change_new_type:
21802179
tty->print_cr(" dependee = %s", k->external_name());
@@ -2203,7 +2202,7 @@ void DepChange::print() {
22032202
}
22042203

22052204
void DepChange::ContextStream::start() {
2206-
Klass* type = (_changes.is_klass_change() ? _changes.as_klass_change()->type() : (Klass*) nullptr);
2205+
InstanceKlass* type = (_changes.is_klass_change() ? _changes.as_klass_change()->type() : (InstanceKlass*) nullptr);
22072206
_change_type = (type == nullptr ? NO_CHANGE : Start_Klass);
22082207
_klass = type;
22092208
_ti_base = nullptr;
@@ -2214,7 +2213,7 @@ void DepChange::ContextStream::start() {
22142213
bool DepChange::ContextStream::next() {
22152214
switch (_change_type) {
22162215
case Start_Klass: // initial state; _klass is the new type
2217-
_ti_base = InstanceKlass::cast(_klass)->transitive_interfaces();
2216+
_ti_base = _klass->transitive_interfaces();
22182217
_ti_index = 0;
22192218
_change_type = Change_new_type;
22202219
return true;
@@ -2224,7 +2223,7 @@ bool DepChange::ContextStream::next() {
22242223
case Change_new_sub:
22252224
// 6598190: brackets workaround Sun Studio C++ compiler bug 6629277
22262225
{
2227-
_klass = _klass->super();
2226+
_klass = _klass->java_super();
22282227
if (_klass != nullptr) {
22292228
return true;
22302229
}
@@ -2254,18 +2253,18 @@ void KlassDepChange::initialize() {
22542253
// Mark all dependee and all its superclasses
22552254
// Mark transitive interfaces
22562255
for (ContextStream str(*this); str.next(); ) {
2257-
Klass* d = str.klass();
2258-
assert(!InstanceKlass::cast(d)->is_marked_dependent(), "checking");
2259-
InstanceKlass::cast(d)->set_is_marked_dependent(true);
2256+
InstanceKlass* d = str.klass();
2257+
assert(!d->is_marked_dependent(), "checking");
2258+
d->set_is_marked_dependent(true);
22602259
}
22612260
}
22622261

22632262
KlassDepChange::~KlassDepChange() {
22642263
// Unmark all dependee and all its superclasses
22652264
// Unmark transitive interfaces
22662265
for (ContextStream str(*this); str.next(); ) {
2267-
Klass* d = str.klass();
2268-
InstanceKlass::cast(d)->set_is_marked_dependent(false);
2266+
InstanceKlass* d = str.klass();
2267+
d->set_is_marked_dependent(false);
22692268
}
22702269
}
22712270

src/hotspot/share/code/dependencies.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ class DepChange : public StackObj {
714714

715715
// Usage:
716716
// for (DepChange::ContextStream str(changes); str.next(); ) {
717-
// Klass* k = str.klass();
717+
// InstanceKlass* k = str.klass();
718718
// switch (str.change_type()) {
719719
// ...
720720
// }
@@ -725,8 +725,8 @@ class DepChange : public StackObj {
725725
friend class DepChange;
726726

727727
// iteration variables:
728-
ChangeType _change_type;
729-
Klass* _klass;
728+
ChangeType _change_type;
729+
InstanceKlass* _klass;
730730
Array<InstanceKlass*>* _ti_base; // i.e., transitive_interfaces
731731
int _ti_index;
732732
int _ti_limit;
@@ -747,7 +747,7 @@ class DepChange : public StackObj {
747747
bool next();
748748

749749
ChangeType change_type() { return _change_type; }
750-
Klass* klass() { return _klass; }
750+
InstanceKlass* klass() { return _klass; }
751751
};
752752
friend class DepChange::ContextStream;
753753
};

src/hotspot/share/code/nmethod.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,12 @@ nmethod* nmethod::new_nmethod(const methodHandle& method,
613613
oop call_site = deps.argument_oop(0);
614614
MethodHandles::add_dependent_nmethod(call_site, nm);
615615
} else {
616-
Klass* klass = deps.context_type();
617-
if (klass == nullptr) {
616+
InstanceKlass* ik = deps.context_type();
617+
if (ik == nullptr) {
618618
continue; // ignore things like evol_method
619619
}
620620
// record this nmethod as dependent on this klass
621-
InstanceKlass::cast(klass)->add_dependent_nmethod(nm);
621+
ik->add_dependent_nmethod(nm);
622622
}
623623
}
624624
NOT_PRODUCT(if (nm != nullptr) note_java_nmethod(nm));
@@ -1496,13 +1496,13 @@ void nmethod::flush_dependencies() {
14961496
oop call_site = deps.argument_oop(0);
14971497
MethodHandles::clean_dependency_context(call_site);
14981498
} else {
1499-
Klass* klass = deps.context_type();
1500-
if (klass == nullptr) {
1499+
InstanceKlass* ik = deps.context_type();
1500+
if (ik == nullptr) {
15011501
continue; // ignore things like evol_method
15021502
}
15031503
// During GC liveness of dependee determines class that needs to be updated.
15041504
// The GC may clean dependency contexts concurrently and in parallel.
1505-
InstanceKlass::cast(klass)->clean_dependency_context();
1505+
ik->clean_dependency_context();
15061506
}
15071507
}
15081508
}
@@ -2487,9 +2487,9 @@ void nmethod::print_dependencies() {
24872487
tty->print_cr("Dependencies:");
24882488
for (Dependencies::DepStream deps(this); deps.next(); ) {
24892489
deps.print_dependency();
2490-
Klass* ctxk = deps.context_type();
2490+
InstanceKlass* ctxk = deps.context_type();
24912491
if (ctxk != nullptr) {
2492-
if (ctxk->is_instance_klass() && InstanceKlass::cast(ctxk)->is_dependent_nmethod(this)) {
2492+
if (ctxk->is_dependent_nmethod(this)) {
24932493
tty->print_cr(" [nmethod<=klass]%s", ctxk->external_name());
24942494
}
24952495
}

0 commit comments

Comments
 (0)