< prev index next >

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

Print this page

144     // the release-cmpxchg that performed the forwarding, possibly in some
145     // other thread.
146     OrderAccess::acquire();
147     // Return the already installed forwardee.
148     return cast_to_oop(m.decode_pointer());
149   }
150 }
151 
152 //
153 // This method is pretty bulky. It would be nice to split it up
154 // into smaller submethods, but we need to be careful not to hurt
155 // performance.
156 //
157 template<bool promote_immediately>
158 inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
159                                                                markWord test_mark) {
160   assert(should_scavenge(&o), "Sanity");
161 
162   oop new_obj = NULL;
163   bool new_obj_is_tenured = false;
164   size_t new_obj_size = o->size();
165 
166   // Find the objects age, MT safe.
167   uint age = (test_mark.has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
168       test_mark.displaced_mark_helper().age() : test_mark.age();
169 
170   if (!promote_immediately) {
171     // Try allocating obj in to-space (unless too old)
172     if (age < PSScavenge::tenuring_threshold()) {
173       new_obj = cast_to_oop(_young_lab.allocate(new_obj_size));
174       if (new_obj == NULL && !_young_gen_is_full) {
175         // Do we allocate directly, or flush and refill?
176         if (new_obj_size > (YoungPLABSize / 2)) {
177           // Allocate this object directly
178           new_obj = cast_to_oop(young_space()->cas_allocate(new_obj_size));
179           promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL);
180         } else {
181           // Flush and fill
182           _young_lab.flush();
183 
184           HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize);

233           }
234         }
235       }
236 
237       // This is the promotion failed test, and code handling.
238       // The code belongs here for two reasons. It is slightly
239       // different than the code below, and cannot share the
240       // CAS testing code. Keeping the code here also minimizes
241       // the impact on the common case fast path code.
242 
243       if (new_obj == NULL) {
244         _old_gen_is_full = true;
245         return oop_promotion_failed(o, test_mark);
246       }
247     }
248   }
249 
250   assert(new_obj != NULL, "allocation should have succeeded");
251 
252   // Copy obj
253   Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(o), cast_from_oop<HeapWord*>(new_obj), new_obj_size);
254 
255   // Now we have to CAS in the header.
256   // Make copy visible to threads reading the forwardee.
257   oop forwardee = o->forward_to_atomic(new_obj, test_mark, memory_order_release);
258   if (forwardee == NULL) {  // forwardee is NULL when forwarding is successful
259     // We won any races, we "own" this object.
260     assert(new_obj == o->forwardee(), "Sanity");
261 
262     // Increment age if obj still in new generation. Now that
263     // we're dealing with a markWord that cannot change, it is
264     // okay to use the non mt safe oop methods.
265     if (!new_obj_is_tenured) {
266       new_obj->incr_age();
267       assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj");
268     }
269 
270     // Do the size comparison first with new_obj_size, which we
271     // already have. Hopefully, only a few objects are larger than
272     // _min_array_size_for_chunking, and most of them will be arrays.
273     // So, the is->objArray() test would be very infrequent.

144     // the release-cmpxchg that performed the forwarding, possibly in some
145     // other thread.
146     OrderAccess::acquire();
147     // Return the already installed forwardee.
148     return cast_to_oop(m.decode_pointer());
149   }
150 }
151 
152 //
153 // This method is pretty bulky. It would be nice to split it up
154 // into smaller submethods, but we need to be careful not to hurt
155 // performance.
156 //
157 template<bool promote_immediately>
158 inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
159                                                                markWord test_mark) {
160   assert(should_scavenge(&o), "Sanity");
161 
162   oop new_obj = NULL;
163   bool new_obj_is_tenured = false;
164   size_t new_obj_size = o->compact_size();
165 
166   // Find the objects age, MT safe.
167   uint age = (test_mark.has_displaced_mark_helper() /* o->has_displaced_mark() */) ?
168       test_mark.displaced_mark_helper().age() : test_mark.age();
169 
170   if (!promote_immediately) {
171     // Try allocating obj in to-space (unless too old)
172     if (age < PSScavenge::tenuring_threshold()) {
173       new_obj = cast_to_oop(_young_lab.allocate(new_obj_size));
174       if (new_obj == NULL && !_young_gen_is_full) {
175         // Do we allocate directly, or flush and refill?
176         if (new_obj_size > (YoungPLABSize / 2)) {
177           // Allocate this object directly
178           new_obj = cast_to_oop(young_space()->cas_allocate(new_obj_size));
179           promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL);
180         } else {
181           // Flush and fill
182           _young_lab.flush();
183 
184           HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize);

233           }
234         }
235       }
236 
237       // This is the promotion failed test, and code handling.
238       // The code belongs here for two reasons. It is slightly
239       // different than the code below, and cannot share the
240       // CAS testing code. Keeping the code here also minimizes
241       // the impact on the common case fast path code.
242 
243       if (new_obj == NULL) {
244         _old_gen_is_full = true;
245         return oop_promotion_failed(o, test_mark);
246       }
247     }
248   }
249 
250   assert(new_obj != NULL, "allocation should have succeeded");
251 
252   // Copy obj
253   o->copy_disjoint_compact(cast_from_oop<HeapWord*>(new_obj), new_obj_size);
254 
255   // Now we have to CAS in the header.
256   // Make copy visible to threads reading the forwardee.
257   oop forwardee = o->forward_to_atomic(new_obj, test_mark, memory_order_release);
258   if (forwardee == NULL) {  // forwardee is NULL when forwarding is successful
259     // We won any races, we "own" this object.
260     assert(new_obj == o->forwardee(), "Sanity");
261 
262     // Increment age if obj still in new generation. Now that
263     // we're dealing with a markWord that cannot change, it is
264     // okay to use the non mt safe oop methods.
265     if (!new_obj_is_tenured) {
266       new_obj->incr_age();
267       assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj");
268     }
269 
270     // Do the size comparison first with new_obj_size, which we
271     // already have. Hopefully, only a few objects are larger than
272     // _min_array_size_for_chunking, and most of them will be arrays.
273     // So, the is->objArray() test would be very infrequent.
< prev index next >