-
Bug
-
Resolution: Fixed
-
P4
-
11, 17, 22
-
b03
The nmethod.hpp and compiledMethod.hpp files have implicit address to int conversions for returning offsets and sizes.Since hopefully an nmethod size should never exceed 32 bits, this seems safe to simply add explicit casts.
The question is which is better:
+ int oops_size () const { return int((address) oops_end () - (address) oops_begin ()); }
Or
+ int oops_size () const { return (int)((address) oops_end () - (address) oops_begin ()); }
It doesn't seem like we should slow down compilation or add noise to make these
+ int oops_size () const { return checked_cast<int>((address) oops_end () - (address) oops_begin ()); }
Compiling with -Wconversion and not -Werror gives these counts for warnings:
5523 /scratch/cphillim/hg/21more-conversion/src/hotspot/share/code/nmethod.hpp
5523 /scratch/cphillim/hg/21more-conversion/src/hotspot/share/code/compiledMethod.hpp
4150 /scratch/cphillim/hg/21more-conversion/src/hotspot/share/code/relocInfo.hpp
The question is which is better:
+ int oops_size () const { return int((address) oops_end () - (address) oops_begin ()); }
Or
+ int oops_size () const { return (int)((address) oops_end () - (address) oops_begin ()); }
It doesn't seem like we should slow down compilation or add noise to make these
+ int oops_size () const { return checked_cast<int>((address) oops_end () - (address) oops_begin ()); }
Compiling with -Wconversion and not -Werror gives these counts for warnings:
5523 /scratch/cphillim/hg/21more-conversion/src/hotspot/share/code/nmethod.hpp
5523 /scratch/cphillim/hg/21more-conversion/src/hotspot/share/code/compiledMethod.hpp
4150 /scratch/cphillim/hg/21more-conversion/src/hotspot/share/code/relocInfo.hpp
- relates to
-
JDK-8177482 Prepare Compiler code for -Wconversion
- Open
-
JDK-8177481 Prepare Runtime code for -Wconversion
- Closed