8383564: Avoid reloading klass when transforming stack chunks

Reviewed-by: stefank, tschatzl
This commit is contained in:
Albert Mingkun Yang 2026-04-30 09:39:12 +00:00
parent 100c500899
commit fbb50f5c6c
5 changed files with 13 additions and 5 deletions

View File

@ -444,7 +444,7 @@ void G1ParScanThreadState::do_iterate_object(oop const obj,
return;
}
ContinuationGCSupport::transform_stack_chunk(obj);
ContinuationGCSupport::transform_stack_chunk(obj, klass);
// Check for deduplicating young Strings.
if (G1StringDedup::is_candidate_from_evacuation(klass,

View File

@ -292,7 +292,7 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj");
}
ContinuationGCSupport::transform_stack_chunk(new_obj);
ContinuationGCSupport::transform_stack_chunk(new_obj, klass);
// Do the size comparison first with new_obj_size, which we
// already have. Hopefully, only a few objects are larger than

View File

@ -698,7 +698,8 @@ void DefNewGeneration::handle_promotion_failure(oop old) {
oop DefNewGeneration::copy_to_survivor_space(oop old) {
assert(is_in_reserved(old) && !old->is_forwarded(),
"shouldn't be scavenging this oop");
size_t s = old->size();
Klass* klass = old->klass();
size_t s = old->size_given_klass(klass);
oop obj = nullptr;
// Try allocating obj in to-space (unless too old)
@ -725,7 +726,7 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
// Copy obj
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), cast_from_oop<HeapWord*>(obj), s);
ContinuationGCSupport::transform_stack_chunk(obj);
ContinuationGCSupport::transform_stack_chunk(obj, klass);
if (!new_obj_is_tenured) {
// Increment age if obj still in new generation

View File

@ -28,6 +28,8 @@
#include "memory/allStatic.hpp"
#include "oops/oopsHierarchy.hpp"
class Klass;
class ContinuationGCSupport : public AllStatic {
public:
// Relativize the given oop if it is a stack chunk.
@ -35,6 +37,7 @@ public:
// Relativize and transform to use a bitmap for future oop iteration for the
// given oop if it is a stack chunk.
static void transform_stack_chunk(oop obj);
static void transform_stack_chunk(oop obj, Klass* klass);
};
#endif // SHARE_GC_SHARED_CONTINUATIONGCSUPPORT_HPP

View File

@ -43,7 +43,11 @@ inline bool ContinuationGCSupport::relativize_stack_chunk(oop obj) {
}
inline void ContinuationGCSupport::transform_stack_chunk(oop obj) {
if (!obj->is_stackChunk()) {
transform_stack_chunk(obj, obj->klass());
}
inline void ContinuationGCSupport::transform_stack_chunk(oop obj, Klass* klass) {
if (!klass->is_stack_chunk_instance_klass()) {
return;
}