Skip to content

Commit 80681b5

Browse files
author
Vladimir Ivanov
committed
8264546: Dependencies: Context class is always an InstanceKlass
Reviewed-by: kvn
1 parent fdfa1dd commit 80681b5

File tree

4 files changed

+27
-32
lines changed

4 files changed

+27
-32
lines changed

src/hotspot/share/ci/ciMethod.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,8 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
709709
methodHandle target;
710710
{
711711
MutexLocker locker(Compile_lock);
712-
Klass* context = actual_recv->get_Klass();
713-
target = methodHandle(THREAD, Dependencies::find_unique_concrete_method(context,
714-
root_m->get_Method()));
712+
InstanceKlass* context = actual_recv->get_instanceKlass();
713+
target = methodHandle(THREAD, Dependencies::find_unique_concrete_method(context, root_m->get_Method()));
715714
// %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods.
716715
}
717716

src/hotspot/share/code/dependencies.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ oop Dependencies::DepStream::argument_oop(int i) {
908908
return result;
909909
}
910910

911-
Klass* Dependencies::DepStream::context_type() {
911+
InstanceKlass* Dependencies::DepStream::context_type() {
912912
assert(must_be_in_vm(), "raw oops here");
913913

914914
// Most dependencies have an explicit context type argument.
@@ -917,7 +917,7 @@ Klass* Dependencies::DepStream::context_type() {
917917
if (ctxkj >= 0) {
918918
Metadata* k = argument(ctxkj);
919919
assert(k != NULL && k->is_klass(), "type check");
920-
return (Klass*)k;
920+
return InstanceKlass::cast((Klass*)k);
921921
}
922922
}
923923

@@ -927,8 +927,8 @@ Klass* Dependencies::DepStream::context_type() {
927927
int ctxkj = dep_implicit_context_arg(type());
928928
if (ctxkj >= 0) {
929929
Klass* k = argument_oop(ctxkj)->klass();
930-
assert(k != NULL && k->is_klass(), "type check");
931-
return (Klass*) k;
930+
assert(k != NULL, "type check");
931+
return InstanceKlass::cast(k);
932932
}
933933
}
934934

@@ -1051,7 +1051,7 @@ class ClassHierarchyWalker {
10511051
#ifdef ASSERT
10521052
// Assert that m is inherited into ctxk, without intervening overrides.
10531053
// (May return true even if this is not true, in corner cases where we punt.)
1054-
bool check_method_context(Klass* ctxk, Method* m) {
1054+
bool check_method_context(InstanceKlass* ctxk, Method* m) {
10551055
if (m->method_holder() == ctxk)
10561056
return true; // Quick win.
10571057
if (m->is_private())
@@ -1169,6 +1169,7 @@ class ClassHierarchyWalker {
11691169
return in_list(k, &_participants[1]);
11701170
}
11711171
}
1172+
11721173
bool ignore_witness(Klass* witness) {
11731174
if (_record_witnesses == 0) {
11741175
return false;
@@ -1196,10 +1197,8 @@ class ClassHierarchyWalker {
11961197
InstanceKlass* context_type,
11971198
bool participants_hide_witnesses);
11981199
public:
1199-
Klass* find_witness_subtype(Klass* k, KlassDepChange* changes = NULL) {
1200+
Klass* find_witness_subtype(InstanceKlass* context_type, KlassDepChange* changes = NULL) {
12001201
assert(doing_subtype_search(), "must set up a subtype search");
1201-
assert(k->is_instance_klass(), "required");
1202-
InstanceKlass* context_type = InstanceKlass::cast(k);
12031202
// When looking for unexpected concrete types,
12041203
// do not look beneath expected ones.
12051204
const bool participants_hide_witnesses = true;
@@ -1211,10 +1210,8 @@ class ClassHierarchyWalker {
12111210
return find_witness_anywhere(context_type, participants_hide_witnesses);
12121211
}
12131212
}
1214-
Klass* find_witness_definer(Klass* k, KlassDepChange* changes = NULL) {
1213+
Klass* find_witness_definer(InstanceKlass* context_type, KlassDepChange* changes = NULL) {
12151214
assert(!doing_subtype_search(), "must set up a method definer search");
1216-
assert(k->is_instance_klass(), "required");
1217-
InstanceKlass* context_type = InstanceKlass::cast(k);
12181215
// When looking for unexpected concrete methods,
12191216
// look beneath expected ones, to see if there are overrides.
12201217
const bool participants_hide_witnesses = true;
@@ -1448,17 +1445,16 @@ Klass* Dependencies::check_evol_method(Method* m) {
14481445
// can be optimized more strongly than this, because we
14491446
// know that the checked type comes from a concrete type,
14501447
// and therefore we can disregard abstract types.)
1451-
Klass* Dependencies::check_leaf_type(Klass* ctxk) {
1448+
Klass* Dependencies::check_leaf_type(InstanceKlass* ctxk) {
14521449
assert(must_be_in_vm(), "raw oops here");
14531450
assert_locked_or_safepoint(Compile_lock);
1454-
InstanceKlass* ctx = InstanceKlass::cast(ctxk);
1455-
Klass* sub = ctx->subklass();
1451+
Klass* sub = ctxk->subklass();
14561452
if (sub != NULL) {
14571453
return sub;
1458-
} else if (ctx->nof_implementors() != 0) {
1454+
} else if (ctxk->nof_implementors() != 0) {
14591455
// if it is an interface, it must be unimplemented
14601456
// (if it is not an interface, nof_implementors is always zero)
1461-
Klass* impl = ctx->implementor();
1457+
InstanceKlass* impl = ctxk->implementor();
14621458
assert(impl != NULL, "must be set");
14631459
return impl;
14641460
} else {
@@ -1470,7 +1466,7 @@ Klass* Dependencies::check_leaf_type(Klass* ctxk) {
14701466
// The type conck itself is allowed to have have further concrete subtypes.
14711467
// This allows the compiler to narrow occurrences of ctxk by conck,
14721468
// when dealing with the types of actual instances.
1473-
Klass* Dependencies::check_abstract_with_unique_concrete_subtype(Klass* ctxk,
1469+
Klass* Dependencies::check_abstract_with_unique_concrete_subtype(InstanceKlass* ctxk,
14741470
Klass* conck,
14751471
KlassDepChange* changes) {
14761472
ClassHierarchyWalker wf(conck);
@@ -1483,7 +1479,7 @@ Klass* Dependencies::check_abstract_with_unique_concrete_subtype(Klass* ctxk,
14831479
// proper subtypes, return ctxk itself, whether it is concrete or not.
14841480
// The returned subtype is allowed to have have further concrete subtypes.
14851481
// That is, return CC1 for CX > CC1 > CC2, but NULL for CX > { CC1, CC2 }.
1486-
Klass* Dependencies::find_unique_concrete_subtype(Klass* ctxk) {
1482+
Klass* Dependencies::find_unique_concrete_subtype(InstanceKlass* ctxk) {
14871483
ClassHierarchyWalker wf(ctxk); // Ignore ctxk when walking.
14881484
wf.record_witnesses(1); // Record one other witness when walking.
14891485
Klass* wit = wf.find_witness_subtype(ctxk);
@@ -1511,7 +1507,7 @@ Klass* Dependencies::find_unique_concrete_subtype(Klass* ctxk) {
15111507

15121508
// If a class (or interface) has a unique concrete method uniqm, return NULL.
15131509
// Otherwise, return a class that contains an interfering method.
1514-
Klass* Dependencies::check_unique_concrete_method(Klass* ctxk,
1510+
Klass* Dependencies::check_unique_concrete_method(InstanceKlass* ctxk,
15151511
Method* uniqm,
15161512
KlassDepChange* changes) {
15171513
// Here is a missing optimization: If uniqm->is_final(),
@@ -1526,7 +1522,7 @@ Klass* Dependencies::check_unique_concrete_method(Klass* ctxk,
15261522
// (The method m must be defined or inherited in ctxk.)
15271523
// Include m itself in the set, unless it is abstract.
15281524
// If this set has exactly one element, return that element.
1529-
Method* Dependencies::find_unique_concrete_method(Klass* ctxk, Method* m) {
1525+
Method* Dependencies::find_unique_concrete_method(InstanceKlass* ctxk, Method* m) {
15301526
// Return NULL if m is marked old; must have been a redefined method.
15311527
if (m->is_old()) {
15321528
return NULL;
@@ -1557,7 +1553,7 @@ Method* Dependencies::find_unique_concrete_method(Klass* ctxk, Method* m) {
15571553
return fm;
15581554
}
15591555

1560-
Klass* Dependencies::check_has_no_finalizable_subclasses(Klass* ctxk, KlassDepChange* changes) {
1556+
Klass* Dependencies::check_has_no_finalizable_subclasses(InstanceKlass* ctxk, KlassDepChange* changes) {
15611557
Klass* search_at = ctxk;
15621558
if (changes != NULL)
15631559
search_at = changes->new_type(); // just look at the new bit

src/hotspot/share/code/dependencies.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ class Dependencies: public ResourceObj {
397397

398398
// Checking old assertions at run-time (in the VM only):
399399
static Klass* check_evol_method(Method* m);
400-
static Klass* check_leaf_type(Klass* ctxk);
401-
static Klass* check_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck, KlassDepChange* changes = NULL);
402-
static Klass* check_unique_concrete_method(Klass* ctxk, Method* uniqm, KlassDepChange* changes = NULL);
403-
static Klass* check_has_no_finalizable_subclasses(Klass* ctxk, KlassDepChange* changes = NULL);
400+
static Klass* check_leaf_type(InstanceKlass* ctxk);
401+
static Klass* check_abstract_with_unique_concrete_subtype(InstanceKlass* ctxk, Klass* conck, KlassDepChange* changes = NULL);
402+
static Klass* check_unique_concrete_method(InstanceKlass* ctxk, Method* uniqm, KlassDepChange* changes = NULL);
403+
static Klass* check_has_no_finalizable_subclasses(InstanceKlass* ctxk, KlassDepChange* changes = NULL);
404404
static Klass* check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes = NULL);
405405
// A returned Klass* is NULL if the dependency assertion is still
406406
// valid. A non-NULL Klass* is a 'witness' to the assertion
@@ -417,8 +417,8 @@ class Dependencies: public ResourceObj {
417417
// It is used by DepStream::spot_check_dependency_at.
418418

419419
// Detecting possible new assertions:
420-
static Klass* find_unique_concrete_subtype(Klass* ctxk);
421-
static Method* find_unique_concrete_method(Klass* ctxk, Method* m);
420+
static Klass* find_unique_concrete_subtype(InstanceKlass* ctxk);
421+
static Method* find_unique_concrete_method(InstanceKlass* ctxk, Method* m);
422422

423423
// Create the encoding which will be stored in an nmethod.
424424
void encode_content_bytes();
@@ -576,7 +576,7 @@ class Dependencies: public ResourceObj {
576576
return _xi[i]; }
577577
Metadata* argument(int i); // => recorded_oop_at(argument_index(i))
578578
oop argument_oop(int i); // => recorded_oop_at(argument_index(i))
579-
Klass* context_type();
579+
InstanceKlass* context_type();
580580

581581
bool is_klass_type() { return Dependencies::is_klass_type(type()); }
582582

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b
458458

459459
C2V_VMENTRY_NULL(jobject, findUniqueConcreteMethod, (JNIEnv* env, jobject, jobject jvmci_type, jobject jvmci_method))
460460
methodHandle method (THREAD, JVMCIENV->asMethod(jvmci_method));
461-
Klass* holder = JVMCIENV->asKlass(jvmci_type);
461+
InstanceKlass* holder = InstanceKlass::cast(JVMCIENV->asKlass(jvmci_type));
462462
if (holder->is_interface()) {
463463
JVMCI_THROW_MSG_NULL(InternalError, err_msg("Interface %s should be handled in Java code", holder->external_name()));
464464
}

0 commit comments

Comments
 (0)