From 9ca7b24421a5ea4fafb39bcf0c9744696932f49d Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Mon, 15 Sep 2025 07:48:38 +0000 Subject: [PATCH] 8367422: Parallel: Refactor local variables names in copy_unmarked_to_survivor_space Reviewed-by: fandreuzzi, tschatzl --- .../gc/parallel/psPromotionManager.inline.hpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp index 31c1c445a32..4c12a4c357f 100644 --- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp +++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp @@ -236,7 +236,7 @@ inline HeapWord* PSPromotionManager::allocate_in_old_gen(Klass* klass, template inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o, markWord test_mark) { - oop new_obj = nullptr; + HeapWord* new_obj_addr = nullptr; bool new_obj_is_tenured = false; // NOTE: With compact headers, it is not safe to load the Klass* from old, because @@ -259,32 +259,33 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o, if (!promote_immediately) { // Try allocating obj in to-space (unless too old) if (age < PSScavenge::tenuring_threshold()) { - new_obj = cast_to_oop(allocate_in_young_gen(klass, new_obj_size, age)); + new_obj_addr = allocate_in_young_gen(klass, new_obj_size, age); } } // Otherwise try allocating obj tenured - if (new_obj == nullptr) { - new_obj = cast_to_oop(allocate_in_old_gen(klass, new_obj_size, age)); - if (new_obj == nullptr) { + if (new_obj_addr == nullptr) { + new_obj_addr = allocate_in_old_gen(klass, new_obj_size, age); + if (new_obj_addr == nullptr) { return oop_promotion_failed(o, test_mark); } new_obj_is_tenured = true; } - assert(new_obj != nullptr, "allocation should have succeeded"); + assert(new_obj_addr != nullptr, "allocation should have succeeded"); // Copy obj - Copy::aligned_disjoint_words(cast_from_oop(o), cast_from_oop(new_obj), new_obj_size); + Copy::aligned_disjoint_words(cast_from_oop(o), new_obj_addr, new_obj_size); // Now we have to CAS in the header. // Because the forwarding is done with memory_order_relaxed there is no // ordering with the above copy. Clients that get the forwardee must not // examine its contents without other synchronization, since the contents // may not be up to date for them. - oop forwardee = o->forward_to_atomic(new_obj, test_mark, memory_order_relaxed); + oop forwardee = o->forward_to_atomic(cast_to_oop(new_obj_addr), test_mark, memory_order_relaxed); if (forwardee == nullptr) { // forwardee is null when forwarding is successful // We won any races, we "own" this object. + oop new_obj = cast_to_oop(new_obj_addr); assert(new_obj == o->forwardee(), "Sanity"); // Increment age if obj still in new generation. Now that @@ -321,9 +322,9 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o, assert(o->forwardee() == forwardee, "invariant"); if (new_obj_is_tenured) { - _old_lab.unallocate_object(cast_from_oop(new_obj), new_obj_size); + _old_lab.unallocate_object(new_obj_addr, new_obj_size); } else { - _young_lab.unallocate_object(cast_from_oop(new_obj), new_obj_size); + _young_lab.unallocate_object(new_obj_addr, new_obj_size); } return forwardee; }