annotate src/share/vm/prims/jvmtiGen.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 f2110083203d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2013, 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 javax.xml.parsers.DocumentBuilder;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 import javax.xml.parsers.DocumentBuilderFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import javax.xml.parsers.FactoryConfigurationError;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import javax.xml.parsers.ParserConfigurationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import org.xml.sax.SAXException;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import org.xml.sax.SAXParseException;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import org.w3c.dom.Document;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import org.w3c.dom.DOMException;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // For write operation
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import javax.xml.transform.Transformer;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import javax.xml.transform.TransformerException;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import javax.xml.transform.TransformerFactory;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import javax.xml.transform.TransformerConfigurationException;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import javax.xml.transform.dom.DOMSource;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import javax.xml.transform.stream.StreamSource;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import javax.xml.transform.stream.StreamResult;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public class jvmtiGen
a61af66fc99e Initial load
duke
parents:
diff changeset
46 {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
48 * Write out usage and exit.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 */
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static void showUsage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 System.err.println("usage:");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 System.err.println(" java jvmtiGen " +
a61af66fc99e Initial load
duke
parents:
diff changeset
53 "-IN <input XML file name> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
54 "-XSL <XSL file> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
55 "-OUT <output file name> " +
a61af66fc99e Initial load
duke
parents:
diff changeset
56 "[-PARAM <name> <expression> ...]");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 System.exit(0); // There is no returning from showUsage()
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Global value so it can be ref'd by the tree-adapter
a61af66fc99e Initial load
duke
parents:
diff changeset
61 static Document document;
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public static void main (String argv [])
a61af66fc99e Initial load
duke
parents:
diff changeset
64 {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 String inFileName=null;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 String xslFileName=null;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 String outFileName=null;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 java.util.Vector<String> params=new java.util.Vector<String>();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 for (int ii = 0; ii < argv.length; ii++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 if (argv[ii].equals("-IN")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 inFileName = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else if (argv[ii].equals("-XSL")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 xslFileName = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
74 } else if (argv[ii].equals("-OUT")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 outFileName = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
76 } else if (argv[ii].equals("-PARAM")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 if (ii + 2 < argv.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 String name = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
79 params.addElement(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 String expression = argv[++ii];
a61af66fc99e Initial load
duke
parents:
diff changeset
81 params.addElement(expression);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 showUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 showUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if (inFileName==null || xslFileName==null || outFileName==null){
a61af66fc99e Initial load
duke
parents:
diff changeset
90 showUsage();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
94 * Due to JAXP breakage in some intermediate Tiger builds, the
a61af66fc99e Initial load
duke
parents:
diff changeset
95 * com.sun.org.apache..... parser may throw an exception:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 * com.sun.org.apache.xml.internal.utils.WrappedRuntimeException:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 * org.apache.xalan.serialize.SerializerToText
a61af66fc99e Initial load
duke
parents:
diff changeset
98 *
a61af66fc99e Initial load
duke
parents:
diff changeset
99 * To work around the problem, this program uses the
a61af66fc99e Initial load
duke
parents:
diff changeset
100 * org.apache.xalan.... version if it is available. It is
a61af66fc99e Initial load
duke
parents:
diff changeset
101 * available in J2SE 1.4.x and early builds of 1.5 (Tiger).
a61af66fc99e Initial load
duke
parents:
diff changeset
102 * It was removed at the same time the thrown exception issue
a61af66fc99e Initial load
duke
parents:
diff changeset
103 * above was fixed, so if the class is not found we can proceed
a61af66fc99e Initial load
duke
parents:
diff changeset
104 * and use the default parser.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 */
a61af66fc99e Initial load
duke
parents:
diff changeset
106 final String parserProperty =
a61af66fc99e Initial load
duke
parents:
diff changeset
107 "javax.xml.transform.TransformerFactory";
a61af66fc99e Initial load
duke
parents:
diff changeset
108 final String workaroundParser =
a61af66fc99e Initial load
duke
parents:
diff changeset
109 "org.apache.xalan.processor.TransformerFactoryImpl";
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 java.lang.Class cls = java.lang.Class.forName(workaroundParser);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
114 * If we get here, we found the class. Use it.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 */
a61af66fc99e Initial load
duke
parents:
diff changeset
116 System.setProperty(parserProperty, workaroundParser);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 System.out.println("Info: jvmtiGen using " + parserProperty +
a61af66fc99e Initial load
duke
parents:
diff changeset
118 " = " + workaroundParser);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 } catch (ClassNotFoundException cnfex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
121 * We didn't find workaroundParser. Ignore the
a61af66fc99e Initial load
duke
parents:
diff changeset
122 * exception and proceed with default settings.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 */
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 DocumentBuilderFactory factory =
a61af66fc99e Initial load
duke
parents:
diff changeset
127 DocumentBuilderFactory.newInstance();
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 factory.setNamespaceAware(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 factory.setValidating(true);
10405
f2110083203d 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 1552
diff changeset
131 factory.setXIncludeAware(true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 File datafile = new File(inFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 File stylesheet = new File(xslFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 DocumentBuilder builder = factory.newDocumentBuilder();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 document = builder.parse(datafile);
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Use a Transformer for output
a61af66fc99e Initial load
duke
parents:
diff changeset
141 TransformerFactory tFactory =
a61af66fc99e Initial load
duke
parents:
diff changeset
142 TransformerFactory.newInstance();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 StreamSource stylesource = new StreamSource(stylesheet);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 Transformer transformer = tFactory.newTransformer(stylesource);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 for (int ii = 0; ii < params.size(); ii += 2){
a61af66fc99e Initial load
duke
parents:
diff changeset
146 transformer.setParameter((String) params.elementAt(ii),
a61af66fc99e Initial load
duke
parents:
diff changeset
147 (String) params.elementAt(ii + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 DOMSource source = new DOMSource(document);
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 PrintStream ps = new PrintStream( new FileOutputStream(outFileName));
a61af66fc99e Initial load
duke
parents:
diff changeset
152 StreamResult result = new StreamResult(ps);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 transformer.transform(source, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } catch (TransformerConfigurationException tce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Error generated by the parser
a61af66fc99e Initial load
duke
parents:
diff changeset
157 System.out.println ("\n** Transformer Factory error");
a61af66fc99e Initial load
duke
parents:
diff changeset
158 System.out.println(" " + tce.getMessage() );
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Use the contained exception, if any
a61af66fc99e Initial load
duke
parents:
diff changeset
161 Throwable x = tce;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (tce.getException() != null)
a61af66fc99e Initial load
duke
parents:
diff changeset
163 x = tce.getException();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 x.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 } catch (TransformerException te) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Error generated by the parser
a61af66fc99e Initial load
duke
parents:
diff changeset
168 System.out.println ("\n** Transformation error");
a61af66fc99e Initial load
duke
parents:
diff changeset
169 System.out.println(" " + te.getMessage() );
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Use the contained exception, if any
a61af66fc99e Initial load
duke
parents:
diff changeset
172 Throwable x = te;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (te.getException() != null)
a61af66fc99e Initial load
duke
parents:
diff changeset
174 x = te.getException();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 x.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 } catch (SAXException sxe) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Error generated by this application
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // (or a parser-initialization error)
a61af66fc99e Initial load
duke
parents:
diff changeset
180 Exception x = sxe;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (sxe.getException() != null)
a61af66fc99e Initial load
duke
parents:
diff changeset
182 x = sxe.getException();
a61af66fc99e Initial load
duke
parents:
diff changeset
183 x.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 } catch (ParserConfigurationException pce) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Parser with specified options can't be built
a61af66fc99e Initial load
duke
parents:
diff changeset
187 pce.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 } catch (IOException ioe) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // I/O error
a61af66fc99e Initial load
duke
parents:
diff changeset
191 ioe.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 } // main
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }