< prev index next >

src/hotspot/share/gc/shared/memAllocator.cpp

Print this page

350       obj = initialize(mem);
351     } else {
352       // The unhandled oop detector will poison local variable obj,
353       // so reset it to null if mem is null.
354       obj = nullptr;
355     }
356   }
357   return obj;
358 }
359 
360 void MemAllocator::mem_clear(HeapWord* mem) const {
361   assert(mem != nullptr, "cannot initialize null object");
362   const size_t hs = oopDesc::header_size();
363   assert(_word_size >= hs, "unexpected object size");
364   oopDesc::set_klass_gap(mem, 0);
365   Copy::fill_to_aligned_words(mem + hs, _word_size - hs);
366 }
367 
368 oop MemAllocator::finish(HeapWord* mem) const {
369   assert(mem != nullptr, "null object pointer");
370   // May be bootstrapping
371   oopDesc::set_mark(mem, markWord::prototype());
372   // Need a release store to ensure array/class length, mark word, and
373   // object zeroing are visible before setting the klass non-null, for
374   // concurrent collectors.
375   oopDesc::release_set_klass(mem, _klass);
376   return cast_to_oop(mem);
377 }
378 
379 oop ObjAllocator::initialize(HeapWord* mem) const {
380   mem_clear(mem);
381   return finish(mem);
382 }
383 






384 oop ObjArrayAllocator::initialize(HeapWord* mem) const {
385   // Set array length before setting the _klass field because a
386   // non-null klass field indicates that the object is parsable by
387   // concurrent GC.
388   assert(_length >= 0, "length should be non-negative");
389   if (_do_zero) {
390     mem_clear(mem);
391     mem_zap_start_padding(mem);
392     mem_zap_end_padding(mem);
393   }
394   arrayOopDesc::set_length(mem, _length);
395   return finish(mem);
396 }
397 
398 #ifndef PRODUCT
399 void ObjArrayAllocator::mem_zap_start_padding(HeapWord* mem) const {
400   const BasicType element_type = ArrayKlass::cast(_klass)->element_type();
401   const size_t base_offset_in_bytes = arrayOopDesc::base_offset_in_bytes(element_type);
402   const size_t header_size_in_bytes = arrayOopDesc::header_size_in_bytes();
403 

350       obj = initialize(mem);
351     } else {
352       // The unhandled oop detector will poison local variable obj,
353       // so reset it to null if mem is null.
354       obj = nullptr;
355     }
356   }
357   return obj;
358 }
359 
360 void MemAllocator::mem_clear(HeapWord* mem) const {
361   assert(mem != nullptr, "cannot initialize null object");
362   const size_t hs = oopDesc::header_size();
363   assert(_word_size >= hs, "unexpected object size");
364   oopDesc::set_klass_gap(mem, 0);
365   Copy::fill_to_aligned_words(mem + hs, _word_size - hs);
366 }
367 
368 oop MemAllocator::finish(HeapWord* mem) const {
369   assert(mem != nullptr, "null object pointer");
370   oopDesc::set_mark(mem, Klass::default_prototype_header(_klass));

371   // Need a release store to ensure array/class length, mark word, and
372   // object zeroing are visible before setting the klass non-null, for
373   // concurrent collectors.
374   oopDesc::release_set_klass(mem, _klass);
375   return cast_to_oop(mem);
376 }
377 
378 oop ObjAllocator::initialize(HeapWord* mem) const {
379   mem_clear(mem);
380   return finish(mem);
381 }
382 
383 oop ObjBufferAllocator::initialize(HeapWord* mem) const {
384   oopDesc::set_klass_gap(mem, 0);
385   return finish(mem);
386 }
387 
388 
389 oop ObjArrayAllocator::initialize(HeapWord* mem) const {
390   // Set array length before setting the _klass field because a
391   // non-null klass field indicates that the object is parsable by
392   // concurrent GC.
393   assert(_length >= 0, "length should be non-negative");
394   if (_do_zero) {
395     mem_clear(mem);
396     mem_zap_start_padding(mem);
397     mem_zap_end_padding(mem);
398   }
399   arrayOopDesc::set_length(mem, _length);
400   return finish(mem);
401 }
402 
403 #ifndef PRODUCT
404 void ObjArrayAllocator::mem_zap_start_padding(HeapWord* mem) const {
405   const BasicType element_type = ArrayKlass::cast(_klass)->element_type();
406   const size_t base_offset_in_bytes = arrayOopDesc::base_offset_in_bytes(element_type);
407   const size_t header_size_in_bytes = arrayOopDesc::header_size_in_bytes();
408 
< prev index next >