RFR: 8313249: Fix -Wconversion warnings in verifier code [v2]
Ioi Lam
iklam at openjdk.org
Sat Jul 29 19:22:41 UTC 2023
On Sat, 29 Jul 2023 12:20:25 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> I would use static_cast to be consistent with `chops_to_frame_type`. That way the reader of this code has less metal exercise to do.
>
> I've struggled with the raw cast versus checked_cast usage in this PR - I could not determine what was guiding the usage of each type of cast. Shouldn't it always be a checked cast? Or does the preceding range check validate the use of a raw cast (so we don't range check twice)?
To me, the two lines serves two purposes:
assert(appends > 0 && appends < 4, "Invalid append amount");
This is the input expected by this function.
return static_cast<u1>(251 + appends);
This is a mechanical check that the code is actually correctly written (i.e., you didn't mess up and wrote (253 + appends). That way the reader doesn't have do the math in order to trust this code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15056#discussion_r1278370610
More information about the hotspot-runtime-dev
mailing list