Skip to content

Commit 57b04e1

Browse files
committed
8325748: Serial: Move Generation::promote to TenuredGeneration
Reviewed-by: stefank
1 parent 7cd25ed commit 57b04e1

File tree

4 files changed

+38
-40
lines changed

4 files changed

+38
-40
lines changed

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "gc/serial/generation.hpp"
2828
#include "gc/serial/serialHeap.hpp"
2929
#include "gc/shared/collectedHeap.inline.hpp"
30-
#include "gc/shared/continuationGCSupport.inline.hpp"
3130
#include "gc/shared/gcLocker.hpp"
3231
#include "gc/shared/gcTimer.hpp"
3332
#include "gc/shared/gcTrace.hpp"
@@ -92,33 +91,3 @@ size_t Generation::max_contiguous_available() const {
9291
}
9392
return MAX2(avail, old_avail);
9493
}
95-
96-
// Ignores "ref" and calls allocate().
97-
oop Generation::promote(oop obj, size_t obj_size) {
98-
assert(obj_size == obj->size(), "bad obj_size passed in");
99-
100-
#ifndef PRODUCT
101-
if (SerialHeap::heap()->promotion_should_fail()) {
102-
return nullptr;
103-
}
104-
#endif // #ifndef PRODUCT
105-
106-
// Allocate new object.
107-
HeapWord* result = allocate(obj_size, false);
108-
if (result == nullptr) {
109-
// Promotion of obj into gen failed. Try to expand and allocate.
110-
result = expand_and_allocate(obj_size, false);
111-
if (result == nullptr) {
112-
return nullptr;
113-
}
114-
}
115-
116-
// Copy to new location.
117-
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size);
118-
oop new_obj = cast_to_oop<HeapWord*>(result);
119-
120-
// Transform object if it is a stack chunk.
121-
ContinuationGCSupport::transform_stack_chunk(new_obj);
122-
123-
return new_obj;
124-
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,6 @@ class Generation: public CHeapObj<mtGC> {
142142
// Thread-local allocation buffers
143143
virtual bool supports_tlab_allocation() const { return false; }
144144

145-
// "obj" is the address of an object in a younger generation. Allocate space
146-
// for "obj" in the current (or some higher) generation, and copy "obj" into
147-
// the newly allocated space, if possible, returning the result (or null if
148-
// the allocation failed).
149-
//
150-
// The "obj_size" argument is just obj->size(), passed along so the caller can
151-
// avoid repeating the virtual call to retrieve it.
152-
virtual oop promote(oop obj, size_t obj_size);
153-
154145
// Returns "true" iff collect() should subsequently be called on this
155146
// this generation. See comment below.
156147
// This is a generic implementation which can be overridden.

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "gc/serial/serialHeap.hpp"
3030
#include "gc/serial/tenuredGeneration.inline.hpp"
3131
#include "gc/shared/collectorCounters.hpp"
32+
#include "gc/shared/continuationGCSupport.inline.hpp"
3233
#include "gc/shared/gcLocker.hpp"
3334
#include "gc/shared/gcTimer.hpp"
3435
#include "gc/shared/gcTrace.hpp"
@@ -413,6 +414,35 @@ bool TenuredGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes)
413414
return res;
414415
}
415416

417+
oop TenuredGeneration::promote(oop obj, size_t obj_size) {
418+
assert(obj_size == obj->size(), "bad obj_size passed in");
419+
420+
#ifndef PRODUCT
421+
if (SerialHeap::heap()->promotion_should_fail()) {
422+
return nullptr;
423+
}
424+
#endif // #ifndef PRODUCT
425+
426+
// Allocate new object.
427+
HeapWord* result = allocate(obj_size, false);
428+
if (result == nullptr) {
429+
// Promotion of obj into gen failed. Try to expand and allocate.
430+
result = expand_and_allocate(obj_size, false);
431+
if (result == nullptr) {
432+
return nullptr;
433+
}
434+
}
435+
436+
// Copy to new location.
437+
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size);
438+
oop new_obj = cast_to_oop<HeapWord*>(result);
439+
440+
// Transform object if it is a stack chunk.
441+
ContinuationGCSupport::transform_stack_chunk(new_obj);
442+
443+
return new_obj;
444+
}
445+
416446
void TenuredGeneration::collect(bool full,
417447
bool clear_all_soft_refs,
418448
size_t size,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ class TenuredGeneration: public Generation {
160160
// might be attempted in the worst case.
161161
bool promotion_attempt_is_safe(size_t max_promoted_in_bytes) const;
162162

163+
// "obj" is the address of an object in young-gen. Allocate space for "obj"
164+
// in the old-gen, and copy "obj" into the newly allocated space, if
165+
// possible, returning the result (or null if the allocation failed).
166+
//
167+
// The "obj_size" argument is just obj->size(), passed along so the caller can
168+
// avoid repeating the virtual call to retrieve it.
169+
oop promote(oop obj, size_t obj_size);
170+
163171
virtual void verify();
164172
virtual void print_on(outputStream* st) const;
165173
};

0 commit comments

Comments
 (0)