On Wed, 5 Feb 2025 16:48:06 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/util/DecimalDigits.java line 143: >> >>> 141: * @return If both characters are numbers, return d0 * 10 + d1, >>> otherwise return -1 >>> 142: */ >>> 143: @ForceInline >> >> Can we leave this out? From the doc: "This annotation must be used >> sparingly." >> I tried without and on M1 performance does not seem to be affected. > > Again, can we avoid `@ForceInline`? The codeSize of the digit2 method is 56, greater than C1 MaxInline 35. I was worried about the performance in the early runtime, so I added @ForceInline >> src/java.base/share/classes/jdk/internal/util/DecimalDigits.java line 175: >> >>> 173: */ >>> 174: int d; >>> 175: short x = UNSAFE.getShortUnaligned(str, >>> Unsafe.ARRAY_BYTE_BASE_OFFSET + offset, false); >> >> @wenshao I'm a bit worried about the use of Unsafe here. >> >> This method is `public` (although in an internal package), and while it is >> used correctly in this PR, there's no warning in the doc that `str` and >> `offset` must come from a trusted caller that ensures that they are safe to >> use with, well..., Unsafe. >> >> Did you consider safer alternatives, like usage of `VarHandle`, even if that >> might mean a slight performance degradation? > > Never mind, `VarHandle` cannot be used in this case. Using VarHandle in this scenario may affect JVM startup performance ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22919#discussion_r1943325107 PR Review Comment: https://git.openjdk.org/jdk/pull/22919#discussion_r1943328441