RFR: 8313435: Clean up unused default methods code [v5]
Ioi Lam
iklam at openjdk.org
Fri Aug 4 01:45:44 UTC 2023
On Fri, 4 Aug 2023 00:19:52 GMT, David Holmes <dholmes at openjdk.org> wrote:
> I'm not at all sure that `BytecodeConstantPool::find_or_add` needs to throw, especially given that requires polluting so much code with TRAPS and CHECK - it looks really awful to see things like:
>
> ```
> assem._new(errorName, CHECK_0));
> ```
>
> Maybe we should be checking for sufficient space at a higher-level somewhere? I'm not familiar with how this code is actually used.
>
> This seems to have strayed somewhat from the primary cleanup of unused code.
It was my suggestion, because otherwise this code would be returning junk on overflow, leading to invalid code being stored in the buffer.
u2 BytecodeConstantPool::find_or_add(BytecodeCPEntry const& bcpe, TRAPS) {
...
return static_cast<u2>(index + _orig->length());
Yes, there's code that checks after the fact that we have overflown the number for CP indices, and rejects the buffer. However, for security, it's better to not have invalid code in the first place. The places of invalid code generation and error detection are far apart, making the code hard to understand, and easy to mess up by future changes.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15095#issuecomment-1664853692
More information about the hotspot-runtime-dev
mailing list