315 // inflating, because inflation can not be interrupted by a safepoint,
316 // and after a safepoint, a Java thread would first have to successfully
317 // evacuate the object before it could inflate the monitor.
318 assert(!w.is_being_inflated() || LockingMode == LM_LIGHTWEIGHT, "must not inflate monitor before evacuation of object succeeds");
319 // It is possible that we have copied the object after another thread has
320 // already successfully completed evacuation. While harmless (we would never
321 // publish our copy), don't even attempt to modify the age when that
322 // happens.
323 if (!w.has_displaced_mark_helper() && !w.is_marked()) {
324 w = w.set_age(MIN2(markWord::max_age, w.age() + additional_age));
325 obj->set_mark(w);
326 }
327 }
328
329 // Return the object's age, or a sentinel value when the age can't
330 // necessarily be determined because of concurrent locking by the
331 // mutator
332 uint ShenandoahHeap::get_object_age(oop obj) {
333 markWord w = obj->mark();
334 assert(!w.is_marked(), "must not be forwarded");
335 if (UseObjectMonitorTable) {
336 assert(LockingMode == LM_LIGHTWEIGHT, "Must use LW locking, too");
337 assert(w.age() <= markWord::max_age, "Impossible!");
338 return w.age();
339 }
340 if (w.has_monitor()) {
341 w = w.monitor()->header();
342 } else if (w.is_being_inflated() || w.has_displaced_mark_helper()) {
343 // Informs caller that we aren't able to determine the age
344 return markWord::max_age + 1; // sentinel
345 }
346 assert(w.age() <= markWord::max_age, "Impossible!");
347 return w.age();
348 }
349
350 inline bool ShenandoahHeap::is_in_active_generation(oop obj) const {
351 if (!mode()->is_generational()) {
352 // everything is the same single generation
353 assert(is_in_reserved(obj), "Otherwise shouldn't return true below");
354 return true;
355 }
356
357 ShenandoahGeneration* const gen = active_generation();
358
359 if (gen == nullptr) {
|
315 // inflating, because inflation can not be interrupted by a safepoint,
316 // and after a safepoint, a Java thread would first have to successfully
317 // evacuate the object before it could inflate the monitor.
318 assert(!w.is_being_inflated() || LockingMode == LM_LIGHTWEIGHT, "must not inflate monitor before evacuation of object succeeds");
319 // It is possible that we have copied the object after another thread has
320 // already successfully completed evacuation. While harmless (we would never
321 // publish our copy), don't even attempt to modify the age when that
322 // happens.
323 if (!w.has_displaced_mark_helper() && !w.is_marked()) {
324 w = w.set_age(MIN2(markWord::max_age, w.age() + additional_age));
325 obj->set_mark(w);
326 }
327 }
328
329 // Return the object's age, or a sentinel value when the age can't
330 // necessarily be determined because of concurrent locking by the
331 // mutator
332 uint ShenandoahHeap::get_object_age(oop obj) {
333 markWord w = obj->mark();
334 assert(!w.is_marked(), "must not be forwarded");
335
336 if (UseObjectMonitorTable) {
337 assert(LockingMode == LM_LIGHTWEIGHT, "Must use LW locking, too");
338 assert(w.age() <= markWord::max_age, "Impossible!");
339 return w.age();
340 }
341
342 if (w.has_monitor()) {
343 w = w.monitor()->header();
344 } else if (w.is_being_inflated() || w.has_displaced_mark_helper()) {
345 // Informs caller that we aren't able to determine the age
346 return markWord::max_age + 1; // sentinel
347 }
348 assert(w.age() <= markWord::max_age, "Impossible!");
349 return w.age();
350 }
351
352 inline bool ShenandoahHeap::is_in_active_generation(oop obj) const {
353 if (!mode()->is_generational()) {
354 // everything is the same single generation
355 assert(is_in_reserved(obj), "Otherwise shouldn't return true below");
356 return true;
357 }
358
359 ShenandoahGeneration* const gen = active_generation();
360
361 if (gen == nullptr) {
|