RFR: 8291972: Fix double copy of arguments when thawing two interpreted frames [v2]

Patricio Chilano Mateo pchilanomate at openjdk.org
Fri Aug 12 16:37:25 UTC 2022


On Fri, 12 Aug 2022 16:33:38 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:

>> When thawing two consecutive interpreted frames the current code makes room in the stack and copies the callee arguments twice, once in the caller and once in the callee. This duplication could use more stack space than the calculation made in prepare_thaw() for the maximum stack space that will be needed during thaw. If that's the case then we will hit an assert that we are writing pass the allowed limit.
>> Today we don't see this issue though because the only case where we could thaw two interpreter frames is the first time after a freeze. The thawed frames are always Continuation.yield and Continuation.yield0 and the extra used space is only 3 words(yield0's three arguments) which will never exceed the calculation made in prepare_thaw(). 
>> The issue can be made visible when changing the number of frames we thaw when hitting a return barrier from 1 to 2 and running test Continuation/Basic.java.
>> 
>> This patch fixes this by adjusting the calculated size of the callee frame in new_stack_frame() so that we use the space for the arguments already allocated by the caller. 
>> 
>> Tested the patch by changing the number of thaw frames from 1 to 2 and running all tests in jdk/internal/vm/Continuation/ and jdk/java/lang/Thread/virtual. Also run tiers1-3 in mach5 and loom-tiers1-4.
>> 
>> Thanks,
>> Patricio
>
> Patricio Chilano Mateo has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add Richard's reproducer

Added Richard's test and run on both x64 and aarch64. Verified it fails on aarch64 without this fix and passes with it.

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

PR: https://git.openjdk.org/jdk/pull/9774


More information about the hotspot-dev mailing list