hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java
author kzhaldyb
Tue, 14 Jun 2016 19:15:27 +0300
changeset 39280 86907793a181
parent 38256 685ac27ed264
child 39618 ced8c3f59678
permissions -rw-r--r--
8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle Reviewed-by: tschatzl, dfazunen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38256
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     1
/*
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     4
 *
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     8
 *
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    13
 * accompanied this code).
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    14
 *
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    18
 *
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    21
 * questions.
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    22
 *
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    23
 */
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    24
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    25
package gc.g1.humongousObjects.objectGraphTest;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    26
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    27
import gc.testlibrary.Helpers;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    28
import jdk.test.lib.Asserts;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    29
import sun.hotspot.WhiteBox;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    30
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    31
import java.util.Arrays;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    32
import java.util.List;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    33
import java.util.function.Consumer;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    34
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    35
/**
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    36
 * Provides methods to initiate GC of requested type and
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    37
 * checks for states of humongous and non-humongous soft/weak externally
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    38
 * referenced objects after GCs
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    39
 */
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    40
public enum GC {
39280
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    41
    CMC {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    42
        @Override
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    43
        public Runnable get() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    44
            return () -> {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    45
                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    46
                WHITE_BOX.g1StartConcMarkCycle();
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    47
                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    48
            };
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    49
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    50
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    51
        public Consumer<ReferenceInfo<Object[]>> getChecker() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    52
            return getCheckerImpl(false, false, true, false);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    53
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    54
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    55
        @Override
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    56
        public List<String> shouldContain() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    57
            return Arrays.asList(GCTokens.WB_INITIATED_CMC);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    58
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    59
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    60
        @Override
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    61
        public List<String> shouldNotContain() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    62
            return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC,
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    63
                    GCTokens.FULL_GC, GCTokens.YOUNG_GC);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    64
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    65
    },
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    66
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    67
    CMC_NO_SURV_ROOTS {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    68
        @Override
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    69
        public Runnable get() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    70
            return () -> {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    71
                WHITE_BOX.youngGC();
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    72
                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    73
                WHITE_BOX.youngGC();
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    74
                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    75
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    76
                WHITE_BOX.g1StartConcMarkCycle();
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    77
                Helpers.waitTillCMCFinished(WHITE_BOX, 0);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    78
            };
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    79
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    80
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    81
        public Consumer<ReferenceInfo<Object[]>> getChecker() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    82
            return getCheckerImpl(true, false, true, false);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    83
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    84
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    85
        @Override
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    86
        public List<String> shouldContain() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    87
            return Arrays.asList(GCTokens.WB_INITIATED_CMC);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    88
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    89
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    90
        @Override
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    91
        public List<String> shouldNotContain() {
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    92
            return Arrays.asList(GCTokens.WB_INITIATED_MIXED_GC,
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    93
                    GCTokens.FULL_GC, GCTokens.YOUNG_GC);
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    94
        }
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
    95
    },
38256
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    96
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    97
    YOUNG_GC {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    98
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
    99
        public Runnable get() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   100
            return WHITE_BOX::youngGC;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   101
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   102
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   103
        public Consumer<ReferenceInfo<Object[]>> getChecker() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   104
            return getCheckerImpl(false, false, true, false);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   105
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   106
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   107
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   108
        public List<String> shouldContain() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   109
            return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   110
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   111
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   112
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   113
        public List<String> shouldNotContain() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   114
            return Arrays.asList(GCTokens.WB_INITIATED_MIXED_GC, GCTokens.FULL_GC, GCTokens.WB_INITIATED_CMC,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   115
                    GCTokens.CMC, GCTokens.YOUNG_GC);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   116
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   117
    },
39280
86907793a181 8132713: Add tests which check that Humongous objects behave as expected after finishing ConcMark Cycle
kzhaldyb
parents: 38256
diff changeset
   118
