On Mon, 14 Jul 2025 15:33:35 GMT, Jorn Vernee <jver...@openjdk.org> wrote:

> Issue copied from the JBS issue:
> 
> When an upcall stub accepts a by-value struct, and the struct is passed by 
> the underlying ABI as a pointer to a temporary copy on the caller's stack 
> (for instance on Windows when the struct doesn't fit into a single register), 
> a scope is created for the duration of the upcall, to which the memory 
> segment for this struct is attached.
> 
> However, if such a scope is created for the upcall, any other unrelated 
> pointer argument will _also_ be attached to the same scope. This is 
> incorrect, as unrelated pointer arguments should be attached to the global 
> scope. The underlying issue is that, when deciding whether a particular 
> argument needs to be attached to the scope, we check if _any_ of the argument 
> needs to be attached to the created scope.
> 
> This PR fixes the issue by calling `boxAddress.needsScope()` in 
> `BindingSpecializer::emitBoxAddress`, which checks only if that particular 
> argument needs to be attached to the upcall scope.
> 
> I've also renamed the 'global' `needsScope` method, which checks whether 
> _any_ of the arguments need a scope, to `anyArgNeedsScope` for clarity.
> 
> Testing: `jdk_foreign` test suite on Mac/Windows/Linux x64, and Mac/Linux 
> aarch64

Looks good!

-------------

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26295#pullrequestreview-3026916106

Reply via email to