Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8310027

Fix -Wconversion warnings in nmethod and compiledMethod related code

XMLWordPrintable

    • 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

            coleenp Coleen Phillimore
            coleenp Coleen Phillimore
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: