RFR: 8308396: Fix offset_of conversion warnings in runtime code

Amit Kumar amitkumar at openjdk.org
Fri May 19 02:49:59 UTC 2023


On Thu, 18 May 2023 22:37:57 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> Please review this change to use ByteSize and byte_offset_of() to refer to offsets to metadata and other types that are used in generated code.  This avoids the int narrowing conversion warning for -Wconversion.  There were a couple that I just added an (int) cast instead because these offsets are either being used in other code currently being changed (in oopDesc) or there are too many (like displaced_header_offset_in_bytes) and should be their own change.
> 
> This change takes a  chunk out of the -Wconversion warnings - see CR for more info.
> 
> It might be easier and less tedious to review the commits separately.  One commit renames blah_offset_in_bytes to blah_offset, since in_bytes(blah_offset()) is typically used (except in Address constructor which has an overload for ByteSize).
> 
> Tested with tier1-4, x86 and aarch64, and built linux-x64-zero linux-x64-zero-debug linux-aarch64-debug linux-s390x-open linux-arm32-debug linux-ppc64le-debug linux-riscv64-debug locally.

src/hotspot/cpu/s390/sharedRuntime_s390.cpp line 2784:

> 2782: #ifndef VM_LITTLE_ENDIAN
> 2783:   + 3
> 2784: #endif

This is breaking build for s390x. 


/home/amit/jdk/src/hotspot/cpu/s390/sharedRuntime_s390.cpp: In static member function 'static void SharedRuntime::generate_uncommon_trap_blob()':           
/home/amit/jdk/src/hotspot/cpu/s390/sharedRuntime_s390.cpp:2783:3: error: no match for 'operator+' (operand types are 'ByteSize' and 'int')                 
   const int unpack_kind_byte_offset = Deoptimization::UnrollBlock::unpack_kind_offset()                                                                    
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                    
 #ifndef VM_LITTLE_ENDIAN                                                                                                                                   
 ~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                   
   + 3                                                                                                                                                      
   ^~~                                                                                                                                                      
In file included from /home/amit/jdk/src/hotspot/share/utilities/exceptions.hpp:31,                                                                         
                 from /home/amit/jdk/src/hotspot/share/oops/metadata.hpp:28,                                                                                
                 from /home/amit/jdk/src/hotspot/share/oops/oop.hpp:32,                                                                                     
                 from /home/amit/jdk/src/hotspot/share/runtime/handles.hpp:29,
                 from /home/amit/jdk/src/hotspot/share/code/oopRecorder.hpp:28,                                                                            
                 from /home/amit/jdk/src/hotspot/share/asm/codeBuffer.hpp:28,
                 from /home/amit/jdk/src/hotspot/share/asm/assembler.hpp:28,
                 from /home/amit/jdk/src/hotspot/share/asm/macroAssembler.hpp:28,                                                                          
                 from /home/amit/jdk/src/hotspot/share/asm/macroAssembler.inline.hpp:28,                                                                   
                 from /home/amit/jdk/src/hotspot/cpu/s390/sharedRuntime_s390.cpp:27:                                                                       
/home/amit/jdk/src/hotspot/share/utilities/sizes.hpp:53:20: note: candidate: 'constexpr ByteSize operator+(ByteSize, ByteSize)'                            
 constexpr ByteSize operator + (ByteSize x, ByteSize y) { return in_ByteSize(in_bytes(x) + in_bytes(y)); }                                                 
                    ^~~~~~~~
/home/amit/jdk/src/hotspot/share/utilities/sizes.hpp:53:20: note:   no known conversion for argument 2 from 'int' to 'ByteSize'                            
gmake[3]: *** [lib/CompileJvm.gmk:147: /home/amit/jdk/build/linux-s390x-server-fastdebug/hotspot/variant-server/libjvm/objs/sharedRuntime_s390.o] Error 1  
gmake[3]: *** Waiting for unfinished jobs....
gmake[2]: *** [make/Main.gmk:252: hotspot-server-libs] Error 2

ERROR: Build failed for target 'images' in configuration 'linux-s390x-server-fastdebug' (exit code 2)                                                      
Stopping javac server

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14053#discussion_r1198492213


More information about the hotspot-dev mailing list