hotspot/test/gc/serial/HeapChangeLogging.java
author iignatyev
Wed, 02 Aug 2017 08:53:18 -0700 (2017-08-02)
changeset 46743 4d9e00487c62
parent 40886 98cb935dc074
permissions -rw-r--r--
8185536: @key aot should be replaced w/ @requires vm.aot Reviewed-by: kvn, goetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
     2
 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     4
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     8
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    13
 * accompanied this code).
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    14
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    18
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    21
 * questions.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    22
 */
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    23
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    24
/*
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    25
 * @test HeapChangeLogging.java
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    26
 * @bug 8027440
40886
98cb935dc074 8164660: MinimalVM is not tested with GC tests
dfazunen
parents: 40631
diff changeset
    27
 * @requires vm.gc.Serial
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    28
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35061
diff changeset
    29
 * @modules java.base/jdk.internal.misc
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    30
 * @summary Allocate to get a promotion failure and verify that that heap change logging is present.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    31
 * @run main HeapChangeLogging
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    32
 */
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    33
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    34
import java.util.regex.Matcher;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    35
import java.util.regex.Pattern;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    36
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    37
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    38
import jdk.test.lib.process.OutputAnalyzer;
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    39
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    40
public class HeapChangeLogging {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    41
  public static void main(String[] args) throws Exception {
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30764
diff changeset
    42
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", "HeapFiller");
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    43
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    44
    String stdout = output.getStdout();
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    45
    System.out.println(stdout);
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30764
diff changeset
    46
    Matcher stdoutMatcher = Pattern.compile(".*\\(Allocation Failure\\) [0-9]+[KMG]->[0-9]+[KMG]\\([0-9]+[KMG]\\)", Pattern.MULTILINE).matcher(stdout);
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    47
    if (!stdoutMatcher.find()) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    48
      throw new RuntimeException("No proper GC log line found");
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    49
    }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    50
    output.shouldHaveExitValue(0);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    51
  }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    52
}
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    53
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    54
class HeapFiller {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    55
  public static Entry root;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    56
  private static final int PAYLOAD_SIZE = 1000;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    57
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    58
  public static void main(String[] args) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    59
    root = new Entry(PAYLOAD_SIZE, null);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    60
    Entry current = root;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    61
    try {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    62
      while (true) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    63
        Entry newEntry = new Entry(PAYLOAD_SIZE, current);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    64
        current = newEntry;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    65
      }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    66
    } catch (OutOfMemoryError e) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    67
      root = null;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    68
    }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    69
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    70
  }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    71
}
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    72
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    73
class Entry {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    74
  public Entry previous;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    75
  public byte[] payload;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    76
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    77
  Entry(int payloadSize, Entry previous) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    78
    payload = new byte[payloadSize];
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    79
    this.previous = previous;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    80
  }
27692
11c231c781dc 8062537: [TESTBUG] Conflicting GC combinations in hotspot tests
eistepan
parents: 22204
diff changeset
    81
}