< prev index next >

src/hotspot/share/gc/z/zObjArrayAllocator.cpp

Print this page

 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 
 77   // Signal to the ZIterator that this is an invisible root, by setting
 78   // the mark word to "marked". Reset to prototype() after the clearing.
 79   arrayOopDesc::set_mark(mem, markWord::prototype().set_marked());
 80   arrayOopDesc::release_set_klass(mem, _klass);




 81   assert(_length >= 0, "length should be non-negative");
 82   arrayOopDesc::set_length(mem, _length);
 83 
 84   // Keep the array alive across safepoints through an invisible
 85   // root. Invisible roots are not visited by the heap iterator
 86   // and the marking logic will not attempt to follow its elements.
 87   // Relocation and remembered set code know how to dodge iterating
 88   // over such objects.
 89   ZThreadLocalData::set_invisible_root(_thread, (zaddress_unsafe*)&mem);
 90 
 91   uint32_t old_seqnum_before = ZGeneration::old()->seqnum();
 92   uint32_t young_seqnum_before = ZGeneration::young()->seqnum();
 93   uintptr_t color_before = ZPointerStoreGoodMask;
 94   auto gc_safepoint_happened = [&]() {
 95     return old_seqnum_before != ZGeneration::old()->seqnum() ||
 96            young_seqnum_before != ZGeneration::young()->seqnum() ||
 97            color_before != ZPointerStoreGoodMask;
 98   };
 99 
100   bool seen_gc_safepoint = false;

130         // The first time we observe a GC safepoint in the yield point,
131         // we have to restart processing with 11 remembered bits.
132         seen_gc_safepoint = true;
133         return false;
134       }
135     }
136     return true;
137   };
138 
139   if (!initialize_memory()) {
140     // Re-color with 11 remset bits if we got intercepted by a GC safepoint
141     const bool result = initialize_memory();
142     assert(result, "Array initialization should always succeed the second time");
143   }
144 
145   mem_zap_end_padding(mem);
146 
147   ZThreadLocalData::clear_invisible_root(_thread);
148 
149   // Signal to the ZIterator that this is no longer an invisible root
150   oopDesc::release_set_mark(mem, markWord::prototype());




151 
152   return cast_to_oop(mem);
153 }

 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 
 77   // Signal to the ZIterator that this is an invisible root, by setting
 78   // the mark word to "marked". Reset to prototype() after the clearing.
 79   if (UseCompactObjectHeaders) {
 80     oopDesc::release_set_mark(mem, _klass->prototype_header().set_marked());
 81   } else {
 82     arrayOopDesc::set_mark(mem, markWord::prototype().set_marked());
 83     arrayOopDesc::release_set_klass(mem, _klass);
 84   }
 85   assert(_length >= 0, "length should be non-negative");
 86   arrayOopDesc::set_length(mem, _length);
 87 
 88   // Keep the array alive across safepoints through an invisible
 89   // root. Invisible roots are not visited by the heap iterator
 90   // and the marking logic will not attempt to follow its elements.
 91   // Relocation and remembered set code know how to dodge iterating
 92   // over such objects.
 93   ZThreadLocalData::set_invisible_root(_thread, (zaddress_unsafe*)&mem);
 94 
 95   uint32_t old_seqnum_before = ZGeneration::old()->seqnum();
 96   uint32_t young_seqnum_before = ZGeneration::young()->seqnum();
 97   uintptr_t color_before = ZPointerStoreGoodMask;
 98   auto gc_safepoint_happened = [&]() {
 99     return old_seqnum_before != ZGeneration::old()->seqnum() ||
100            young_seqnum_before != ZGeneration::young()->seqnum() ||
101            color_before != ZPointerStoreGoodMask;
102   };
103 
104   bool seen_gc_safepoint = false;

134         // The first time we observe a GC safepoint in the yield point,
135         // we have to restart processing with 11 remembered bits.
136         seen_gc_safepoint = true;
137         return false;
138       }
139     }
140     return true;
141   };
142 
143   if (!initialize_memory()) {
144     // Re-color with 11 remset bits if we got intercepted by a GC safepoint
145     const bool result = initialize_memory();
146     assert(result, "Array initialization should always succeed the second time");
147   }
148 
149   mem_zap_end_padding(mem);
150 
151   ZThreadLocalData::clear_invisible_root(_thread);
152 
153   // Signal to the ZIterator that this is no longer an invisible root
154   if (UseCompactObjectHeaders) {
155     oopDesc::release_set_mark(mem, _klass->prototype_header());
156   } else {
157     oopDesc::release_set_mark(mem, markWord::prototype());
158   }
159 
160   return cast_to_oop(mem);
161 }
< prev index next >