38256
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   119
    FULL_GC {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   120
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   121
        public Runnable get() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   122
            return System::gc;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   123
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   124
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   125
        public Consumer<ReferenceInfo<Object[]>> getChecker() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   126
            return getCheckerImpl(true, false, true, false);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   127
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   128
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   129
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   130
        public List<String> shouldContain() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   131
            return Arrays.asList(GCTokens.FULL_GC);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   132
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   133
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   134
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   135
        public List<String> shouldNotContain() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   136
            return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   137
                    GCTokens.WB_INITIATED_CMC, GCTokens.CMC, GCTokens.YOUNG_GC);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   138
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   139
    },
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   140
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   141
    FULL_GC_MEMORY_PRESSURE {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   142
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   143
        public Runnable get() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   144
            return WHITE_BOX::fullGC;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   145
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   146
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   147
        public Consumer<ReferenceInfo<Object[]>> getChecker() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   148
            return getCheckerImpl(true, true, true, true);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   149
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   150
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   151
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   152
        public List<String> shouldContain() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   153
            return Arrays.asList(GCTokens.FULL_GC_MEMORY_PRESSURE);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   154
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   155
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   156
        @Override
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   157
        public List<String> shouldNotContain() {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   158
            return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   159
                    GCTokens.WB_INITIATED_CMC, GCTokens.CMC, GCTokens.YOUNG_GC, GCTokens.FULL_GC);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   160
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   161
    };
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   162
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   163
    protected String getErrorMessage(ReferenceInfo<Object[]> ref, boolean expectedNull, String gcType) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   164
        return String.format("Externally effectively %s referenced %shumongous object was%s deleted after %s",
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   165
                (ref.softlyReachable ? "soft" : "weak"), (ref.effectiveHumongous ? "" : "non-"),
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   166
                (expectedNull ? " not" : ""), gcType);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   167
    }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   168
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   169
    protected Consumer<ReferenceInfo<Object[]>> getCaseCheck(boolean expectedNull) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   170
        return expectedNull
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   171
                ? r -> Asserts.assertNull(r.reference.get(), getErrorMessage(r, true, name()))
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   172
                : r -> Asserts.assertNotNull(r.reference.get(), getErrorMessage(r, false, name()));
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   173
    }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   174
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   175
    protected Consumer<ReferenceInfo<Object[]>> getCheckerImpl(boolean weakH, boolean softH,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   176
                                                               boolean weakS, boolean softS) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   177
        return new Checker(getCaseCheck(weakH), getCaseCheck(softH), getCaseCheck(weakS), getCaseCheck(softS));
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   178
    }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   179
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   180
    protected String getGcLogName(String prefix) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   181
        return prefix + "_" + name() + ".gc.log";
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   182
    }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   183
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   184
    private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   185
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   186
    /**
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   187
     * @return method to initiate GC
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   188
     */
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   189
    public abstract Runnable get();
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   190
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   191
    /**
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   192
     * @return checker for objects' states after GC
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   193
     */
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   194
    public abstract Consumer<ReferenceInfo<Object[]>> getChecker();
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   195
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   196
    /**
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   197
     * @return list of tokens that should be contained in gc log after gc of specified type
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   198
     */
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   199
    public abstract List<String> shouldContain();
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   200
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   201
    /**
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   202
     * @return list of tokens that should not be contained in gc log after gc of specified type
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   203
     */
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   204
    public abstract List<String> shouldNotContain();
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   205
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   206
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   207
    /**
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   208
     * Checks object' state after gc
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   209
     * Contains 4 Consumers which are called depending on humongous/non-humongous and
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   210
     * external weak/soft referenced objects
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   211
     */
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   212
    private static class Checker implements Consumer<ReferenceInfo<Object[]>> {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   213
        // 4 consumers with checks for (humongous /simple objects)*(weak/soft referenced)
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   214
        final Consumer<ReferenceInfo<Object[]>> weakHumongousCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   215
        final Consumer<ReferenceInfo<Object[]>> softHumongousCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   216
        final Consumer<ReferenceInfo<Object[]>> weakSimpleCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   217
        final Consumer<ReferenceInfo<Object[]>> softSimpleCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   218
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   219
        public Checker(Consumer<ReferenceInfo<Object[]>> weakHumongousCheck,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   220
                       Consumer<ReferenceInfo<Object[]>> softHumongousCheck,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   221
                       Consumer<ReferenceInfo<Object[]>> weakSimpleCheck,
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   222
                       Consumer<ReferenceInfo<Object[]>> softSimpleCheck) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   223
            this.weakHumongousCheck = weakHumongousCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   224
            this.softHumongousCheck = softHumongousCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   225
            this.weakSimpleCheck = weakSimpleCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   226
            this.softSimpleCheck = softSimpleCheck;
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   227
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   228
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   229
        public void accept(ReferenceInfo<Object[]> ref) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   230
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   231
            System.out.println("reference.get() returned " + ref.reference.get());
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   232
            if (ref.effectiveHumongous && ref.softlyReachable) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   233
                System.out.println("soft and humongous");
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   234
                softHumongousCheck.accept(ref);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   235
            }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   236
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   237
            if (ref.effectiveHumongous && !ref.softlyReachable) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   238
                System.out.println("weak and humongous");
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   239
                weakHumongousCheck.accept(ref);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   240
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   241
            }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   242
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   243
            if (!ref.effectiveHumongous && ref.softlyReachable) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   244
                System.out.println("soft and non-humongous");
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   245
                softSimpleCheck.accept(ref);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   246
            }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   247
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   248
            if (!ref.effectiveHumongous && !ref.softlyReachable) {
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   249
                System.out.println("weak and non-humongous");
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   250
                weakSimpleCheck.accept(ref);
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   251
            }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   252
        }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   253
    }
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   254
685ac27ed264 8132710: Add tests which check that Humongous objects behave as expected after Young GC
kzhaldyb
parents:
diff changeset
   255
}