On Wed, 11 Nov 2026 11:14:17 GMT, Andrew Dinn <[email protected]> wrote:
>> Shawn Emery has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Update based on @adinn's comments
>
> src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp line 9152:
>
>> 9150: auto saved_regs = RegSet::range(r19, r20);
>> 9151:
>> 9152: const int32_t limbs = 7;
>
> I'm getting DEJA_VU here. These could be defined as constants at file scope
> (caps with a suitable P384 suffix) allowing them to be shared by both top
> level intrinsic generators and also any auxiliary helpers you might want to
> introduce (see below).
Done.
> src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp line 9175:
>
>> 9173: for (int i = 0; i < 7; i++) {
>> 9174: __ ldr(aArg, Address(aLimbs, i * 8));
>> 9175: __ smulh(high, aArg, aArg);
>
> Hmm, yet more DEJA_VU.
>
> Can we have an auxiliary generator method mul55(c_lo, c_hi, a, b, h, l) for
> this repeated sequence. That serves to clarify that the same higher level
> operation that is being performed and makes it harder for a maintainer to
> avoid introducing errors.
This is not a repeated sequence from the multiplication method.
> src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp line 9192:
>
>> 9190: }
>> 9191:
>> 9192: Register v = a;
>
> Is this not just a cut and paste of the same generated code for `carryReduce`
> implementation that we see in `generate_intpoly_mult_P384`.
>
> If it is not then where (and why) do the two implementations differ?
>
> If it is the same then we should really be generating this using an auxiliary
> method (`generate_carry_reduce_P384`).
Re: testing; I've tested the intrinsics through benchmarks and the following
P-384 related test suites:
sun/security/util/math/TestIntegerModuloP.java#IntegerPolynomialP384
test/jdk/sun/security/ec/ECDHPrimitive.java
test/jdk/sun/security/ec/SignatureKAT.java
test/jdk/sun/security/ec/ECDSAPrimitive.java
test/jdk/sun/security/ec/SignedObjectChain.java
test/jdk/sun/security/ec/SignatureParameters.java
test/jdk/sun/security/ec/TestEC.java
test/jdk/com/sun/crypto/provider/Cipher/HPKE/Functions.java
Re: `carryReduce` code reuse; yes, they are the same. I was still in the
nesting vs. performance mode, but nesting the helper function only reduces
performance by ~1%, which is negligible. Done.
> src/hotspot/share/runtime/stubDeclarations.hpp line 823:
>
>> 821: do_entry(compiler, intpoly_square_25519,
>> \
>> 822: intpoly_square_25519, intpoly_square_25519)
>> \
>> 823: do_stub(compiler, intpoly_mult_P384)
>> \
>
> Adding an implementation for a new intrinsic on any given architecture
> increases the amount of code generated. That could potentially lead to
> overflow of the compiler StubGen blob on that architecture. Can you report
> how much this change contributes to the blob on AArch64. If it is significant
> then you will need to update the arch-specific StubGen compiler blob sizing
> in file stubDeclarations_aarch64.hpp
>
> n.b. You can get a printout of the StubGen blob sizes by running with
> `-Xlog:stubs=info` and enabling/disabling the intrinsic to obtain a delta.
> Alternatively, you could eyeball the actual stub code and measure its size by
> running with `-XX:+UnlockDiagnosticVMOptions -XX:+PrintStubCode`.
On my AArch64 system (M3 Pro) the two new stubs allocate an additional 3,584
bytes which still leaves a 200 byte reserve with a 75,000 byte base. Ergo, the
free bytes for the VM with the two new stubs is 3,984 bytes for 64 byte
alignment, 2,768 bytes for 32 byte alignment, and 2,128 bytes at 16 byte
alignment.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/33618#discussion_r4561010168
PR Review Comment: https://git.openjdk.org/jdk/pull/33618#discussion_r4561011093
PR Review Comment: https://git.openjdk.org/jdk/pull/33618#discussion_r4561009560
PR Review Comment: https://git.openjdk.org/jdk/pull/33618#discussion_r4561011721