annotate agent/test/jdi/SASanityChecker.java @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 import sun.jvm.hotspot.tools.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.util.jar.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
32 This is a sanity checking tool for Serviceability Agent. To use this class,
a61af66fc99e Initial load
duke
parents:
diff changeset
33 refer to sasanity.sh script in the current directory.
a61af66fc99e Initial load
duke
parents:
diff changeset
34 */
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 public class SASanityChecker extends Tool {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private static final String saJarName;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private static final Map c2types;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 saJarName = System.getProperty("SASanityChecker.SAJarName", "sa-jdi.jar");
a61af66fc99e Initial load
duke
parents:
diff changeset
42 c2types = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
43 Object value = new Object();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 c2types.put("sun.jvm.hotspot.code.ExceptionBlob", value);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 c2types.put("sun.jvm.hotspot.code.DeoptimizationBlob", value);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 c2types.put("sun.jvm.hotspot.code.UncommonTrapBlob", value);
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 String classPath = System.getProperty("java.class.path");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 String saJarPath = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 while (st.hasMoreTokens()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 saJarPath = st.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 if (saJarPath.endsWith(saJarName)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (saJarPath == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 throw new RuntimeException(saJarName + " is not the CLASSPATH");
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 String cpuDot = "." + VM.getVM().getCPU() + ".";
a61af66fc99e Initial load
duke
parents:
diff changeset
66 String platformDot = "." + VM.getVM().getOS() + "_" + VM.getVM().getCPU() + ".";
a61af66fc99e Initial load
duke
parents:
diff changeset
67 boolean isClient = VM.getVM().isClientCompiler();
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 FileInputStream fis = new FileInputStream(saJarPath);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 JarInputStream jis = new JarInputStream(fis);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 JarEntry je = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 while ( (je = jis.getNextJarEntry()) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 String entryName = je.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 int dotClassIndex = entryName.indexOf(".class");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (dotClassIndex == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // skip non-.class stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
78 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 entryName = entryName.substring(0, dotClassIndex).replace('/', '.');
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // skip debugger, asm classes, type classes and jdi binding classes
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (entryName.startsWith("sun.jvm.hotspot.debugger.") ||
a61af66fc99e Initial load
duke
parents:
diff changeset
85 entryName.startsWith("sun.jvm.hotspot.asm.") ||
a61af66fc99e Initial load
duke
parents:
diff changeset
86 entryName.startsWith("sun.jvm.hotspot.type.") ||
a61af66fc99e Initial load
duke
parents:
diff changeset
87 entryName.startsWith("sun.jvm.hotspot.jdi.") ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 String runtimePkgPrefix = "sun.jvm.hotspot.runtime.";
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int runtimeIndex = entryName.indexOf(runtimePkgPrefix);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (runtimeIndex != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // look for further dot. if there, it has to be sub-package.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // in runtime sub-packages include only current platform classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (entryName.substring(runtimePkgPrefix.length() + 1, entryName.length()).indexOf('.') != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (entryName.indexOf(cpuDot) == -1 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
98 entryName.indexOf(platformDot) == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (isClient) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (c2types.get(entryName) != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 if (entryName.equals("sun.jvm.hotspot.c1.Runtime1")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 System.out.println("checking " + entryName + " ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // force init of the class to uncover any vmStructs mismatch
a61af66fc99e Initial load
duke
parents:
diff changeset
116 Class.forName(entryName);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 System.out.println("FAILED");
a61af66fc99e Initial load
duke
parents:
diff changeset
121 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 throw new RuntimeException(exp.getMessage());
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 System.out.println("PASSED");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 System.out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public static void main(String[] args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 SASanityChecker checker = new SASanityChecker();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 checker.start(args);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 checker.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }