Skip to content

Commit

Permalink
Revert resolved class to unresolved for comparison
Browse files Browse the repository at this point in the history
remove is_unresolved_class_mismatch
  • Loading branch information
jpbempel committed Jul 18, 2023
1 parent 2ff1721 commit 05071a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 38 deletions.
36 changes: 7 additions & 29 deletions src/hotspot/share/oops/constantPool.cpp
Expand Up @@ -1276,34 +1276,6 @@ void ConstantPool::unreference_symbols() {
}
}

// Returns true if the current mismatch is due to a resolved/unresolved
// class pair. Otherwise, returns false.
bool ConstantPool::is_unresolved_class_mismatch(int index1,
const constantPoolHandle& cp2, int index2) {

jbyte t1 = tag_at(index1).value();
if (t1 != JVM_CONSTANT_Class && t1 != JVM_CONSTANT_UnresolvedClass) {
return false; // wrong entry type; not our special case
}

jbyte t2 = cp2->tag_at(index2).value();
if (t2 != JVM_CONSTANT_Class && t2 != JVM_CONSTANT_UnresolvedClass) {
return false; // wrong entry type; not our special case
}

if (t1 == t2) {
return false; // not a mismatch; not our special case
}

char *s1 = klass_name_at(index1)->as_C_string();
char *s2 = cp2->klass_name_at(index2)->as_C_string();
if (strcmp(s1, s2) != 0) {
return false; // strings don't match; not our special case
}

return true; // made it through the gauntlet; this is our special case
} // end is_unresolved_class_mismatch()

// Compare this constant pool's entry at index1 to the constant pool
// cp2's entry at index2.
bool ConstantPool::compare_entry_to(int index1, const constantPoolHandle& cp2,
Expand All @@ -1313,6 +1285,13 @@ bool ConstantPool::compare_entry_to(int index1, const constantPoolHandle& cp2,
jbyte t1 = tag_at(index1).non_error_value();
jbyte t2 = cp2->tag_at(index2).non_error_value();

if (t1 == JVM_CONSTANT_Class) {
// Some classes are pre-resolved (like Throwable) which may lead to

Check failure on line 1289 in src/hotspot/share/oops/constantPool.cpp

View check run for this annotation

openjdk / jcheck-openjdk/jdk-14780

Whitespace error

Column 71: trailing whitespace
// consider it as a different entry. we then revert them back temporarily
// to ensure proper comparison.
t1 = JVM_CONSTANT_UnresolvedClass;
}

if (t1 != t2) {
// Not the same entry type so there is nothing else to check. Note
// that this style of checking will consider resolved/unresolved
Expand Down Expand Up @@ -1358,7 +1337,6 @@ bool ConstantPool::compare_entry_to(int index1, const constantPoolHandle& cp2,
int recur1 = uncached_klass_ref_index_at(index1);
int recur2 = cp2->uncached_klass_ref_index_at(index2);
bool match = compare_entry_to(recur1, cp2, recur2);
match |= is_unresolved_class_mismatch(recur1, cp2, recur2);
if (match) {
recur1 = uncached_name_and_type_ref_index_at(index1);
recur2 = cp2->uncached_name_and_type_ref_index_at(index2);
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/oops/constantPool.hpp
Expand Up @@ -853,7 +853,6 @@ class ConstantPool : public Metadata {
static void throw_resolution_error(const constantPoolHandle& this_cp, int which, TRAPS);

// Merging ConstantPool* support:
bool is_unresolved_class_mismatch(int index1, const constantPoolHandle& cp2, int index2);
bool compare_entry_to(int index1, const constantPoolHandle& cp2, int index2);
void copy_cp_to(int start_i, int end_i, const constantPoolHandle& to_cp, int to_i, TRAPS) {
constantPoolHandle h_this(THREAD, this);
Expand Down
8 changes: 0 additions & 8 deletions src/hotspot/share/prims/jvmtiRedefineClasses.cpp
Expand Up @@ -1671,14 +1671,6 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp,
if (match) {
// found a match at the same index so nothing more to do
continue;
} else if (scratch_cp->is_unresolved_class_mismatch(scratch_i, *merge_cp_p,
scratch_i)) {
// The mismatch in compare_entry_to() above is because of a
// resolved versus unresolved class entry at the same index
// with the same string value. Since Pass 0 reverted any
// class entries to unresolved class entries in *merge_cp_p,
// we go with the unresolved class entry.
continue;
}

int found_i = scratch_cp->find_matching_entry(scratch_i, *merge_cp_p);
Expand Down

0 comments on commit 05071a5

Please sign in to comment.