Skip to content

Commit 38574d5

Browse files
author
Thomas Schatzl
committed
8255298: Remove SurvivorAlignmentInBytes functionality
Reviewed-by: shade, ayang, kbarrett
1 parent 4031cb4 commit 38574d5

24 files changed

+6
-1426
lines changed

src/hotspot/share/gc/g1/g1Allocator.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -281,22 +281,9 @@ HeapWord* G1Allocator::old_attempt_allocation(size_t min_word_size,
281281
return result;
282282
}
283283

284-
uint G1PLABAllocator::calc_survivor_alignment_bytes() {
285-
assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
286-
if (SurvivorAlignmentInBytes == ObjectAlignmentInBytes) {
287-
// No need to align objects in the survivors differently, return 0
288-
// which means "survivor alignment is not used".
289-
return 0;
290-
} else {
291-
assert(SurvivorAlignmentInBytes > 0, "sanity");
292-
return SurvivorAlignmentInBytes;
293-
}
294-
}
295-
296284
G1PLABAllocator::G1PLABAllocator(G1Allocator* allocator) :
297285
_g1h(G1CollectedHeap::heap()),
298-
_allocator(allocator),
299-
_survivor_alignment_bytes(calc_survivor_alignment_bytes()) {
286+
_allocator(allocator) {
300287
for (region_type_t state = 0; state < G1HeapRegionAttr::Num; state++) {
301288
_direct_allocated[state] = 0;
302289
uint length = alloc_buffers_length(state);

src/hotspot/share/gc/g1/g1Allocator.hpp

-11
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ class G1PLABAllocator : public CHeapObj<mtGC> {
149149

150150
PLAB** _alloc_buffers[G1HeapRegionAttr::Num];
151151

152-
// The survivor alignment in effect in bytes.
153-
// == 0 : don't align survivors
154-
// != 0 : align survivors to that alignment
155-
// These values were chosen to favor the non-alignment case since some
156-
// architectures have a special compare against zero instructions.
157-
const uint _survivor_alignment_bytes;
158-
159152
// Number of words allocated directly (not counting PLAB allocation).
160153
size_t _direct_allocated[G1HeapRegionAttr::Num];
161154

@@ -168,10 +161,6 @@ class G1PLABAllocator : public CHeapObj<mtGC> {
168161
// active NUMA nodes.
169162
inline uint alloc_buffers_length(region_type_t dest) const;
170163

171-
// Calculate the survivor space object alignment in bytes. Returns that or 0 if
172-
// there are no restrictions on survivor alignment.
173-
static uint calc_survivor_alignment_bytes();
174-
175164
bool may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const;
176165
public:
177166
G1PLABAllocator(G1Allocator* allocator);

src/hotspot/share/gc/g1/g1Allocator.inline.hpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,7 @@ inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
105105
size_t word_sz,
106106
uint node_index) {
107107
PLAB* buffer = alloc_buffer(dest, node_index);
108-
if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
109-
return buffer->allocate(word_sz);
110-
} else {
111-
return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
112-
}
108+
return buffer->allocate(word_sz);
113109
}
114110

115111
inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,

src/hotspot/share/gc/parallel/psPromotionLAB.inline.hpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,14 @@
3232
HeapWord* PSYoungPromotionLAB::allocate(size_t size) {
3333
// Can't assert this, when young fills, we keep the LAB around, but flushed.
3434
// assert(_state != flushed, "Sanity");
35-
HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes);
36-
if (obj == NULL) {
37-
return NULL;
38-
}
39-
35+
HeapWord* obj = top();
4036
HeapWord* new_top = obj + size;
4137
// The 'new_top>obj' check is needed to detect overflow of obj+size.
4238
if (new_top > obj && new_top <= end()) {
4339
set_top(new_top);
44-
assert(is_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned(new_top),
45-
"checking alignment");
40+
assert(is_object_aligned(new_top), "checking alignment");
4641
return obj;
4742
} else {
48-
set_top(obj);
4943
return NULL;
5044
}
5145
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
711711

712712
// Try allocating obj in to-space (unless too old)
713713
if (old->age() < tenuring_threshold()) {
714-
obj = (oop) to()->allocate_aligned(s);
714+
obj = (oop) to()->allocate(s);
715715
}
716716

717717
// Otherwise try allocating obj tenured

src/hotspot/share/gc/shared/collectedHeap.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,6 @@ class CollectedHeap : public CHeapObj<mtInternal> {
310310
virtual size_t min_dummy_object_size() const;
311311
size_t tlab_alloc_reserve() const;
312312

313-
// Return the address "addr" aligned by "alignment_in_bytes" if such
314-
// an address is below "end". Return NULL otherwise.
315-
inline static HeapWord* align_allocation_or_fail(HeapWord* addr,
316-
HeapWord* end,
317-
unsigned short alignment_in_bytes);
318-
319313
// Some heaps may offer a contiguous region for shared non-blocking
320314
// allocation, via inlined code (by exporting the address of the top and
321315
// end fields defining the extent of the contiguous allocation region.)

src/hotspot/share/gc/shared/collectedHeap.inline.hpp

-37
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,6 @@
3030
#include "oops/oop.inline.hpp"
3131
#include "utilities/align.hpp"
3232

33-
inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
34-
HeapWord* end,
35-
unsigned short alignment_in_bytes) {
36-
if (alignment_in_bytes <= ObjectAlignmentInBytes) {
37-
return addr;
38-
}
39-
40-
assert(is_aligned(addr, HeapWordSize),
41-
"Address " PTR_FORMAT " is not properly aligned.", p2i(addr));
42-
assert(is_aligned(alignment_in_bytes, HeapWordSize),
43-
"Alignment size %u is incorrect.", alignment_in_bytes);
44-
45-
HeapWord* new_addr = align_up(addr, alignment_in_bytes);
46-
size_t padding = pointer_delta(new_addr, addr);
47-
48-
if (padding == 0) {
49-
return addr;
50-
}
51-
52-
if (padding < CollectedHeap::min_fill_size()) {
53-
padding += alignment_in_bytes / HeapWordSize;
54-
assert(padding >= CollectedHeap::min_fill_size(),
55-
"alignment_in_bytes %u is expect to be larger "
56-
"than the minimum object size", alignment_in_bytes);
57-
new_addr = addr + padding;
58-
}
59-
60-
assert(new_addr > addr, "Unexpected arithmetic overflow "
61-
PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr));
62-
if(new_addr < end) {
63-
CollectedHeap::fill_with_object(addr, padding);
64-
return new_addr;
65-
} else {
66-
return NULL;
67-
}
68-
}
69-
7033
inline oop CollectedHeap::obj_allocate(Klass* klass, int size, TRAPS) {
7134
ObjAllocator allocator(klass, size, THREAD);
7235
return allocator.allocate();

src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,3 @@ JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) {
438438
}
439439
}
440440

441-
JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) {
442-
if (value != 0) {
443-
if (!is_power_of_2(value)) {
444-
JVMFlag::printError(verbose,
445-
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
446-
"power of 2\n",
447-
value);
448-
return JVMFlag::VIOLATES_CONSTRAINT;
449-
}
450-
if (value < ObjectAlignmentInBytes) {
451-
JVMFlag::printError(verbose,
452-
"SurvivorAlignmentInBytes (" INTX_FORMAT ") must be "
453-
"greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n",
454-
value, ObjectAlignmentInBytes);
455-
return JVMFlag::VIOLATES_CONSTRAINT;
456-
}
457-
}
458-
return JVMFlag::SUCCESS;
459-
}

