Skip to content

Commit 75bf106

Browse files
author
Harold Seigel
committed
8262028: Make InstanceKlass::implementor return InstanceKlass
Reviewed-by: coleenp, ccheung, vlivanov
1 parent fe8e370 commit 75bf106

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

src/hotspot/share/code/dependencies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(InstanceKlass* context_type,
13421342
return NULL; // no implementors
13431343
} else if (nof_impls == 1) { // unique implementor
13441344
assert(context_type != context_type->implementor(), "not unique");
1345-
context_type = InstanceKlass::cast(context_type->implementor());
1345+
context_type = context_type->implementor();
13461346
} else { // nof_impls >= 2
13471347
// Avoid this case: *I.m > { A.m, C }; B.m > C
13481348
// Here, I.m has 2 concrete implementations, but m appears unique

src/hotspot/share/oops/instanceKlass.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,37 +1223,37 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS)
12231223
}
12241224
}
12251225

1226-
Klass* InstanceKlass::implementor() const {
1227-
Klass* volatile* k = adr_implementor();
1228-
if (k == NULL) {
1226+
InstanceKlass* InstanceKlass::implementor() const {
1227+
InstanceKlass* volatile* ik = adr_implementor();
1228+
if (ik == NULL) {
12291229
return NULL;
12301230
} else {
12311231
// This load races with inserts, and therefore needs acquire.
1232-
Klass* kls = Atomic::load_acquire(k);
1233-
if (kls != NULL && !kls->is_loader_alive()) {
1232+
InstanceKlass* ikls = Atomic::load_acquire(ik);
1233+
if (ikls != NULL && !ikls->is_loader_alive()) {
12341234
return NULL; // don't return unloaded class
12351235
} else {
1236-
return kls;
1236+
return ikls;
12371237
}
12381238
}
12391239
}
12401240

12411241

1242-
void InstanceKlass::set_implementor(Klass* k) {
1242+
void InstanceKlass::set_implementor(InstanceKlass* ik) {
12431243
assert_locked_or_safepoint(Compile_lock);
12441244
assert(is_interface(), "not interface");
1245-
Klass* volatile* addr = adr_implementor();
1245+
InstanceKlass* volatile* addr = adr_implementor();
12461246
assert(addr != NULL, "null addr");
12471247
if (addr != NULL) {
1248-
Atomic::release_store(addr, k);
1248+
Atomic::release_store(addr, ik);
12491249
}
12501250
}
12511251

12521252
int InstanceKlass::nof_implementors() const {
1253-
Klass* k = implementor();
1254-
if (k == NULL) {
1253+
InstanceKlass* ik = implementor();
1254+
if (ik == NULL) {
12551255
return 0;
1256-
} else if (k != this) {
1256+
} else if (ik != this) {
12571257
return 1;
12581258
} else {
12591259
return 2;
@@ -1269,37 +1269,37 @@ int InstanceKlass::nof_implementors() const {
12691269
// self - more than one implementor
12701270
//
12711271
// The _implementor field only exists for interfaces.
1272-
void InstanceKlass::add_implementor(Klass* k) {
1272+
void InstanceKlass::add_implementor(InstanceKlass* ik) {
12731273
if (Universe::is_fully_initialized()) {
12741274
assert_lock_strong(Compile_lock);
12751275
}
12761276
assert(is_interface(), "not interface");
12771277
// Filter out my subinterfaces.
12781278
// (Note: Interfaces are never on the subklass list.)
1279-
if (InstanceKlass::cast(k)->is_interface()) return;
1279+
if (ik->is_interface()) return;
12801280

12811281
// Filter out subclasses whose supers already implement me.
12821282
// (Note: CHA must walk subclasses of direct implementors
12831283
// in order to locate indirect implementors.)
1284-
Klass* sk = k->super();
1285-
if (sk != NULL && InstanceKlass::cast(sk)->implements_interface(this))
1284+
InstanceKlass* super_ik = ik->java_super();
1285+
if (super_ik != NULL && super_ik->implements_interface(this))
12861286
// We only need to check one immediate superclass, since the
12871287
// implements_interface query looks at transitive_interfaces.
12881288
// Any supers of the super have the same (or fewer) transitive_interfaces.
12891289
return;
12901290

1291-
Klass* ik = implementor();
1292-
if (ik == NULL) {
1293-
set_implementor(k);
1294-
} else if (ik != this && ik != k) {
1291+
InstanceKlass* iklass = implementor();
1292+
if (iklass == NULL) {
1293+
set_implementor(ik);
1294+
} else if (iklass != this && iklass != ik) {
12951295
// There is already an implementor. Use itself as an indicator of
12961296
// more than one implementors.
12971297
set_implementor(this);
12981298
}
12991299

13001300
// The implementor also implements the transitive_interfaces
13011301
for (int index = 0; index < local_interfaces()->length(); index++) {
1302-
InstanceKlass::cast(local_interfaces()->at(index))->add_implementor(k);
1302+
local_interfaces()->at(index)->add_implementor(ik);
13031303
}
13041304
}
13051305

@@ -1314,7 +1314,7 @@ void InstanceKlass::process_interfaces() {
13141314
// link this class into the implementors list of every interface it implements
13151315
for (int i = local_interfaces()->length() - 1; i >= 0; i--) {
13161316
assert(local_interfaces()->at(i)->is_klass(), "must be a klass");
1317-
InstanceKlass* interf = InstanceKlass::cast(local_interfaces()->at(i));
1317+
InstanceKlass* interf = local_interfaces()->at(i);
13181318
assert(interf->is_interface(), "expected interface");
13191319
interf->add_implementor(this);
13201320
}
@@ -2344,11 +2344,11 @@ void InstanceKlass::clean_implementors_list() {
23442344
assert (ClassUnloading, "only called for ClassUnloading");
23452345
for (;;) {
23462346
// Use load_acquire due to competing with inserts
2347-
Klass* impl = Atomic::load_acquire(adr_implementor());
2347+
InstanceKlass* impl = Atomic::load_acquire(adr_implementor());
23482348
if (impl != NULL && !impl->is_loader_alive()) {
2349-
// NULL this field, might be an unloaded klass or NULL
2350-
Klass* volatile* klass = adr_implementor();
2351-
if (Atomic::cmpxchg(klass, impl, (Klass*)NULL) == impl) {
2349+
// NULL this field, might be an unloaded instance klass or NULL
2350+
InstanceKlass* volatile* iklass = adr_implementor();
2351+
if (Atomic::cmpxchg(iklass, impl, (InstanceKlass*)NULL) == impl) {
23522352
// Successfully unlinking implementor.
23532353
if (log_is_enabled(Trace, class, unload)) {
23542354
ResourceMark rm;

src/hotspot/share/oops/instanceKlass.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class InstanceKlass: public Klass {
327327
// embedded nonstatic oop-map blocks follows here
328328
// embedded implementor of this interface follows here
329329
// The embedded implementor only exists if the current klass is an
330-
// iterface. The possible values of the implementor fall into following
330+
// interface. The possible values of the implementor fall into following
331331
// three cases:
332332
// NULL: no implementor.
333333
// A Klass* that's not itself: one implementor.
@@ -1016,10 +1016,10 @@ class InstanceKlass: public Klass {
10161016
#endif
10171017

10181018
// Access to the implementor of an interface.
1019-
Klass* implementor() const;
1020-
void set_implementor(Klass* k);
1019+
InstanceKlass* implementor() const;
1020+
void set_implementor(InstanceKlass* ik);
10211021
int nof_implementors() const;
1022-
void add_implementor(Klass* k); // k is a new class that implements this interface
1022+
void add_implementor(InstanceKlass* ik); // ik is a new class that implements this interface
10231023
void init_implementor(); // initialize
10241024

10251025
// link this class into the implementors list of every interface it implements
@@ -1087,7 +1087,7 @@ class InstanceKlass: public Klass {
10871087
inline OopMapBlock* start_of_nonstatic_oop_maps() const;
10881088
inline Klass** end_of_nonstatic_oop_maps() const;
10891089

1090-
inline Klass* volatile* adr_implementor() const;
1090+
inline InstanceKlass* volatile* adr_implementor() const;
10911091
inline InstanceKlass** adr_unsafe_anonymous_host() const;
10921092
inline address adr_fingerprint() const;
10931093

src/hotspot/share/oops/instanceKlass.inline.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -74,9 +74,9 @@ inline Klass** InstanceKlass::end_of_nonstatic_oop_maps() const {
7474
nonstatic_oop_map_count());
7575
}
7676

77-
inline Klass* volatile* InstanceKlass::adr_implementor() const {
77+
inline InstanceKlass* volatile* InstanceKlass::adr_implementor() const {
7878
if (is_interface()) {
79-
return (Klass* volatile*)end_of_nonstatic_oop_maps();
79+
return (InstanceKlass* volatile*)end_of_nonstatic_oop_maps();
8080
} else {
8181
return NULL;
8282
}
@@ -102,7 +102,7 @@ inline address InstanceKlass::adr_fingerprint() const {
102102
return (address)(adr_host + 1);
103103
}
104104

105-
Klass* volatile* adr_impl = adr_implementor();
105+
InstanceKlass* volatile* adr_impl = adr_implementor();
106106
if (adr_impl != NULL) {
107107
return (address)(adr_impl + 1);
108108
}

0 commit comments

Comments
 (0)