< prev index next >

src/hotspot/share/gc/x/xObjArrayAllocator.cpp

Print this page

 56   if (!is_aligned(base_offset, HeapWordSize)) {
 57     assert(is_aligned(base_offset, BytesPerInt), "array base must be 32 bit aligned");
 58     *reinterpret_cast<jint*>(reinterpret_cast<char*>(mem) + base_offset) = 0;
 59     base_offset += BytesPerInt;
 60   }
 61   assert(is_aligned(base_offset, HeapWordSize), "remaining array base must be 64 bit aligned");
 62 
 63   const size_t header = heap_word_size(base_offset);
 64   const size_t payload_size = _word_size - header;
 65 
 66   if (payload_size <= segment_max) {
 67     // To small to use segmented clearing
 68     return ObjArrayAllocator::initialize(mem);
 69   }
 70 
 71   // Segmented clearing
 72 
 73   // The array is going to be exposed before it has been completely
 74   // cleared, therefore we can't expose the header at the end of this
 75   // function. Instead explicitly initialize it according to our needs.
 76   arrayOopDesc::set_mark(mem, markWord::prototype());
 77   arrayOopDesc::release_set_klass(mem, _klass);
 78   assert(_length >= 0, "length should be non-negative");
 79   arrayOopDesc::set_length(mem, _length);
 80 
 81   // Keep the array alive across safepoints through an invisible
 82   // root. Invisible roots are not visited by the heap itarator
 83   // and the marking logic will not attempt to follow its elements.
 84   // Relocation knows how to dodge iterating over such objects.
 85   XThreadLocalData::set_invisible_root(_thread, (oop*)&mem);
 86 
 87   for (size_t processed = 0; processed < payload_size; processed += segment_max) {
 88     // Calculate segment
 89     HeapWord* const start = (HeapWord*)(mem + header + processed);
 90     const size_t remaining = payload_size - processed;
 91     const size_t segment_size = MIN2(remaining, segment_max);
 92 
 93     // Clear segment
 94     Copy::zero_to_words(start, segment_size);
 95 
 96     // Safepoint

 56   if (!is_aligned(base_offset, HeapWordSize)) {
 57     assert(is_aligned(base_offset, BytesPerInt), "array base must be 32 bit aligned");
 58     *reinterpret_cast<jint*>(reinterpret_cast<char*>(mem) + base_offset) = 0;
 59     base_offset += BytesPerInt;
 60   }
 61   assert(is_aligned(base_offset, HeapWordSize), "remaining array base must be 64 bit aligned");
 62 
 63   const size_t header = heap_word_size(base_offset);
 64   const size_t payload_size = _word_size - header;
 65 
 66   if (payload_size <= segment_max) {
 67     // To small to use segmented clearing
 68     return ObjArrayAllocator::initialize(mem);
 69   }
 70 
 71   // Segmented clearing
 72 
 73   // The array is going to be exposed before it has been completely
 74   // cleared, therefore we can't expose the header at the end of this
 75   // function. Instead explicitly initialize it according to our needs.
 76   arrayOopDesc::set_mark(mem, Klass::default_prototype_header(_klass));
 77   arrayOopDesc::release_set_klass(mem, _klass);
 78   assert(_length >= 0, "length should be non-negative");
 79   arrayOopDesc::set_length(mem, _length);
 80 
 81   // Keep the array alive across safepoints through an invisible
 82   // root. Invisible roots are not visited by the heap itarator
 83   // and the marking logic will not attempt to follow its elements.
 84   // Relocation knows how to dodge iterating over such objects.
 85   XThreadLocalData::set_invisible_root(_thread, (oop*)&mem);
 86 
 87   for (size_t processed = 0; processed < payload_size; processed += segment_max) {
 88     // Calculate segment
 89     HeapWord* const start = (HeapWord*)(mem + header + processed);
 90     const size_t remaining = payload_size - processed;
 91     const size_t segment_size = MIN2(remaining, segment_max);
 92 
 93     // Clear segment
 94     Copy::zero_to_words(start, segment_size);
 95 
 96     // Safepoint
< prev index next >