src/hotspot/share/gc/shared/jvmFlagConstraintsGC.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
f(uintx, TLABWasteIncrementConstraintFunc) \
6868
f(uintx, SurvivorRatioConstraintFunc) \
6969
f(size_t, MetaspaceSizeConstraintFunc) \
70-
f(size_t, MaxMetaspaceSizeConstraintFunc) \
71-
f(intx, SurvivorAlignmentInBytesConstraintFunc)
70+
f(size_t, MaxMetaspaceSizeConstraintFunc)
7271

7372
SHARED_GC_CONSTRAINTS(DECLARE_CONSTRAINT)
7473

src/hotspot/share/gc/shared/plab.inline.hpp

-12
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@
3030
#include "memory/allocation.inline.hpp"
3131
#include "runtime/atomic.hpp"
3232

33-
inline HeapWord* PLAB::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
34-
HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
35-
if (res == NULL) {
36-
return NULL;
37-
}
38-
39-
// Set _top so that allocate(), which expects _top to be correctly set,
40-
// can be used below.
41-
_top = res;
42-
return allocate(word_sz);
43-
}
44-
4533
void PLABStats::add_allocated(size_t v) {
4634
Atomic::add(&_allocated, v);
4735
}

src/hotspot/share/gc/shared/space.cpp

