RFR: 8313249: Fix -Wconversion warnings in verifier code
Ioi Lam
iklam at openjdk.org
Fri Jul 28 19:19:51 UTC 2023
On Thu, 27 Jul 2023 15:51:01 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
> See bugid for comments. Most of the verifier code deals with ints, so the u2 and other parameters weren't really needed and can be promoted to int. Mostly types are changed, but a few checked_cast<>s are added.
> Tested with tier1-4, sanity Oracle platforms.
Looks OK. I think some casts should be changed to static_cast<>.
src/hotspot/share/classfile/stackMapTableFormat.hpp line 481:
> 479:
> 480: static u1 chops_to_frame_type(int chop) {
> 481: return (u1)(251 - chop);
This looks dangerous. If the range is alway within `u1`, it should use `checked_cast<u1>`, and you should also assert `chop <= 251`.
src/hotspot/share/classfile/stackMapTableFormat.hpp line 552:
> 550: static u1 appends_to_frame_type(int appends) {
> 551: assert(appends > 0 && appends < 4, "Invalid append amount");
> 552: return (u1)(251 + appends);
This should use `checked_cast<u1>`
src/hotspot/share/interpreter/bytecode.hpp line 74:
> 72:
> 73: // Static functions for parsing bytecodes in place.
> 74: u1 get_index_u1(Bytecodes::Code bc) const {
We have a mix of u1 and jubyte in these functions. That looks odd. I am not sure whether we should fix that.
-------------
Changes requested by iklam (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15056#pullrequestreview-1552788740
PR Review Comment: https://git.openjdk.org/jdk/pull/15056#discussion_r1277991935
PR Review Comment: https://git.openjdk.org/jdk/pull/15056#discussion_r1277992533
PR Review Comment: https://git.openjdk.org/jdk/pull/15056#discussion_r1277996656
More information about the hotspot-runtime-dev
mailing list