< prev index next >

src/hotspot/share/oops/valueKlass.cpp

Print this page




 113         guarantee(0, "Unknown type %d", type);
 114       }
 115       assert(last_tsz != 0, "Invariant");
 116       last_offset = fs.offset();
 117     }
 118   }
 119   // Assumes VT with no fields are meaningless and illegal
 120   last_offset += last_tsz;
 121   assert(last_offset > first_offset && last_tsz, "Invariant");
 122   return 1 << upper_log2(last_offset - first_offset);
 123 }
 124 
 125 instanceOop ValueKlass::allocate_instance(TRAPS) {
 126   int size = size_helper();  // Query before forming handle.
 127 
 128   instanceOop oop = (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
 129   assert(oop->mark().is_always_locked(), "Unlocked value type");
 130   return oop;
 131 }
 132 








 133 bool ValueKlass::is_atomic() {
 134   return (nonstatic_field_size() * heapOopSize) <= longSize;
 135 }
 136 
 137 int ValueKlass::nonstatic_oop_count() {
 138   int oops = 0;
 139   int map_count = nonstatic_oop_map_count();
 140   OopMapBlock* block = start_of_nonstatic_oop_maps();
 141   OopMapBlock* end = block + map_count;
 142   while (block != end) {
 143     oops += block->count();
 144     block++;
 145   }
 146   return oops;
 147 }
 148 
 149 oop ValueKlass::read_flattened_field(oop obj, int offset, TRAPS) {
 150   oop res = NULL;
 151   this->initialize(CHECK_NULL); // will throw an exception if in error state
 152   if (is_empty_value()) {
 153     res = (instanceOop)default_value();
 154   } else {
 155     Handle obj_h(THREAD, obj);
 156     res = allocate_instance(CHECK_NULL);
 157     value_copy_payload_to_new_oop(((char*)(oopDesc*)obj_h()) + offset, res);
 158   }
 159   assert(res != NULL, "Must be set in one of two paths above");
 160   return res;
 161 }
 162 
 163 void ValueKlass::write_flattened_field(oop obj, int offset, oop value, TRAPS) {
 164   if (value == NULL) {
 165     THROW(vmSymbols::java_lang_NullPointerException());
 166   }
 167   if (!is_empty_value()) {
 168     value_copy_oop_to_payload(value, ((char*)(oopDesc*)obj) + offset);
 169   }
 170 }
 171 
 172 // Arrays of...
 173 
 174 bool ValueKlass::flatten_array() {
 175   if (!ValueArrayFlatten) {
 176     return false;




 113         guarantee(0, "Unknown type %d", type);
 114       }
 115       assert(last_tsz != 0, "Invariant");
 116       last_offset = fs.offset();
 117     }
 118   }
 119   // Assumes VT with no fields are meaningless and illegal
 120   last_offset += last_tsz;
 121   assert(last_offset > first_offset && last_tsz, "Invariant");
 122   return 1 << upper_log2(last_offset - first_offset);
 123 }
 124 
 125 instanceOop ValueKlass::allocate_instance(TRAPS) {
 126   int size = size_helper();  // Query before forming handle.
 127 
 128   instanceOop oop = (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
 129   assert(oop->mark().is_always_locked(), "Unlocked value type");
 130   return oop;
 131 }
 132 
 133 instanceOop ValueKlass::allocate_instance_buffer(TRAPS) {
 134   int size = size_helper();  // Query before forming handle.
 135 
 136   instanceOop oop = (instanceOop)Universe::heap()->obj_buffer_allocate(this, size, CHECK_NULL);
 137   assert(oop->mark().is_always_locked(), "Unlocked value type");
 138   return oop;
 139 }
 140 
 141 bool ValueKlass::is_atomic() {
 142   return (nonstatic_field_size() * heapOopSize) <= longSize;
 143 }
 144 
 145 int ValueKlass::nonstatic_oop_count() {
 146   int oops = 0;
 147   int map_count = nonstatic_oop_map_count();
 148   OopMapBlock* block = start_of_nonstatic_oop_maps();
 149   OopMapBlock* end = block + map_count;
 150   while (block != end) {
 151     oops += block->count();
 152     block++;
 153   }
 154   return oops;
 155 }
 156 
 157 oop ValueKlass::read_flattened_field(oop obj, int offset, TRAPS) {
 158   oop res = NULL;
 159   this->initialize(CHECK_NULL); // will throw an exception if in error state
 160   if (is_empty_value()) {
 161     res = (instanceOop)default_value();
 162   } else {
 163     Handle obj_h(THREAD, obj);
 164     res = allocate_instance_buffer(CHECK_NULL);
 165     value_copy_payload_to_new_oop(((char*)(oopDesc*)obj_h()) + offset, res);
 166   }
 167   assert(res != NULL, "Must be set in one of two paths above");
 168   return res;
 169 }
 170 
 171 void ValueKlass::write_flattened_field(oop obj, int offset, oop value, TRAPS) {
 172   if (value == NULL) {
 173     THROW(vmSymbols::java_lang_NullPointerException());
 174   }
 175   if (!is_empty_value()) {
 176     value_copy_oop_to_payload(value, ((char*)(oopDesc*)obj) + offset);
 177   }
 178 }
 179 
 180 // Arrays of...
 181 
 182 bool ValueKlass::flatten_array() {
 183   if (!ValueArrayFlatten) {
 184     return false;


< prev index next >