1 /* 2 * Copyright Amazon.com Inc. 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 * 23 */ 24 25 #include "precompiled.hpp" 26 27 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" 28 #include "unittest.hpp" 29 30 TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_sanity) { 31 ShenandoahCollectorPolicy policy; 32 EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 0UL); 33 EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false); 34 } 35 36 TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_no_upgrade) { 37 ShenandoahCollectorPolicy policy; 38 policy.record_degenerated(true, true, true); 39 policy.record_degenerated(true, true, true); 40 EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 2UL); 41 EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false); 42 } 43 44 TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_upgrade) { 45 ShenandoahCollectorPolicy policy; 46 policy.record_degenerated(true, true, false); 47 policy.record_degenerated(true, true, false); 48 EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 2UL); 49 EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), true); 50 } 51 52 TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_reset_progress) { 53 ShenandoahCollectorPolicy policy; 54 policy.record_degenerated(true, true, false); 55 policy.record_degenerated(true, true, true); 56 EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 2UL); 57 EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false); 58 } 59 60 TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_full_reset) { 61 ShenandoahCollectorPolicy policy; 62 policy.record_degenerated(true, true, false); 63 policy.record_success_full(); 64 EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 0UL); 65 EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false); 66 } 67 68 TEST(ShenandoahCollectorPolicyTest, track_degen_cycles_reset) { 69 ShenandoahCollectorPolicy policy; 70 policy.record_degenerated(true, true, false); 71 policy.record_success_concurrent(true, true); 72 EXPECT_EQ(policy.consecutive_degenerated_gc_count(), 0UL); 73 EXPECT_EQ(policy.generational_should_upgrade_degenerated_gc(), false); 74 }