On Thu, 19 Jun 2025 09:59:41 GMT, Per Minborg <[email protected]> wrote:
>> This PR proposes to release the underlying function if a stable function or
>> collection has invoked its underlying supplier exhaustively so that it can
>> be collected.
>>
>> This PR passes tier1, tier2, and tier3 testing on multiple platforms.
>
> Per Minborg has updated the pull request with a new target base due to a
> merge or a rebase. The incremental webrev excludes the unrelated changes
> brought in by the merge/rebase. The pull request contains eight additional
> commits since the last revision:
>
> - Merge branch 'master' into sv-release-supplier2
> - Fix performance regression
> - Clean up
> - Fix bug
> - Simplify
> - Revert to records
> - Make code more like the old one
> - Add removable underlying functions
src/java.base/share/classes/jdk/internal/lang/stable/StableSupplier.java line
46:
> 44: @Override
> 45: public T get() {
> 46: return delegate.orElseSet(underlyingHolder.underlying(),
> underlyingHolder);
By avoiding reading from `underlyingHolder` when the `StableValue` is already
set, this can avoid the overhead of a field read from `underlyingHolder`:
Suggestion:
final Object t = delegate.wrappedContentsAcquire();
if (t != null) {
return unwrap(t);
}
return delegate.orElseSet(underlyingHolder.underlying(),
underlyingHolder);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25878#discussion_r2156730614