RFR: JDK-8282798 java.lang.runtime.Carrier [v17]

Jim Laskey jlaskey at openjdk.java.net
Tue Mar 29 15:59:50 UTC 2022


On Tue, 29 Mar 2022 15:49:51 GMT, liach <duke at openjdk.java.net> wrote:

>> src/java.base/share/classes/java/lang/runtime/Carrier.java line 335:
>> 
>>> 333:             CarrierArray(int primitiveCount, int objectCount) {
>>> 334:                 this.primitives =
>>> 335:                     primitiveCount != 0 ? new long[(primitiveCount + 1) / 2] : null;
>> 
>> It might be better to use an unsigned shift here:
>> Suggestion:
>> 
>>                     primitiveCount != 0 ? new long[(primitiveCount + 1) >>> 1] : null;
>
> doesn't the compiler (either javac or hotspot) automatically do that?

Yes, the compilers handle this.  I did however switch to 


                    primitiveCount != 0 ? new long[(primitiveCount + 1) / LONG_SLOTS] : null;

-------------

PR: https://git.openjdk.java.net/jdk/pull/7744


More information about the core-libs-dev mailing list