Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Chen Liang
On Mon, 30 Sep 2024 12:38:47 GMT, Shaojin Wen wrote: >> The new API loadConstant(int) can shorten the calling path and can replace >> ldc when the parameter is of int/Integer type. > > I think loadConstant should be renamed to ldc @wenshao You can integrate this patch early even though it's muc

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Claes Redestad
On Mon, 30 Sep 2024 10:03:57 GMT, Shaojin Wen wrote: > The new API loadConstant(int) can shorten the calling path and can replace > ldc when the parameter is of int/Integer type. I'm in favor of removing `ldc(ConstantDesc)`, keeping the `ldc(LoadableConstantEntry)` for advanced uses. It's easi

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Chen Liang
On Mon, 30 Sep 2024 10:03:57 GMT, Shaojin Wen wrote: > The new API loadConstant(int) can shorten the calling path and can replace > ldc when the parameter is of int/Integer type. I think to address these, we will leave the specification of `loadConstant` open so we can always flexibly adjust i

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Claes Redestad
On Mon, 30 Sep 2024 10:03:57 GMT, Shaojin Wen wrote: > The new API loadConstant(int) can shorten the calling path and can replace > ldc when the parameter is of int/Integer type. I consider this a bug in the API, too. Perhaps we could assert against usage that would have been better expressed

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread David M . Lloyd
On Mon, 30 Sep 2024 10:03:57 GMT, Shaojin Wen wrote: > The new API loadConstant(int) can shorten the calling path and can replace > ldc when the parameter is of int/Integer type. I was also curious about a few other seemingly "obvious" small optimizations, like loading `-1L` as `iconst_m1; i2l

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Shaojin Wen
On Mon, 30 Sep 2024 10:03:57 GMT, Shaojin Wen wrote: > The new API loadConstant(int) can shorten the calling path and can replace > ldc when the parameter is of int/Integer type. I think loadConstant should be renamed to ldc - PR Comment: https://git.openjdk.org/jdk/pull/21259#iss

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Claes Redestad
On Mon, 30 Sep 2024 11:17:20 GMT, Chen Liang wrote: > This can also avoid cp entries for small values and use 2-byte bipush or > 1-byte constants, both smaller in size. Yikes, I was unaware `ldc` wouldn't optimize the emitted bytecode but reading through the code and docs it's pretty obvious.

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Claes Redestad
On Mon, 30 Sep 2024 10:03:57 GMT, Shaojin Wen wrote: > The new API loadConstant(int) can shorten the calling path and can replace > ldc when the parameter is of int/Integer type. Marked as reviewed by redestad (Reviewer). - PR Review: https://git.openjdk.org/jdk/pull/21259#pullreq

Re: RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Chen Liang
On Mon, 30 Sep 2024 10:03:57 GMT, Shaojin Wen wrote: > The new API loadConstant(int) can shorten the calling path and can replace > ldc when the parameter is of int/Integer type. Indeed, loadConstant was invented to be more optimized than ldc. This can also avoid cp entries for small values an

RFR: 8341199: Use ClassFile's new API loadConstant(int)

2024-09-30 Thread Shaojin Wen
The new API loadConstant(int) can shorten the calling path and can replace ldc when the parameter is of int/Integer type. - Commit messages: - use loadConstant instead of ldc Changes: https://git.openjdk.org/jdk/pull/21259/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21