< prev index next >

src/hotspot/share/oops/typeArrayOop.hpp

Print this page
rev 49674 : 8198285: More consistent Access API for arraycopy


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_TYPEARRAYOOP_HPP
  26 #define SHARE_VM_OOPS_TYPEARRAYOOP_HPP
  27 
  28 #include "oops/arrayOop.hpp"
  29 #include "oops/typeArrayKlass.hpp"
  30 
  31 // A typeArrayOop is an array containing basic types (non oop elements).
  32 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs}
  33 #include <limits.h>
  34 












  35 class typeArrayOopDesc : public arrayOopDesc {
  36 private:
  37   template <class T>
  38   static ptrdiff_t element_offset(BasicType bt, int index) {
  39     return arrayOopDesc::base_offset_in_bytes(bt) + sizeof(T) * index;
  40   }
  41 
  42  protected:
  43   jchar*    char_base()   const;
  44   jboolean* bool_base()   const;
  45   jbyte*    byte_base()   const;
  46   jint*     int_base()    const;
  47   jlong*    long_base()   const;
  48   jshort*   short_base()  const;
  49   jfloat*   float_base()  const;
  50   jdouble*  double_base() const;
  51 
  52   friend class TypeArrayKlass;
  53 
  54  public:





  55   jbyte* byte_at_addr(int which) const;
  56   jboolean* bool_at_addr(int which) const;
  57   jchar* char_at_addr(int which) const;
  58   jint* int_at_addr(int which) const;
  59   jshort* short_at_addr(int which) const;
  60   jushort* ushort_at_addr(int which) const;
  61   jlong* long_at_addr(int which) const;
  62   jfloat* float_at_addr(int which) const;
  63   jdouble* double_at_addr(int which) const;
  64 
  65   jbyte byte_at(int which) const;
  66   void byte_at_put(int which, jbyte contents);
  67 
  68   jboolean bool_at(int which) const;
  69   void bool_at_put(int which, jboolean contents);
  70 
  71   jchar char_at(int which) const;
  72   void char_at_put(int which, jchar contents);
  73 
  74   jint int_at(int which) const;




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_TYPEARRAYOOP_HPP
  26 #define SHARE_VM_OOPS_TYPEARRAYOOP_HPP
  27 
  28 #include "oops/arrayOop.hpp"
  29 #include "oops/typeArrayKlass.hpp"
  30 
  31 // A typeArrayOop is an array containing basic types (non oop elements).
  32 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs}
  33 #include <limits.h>
  34 
  35 namespace TypeToBT {
  36   template<typename T> BasicType to_basic_type();
  37   template<> inline BasicType to_basic_type<jboolean>() { return T_BOOLEAN; }
  38   template<> inline BasicType to_basic_type<jbyte>()    { return T_BYTE;    }
  39   template<> inline BasicType to_basic_type<jchar>()    { return T_CHAR;    }
  40   template<> inline BasicType to_basic_type<jshort>()   { return T_SHORT;   }
  41   template<> inline BasicType to_basic_type<jint>()     { return T_INT;     }
  42   template<> inline BasicType to_basic_type<jlong>()    { return T_LONG;    }
  43   template<> inline BasicType to_basic_type<jfloat>()   { return T_FLOAT;   }
  44   template<> inline BasicType to_basic_type<jdouble>()  { return T_DOUBLE;  }
  45 };
  46 
  47 class typeArrayOopDesc : public arrayOopDesc {
  48 private:
  49   template <typename T>
  50   static BasicType bt() { return TypeToBT::to_basic_type<T>(); }


  51 
  52  protected:
  53   jchar*    char_base()   const;
  54   jboolean* bool_base()   const;
  55   jbyte*    byte_base()   const;
  56   jint*     int_base()    const;
  57   jlong*    long_base()   const;
  58   jshort*   short_base()  const;
  59   jfloat*   float_base()  const;
  60   jdouble*  double_base() const;
  61 
  62   friend class TypeArrayKlass;
  63 
  64  public:
  65   template <typename T>
  66   static ptrdiff_t element_offset(int index) {
  67     return arrayOopDesc::base_offset_in_bytes(bt<T>()) + sizeof(T) * index;
  68   }
  69 
  70   jbyte* byte_at_addr(int which) const;
  71   jboolean* bool_at_addr(int which) const;
  72   jchar* char_at_addr(int which) const;
  73   jint* int_at_addr(int which) const;
  74   jshort* short_at_addr(int which) const;
  75   jushort* ushort_at_addr(int which) const;
  76   jlong* long_at_addr(int which) const;
  77   jfloat* float_at_addr(int which) const;
  78   jdouble* double_at_addr(int which) const;
  79 
  80   jbyte byte_at(int which) const;
  81   void byte_at_put(int which, jbyte contents);
  82 
  83   jboolean bool_at(int which) const;
  84   void bool_at_put(int which, jboolean contents);
  85 
  86   jchar char_at(int which) const;
  87   void char_at_put(int which, jchar contents);
  88 
  89   jint int_at(int which) const;


< prev index next >