< prev index next >

src/hotspot/share/oops/typeArrayOop.inline.hpp

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


  73   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  74   return (jushort*) &short_base()[which];
  75 }
  76 
  77 inline jlong* typeArrayOopDesc::long_at_addr(int which) const {
  78   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  79   return &long_base()[which];
  80 }
  81 
  82 inline jfloat* typeArrayOopDesc::float_at_addr(int which) const {
  83   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  84   return &float_base()[which];
  85 }
  86 
  87 inline jdouble* typeArrayOopDesc::double_at_addr(int which) const {
  88   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  89   return &double_base()[which];
  90 }
  91 
  92 inline jbyte typeArrayOopDesc::byte_at(int which) const {
  93   ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
  94   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
  95 }
  96 inline void typeArrayOopDesc::byte_at_put(int which, jbyte contents) {
  97   ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
  98   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
  99 }
 100 
 101 inline jboolean typeArrayOopDesc::bool_at(int which) const {
 102   ptrdiff_t offset = element_offset<jboolean>(T_BOOLEAN, which);
 103   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 104 }
 105 inline void typeArrayOopDesc::bool_at_put(int which, jboolean contents) {
 106   ptrdiff_t offset = element_offset<jboolean>(T_BOOLEAN, which);
 107   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, jboolean(contents & 1));
 108 }
 109 
 110 inline jchar typeArrayOopDesc::char_at(int which) const {
 111   ptrdiff_t offset = element_offset<jchar>(T_CHAR, which);
 112   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 113 }
 114 inline void typeArrayOopDesc::char_at_put(int which, jchar contents) {
 115   ptrdiff_t offset = element_offset<jchar>(T_CHAR, which);
 116   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 117 }
 118 
 119 inline jint typeArrayOopDesc::int_at(int which) const {
 120   ptrdiff_t offset = element_offset<jint>(T_INT, which);
 121   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 122 }
 123 inline void typeArrayOopDesc::int_at_put(int which, jint contents) {
 124   ptrdiff_t offset = element_offset<jint>(T_INT, which);
 125   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 126 }
 127 
 128 inline jshort typeArrayOopDesc::short_at(int which) const {
 129   ptrdiff_t offset = element_offset<jshort>(T_SHORT, which);
 130   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 131 }
 132 inline void typeArrayOopDesc::short_at_put(int which, jshort contents) {
 133   ptrdiff_t offset = element_offset<jshort>(T_SHORT, which);
 134   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 135 }
 136 
 137 inline jushort typeArrayOopDesc::ushort_at(int which) const {
 138   ptrdiff_t offset = element_offset<jushort>(T_SHORT, which);
 139   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 140 }
 141 inline void typeArrayOopDesc::ushort_at_put(int which, jushort contents) {
 142   ptrdiff_t offset = element_offset<jushort>(T_SHORT, which);
 143   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 144 }
 145 
 146 inline jlong typeArrayOopDesc::long_at(int which) const {
 147   ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
 148   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 149 }
 150 inline void typeArrayOopDesc::long_at_put(int which, jlong contents) {
 151   ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
 152   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 153 }
 154 
 155 inline jfloat typeArrayOopDesc::float_at(int which) const {
 156   ptrdiff_t offset = element_offset<jfloat>(T_FLOAT, which);
 157   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 158 }
 159 inline void typeArrayOopDesc::float_at_put(int which, jfloat contents) {
 160   ptrdiff_t offset = element_offset<jfloat>(T_FLOAT, which);
 161   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 162 }
 163 
 164 inline jdouble typeArrayOopDesc::double_at(int which) const {
 165   ptrdiff_t offset = element_offset<jdouble>(T_DOUBLE, which);
 166   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 167 }
 168 inline void typeArrayOopDesc::double_at_put(int which, jdouble contents) {
 169   ptrdiff_t offset = element_offset<jdouble>(T_DOUBLE, which);
 170   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 171 }
 172 
 173 inline jbyte typeArrayOopDesc::byte_at_acquire(int which) const {
 174   ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
 175   return HeapAccess<MO_ACQUIRE | IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 176 }
 177 inline void typeArrayOopDesc::release_byte_at_put(int which, jbyte contents) {
 178   ptrdiff_t offset = element_offset<jbyte>(T_BYTE, which);
 179   HeapAccess<MO_RELEASE | IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 180 }
 181 
 182 // Java thinks Symbol arrays are just arrays of either long or int, since
 183 // there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate
 184 // casting
 185 #ifdef _LP64
 186 inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
 187   ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
 188   return (Symbol*)(jlong) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 189 }
 190 inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
 191   ptrdiff_t offset = element_offset<jlong>(T_LONG, which);
 192   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jlong)contents);
 193 }
 194 #else
 195 inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
 196   ptrdiff_t offset = element_offset<jint>(T_INT, which);
 197   return (Symbol*)(jint) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 198 }
 199 inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
 200   ptrdiff_t offset = element_offset<jint>(T_INT, which);
 201   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jint)contents);
 202 }
 203 #endif // _LP64
 204 
 205 
 206 #endif // SHARE_VM_OOPS_TYPEARRAYOOP_INLINE_HPP


  73   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  74   return (jushort*) &short_base()[which];
  75 }
  76 
  77 inline jlong* typeArrayOopDesc::long_at_addr(int which) const {
  78   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  79   return &long_base()[which];
  80 }
  81 
  82 inline jfloat* typeArrayOopDesc::float_at_addr(int which) const {
  83   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  84   return &float_base()[which];
  85 }
  86 
  87 inline jdouble* typeArrayOopDesc::double_at_addr(int which) const {
  88   assert(is_within_bounds(which), "index %d out of bounds %d", which, length());
  89   return &double_base()[which];
  90 }
  91 
  92 inline jbyte typeArrayOopDesc::byte_at(int which) const {
  93   ptrdiff_t offset = element_offset<jbyte>(which);
  94   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
  95 }
  96 inline void typeArrayOopDesc::byte_at_put(int which, jbyte contents) {
  97   ptrdiff_t offset = element_offset<jbyte>(which);
  98   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
  99 }
 100 
 101 inline jboolean typeArrayOopDesc::bool_at(int which) const {
 102   ptrdiff_t offset = element_offset<jboolean>(which);
 103   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 104 }
 105 inline void typeArrayOopDesc::bool_at_put(int which, jboolean contents) {
 106   ptrdiff_t offset = element_offset<jboolean>(which);
 107   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, jboolean(contents & 1));
 108 }
 109 
 110 inline jchar typeArrayOopDesc::char_at(int which) const {
 111   ptrdiff_t offset = element_offset<jchar>(which);
 112   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 113 }
 114 inline void typeArrayOopDesc::char_at_put(int which, jchar contents) {
 115   ptrdiff_t offset = element_offset<jchar>(which);
 116   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 117 }
 118 
 119 inline jint typeArrayOopDesc::int_at(int which) const {
 120   ptrdiff_t offset = element_offset<jint>(which);
 121   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 122 }
 123 inline void typeArrayOopDesc::int_at_put(int which, jint contents) {
 124   ptrdiff_t offset = element_offset<jint>(which);
 125   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 126 }
 127 
 128 inline jshort typeArrayOopDesc::short_at(int which) const {
 129   ptrdiff_t offset = element_offset<jshort>(which);
 130   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 131 }
 132 inline void typeArrayOopDesc::short_at_put(int which, jshort contents) {
 133   ptrdiff_t offset = element_offset<jshort>(which);
 134   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 135 }
 136 
 137 inline jushort typeArrayOopDesc::ushort_at(int which) const {
 138   ptrdiff_t offset = element_offset<jushort>(which);
 139   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 140 }
 141 inline void typeArrayOopDesc::ushort_at_put(int which, jushort contents) {
 142   ptrdiff_t offset = element_offset<jushort>(which);
 143   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 144 }
 145 
 146 inline jlong typeArrayOopDesc::long_at(int which) const {
 147   ptrdiff_t offset = element_offset<jlong>(which);
 148   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 149 }
 150 inline void typeArrayOopDesc::long_at_put(int which, jlong contents) {
 151   ptrdiff_t offset = element_offset<jlong>(which);
 152   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 153 }
 154 
 155 inline jfloat typeArrayOopDesc::float_at(int which) const {
 156   ptrdiff_t offset = element_offset<jfloat>(which);
 157   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 158 }
 159 inline void typeArrayOopDesc::float_at_put(int which, jfloat contents) {
 160   ptrdiff_t offset = element_offset<jfloat>(which);
 161   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 162 }
 163 
 164 inline jdouble typeArrayOopDesc::double_at(int which) const {
 165   ptrdiff_t offset = element_offset<jdouble>(which);
 166   return HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 167 }
 168 inline void typeArrayOopDesc::double_at_put(int which, jdouble contents) {
 169   ptrdiff_t offset = element_offset<jdouble>(which);
 170   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 171 }
 172 
 173 inline jbyte typeArrayOopDesc::byte_at_acquire(int which) const {
 174   ptrdiff_t offset = element_offset<jbyte>(which);
 175   return HeapAccess<MO_ACQUIRE | IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 176 }
 177 inline void typeArrayOopDesc::release_byte_at_put(int which, jbyte contents) {
 178   ptrdiff_t offset = element_offset<jbyte>(which);
 179   HeapAccess<MO_RELEASE | IN_HEAP_ARRAY>::store_at(as_oop(), offset, contents);
 180 }
 181 
 182 // Java thinks Symbol arrays are just arrays of either long or int, since
 183 // there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate
 184 // casting
 185 #ifdef _LP64
 186 inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
 187   ptrdiff_t offset = element_offset<jlong>(which);
 188   return (Symbol*)(jlong) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 189 }
 190 inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
 191   ptrdiff_t offset = element_offset<jlong>(which);
 192   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jlong)contents);
 193 }
 194 #else
 195 inline Symbol* typeArrayOopDesc::symbol_at(int which) const {
 196   ptrdiff_t offset = element_offset<jint>(which);
 197   return (Symbol*)(jint) HeapAccess<IN_HEAP_ARRAY>::load_at(as_oop(), offset);
 198 }
 199 inline void typeArrayOopDesc::symbol_at_put(int which, Symbol* contents) {
 200   ptrdiff_t offset = element_offset<jint>(which);
 201   HeapAccess<IN_HEAP_ARRAY>::store_at(as_oop(), offset, (jint)contents);
 202 }
 203 #endif // _LP64
 204 
 205 
 206 #endif // SHARE_VM_OOPS_TYPEARRAYOOP_INLINE_HPP
< prev index next >