On Thu, 3 Dec 2026 01:57:35 GMT, Shaojin Wen <[email protected]> wrote:

> Reopening #22919 as a new PR since the original PR could not be reopened.
> 
> Changes:
> - Redirect `radix == 10` in `Integer.parseInt(String, int)` and 
> `Long.parseLong(String, int)` to `parseInt(String)` and `parseLong(String)`, 
> and call `parseInt(s)` / `parseLong(s)` directly from `valueOf(String)` and 
> the deprecated `String` constructors.
> - Add a Latin1 decimal fast path in `Integer.parseInt(String)` and 
> `Long.parseLong(String)` without using `Unsafe`, parsing two ASCII digits per 
> iteration directly from `String.value()` without `Character.digit` table 
> lookups.
> - Accumulate up to 9 digits (`int`) / 18 digits (`long`) without overflow 
> checks in the loop, and check overflow once on the last digit 
> (`parseLastDigit`) for 10-digit `int` / 19-digit `long`. `null`, empty 
> strings, UTF-16 strings, and inputs with a valid first character exceeding 
> 10/11 (unsigned/signed `int`) or 19/20 (unsigned/signed `long`) chars fall 
> back to `parseInt0` / `parseLong0`, keeping all existing exception messages 
> unchanged.
> - Keep `Integer.parseInt(String)` (301 bytes) and `Long.parseLong(String)` 
> (306 bytes) below `FreqInlineSize` (325 bytes).
> - Add `Longs.parseLong` microbenchmark and expand `Integer/ParsingTest` and 
> `Long/ParsingTest` (covering boundary values, exception messages, non-decimal 
> radices, and both `+CompactStrings` / `-CompactStrings`).
> 
> ### Benchmark
> 
> Baseline for `Longs.parseLong` was measured with the same benchmark added on 
> top of baseline.
> 
> Linux x86_64 (Intel Xeon 6982P-C, `taskset -c 0`, `-f 3 -wi 10 -i 5`):
> 
> | Benchmark | (size) | Mode | Cnt | Baseline (us/op) | Patch (us/op) | Diff 
> (Speedup) |
> |---|---:|---|---:|---:|---:|---:|
> | `Integers.parseInt` | 500 | avgt | 15 | 2.784 ± 0.007 | 2.258 ± 0.006 | 
> -18.9% (1.23x) |
> | `Longs.parseLong` | 500 | avgt | 15 | 3.027 ± 0.036 | 2.558 ± 0.011 | 
> -15.5% (1.18x) |
> 
> Linux aarch64 (Orange Pi 6 Plus, `taskset -c 0`, `-f 3 -wi 10 -i 5`):
> 
> | Benchmark | (size) | Mode | Cnt | Baseline (us/op) | Patch (us/op) | Diff 
> (Speedup) |
> |---|---:|---|---:|---:|---:|---:|
> | `Integers.parseInt` | 500 | avgt | 15 | 4.540 ± 0.027 | 3.599 ± 0.016 | 
> -20.7% (1.26x) |
> | `Longs.parseLong` | 500 | avgt | 15 | 4.857 ± 0.026 | 3.964 ± 0.036 | 
> -18.4% (1.23x) |
> 
> ### Testing
> 
> - `test/jdk/java/lang/Integer`, `test/jdk/java/lang/Long`, 
> `test/jdk/java/lang/Byte`, `test/jdk/java/lang/Short`, 
> `test/jdk/com/sun/jdi/JdbExprTest.java` (17/17 passed, including both 
> `-XX:+CompactStrings` and `-XX:-CompactStrings` for `ParsingTest`).
> 
> ---------
> - [x] I confirm t...

It is worth mentioning that according to the OpenJDK Interim Policy on 
Generative AI:
> Content, in this context, includes but is not limited to source code, text, 
> and images in OpenJDK Git repositories, GitHub pull requests, e-mail 
> messages, wiki pages, and JBS issues.

So, not even the Pull Request description should be (partially) written by such 
tool.

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

PR Comment: https://git.openjdk.org/jdk/pull/34188#issuecomment-7406421960

Reply via email to