Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent inlining of *.runWith methods #18152

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Conversation

nbhuiyan
Copy link
Member

Thread.findScopedValueBindings implementation relies on iterating the O-slots of these methods to find the most recent ScopedValue binding. The scoped value binding is the first argument in runWith, and if runWith is compiled, the O-slot walker would rely on iterating through the O-slots until an object that is an instance of
jdk.incubator.concurrent.ScopedValue$Snapshot is found. If we were to allow inlining of runWith, this slot walking mechanism would be unreliable, such as when there are more than one runWith calls in the same caller, and iterating through the O-slots and relying on instanceof checks could then yield the wrong bindings.

@0xdaryl 0xdaryl self-assigned this Sep 15, 2023
* relies on iterating the O-slots of these methods to find the most recent ScopedValue binding.
* The scoped value binding is the first argument in runWith, and if runWith is compiled, the
* O-slot walker would rely on iterating through the O-slots until an object that is an instance
* of jdk.incubator.concurrent.ScopedValue$Snapshot is found. If we were to allow inlining of
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an incubator package name here? For JDK21 I imagine it isn't.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not in incubator package in JDK21, so I fixed the comment.

@@ -3957,6 +3958,18 @@ void TR_ResolvedJ9Method::construct()
{TR::unknownMethod}
};

static X VirtualThreadMethods [] =
{
{ TR::java_lang_VirtualThread_runWith, 7, "runWith", (int16_t)-1, "*"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious about the whitespace here. I imagine it is for alignment, but since these are the only entries in these tables it is hard to see what they are being aligned with.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Thread.findScopedValueBindings implementation relies on
iterating the O-slots of these methods to find the most
recent ScopedValue binding. The scoped value binding is
the first argument in runWith, and if runWith is compiled,
the O-slot walker would rely on iterating through the
O-slots until an object that is an instance of
jdk.incubator.concurrent.ScopedValue$Snapshot is found.
If we were to allow inlining of runWith, this slot walking
mechanism would be unreliable, such as when there are
more than one runWith calls in the same caller, and
iterating through the O-slots and relying on instanceof
checks could then yield the wrong bindings.

Signed-off-by: Nazim Bhuiyan <[email protected]>
@0xdaryl
Copy link
Contributor

0xdaryl commented Sep 15, 2023

Jenkins test sanity all jdk21

@0xdaryl
Copy link
Contributor

0xdaryl commented Sep 16, 2023

Jenkins test sanity plinux jdk21

@0xdaryl 0xdaryl merged commit 3c948e8 into eclipse-openj9:master Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants