< prev index next >

src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp

Print this page

160 //
161 template<bool promote_immediately>
162 inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
163                                                                markWord test_mark) {
164   assert(should_scavenge(&o), "Sanity");
165 
166   oop new_obj = nullptr;
167   bool new_obj_is_tenured = false;
168 
169   // NOTE: With compact headers, it is not safe to load the Klass* from old, because
170   // that would access the mark-word, that might change at any time by concurrent
171   // workers.
172   // This mark word would refer to a forwardee, which may not yet have completed
173   // copying. Therefore we must load the Klass* from the mark-word that we already
174   // loaded. This is safe, because we only enter here if not yet forwarded.
175   assert(!test_mark.is_forwarded(), "precondition");
176   Klass* klass = UseCompactObjectHeaders
177       ? test_mark.klass()
178       : o->klass();
179 
180   size_t new_obj_size = o->size_given_klass(klass);

181 
182   // Find the objects age, MT safe.
183   uint age = (test_mark.has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
184       test_mark.displaced_mark_helper().age() : test_mark.age();
185 
186   if (!promote_immediately) {
187     // Try allocating obj in to-space (unless too old)
188     if (age < PSScavenge::tenuring_threshold()) {
189       new_obj = cast_to_oop(_young_lab.allocate(new_obj_size));
190       if (new_obj == nullptr && !_young_gen_is_full) {
191         // Do we allocate directly, or flush and refill?
192         if (new_obj_size > (YoungPLABSize / 2)) {
193           // Allocate this object directly
194           new_obj = cast_to_oop(young_space()->cas_allocate(new_obj_size));
195           promotion_trace_event(new_obj, klass, new_obj_size, age, false, nullptr);
196         } else {
197           // Flush and fill
198           _young_lab.flush();
199 
200           HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize);

160 //
161 template<bool promote_immediately>
162 inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
163                                                                markWord test_mark) {
164   assert(should_scavenge(&o), "Sanity");
165 
166   oop new_obj = nullptr;
167   bool new_obj_is_tenured = false;
168 
169   // NOTE: With compact headers, it is not safe to load the Klass* from old, because
170   // that would access the mark-word, that might change at any time by concurrent
171   // workers.
172   // This mark word would refer to a forwardee, which may not yet have completed
173   // copying. Therefore we must load the Klass* from the mark-word that we already
174   // loaded. This is safe, because we only enter here if not yet forwarded.
175   assert(!test_mark.is_forwarded(), "precondition");
176   Klass* klass = UseCompactObjectHeaders
177       ? test_mark.klass()
178       : o->klass();
179 
180   size_t old_obj_size = o->size_given_mark_and_klass(test_mark, klass);
181   size_t new_obj_size = o->copy_size(old_obj_size, test_mark);
182 
183   // Find the objects age, MT safe.
184   uint age = (test_mark.has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
185       test_mark.displaced_mark_helper().age() : test_mark.age();
186 
187   if (!promote_immediately) {
188     // Try allocating obj in to-space (unless too old)
189     if (age < PSScavenge::tenuring_threshold()) {
190       new_obj = cast_to_oop(_young_lab.allocate(new_obj_size));
191       if (new_obj == nullptr && !_young_gen_is_full) {
192         // Do we allocate directly, or flush and refill?
193         if (new_obj_size > (YoungPLABSize / 2)) {
194           // Allocate this object directly
195           new_obj = cast_to_oop(young_space()->cas_allocate(new_obj_size));
196           promotion_trace_event(new_obj, klass, new_obj_size, age, false, nullptr);
197         } else {
198           // Flush and fill
199           _young_lab.flush();
200 
201           HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize);
< prev index next >