RFR: 8330465: Stable Values and Collections (Internal) [v2]
Per Minborg
pminborg at openjdk.org
Wed May 15 06:49:07 UTC 2024
On Tue, 14 May 2024 16:02:41 GMT, Viktor Klang <vklang at openjdk.org> wrote:
>> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove text in public class that references an internal class
>
> src/java.base/share/classes/jdk/internal/lang/StableValue.java line 171:
>
>> 169: /**
>> 170: * {@return a fresh stable value with an unset value where the returned stable's
>> 171: * value is computed in a separate background thread (created via the provided
>
> Suggestion:
>
> * {@return a fresh stable value with an unset value where the returned stable
> * value is computed in a separate background thread (created via the provided
It is a bit confusing with "stable value" and the "stable value's value". Maybe something like:
* {@return a fresh stable value with an unset value where its
* value is computed in a separate background thread (created via the provided ...
?
> src/java.base/share/classes/jdk/internal/lang/StableValue.java line 175:
>
>> 173: * <p>
>> 174: * If the supplier throws an (unchecked) exception, the exception is ignored, and no
>> 175: * value is set.
>
> Is it likely that users will want to be made aware of failures? If so, perhaps it would make sense to make sure that the Exception hits the UncaughtExceptionHandler? 🤔
Good suggestion. An alternative would be to provide an exception listener getting invoked upon hitting an exception.
> src/java.base/share/classes/jdk/internal/lang/stable/StableArray3DImpl.java line 33:
>
>> 31: Objects.checkIndex(i1, dim1);
>> 32: Objects.checkIndex(i2, dim2);
>> 33: final int index = i0 * dim1 * dim2 + i1 * dim2 + i2;
>
> Might be worth doing some overflow checking here?
At construction, we assert the invariant; the product of `dim0, dim1, and dim2` can be fit in an `int`:
private StableArray3DImpl(int dim0, int dim1, int dim2) {
this(dim0, dim1, dim2, Math.multiplyExact(Math.multiplyExact(dim0, dim1), dim2));
}
The three `checkIndex(iN, dimN)` ensures each iN is greater than zero and less than dimN. This means, by induction, that the operation `final int index = i0 * dim1 * dim2 + i1 * dim2 + i2;` will never overflow.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18794#discussion_r1601035645
PR Review Comment: https://git.openjdk.org/jdk/pull/18794#discussion_r1601028336
PR Review Comment: https://git.openjdk.org/jdk/pull/18794#discussion_r1601025953
More information about the compiler-dev
mailing list