-21
Original file line numberDiff line numberDiff line change
@@ -567,27 +567,6 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size) {
567567
} while (true);
568568
}
569569

570-
HeapWord* ContiguousSpace::allocate_aligned(size_t size) {
571-
assert(Heap_lock->owned_by_self() || (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked");
572-
HeapWord* end_value = end();
573-
574-
HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end_value, SurvivorAlignmentInBytes);
575-
if (obj == NULL) {
576-
return NULL;
577-
}
578-
579-
if (pointer_delta(end_value, obj) >= size) {
580-
HeapWord* new_top = obj + size;
581-
set_top(new_top);
582-
assert(::is_aligned(obj, SurvivorAlignmentInBytes) && is_aligned(new_top),
583-
"checking alignment");
584-
return obj;
585-
} else {
586-
set_top(obj);
587-
return NULL;
588-
}
589-
}
590-
591570
// Requires locking.
592571
HeapWord* ContiguousSpace::allocate(size_t size) {
593572
return allocate_impl(size);

src/hotspot/share/gc/shared/space.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ class ContiguousSpace: public CompactibleSpace {
560560
// Allocation (return NULL if full)
561561
virtual HeapWord* allocate(size_t word_size);
562562
virtual HeapWord* par_allocate(size_t word_size);
563-
HeapWord* allocate_aligned(size_t word_size);
564563

565564
// Iteration
566565
void oop_iterate(OopIterateClosure* cl);

src/hotspot/share/runtime/arguments.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -1659,10 +1659,6 @@ void set_object_alignment() {
16591659

16601660
// Oop encoding heap max
16611661
OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1662-
1663-
if (SurvivorAlignmentInBytes == 0) {
1664-
SurvivorAlignmentInBytes = ObjectAlignmentInBytes;
1665-
}
16661662
}
16671663

16681664
size_t Arguments::max_heap_for_compressed_oops() {

src/hotspot/share/runtime/globals.hpp

-5
Original file line numberDiff line numberDiff line change
@@ -2393,11 +2393,6 @@ const intx ObjectAlignmentInBytes = 8;
23932393
product(bool, WhiteBoxAPI, false, DIAGNOSTIC, \
23942394
"Enable internal testing APIs") \
23952395
\
2396-
product(intx, SurvivorAlignmentInBytes, 0, EXPERIMENTAL, \
2397-
"Default survivor space alignment in bytes") \
2398-
range(8, 256) \
2399-
constraint(SurvivorAlignmentInBytesConstraintFunc,AfterErgo) \
2400-
\
24012396
product(ccstr, DumpLoadedClassList, NULL, \
24022397
"Dump the names all loaded classes, that could be stored into " \
24032398
"the CDS archive, in the specified file") \

test/hotspot/jtreg/TEST.groups

-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ tier1_gc_2 = \
202202
-gc/g1/ \
203203
-gc/logging/TestUnifiedLoggingSwitchStress.java \
204204
-gc/stress \
205-
-gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java \
206205
-gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java \
207206
-gc/shenandoah \
208207
-gc/nvdimm

0 commit comments

Comments
 (0)