1 /*
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
949 FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
950 verify_young_initial(flag_value);
951
952 // If NewSize has been ergonomically set, the collector policy
953 // should use it for min but calculate the initial young size
954 // using NewRatio.
955 flag_value = 20 * M;
956 set_basic_flag_values();
957 FLAG_SET_ERGO(uintx, NewSize, flag_value);
958 verify_young_min(flag_value);
959
960 set_basic_flag_values();
961 FLAG_SET_ERGO(uintx, NewSize, flag_value);
962 verify_scaled_young_initial(InitialHeapSize);
963
964 restore_flags();
965 }
966
967 static void test_old_size() {
968 size_t flag_value;
969
970 save_flags();
971
972 // If OldSize is set on the command line, it should be used
973 // for both min and initial old size if less than min heap.
974 flag_value = 20 * M;
975 set_basic_flag_values();
976 FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
977 verify_old_min(flag_value);
978
979 set_basic_flag_values();
980 FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
981 verify_old_initial(flag_value);
982
983 // If MaxNewSize is large, the maximum OldSize will be less than
984 // what's requested on the command line and it should be reset
985 // ergonomically.
986 flag_value = 30 * M;
987 set_basic_flag_values();
988 FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
989 FLAG_SET_CMDLINE(uintx, MaxNewSize, 170*M);
990 // Calculate what we expect the flag to be.
991 flag_value = MaxHeapSize - MaxNewSize;
992 verify_old_initial(flag_value);
993
994 }
995
996 static void verify_young_min(size_t expected) {
997 MarkSweepPolicy msp;
998 msp.initialize_all();
999
1000 assert(msp.min_young_size() <= expected, err_msg("%zu > %zu", msp.min_young_size(), expected));
1001 }
1002
1003 static void verify_young_initial(size_t expected) {
1004 MarkSweepPolicy msp;
1005 msp.initialize_all();
1006
1007 assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected));
1008 }
1009
1010 static void verify_scaled_young_initial(size_t initial_heap_size) {
1011 MarkSweepPolicy msp;
1012 msp.initialize_all();
1013
1014 size_t expected = msp.scale_by_NewRatio_aligned(initial_heap_size);
1015 assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected));
1016 assert(FLAG_IS_ERGO(NewSize) && NewSize == expected,
1017 err_msg("NewSize should have been set ergonomically to %zu, but was %zu", expected, NewSize));
1018 }
1019
1020 static void verify_old_min(size_t expected) {
1021 MarkSweepPolicy msp;
1022 msp.initialize_all();
1023
1024 assert(msp.min_old_size() <= expected, err_msg("%zu > %zu", msp.min_old_size(), expected));
1025 }
1026
1027 static void verify_old_initial(size_t expected) {
1028 MarkSweepPolicy msp;
1029 msp.initialize_all();
1030
1031 assert(msp.initial_old_size() == expected, err_msg("%zu != %zu", msp.initial_old_size(), expected));
1032 }
|
1 /*
2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
949 FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
950 verify_young_initial(flag_value);
951
952 // If NewSize has been ergonomically set, the collector policy
953 // should use it for min but calculate the initial young size
954 // using NewRatio.
955 flag_value = 20 * M;
956 set_basic_flag_values();
957 FLAG_SET_ERGO(uintx, NewSize, flag_value);
958 verify_young_min(flag_value);
959
960 set_basic_flag_values();
961 FLAG_SET_ERGO(uintx, NewSize, flag_value);
962 verify_scaled_young_initial(InitialHeapSize);
963
964 restore_flags();
965 }
966
967 static void test_old_size() {
968 size_t flag_value;
969 size_t heap_alignment = CollectorPolicy::compute_heap_alignment();
970
971 save_flags();
972
973 // If OldSize is set on the command line, it should be used
974 // for both min and initial old size if less than min heap.
975 flag_value = 20 * M;
976 set_basic_flag_values();
977 FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
978 verify_old_min(flag_value);
979
980 set_basic_flag_values();
981 FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
982 // Calculate what we expect the flag to be.
983 size_t expected_old_initial = align_size_up(InitialHeapSize, heap_alignment) - MaxNewSize;
984 verify_old_initial(expected_old_initial);
985
986 // If MaxNewSize is large, the maximum OldSize will be less than
987 // what's requested on the command line and it should be reset
988 // ergonomically.
989 // We intentionally set MaxNewSize + OldSize > MaxHeapSize (see over_size).
990 flag_value = 30 * M;
991 set_basic_flag_values();
992 FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
993 size_t over_size = 20*M;
994 size_t new_size_value = align_size_up(MaxHeapSize, heap_alignment) - flag_value + over_size;
995 FLAG_SET_CMDLINE(uintx, MaxNewSize, new_size_value);
996 // Calculate what we expect the flag to be.
997 expected_old_initial = align_size_up(MaxHeapSize, heap_alignment) - MaxNewSize;
998 verify_old_initial(expected_old_initial);
999 restore_flags();
1000 }
1001
1002 static void verify_young_min(size_t expected) {
1003 MarkSweepPolicy msp;
1004 msp.initialize_all();
1005
1006 assert(msp.min_young_size() <= expected, err_msg("%zu > %zu", msp.min_young_size(), expected));
1007 }
1008
1009 static void verify_young_initial(size_t expected) {
1010 MarkSweepPolicy msp;
1011 msp.initialize_all();
1012
1013 assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected));
1014 }
1015
1016 static void verify_scaled_young_initial(size_t initial_heap_size) {
1017 MarkSweepPolicy msp;
1018 msp.initialize_all();
1019
1020 if (InitialHeapSize > initial_heap_size) {
1021 // InitialHeapSize was adapted by msp.initialize_all, e.g. due to alignment
1022 // caused by 64K page size.
1023 initial_heap_size = InitialHeapSize;
1024 }
1025
1026 size_t expected = msp.scale_by_NewRatio_aligned(initial_heap_size);
1027 assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected));
1028 assert(FLAG_IS_ERGO(NewSize) && NewSize == expected,
1029 err_msg("NewSize should have been set ergonomically to %zu, but was %zu", expected, NewSize));
1030 }
1031
1032 static void verify_old_min(size_t expected) {
1033 MarkSweepPolicy msp;
1034 msp.initialize_all();
1035
1036 assert(msp.min_old_size() <= expected, err_msg("%zu > %zu", msp.min_old_size(), expected));
1037 }
1038
1039 static void verify_old_initial(size_t expected) {
1040 MarkSweepPolicy msp;
1041 msp.initialize_all();
1042
1043 assert(msp.initial_old_size() == expected, err_msg("%zu != %zu", msp.initial_old_size(), expected));
1044 }
|