src/share/vm/prims/jvmtiGen.java

Fri, 16 Aug 2013 13:22:32 +0200

author
stefank
date
Fri, 16 Aug 2013 13:22:32 +0200
changeset 5578
4c84d351cca9
parent 5237
f2110083203d
child 6876
710a3c8b516e
permissions
-rw-r--r--

8007074: SIGSEGV at ParMarkBitMap::verify_clear()
Summary: Replace the broken large pages implementation on Linux. New flag: -XX:+UseTransparentHugePages - Linux specific flag to turn on transparent huge page hinting with madvise(..., MAP_HUGETLB). Changed behavior: -XX:+UseLargePages - tries to use -XX:+UseTransparentHugePages before trying other large pages implementations (on Linux). Changed behavior: -XX:+UseHugeTLBFS - Use upfront allocation of Large Pages instead of using the broken implementation to dynamically committing large pages. Changed behavior: -XX:LargePageSizeInBytes - Turned off the ability to use this flag on Linux and provides warning to user if set to a value different than the OS chosen large page size. Changed behavior: Setting no large page size - Now defaults to use -XX:UseTransparentHugePages if the OS supports it. Previously, -XX:+UseHugeTLBFS was chosen if the OS was configured to use large pages.
Reviewed-by: tschatzl, dcubed, brutisso

