RFR: 8260053: Optimize Tokens' use of Names [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Jan 21 18:49:34 UTC 2021


On Thu, 21 Jan 2021 18:26:50 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:

>> Hi all,
>> 
>> This patch initializes the names about `TokenKind` at the beginning of the constructor of the class `Names`. As a result, the `Tokens.maxKey` and the length of the array `Tokens.key` become small. By using this patch, the length of the array `Tokens.key` is changed from 4280 to 383.
>> 
>> The original discussion is at [compiler-dev](https://mail.openjdk.java.net/pipermail/compiler-dev/2021-January/016126.html).
>> 
>> Thank you for taking the time to review.
>> 
>> Best Regards.
>
> Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Use Map<String, TokenKind>

Looks great - and much simpler. Have you tried running some benchmark?

If you are not familiar with JMH, another way to quickly (and unofficially :-) benchmark javac is typically trying to clean/build the JDK before/after the change and see if there's an impact. Since this change affects tokenization, if there's a regression you should be able to see it.

If you are familiar with JMH, and alternative would be to setup a compilation task using the compiler API, and then just parse some files.

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

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


More information about the compiler-dev mailing list