Skip to content

Commit dd74e7f

Browse files
committed
8335147: Serial: Refactor TenuredGeneration::promote
Reviewed-by: tschatzl, iwalulya
1 parent a537e87 commit dd74e7f

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

src/hotspot/share/gc/serial/defNewGeneration.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -768,25 +768,25 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
768768
bool new_obj_is_tenured = false;
769769
// Otherwise try allocating obj tenured
770770
if (obj == nullptr) {
771-
obj = _old_gen->promote(old, s);
771+
obj = _old_gen->allocate_for_promotion(old, s);
772772
if (obj == nullptr) {
773773
handle_promotion_failure(old);
774774
return old;
775775
}
776776

777-
ContinuationGCSupport::transform_stack_chunk(obj);
778-
779777
new_obj_is_tenured = true;
780-
} else {
781-
// Prefetch beyond obj
782-
const intx interval = PrefetchCopyIntervalInBytes;
783-
Prefetch::write(obj, interval);
778+
}
779+
780+
// Prefetch beyond obj
781+
const intx interval = PrefetchCopyIntervalInBytes;
782+
Prefetch::write(obj, interval);
784783

785-
// Copy obj
786-
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), cast_from_oop<HeapWord*>(obj), s);
784+
// Copy obj
785+
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), cast_from_oop<HeapWord*>(obj), s);
787786

788-
ContinuationGCSupport::transform_stack_chunk(obj);
787+
ContinuationGCSupport::transform_stack_chunk(obj);
789788

789+
if (!new_obj_is_tenured) {
790790
// Increment age if obj still in new generation
791791
obj->incr_age();
792792
age_table()->add(obj, s);

src/hotspot/share/gc/serial/tenuredGeneration.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ bool TenuredGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes)
387387
return res;
388388
}
389389

390-
oop TenuredGeneration::promote(oop obj, size_t obj_size) {
390+
oop TenuredGeneration::allocate_for_promotion(oop obj, size_t obj_size) {
391391
assert(obj_size == obj->size(), "bad obj_size passed in");
392392

393393
#ifndef PRODUCT
@@ -401,15 +401,9 @@ oop TenuredGeneration::promote(oop obj, size_t obj_size) {
401401
if (result == nullptr) {
402402
// Promotion of obj into gen failed. Try to expand and allocate.
403403
result = expand_and_allocate(obj_size, false);
404-
if (result == nullptr) {
405-
return nullptr;
406-
}
407404
}
408405

409-
// Copy to new location.
410-
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size);
411-
oop new_obj = cast_to_oop<HeapWord*>(result);
412-
return new_obj;
406+
return cast_to_oop<HeapWord*>(result);
413407
}
414408

415409
HeapWord*

src/hotspot/share/gc/serial/tenuredGeneration.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,11 @@ class TenuredGeneration: public Generation {
163163
bool promotion_attempt_is_safe(size_t max_promoted_in_bytes) const;
164164

165165
// "obj" is the address of an object in young-gen. Allocate space for "obj"
166-
// in the old-gen, and copy "obj" into the newly allocated space, if
167-
// possible, returning the result (or null if the allocation failed).
166+
// in the old-gen, returning the result (or null if the allocation failed).
168167
//
169168
// The "obj_size" argument is just obj->size(), passed along so the caller can
170169
// avoid repeating the virtual call to retrieve it.
171-
oop promote(oop obj, size_t obj_size);
170+
oop allocate_for_promotion(oop obj, size_t obj_size);
172171

173172
virtual void verify();
174173
virtual void print_on(outputStream* st) const;

0 commit comments

Comments
 (0)