duke@435 1 /*
sla@5237 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 import javax.xml.parsers.DocumentBuilder;
duke@435 26 import javax.xml.parsers.DocumentBuilderFactory;
duke@435 27 import javax.xml.parsers.FactoryConfigurationError;
duke@435 28 import javax.xml.parsers.ParserConfigurationException;
duke@435 29
duke@435 30 import org.xml.sax.SAXException;
duke@435 31 import org.xml.sax.SAXParseException;
duke@435 32 import org.w3c.dom.Document;
duke@435 33 import org.w3c.dom.DOMException;
duke@435 34 // For write operation
duke@435 35 import javax.xml.transform.Transformer;
duke@435 36 import javax.xml.transform.TransformerException;
duke@435 37 import javax.xml.transform.TransformerFactory;
duke@435 38 import javax.xml.transform.TransformerConfigurationException;
duke@435 39 import javax.xml.transform.dom.DOMSource;
duke@435 40 import javax.xml.transform.stream.StreamSource;
duke@435 41 import javax.xml.transform.stream.StreamResult;
duke@435 42
duke@435 43 import java.io.*;
duke@435 44
duke@435 45 public class jvmtiGen
duke@435 46 {
duke@435 47 /**
duke@435 48 * Write out usage and exit.
duke@435 49 */
duke@435 50 private static void showUsage() {
duke@435 51 System.err.println("usage:");
duke@435 52 System.err.println(" java jvmtiGen " +
duke@435 53 "-IN <input XML file name> " +
duke@435 54 "-XSL <XSL file> " +
duke@435 55 "-OUT <output file name> " +
duke@435 56 "[-PARAM <name> <expression> ...]");
duke@435 57 System.exit(0); // There is no returning from showUsage()
duke@435 58 }
duke@435 59
duke@435 60 // Global value so it can be ref'd by the tree-adapter
duke@435 61 static Document document;
duke@435 62
duke@435 63 public static void main (String argv [])
duke@435 64 {
duke@435 65 String inFileName=null;
duke@435 66 String xslFileName=null;
duke@435 67 String outFileName=null;
duke@435 68 java.util.Vector<String> params=new java.util.Vector<String>();
duke@435 69 for (int ii = 0; ii < argv.length; ii++) {
duke@435 70 if (argv[ii].equals("-IN")) {
duke@435 71 inFileName = argv[++ii];
duke@435 72 } else if (argv[ii].equals("-XSL")) {
duke@435 73 xslFileName = argv[++ii];
duke@435 74 } else if (argv[ii].equals("-OUT")) {
duke@435 75 outFileName = argv[++ii];
duke@435 76 } else if (argv[ii].equals("-PARAM")) {
duke@435 77 if (ii + 2 < argv.length) {
duke@435 78 String name = argv[++ii];
duke@435 79 params.addElement(name);
duke@435 80 String expression = argv[++ii];
duke@435 81 params.addElement(expression);
duke@435 82 } else {
duke@435 83 showUsage();
duke@435 84 }
duke@435 85 } else {
duke@435 86 showUsage();
duke@435 87 }
duke@435 88 }
duke@435 89 if (inFileName==null || xslFileName==null || outFileName==null){
duke@435 90 showUsage();
duke@435 91 }
duke@435 92
duke@435 93 /*
duke@435 94 * Due to JAXP breakage in some intermediate Tiger builds, the
duke@435 95 * com.sun.org.apache..... parser may throw an exception:
duke@435 96 * com.sun.org.apache.xml.internal.utils.WrappedRuntimeException:
duke@435 97 * org.apache.xalan.serialize.SerializerToText
duke@435 98 *
duke@435 99 * To work around the problem, this program uses the
duke@435 100 * org.apache.xalan.... version if it is available. It is
duke@435 101 * available in J2SE 1.4.x and early builds of 1.5 (Tiger).
duke@435 102 * It was removed at the same time the thrown exception issue
duke@435 103 * above was fixed, so if the class is not found we can proceed
duke@435 104 * and use the default parser.
duke@435 105 */
duke@435 106 final String parserProperty =
duke@435 107 "javax.xml.transform.TransformerFactory";
duke@435 108 final String workaroundParser =
duke@435 109 "org.apache.xalan.processor.TransformerFactoryImpl";
duke@435 110
duke@435 111 try {
duke@435 112 java.lang.Class cls = java.lang.Class.forName(workaroundParser);
duke@435 113 /*
duke@435 114 * If we get here, we found the class. Use it.
duke@435 115 */
duke@435 116 System.setProperty(parserProperty, workaroundParser);
duke@435 117 System.out.println("Info: jvmtiGen using " + parserProperty +
duke@435 118 " = " + workaroundParser);
duke@435 119 } catch (ClassNotFoundException cnfex) {
duke@435 120 /*
duke@435 121 * We didn't find workaroundParser. Ignore the
duke@435 122 * exception and proceed with default settings.
duke@435 123 */
duke@435 124 }
duke@435 125
duke@435 126 DocumentBuilderFactory factory =
duke@435 127 DocumentBuilderFactory.newInstance();
duke@435 128
duke@435 129 factory.setNamespaceAware(true);
duke@435 130 factory.setValidating(true);
sla@5237 131 factory.setXIncludeAware(true);
duke@435 132
duke@435 133 try {
duke@435 134 File datafile = new File(inFileName);
duke@435 135 File stylesheet = new File(xslFileName);
duke@435 136
duke@435 137 DocumentBuilder builder = factory.newDocumentBuilder();
duke@435 138 document = builder.parse(datafile);
duke@435 139
duke@435 140 // Use a Transformer for output
duke@435 141 TransformerFactory tFactory =
duke@435 142 TransformerFactory.newInstance();
duke@435 143 StreamSource stylesource = new StreamSource(stylesheet);
duke@435 144 Transformer transformer = tFactory.newTransformer(stylesource);
duke@435 145 for (int ii = 0; ii < params.size(); ii += 2){
duke@435 146 transformer.setParameter((String) params.elementAt(ii),
duke@435 147 (String) params.elementAt(ii + 1));
duke@435 148 }
duke@435 149 DOMSource source = new DOMSource(document);
duke@435 150
duke@435 151 PrintStream ps = new PrintStream( new FileOutputStream(outFileName));
duke@435 152 StreamResult result = new StreamResult(ps);
duke@435 153 transformer.transform(source, result);
duke@435 154
duke@435 155 } catch (TransformerConfigurationException tce) {
duke@435 156 // Error generated by the parser
duke@435 157 System.out.println ("\n** Transformer Factory error");
duke@435 158 System.out.println(" " + tce.getMessage() );
duke@435 159
duke@435 160 // Use the contained exception, if any
duke@435 161 Throwable x = tce;
duke@435 162 if (tce.getException() != null)
duke@435 163 x = tce.getException();
duke@435 164 x.printStackTrace();
duke@435 165
duke@435 166 } catch (TransformerException te) {
duke@435 167 // Error generated by the parser
duke@435 168 System.out.println ("\n** Transformation error");
duke@435 169 System.out.println(" " + te.getMessage() );
duke@435 170
duke@435 171 // Use the contained exception, if any
duke@435 172 Throwable x = te;
duke@435 173 if (te.getException() != null)
duke@435 174 x = te.getException();
duke@435 175 x.printStackTrace();
duke@435 176
duke@435 177 } catch (SAXException sxe) {
duke@435 178 // Error generated by this application
duke@435 179 // (or a parser-initialization error)
duke@435 180 Exception x = sxe;
duke@435 181 if (sxe.getException() != null)
duke@435 182 x = sxe.getException();
duke@435 183 x.printStackTrace();
duke@435 184
duke@435 185 } catch (ParserConfigurationException pce) {
duke@435 186 // Parser with specified options can't be built
duke@435 187 pce.printStackTrace();
duke@435 188
duke@435 189 } catch (IOException ioe) {
duke@435 190 // I/O error
duke@435 191 ioe.printStackTrace();
duke@435 192 }
duke@435 193 } // main
duke@435 194 }

mercurial