Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
/ jdk22u Public archive

Commit

Permalink
8331885: C2: meet between unloaded and speculative types is not symme…
Browse files Browse the repository at this point in the history
…tric

Reviewed-by: chagedorn
Backport-of: 7652f9811bfddf08650b0c3277012074873deade
  • Loading branch information
Fairoz Matte authored and chhagedorn committed Jun 3, 2024
1 parent 108e164 commit 92e4ba2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/hotspot/share/opto/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4174,24 +4174,24 @@ const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst, const T
//
assert(loaded->ptr() != TypePtr::Null, "insanity check");
//
if (loaded->ptr() == TypePtr::TopPTR) { return unloaded; }
if (loaded->ptr() == TypePtr::TopPTR) { return unloaded->with_speculative(speculative); }
else if (loaded->ptr() == TypePtr::AnyNull) { return make(ptr, unloaded->klass(), interfaces, false, nullptr, off, instance_id, speculative, depth); }
else if (loaded->ptr() == TypePtr::BotPTR) { return TypeInstPtr::BOTTOM; }
else if (loaded->ptr() == TypePtr::BotPTR) { return TypeInstPtr::BOTTOM->with_speculative(speculative); }
else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
if (unloaded->ptr() == TypePtr::BotPTR) { return TypeInstPtr::BOTTOM; }
else { return TypeInstPtr::NOTNULL; }
if (unloaded->ptr() == TypePtr::BotPTR) { return TypeInstPtr::BOTTOM->with_speculative(speculative); }
else { return TypeInstPtr::NOTNULL->with_speculative(speculative); }
}
else if (unloaded->ptr() == TypePtr::TopPTR) { return unloaded; }
else if (unloaded->ptr() == TypePtr::TopPTR) { return unloaded->with_speculative(speculative); }

return unloaded->cast_to_ptr_type(TypePtr::AnyNull)->is_instptr();
return unloaded->cast_to_ptr_type(TypePtr::AnyNull)->is_instptr()->with_speculative(speculative);
}

// Both are unloaded, not the same class, not Object
// Or meet unloaded with a different loaded class, not java/lang/Object
if (ptr != TypePtr::BotPTR) {
return TypeInstPtr::NOTNULL;
return TypeInstPtr::NOTNULL->with_speculative(speculative);
}
return TypeInstPtr::BOTTOM;
return TypeInstPtr::BOTTOM->with_speculative(speculative);
}


Expand Down Expand Up @@ -4594,6 +4594,10 @@ const TypeInstPtr* TypeInstPtr::remove_speculative() const {
_instance_id, nullptr, _inline_depth);
}

const TypeInstPtr* TypeInstPtr::with_speculative(const TypePtr* speculative) const {
return make(_ptr, klass(), _interfaces, klass_is_exact(), const_oop(), _offset, _instance_id, speculative, _inline_depth);
}

const TypePtr* TypeInstPtr::with_inline_depth(int depth) const {
if (!UseInlineDepthForSpeculativeTypes) {
return this;
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/opto/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@ class TypeInstPtr : public TypeOopPtr {

// Speculative type helper methods.
virtual const TypeInstPtr* remove_speculative() const;
const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
virtual const TypePtr* with_inline_depth(int depth) const;
virtual const TypePtr* with_instance_id(int instance_id) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@
*
* @compile TestMHUnloaded.java TestMHUnloadedHelper.java
* @run driver jdk.test.lib.helpers.ClassFileInstaller compiler.runtime.unloaded.TestMHUnloadedHelper
*
* @run main/othervm -Xbootclasspath/a:.
* -Xbatch -XX:-TieredCompilation -XX:CompileCommand=exclude,*::test
* -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompilation -XX:+PrintInlining
* compiler.runtime.unloaded.TestMHUnloaded
*
* @run main/othervm -Xbootclasspath/a:.
* -Xbatch -XX:-TieredCompilation -XX:CompileCommand=exclude,*::test
* -XX:+UnlockDiagnosticVMOptions -XX:+PrintCompilation -XX:+PrintInlining
* -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
* compiler.runtime.unloaded.TestMHUnloaded
*/

Expand Down

1 comment on commit 92e4ba2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.