< prev index next >

src/share/vm/oops/typeArrayOop.hpp

Print this page




  75   jushort* ushort_at_addr(int which) const {  // for field descriptor arrays
  76     assert(is_within_bounds(which), "index out of bounds");
  77     return (jushort*) &short_base()[which];
  78   }
  79 
  80   jlong* long_at_addr(int which) const {
  81     assert(is_within_bounds(which), "index out of bounds");
  82     return &long_base()[which];
  83   }
  84 
  85   jfloat* float_at_addr(int which) const {
  86     assert(is_within_bounds(which), "index out of bounds");
  87     return &float_base()[which];
  88   }
  89 
  90   jdouble* double_at_addr(int which) const {
  91     assert(is_within_bounds(which), "index out of bounds");
  92     return &double_base()[which];
  93   }
  94 
  95   jbyte byte_at(int which) const                  { return *byte_at_addr(which); }
  96   void byte_at_put(int which, jbyte contents)     { *byte_at_addr(which) = contents; }




  97 
  98   jboolean bool_at(int which) const               { return *bool_at_addr(which); }
  99   void bool_at_put(int which, jboolean contents)  { *bool_at_addr(which) = (((jint)contents) & 1); }




 100 
 101   jchar char_at(int which) const                  { return *char_at_addr(which); }
 102   void char_at_put(int which, jchar contents)     { *char_at_addr(which) = contents; }




 103 
 104   jint int_at(int which) const                    { return *int_at_addr(which); }
 105   void int_at_put(int which, jint contents)       { *int_at_addr(which) = contents; }




 106 
 107   jshort short_at(int which) const                { return *short_at_addr(which); }
 108   void short_at_put(int which, jshort contents)   { *short_at_addr(which) = contents; }




 109 
 110   jushort ushort_at(int which) const              { return *ushort_at_addr(which); }
 111   void ushort_at_put(int which, jushort contents) { *ushort_at_addr(which) = contents; }




 112 
 113   jlong long_at(int which) const                  { return *long_at_addr(which); }
 114   void long_at_put(int which, jlong contents)     { *long_at_addr(which) = contents; }




 115 
 116   jfloat float_at(int which) const                { return *float_at_addr(which); }
 117   void float_at_put(int which, jfloat contents)   { *float_at_addr(which) = contents; }




 118 
 119   jdouble double_at(int which) const              { return *double_at_addr(which); }
 120   void double_at_put(int which, jdouble contents) { *double_at_addr(which) = contents; }




 121 
 122   jbyte byte_at_acquire(int which) const              { return OrderAccess::load_acquire(byte_at_addr(which)); }
 123   void release_byte_at_put(int which, jbyte contents) { OrderAccess::release_store(byte_at_addr(which), contents); }




 124 
 125   // Java thinks metadata arrays are just arrays of either long or int, since
 126   // there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate
 127   // casting
 128 #ifdef _LP64
 129   Metadata* metadata_at(int which) const {
 130     return (Metadata*)*long_at_addr(which); }

 131   void metadata_at_put(int which, Metadata* contents) {
 132     *long_at_addr(which) = (jlong)contents;
 133   }
 134 #else
 135   Metadata* metadata_at(int which) const {
 136     return (Metadata*)*int_at_addr(which); }

 137   void metadata_at_put(int which, Metadata* contents) {
 138     *int_at_addr(which) = (int)contents;
 139   }
 140 #endif // _LP64
 141 
 142   // Sizing
 143 
 144   // Returns the number of words necessary to hold an array of "len"
 145   // elements each of the given "byte_size".
 146  private:
 147   static int object_size(int lh, int length) {
 148     int instance_header_size = Klass::layout_helper_header_size(lh);
 149     int element_shift = Klass::layout_helper_log2_element_size(lh);
 150     DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh));
 151     assert(length <= arrayOopDesc::max_array_length(etype), "no overflow");
 152 
 153     julong size_in_bytes = (juint)length;
 154     size_in_bytes <<= element_shift;
 155     size_in_bytes += instance_header_size;
 156     julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize);


  75   jushort* ushort_at_addr(int which) const {  // for field descriptor arrays
  76     assert(is_within_bounds(which), "index out of bounds");
  77     return (jushort*) &short_base()[which];
  78   }
  79 
  80   jlong* long_at_addr(int which) const {
  81     assert(is_within_bounds(which), "index out of bounds");
  82     return &long_base()[which];
  83   }
  84 
  85   jfloat* float_at_addr(int which) const {
  86     assert(is_within_bounds(which), "index out of bounds");
  87     return &float_base()[which];
  88   }
  89 
  90   jdouble* double_at_addr(int which) const {
  91     assert(is_within_bounds(which), "index out of bounds");
  92     return &double_base()[which];
  93   }
  94 
  95   jbyte byte_at(int which) const                  {
  96     return *byte_at_addr(which);
  97   }
  98   void byte_at_put(int which, jbyte contents)     {
  99     *byte_at_addr(which) = contents;
 100   }
 101 
 102   jboolean bool_at(int which) const               {
 103     return *bool_at_addr(which);
 104   }
 105   void bool_at_put(int which, jboolean contents)  {
 106     *bool_at_addr(which) = (((jint)contents) & 1);
 107   }
 108 
 109   jchar char_at(int which) const                  {
 110     return *char_at_addr(which);
 111   }
 112   void char_at_put(int which, jchar contents)     {
 113     *char_at_addr(which) = contents;
 114   }
 115 
 116   jint int_at(int which) const                    {
 117     return *int_at_addr(which);
 118   }
 119   void int_at_put(int which, jint contents)       {
 120     *int_at_addr(which) = contents;
 121   }
 122 
 123   jshort short_at(int which) const                {
 124     return *short_at_addr(which);
 125   }
 126   void short_at_put(int which, jshort contents)   {
 127     *short_at_addr(which) = contents;
 128   }
 129 
 130   jushort ushort_at(int which) const              {
 131     return *ushort_at_addr(which);
 132   }
 133   void ushort_at_put(int which, jushort contents) {
 134     *ushort_at_addr(which) = contents;
 135   }
 136 
 137   jlong long_at(int which) const                  {
 138     return *long_at_addr(which);
 139   }
 140   void long_at_put(int which, jlong contents)     {
 141     *long_at_addr(which) = contents;
 142   }
 143 
 144   jfloat float_at(int which) const                {
 145     return *float_at_addr(which);
 146   }
 147   void float_at_put(int which, jfloat contents)   {
 148     *float_at_addr(which) = contents;
 149   }
 150 
 151   jdouble double_at(int which) const              {
 152     return *double_at_addr(which);
 153   }
 154   void double_at_put(int which, jdouble contents) {
 155     *double_at_addr(which) = contents;
 156   }
 157 
 158   jbyte byte_at_acquire(int which) const              {
 159     return OrderAccess::load_acquire(byte_at_addr(which));
 160   }
 161   void release_byte_at_put(int which, jbyte contents) {
 162     OrderAccess::release_store(byte_at_addr(which), contents);
 163   }
 164 
 165   // Java thinks metadata arrays are just arrays of either long or int, since
 166   // there doesn't seem to be T_ADDRESS, so this is a bit of unfortunate
 167   // casting
 168 #ifdef _LP64
 169   Metadata* metadata_at(int which) const {
 170     return (Metadata*)*long_at_addr(which);
 171   }
 172   void metadata_at_put(int which, Metadata* contents) {
 173     *long_at_addr(which) = (jlong)contents;
 174   }
 175 #else
 176   Metadata* metadata_at(int which) const {
 177     return (Metadata*)*int_at_addr(which);
 178   }
 179   void metadata_at_put(int which, Metadata* contents) {
 180     *int_at_addr(which) = (int)contents;
 181   }
 182 #endif // _LP64
 183 
 184   // Sizing
 185 
 186   // Returns the number of words necessary to hold an array of "len"
 187   // elements each of the given "byte_size".
 188  private:
 189   static int object_size(int lh, int length) {
 190     int instance_header_size = Klass::layout_helper_header_size(lh);
 191     int element_shift = Klass::layout_helper_log2_element_size(lh);
 192     DEBUG_ONLY(BasicType etype = Klass::layout_helper_element_type(lh));
 193     assert(length <= arrayOopDesc::max_array_length(etype), "no overflow");
 194 
 195     julong size_in_bytes = (juint)length;
 196     size_in_bytes <<= element_shift;
 197     size_in_bytes += instance_header_size;
 198     julong size_in_words = ((size_in_bytes + (HeapWordSize-1)) >> LogHeapWordSize);
< prev index next >