RFR: 8299673: Simplify object pinning interactions with string deduplication [v2]
David Holmes
dholmes at openjdk.org
Tue Jan 17 02:05:11 UTC 2023
On Mon, 16 Jan 2023 11:32:52 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:
>> When raw char* String contents are exposed to JNI code, we
>>
>> 1. Load the string.value and pin it
>> 2. Run native code
>> 3. Load the string.value and unpin it
>>
>> Given this sequence we would be in trouble if between 1 and 3, string deduplication changed the value object. Then the pinning and unpinning wouldn't be balanced.
>>
>> The current approach for dealing with this is to have a bunch of code to guard against deduplication. An alternative simpler solution is to just change step 3 to pass in the same value. We already have enough information available to do that. Then the pinning and unpinning is also balanced, and we don't need to have any special interactions with string deduplication and can decouple these orthogonal concerns.
>>
>> It's worth noting though that the contract of pin_object now makes it explicit that pinned objects must not be recycled, even if not otherwise reachable. That seems to come naturally for region based pinning, but is worth keeping in mind. The exposed char* might be the only thing referencing the string value when string dedup happens concurrently.
>
> Erik Österlund has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains five commits:
>
> - Include sorting order
> - Merge branch 'master' into 8299673_pin_dedup
> - More Kim feedback
> - Feedback from Kim
> - 8299673: Simplify object pinning interactions with string deduplication
Initially I was a bit unsure about the conceptual model here, as I was thinking that pinning is a very general concept, where in fact it only relates to these JNI "critical" functions. So in that sense every GC must support pinning as required by those functions, so this simplification looks very neat. Thanks.
-------------
Marked as reviewed by dholmes (Reviewer).
PR: https://git.openjdk.org/jdk/pull/11923
More information about the shenandoah-dev
mailing list