Skip to content

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: roland, thartmann
  • Loading branch information
Vladimir Ivanov committed May 20, 2024
1 parent d6b7f9b commit 7652f98
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 @@ -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);
}


Expand Down Expand Up @@ -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;
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

3 comments on commit 7652f98

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@TheRealMDoerr
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 7652f98 Jun 4, 2024

Choose a reason for hiding this comment

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

@TheRealMDoerr the backport was successfully created on the branch backport-TheRealMDoerr-7652f981-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 7652f981 from the openjdk/jdk repository.

The commit being backported was authored by Vladimir Ivanov on 20 May 2024 and was reviewed by Roland Westrelin and Tobias Hartmann.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-TheRealMDoerr-7652f981-master:backport-TheRealMDoerr-7652f981-master
$ git checkout backport-TheRealMDoerr-7652f981-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-TheRealMDoerr-7652f981-master

Please sign in to comment.