2013-11-01 17:09:38 +01:00
|
|
|
/*
|
2015-05-13 15:16:06 +02:00
|
|
|
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
|
2013-11-01 17:09:38 +01:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/parallel/generationSizer.hpp"
|
|
|
|
#include "gc/shared/collectorPolicy.hpp"
|
2017-06-22 09:07:47 +02:00
|
|
|
#include "runtime/globals_extension.hpp"
|
2017-07-05 11:33:17 +02:00
|
|
|
#include "utilities/align.hpp"
|
2017-06-22 09:07:47 +02:00
|
|
|
#include "utilities/globalDefinitions.hpp"
|
2013-11-01 17:09:38 +01:00
|
|
|
|
|
|
|
void GenerationSizer::initialize_alignments() {
|
|
|
|
_space_alignment = _gen_alignment = default_gen_alignment();
|
|
|
|
_heap_alignment = compute_heap_alignment();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenerationSizer::initialize_flags() {
|
|
|
|
// Do basic sizing work
|
2014-04-29 22:57:19 +02:00
|
|
|
GenCollectorPolicy::initialize_flags();
|
2013-11-01 17:09:38 +01:00
|
|
|
|
|
|
|
// The survivor ratio's are calculated "raw", unlike the
|
|
|
|
// default gc, which adds 2 to the ratio value. We need to
|
|
|
|
// make sure the values are valid before using them.
|
|
|
|
if (MinSurvivorRatio < 3) {
|
|
|
|
FLAG_SET_ERGO(uintx, MinSurvivorRatio, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InitialSurvivorRatio < 3) {
|
|
|
|
FLAG_SET_ERGO(uintx, InitialSurvivorRatio, 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GenerationSizer::initialize_size_info() {
|
2015-01-16 10:29:12 +01:00
|
|
|
const size_t max_page_sz = os::page_size_for_region_aligned(_max_heap_byte_size, 8);
|
2014-06-24 15:50:50 +02:00
|
|
|
const size_t min_pages = 4; // 1 for eden + 1 for each survivor + 1 for old
|
2015-01-16 10:29:12 +01:00
|
|
|
const size_t min_page_sz = os::page_size_for_region_aligned(_min_heap_byte_size, min_pages);
|
2014-06-24 15:50:50 +02:00
|
|
|
const size_t page_sz = MIN2(max_page_sz, min_page_sz);
|
2013-11-01 17:09:38 +01:00
|
|
|
|
|
|
|
// Can a page size be something else than a power of two?
|
|
|
|
assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2");
|
2017-04-13 09:57:51 +02:00
|
|
|
size_t new_alignment = align_up(page_sz, _gen_alignment);
|
2013-11-01 17:09:38 +01:00
|
|
|
if (new_alignment != _gen_alignment) {
|
|
|
|
_gen_alignment = new_alignment;
|
2013-11-08 17:46:53 +01:00
|
|
|
_space_alignment = new_alignment;
|
2013-11-01 17:09:38 +01:00
|
|
|
// Redo everything from the start
|
|
|
|
initialize_flags();
|
|
|
|
}
|
2014-04-29 22:57:19 +02:00
|
|
|
GenCollectorPolicy::initialize_size_info();
|
2013-11-01 17:09:38 +01:00
|
|
|
}
|