8331885: C2: meet between unloaded and speculative types is not symmetric

Reviewed-by: roland, thartmann
This commit is contained in:
Vladimir Ivanov 2024-05-20 17:56:44 +00:00
parent d6b7f9b170
commit 7652f9811b
3 changed files with 20 additions and 8 deletions
src/hotspot/share/opto
test/hotspot/jtreg/compiler/runtime/unloaded

@ -4180,24 +4180,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);
}
@ -4600,6 +4600,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;

@ -1356,6 +1356,7 @@ public:
// 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;

@ -31,10 +31,17 @@
*
* @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
*/
package compiler.runtime.unloaded;