< prev index next >

src/share/vm/oops/valueArrayKlass.cpp

Print this page




 114 
 115   size_t size = valueArrayOopDesc::object_size(layout_helper(), length);
 116   KlassHandle h_k(THREAD, this);
 117   if (do_zero) {
 118     return CollectedHeap::array_allocate(h_k, (int)size, length, CHECK_NULL);
 119   } else {
 120     return CollectedHeap::array_allocate_nozero(h_k, (int)size, length, CHECK_NULL);
 121   }
 122 }
 123 
 124 
 125 oop ValueArrayKlass::multi_allocate(int rank, jint* last_size, TRAPS) {
 126   // For valueArrays this is only called for the last dimension
 127   assert(rank == 1, "just checking");
 128   int length = *last_size;
 129   return allocate(length, true, THREAD);
 130 }
 131 
 132 jint ValueArrayKlass::array_layout_helper(ValueKlass* vk) {
 133   BasicType etype = T_VALUETYPE;
 134   int atag  = _lh_array_tag_type_value;
 135   int esize = upper_log2(vk->raw_value_byte_size());
 136   int hsize = arrayOopDesc::base_offset_in_bytes(etype);
 137 
 138   int lh = (atag       << _lh_array_tag_shift)
 139     |      (1          << _lh_valuetype_bit)
 140     |      (hsize      << _lh_header_size_shift)
 141     |      ((int)etype << _lh_element_type_shift)
 142     |      ((esize)    << _lh_log2_element_size_shift);
 143 
 144   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 145   assert(layout_helper_is_array(lh), "correct kind");
 146   assert(layout_helper_is_valueArray(lh), "correct kind");


 147   assert(layout_helper_header_size(lh) == hsize, "correct decode");
 148   assert(layout_helper_element_type(lh) == etype, "correct decode");
 149   assert(layout_helper_is_typeArray(lh), "correct kind");
 150   assert(layout_helper_log2_element_size(lh) == esize, "correct decode");
 151   assert((1 << esize) < BytesPerLong || is_size_aligned(hsize, HeapWordsPerLong), "unaligned base");
 152 
 153   return lh;
 154 }
 155 
 156 int ValueArrayKlass::oop_size(oop obj) const {
 157   assert(obj->is_valueArray(),"must be a value array");
 158   valueArrayOop array = valueArrayOop(obj);
 159   return array->object_size();
 160 }
 161 
 162 jint ValueArrayKlass::max_elements() const {
 163   return arrayOopDesc::max_array_length(arrayOopDesc::header_size(T_VALUETYPE), element_byte_size());
 164 }
 165 
 166 oop ValueArrayKlass::protection_domain() const {
 167   return element_klass()->protection_domain();
 168 }
 169 




 114 
 115   size_t size = valueArrayOopDesc::object_size(layout_helper(), length);
 116   KlassHandle h_k(THREAD, this);
 117   if (do_zero) {
 118     return CollectedHeap::array_allocate(h_k, (int)size, length, CHECK_NULL);
 119   } else {
 120     return CollectedHeap::array_allocate_nozero(h_k, (int)size, length, CHECK_NULL);
 121   }
 122 }
 123 
 124 
 125 oop ValueArrayKlass::multi_allocate(int rank, jint* last_size, TRAPS) {
 126   // For valueArrays this is only called for the last dimension
 127   assert(rank == 1, "just checking");
 128   int length = *last_size;
 129   return allocate(length, true, THREAD);
 130 }
 131 
 132 jint ValueArrayKlass::array_layout_helper(ValueKlass* vk) {
 133   BasicType etype = T_VALUETYPE;
 134   int atag  = _lh_array_tag_vt_value;
 135   int esize = upper_log2(vk->raw_value_byte_size());
 136   int hsize = arrayOopDesc::base_offset_in_bytes(etype);
 137 
 138   int lh = (atag       << _lh_array_tag_shift)

 139     |      (hsize      << _lh_header_size_shift)
 140     |      ((int)etype << _lh_element_type_shift)
 141     |      ((esize)    << _lh_log2_element_size_shift);
 142 
 143   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 144   assert(layout_helper_is_array(lh), "correct kind");
 145   assert(layout_helper_is_valueArray(lh), "correct kind");
 146   assert(!layout_helper_is_typeArray(lh), "correct kind");
 147   assert(!layout_helper_is_objArray(lh), "correct kind");
 148   assert(layout_helper_header_size(lh) == hsize, "correct decode");
 149   assert(layout_helper_element_type(lh) == etype, "correct decode");

 150   assert(layout_helper_log2_element_size(lh) == esize, "correct decode");
 151   assert((1 << esize) < BytesPerLong || is_size_aligned(hsize, HeapWordsPerLong), "unaligned base");
 152 
 153   return lh;
 154 }
 155 
 156 int ValueArrayKlass::oop_size(oop obj) const {
 157   assert(obj->is_valueArray(),"must be a value array");
 158   valueArrayOop array = valueArrayOop(obj);
 159   return array->object_size();
 160 }
 161 
 162 jint ValueArrayKlass::max_elements() const {
 163   return arrayOopDesc::max_array_length(arrayOopDesc::header_size(T_VALUETYPE), element_byte_size());
 164 }
 165 
 166 oop ValueArrayKlass::protection_domain() const {
 167   return element_klass()->protection_domain();
 168 }
 169 


< prev index next >