提交 70cdfd06 编写于 作者: J jwilhelm

8026852: Use restricted_align_down in collector policy code

Summary: Moved restricted_align_down to globalDefinitions and renamed it align_size_down_bounded
Reviewed-by: stefank, mgerdin, tschatzl
上级 1d78780a
......@@ -146,11 +146,7 @@ size_t CollectorPolicy::compute_max_alignment() {
// GenCollectorPolicy methods.
size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) {
size_t x = base_size / (NewRatio+1);
size_t new_gen_size = x > _min_alignment ?
align_size_down(x, _min_alignment) :
_min_alignment;
return new_gen_size;
return align_size_down_bounded(base_size / (NewRatio + 1), _min_alignment);
}
size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size,
......@@ -410,15 +406,11 @@ bool TwoGenerationCollectorPolicy::adjust_gen0_sizes(size_t* gen0_size_ptr,
if ((heap_size < (*gen0_size_ptr + min_gen1_size)) &&
(heap_size >= min_gen1_size + _min_alignment)) {
// Adjust gen0 down to accommodate min_gen1_size
*gen0_size_ptr = heap_size - min_gen1_size;
*gen0_size_ptr =
MAX2((uintx)align_size_down(*gen0_size_ptr, _min_alignment), _min_alignment);
*gen0_size_ptr = align_size_down_bounded(heap_size - min_gen1_size, _min_alignment);
assert(*gen0_size_ptr > 0, "Min gen0 is too large");
result = true;
} else {
*gen1_size_ptr = heap_size - *gen0_size_ptr;
*gen1_size_ptr =
MAX2((uintx)align_size_down(*gen1_size_ptr, _min_alignment), _min_alignment);
*gen1_size_ptr = align_size_down_bounded(heap_size - *gen0_size_ptr, _min_alignment);
}
}
return result;
......
......@@ -2965,11 +2965,6 @@ void Metaspace::initialize_class_space(ReservedSpace rs) {
#endif
// Align down. If the aligning result in 0, return 'alignment'.
static size_t restricted_align_down(size_t size, size_t alignment) {
return MAX2(alignment, align_size_down_(size, alignment));
}
void Metaspace::ergo_initialize() {
if (DumpSharedSpaces) {
// Using large pages when dumping the shared archive is currently not implemented.
......@@ -2992,13 +2987,13 @@ void Metaspace::ergo_initialize() {
// Ideally, we would be able to set the default value of MaxMetaspaceSize in
// globals.hpp to the aligned value, but this is not possible, since the
// alignment depends on other flags being parsed.
MaxMetaspaceSize = restricted_align_down(MaxMetaspaceSize, _reserve_alignment);
MaxMetaspaceSize = align_size_down_bounded(MaxMetaspaceSize, _reserve_alignment);
if (MetaspaceSize > MaxMetaspaceSize) {
MetaspaceSize = MaxMetaspaceSize;
}
MetaspaceSize = restricted_align_down(MetaspaceSize, _commit_alignment);
MetaspaceSize = align_size_down_bounded(MetaspaceSize, _commit_alignment);
assert(MetaspaceSize <= MaxMetaspaceSize, "MetaspaceSize should be limited by MaxMetaspaceSize");
......@@ -3006,10 +3001,10 @@ void Metaspace::ergo_initialize() {
vm_exit_during_initialization("Too small initial Metaspace size");
}
MinMetaspaceExpansion = restricted_align_down(MinMetaspaceExpansion, _commit_alignment);
MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, _commit_alignment);
MinMetaspaceExpansion = align_size_down_bounded(MinMetaspaceExpansion, _commit_alignment);
MaxMetaspaceExpansion = align_size_down_bounded(MaxMetaspaceExpansion, _commit_alignment);
CompressedClassSpaceSize = restricted_align_down(CompressedClassSpaceSize, _reserve_alignment);
CompressedClassSpaceSize = align_size_down_bounded(CompressedClassSpaceSize, _reserve_alignment);
set_class_metaspace_size(CompressedClassSpaceSize);
}
......
......@@ -458,6 +458,13 @@ inline void* align_pointer_up(const void* addr, size_t size) {
return (void*) align_size_up_((uintptr_t)addr, size);
}
// Align down with a lower bound. If the aligning results in 0, return 'alignment'.
inline size_t align_size_down_bounded(size_t size, size_t alignment) {
size_t aligned_size = align_size_down_(size, alignment);
return aligned_size > 0 ? aligned_size : alignment;
}
// Clamp an address to be within a specific page
// 1. If addr is on the page it is returned as is
// 2. If addr is above the page_address the start of the *next* page will be returned
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册