RFR: 8336274: MutableBigInteger.leftShift(int) optimization [v7]
Raffaello Giulietti
rgiulietti at openjdk.org
Thu Sep 12 12:25:05 UTC 2024
On Thu, 12 Sep 2024 11:21:10 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> The implementation of the shift methods in `MutableBigInteger` has several control flow paths, depending on whether a new `int[]` is needed, whether `arraycopy()` can be used, etc.
>>
>> Relying on random tests is good if the "search space" (the number of control flow paths) is too big for a systematic approach. But here I think it should be possible to exercise all paths with a dozen or so well targeted tests, in addition to the existing ones.
>>
>> These are white-box tests, so the internal structure of the algorithms is supposed to be known and this knowledge should be exploited in trying to hit the weak points, if there are.
>
> So, a test should be done for every possible path of computation of `MBI.leftShift()` method...
Looking at the code of `leftShift()` alone, I roughly count a dozen or so paths.
But if you feel confident that the random tests cover all paths over several executions with high probability and that no corner cases are left out, then they might suffice.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20008#discussion_r1756752098
More information about the core-libs-dev
mailing list