# HG changeset patch # User coleenp # Date 1353461260 18000 # Node ID 3ed6de6e139bf2c0bbdaf275e37b0f3199b49b44 # Parent e1d42ba865dee02810e2bcda85b9dc793b2f4e0a# Parent 49cbd3e25ba9099fb46d038905b982aa1b06da59 Merge diff -r 49cbd3e25ba9 -r 3ed6de6e139b .hgtags --- a/.hgtags Fri Nov 16 09:05:19 2012 -0500 +++ b/.hgtags Tue Nov 20 20:27:40 2012 -0500 @@ -291,3 +291,7 @@ dc16fe422c535ecd4e9f80fb814a1bb9704da6f5 hs25-b07 acabb5c282f59be7e3238920b2ea06b684ab68f7 jdk8-b63 8cb93eadfb6dcab88d91b8e2cd3e0e07d0ac4048 hs25-b08 +5920f72e799c8133d1066c4a62fa1fafcb729966 jdk8-b64 +b4ee7b773144a88af8b6b92e4384dea82cb948d8 hs25-b09 +0f7290a03b24bd562583fa325d3566c21c51fb94 jdk8-b65 +cfc5309f03b7bd6c1567618b63cf1fc74c0f2a8f hs25-b10 diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/doc/c2replay.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/doc/c2replay.html Tue Nov 20 20:27:40 2012 -0500 @@ -0,0 +1,41 @@ + + + +C2 Replay + + + + +

C2 compiler replay

+

+The C2 compiler replay is a function to repeat the compiling process from a crashed java process in compiled method
+This function only exists in debug version of VM +

+

Usage

+
 
+First, use SA to attach to the core file, if suceeded, do
+       clhsdb>dumpreplaydata 
| -a | [> replay.txt] + create file replay.txt, address is address of Method, or nmethod(CodeBlob) + clhsdb>buildreplayjars [all | boot | app] + create files: + all: + app.jar, boot.jar + boot: + boot.jar + app: + app.jar + exit SA now. +Second, use the obtained replay text file, replay.txt and jar files, app.jar and boot.jar, using debug version of java + java -Xbootclasspath/p:boot.jar -cp app.jar -XX:ReplayDataFile= -XX:+ReplayCompiles .... + This will replay the compiling process. + + With ReplayCompiles, the replay will recompile all the methods in app.jar, and in boot.jar to emulate the process in java app. + +notes: + 1) Most time, we don't need the boot.jar which is the classes loaded from JDK. It will be only modified when an agent(JVMDI) is running and modifies the classes. + 2) If encounter error as "" not found, that means the SA is using a VMStructs which is different from the one with corefile. In this case, SA has a utility tool vmstructsdump which is located at agent/src/os//proc/ + + Use this tool to dump VM type library: + vmstructsdump libjvm.so > .db + + set env SA_TYPEDB=.db (refer different shell for set envs) diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/doc/clhsdb.html --- a/agent/doc/clhsdb.html Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/doc/clhsdb.html Tue Nov 20 20:27:40 2012 -0500 @@ -37,12 +37,19 @@ Available commands: assert true | false turn on/off asserts in SA code attach pid | exec core attach SA to a process or core + buildreplayjars [all | boot | app] build jars for replay, boot.jar for bootclasses, app.jar for application classes class name find a Java class from debuggee and print oop classes print all loaded Java classes with Klass* detach detach SA from current target dis address [ length ] disassemble (sparc/x86) specified number of instructions from given address + dissemble address disassemble nmethod + dumpcfg -a | id Dump the PhaseCFG for every compiler thread that has one live dumpclass { address | name } [ directory ] dump .class file for given Klass* or class name + dumpcodecache dump codecache contents dumpheap [ file ] dump heap in hprof binary format + dumpideal -a | id dump ideal graph like debug flag -XX:+PrintIdeal + dumpilt -a | id dump inline tree for C2 compilation + dumpreplaydata
| -a | [>replay.txt] dump replay data into a file echo [ true | false ] turn on/off command echo mode examine [ address/count ] | [ address,address] show contents of memory from given address field [ type [ name fieldtype isStatic offset address ] ] print info about a field of HotSpot type @@ -51,29 +58,35 @@ help [ command ] print help message for all commands or just given command history show command history. usual !command-number syntax works. inspect expression inspect a given oop + intConstant [ name [ value ] ] print out hotspot integer constant(s) jdis address show bytecode disassembly of a given Method* jhisto show Java heap histogram jseval script evaluate a given string as JavaScript code jsload file load and evaluate a JavaScript file jstack [-v] show Java stack trace of all Java threads. -v is verbose mode livenmethods show all live nmethods + longConstant [ name [ value ] ] print out hotspot long constant(s)s mem address [ length ] show contents of memory -- also shows closest ELF/COFF symbol if found pmap show Solaris pmap-like output print expression print given Klass*, Method* or arbitrary address printas type expression print given address as given HotSpot type. eg. print JavaThread <address> + printmdo -a | expression print method data oop printstatics [ type ] print static fields of given HotSpot type (or all types if none specified) pstack [-v] show mixed mode stack trace for all Java, non-Java threads. -v is verbose mode quit quit CLHSDB tool reattach detach and re-attach SA to current target + revptrs find liveness of oops scanoops start end [ type ] scan a Oop from given start to end address search [ heap | codecache | threads ] value search a value in heap or codecache or threads source filename load and execute CLHSDB commands from given file symbol name show address of a given ELF/COFF symbol sysprops show all Java System properties + thread id show thread of id threads show all Java threads tokenize ... type [ type [ name super isOop isInteger isUnsigned size ] ] show info. on HotSpot type universe print gc universe + vmstructsdump dump hotspot type library in text verbose true | false turn on/off verbose mode versioncheck [ true | false ] turn on/off debuggee VM version check whatis address print info about any arbitrary address @@ -114,5 +127,11 @@
+

C2 Compilation Replay

+

+When a java process crashes in compiled method, usually a core file is saved. +The C2 replay function can reproduce the compiling process in the core. +c2replay.html + diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/doc/index.html --- a/agent/doc/index.html Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/doc/index.html Tue Nov 20 20:27:40 2012 -0500 @@ -220,6 +220,12 @@ +

C2 Compilation Replay

+

+When a java process crashes in compiled method, usually a core file is saved. +The C2 replay function can reproduce the compiling process in the core. +c2replay.html +

Debugging transported core dumps

When a core dump is moved from the machine where it was produced to a diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/make/Makefile --- a/agent/make/Makefile Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/make/Makefile Tue Nov 20 20:27:40 2012 -0500 @@ -58,10 +58,8 @@ sun.jvm.hotspot.debugger.cdbg.basic.amd64 \ sun.jvm.hotspot.debugger.cdbg.basic.x86 \ sun.jvm.hotspot.debugger.dummy \ -sun.jvm.hotspot.debugger.ia64 \ sun.jvm.hotspot.debugger.linux \ sun.jvm.hotspot.debugger.linux.amd64 \ -sun.jvm.hotspot.debugger.linux.ia64 \ sun.jvm.hotspot.debugger.linux.x86 \ sun.jvm.hotspot.debugger.posix \ sun.jvm.hotspot.debugger.posix.elf \ @@ -77,7 +75,6 @@ sun.jvm.hotspot.debugger.win32.coff \ sun.jvm.hotspot.debugger.windbg \ sun.jvm.hotspot.debugger.windbg.amd64 \ -sun.jvm.hotspot.debugger.windbg.ia64 \ sun.jvm.hotspot.debugger.windbg.x86 \ sun.jvm.hotspot.debugger.x86 \ sun.jvm.hotspot.gc_implementation \ @@ -97,10 +94,8 @@ sun.jvm.hotspot.runtime.bsd \ sun.jvm.hotspot.runtime.bsd_amd64 \ sun.jvm.hotspot.runtime.bsd_x86 \ -sun.jvm.hotspot.runtime.ia64 \ sun.jvm.hotspot.runtime.linux \ sun.jvm.hotspot.runtime.linux_amd64 \ -sun.jvm.hotspot.runtime.linux_ia64 \ sun.jvm.hotspot.runtime.linux_sparc \ sun.jvm.hotspot.runtime.linux_x86 \ sun.jvm.hotspot.runtime.posix \ @@ -109,7 +104,6 @@ sun.jvm.hotspot.runtime.solaris_x86 \ sun.jvm.hotspot.runtime.sparc \ sun.jvm.hotspot.runtime.win32_amd64 \ -sun.jvm.hotspot.runtime.win32_ia64 \ sun.jvm.hotspot.runtime.win32_x86 \ sun.jvm.hotspot.runtime.x86 \ sun.jvm.hotspot.tools \ @@ -152,7 +146,6 @@ sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \ sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \ sun/jvm/hotspot/debugger/dummy/*.java \ -sun/jvm/hotspot/debugger/ia64/*.java \ sun/jvm/hotspot/debugger/linux/*.java \ sun/jvm/hotspot/debugger/linux/x86/*.java \ sun/jvm/hotspot/debugger/posix/*.java \ @@ -168,7 +161,6 @@ sun/jvm/hotspot/debugger/sparc/*.java \ sun/jvm/hotspot/debugger/win32/coff/*.java \ sun/jvm/hotspot/debugger/windbg/*.java \ -sun/jvm/hotspot/debugger/windbg/ia64/*.java \ sun/jvm/hotspot/debugger/windbg/x86/*.java \ sun/jvm/hotspot/debugger/x86/*.java \ sun/jvm/hotspot/gc_implementation/g1/*.java \ @@ -186,10 +178,8 @@ sun/jvm/hotspot/runtime/bsd/*.java \ sun/jvm/hotspot/runtime/bsd_amd64/*.java \ sun/jvm/hotspot/runtime/bsd_x86/*.java \ -sun/jvm/hotspot/runtime/ia64/*.java \ sun/jvm/hotspot/runtime/linux/*.java \ sun/jvm/hotspot/runtime/linux_amd64/*.java \ -sun/jvm/hotspot/runtime/linux_ia64/*.java \ sun/jvm/hotspot/runtime/linux_sparc/*.java \ sun/jvm/hotspot/runtime/linux_x86/*.java \ sun/jvm/hotspot/runtime/posix/*.java \ @@ -198,7 +188,6 @@ sun/jvm/hotspot/runtime/solaris_x86/*.java \ sun/jvm/hotspot/runtime/sparc/*.java \ sun/jvm/hotspot/runtime/win32_amd64/*.java \ -sun/jvm/hotspot/runtime/win32_ia64/*.java \ sun/jvm/hotspot/runtime/win32_x86/*.java \ sun/jvm/hotspot/runtime/x86/*.java \ sun/jvm/hotspot/tools/*.java \ @@ -258,6 +247,7 @@ SA_PROPERTIES = $(OUTPUT_DIR)/sa.properties JAVAC = $(JDK_HOME)/bin/javac +JAVA = $(JDK_HOME)/bin/java JAVADOC = $(JDK_HOME)/bin/javadoc RMIC = $(JDK_HOME)/bin/rmic @@ -298,7 +288,7 @@ .PHONY: natives natives: - cd ../src/os/`java -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) all + cd ../src/os/`$(JAVA) -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) all .PHONY: sa-jdi.jar sa-jdi.jar: @@ -323,5 +313,5 @@ clean:: rm -rf filelist - cd ../src/os/`java -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) clean + cd ../src/os/`$(JAVA) -classpath $(OUTPUT_DIR) sun.jvm.hotspot.utilities.PlatformInfo`; $(MAKE) clean rm -rf $(BUILD_DIR)/* diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java --- a/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Tue Nov 20 20:27:40 2012 -0500 @@ -33,6 +33,7 @@ import sun.jvm.hotspot.types.Field; import sun.jvm.hotspot.HotSpotTypeDataBase; import sun.jvm.hotspot.types.basic.BasicType; +import sun.jvm.hotspot.types.basic.BasicTypeDataBase; import sun.jvm.hotspot.types.CIntegerType; import sun.jvm.hotspot.code.*; import sun.jvm.hotspot.compiler.*; @@ -448,6 +449,112 @@ } } }, + new Command("dumpreplaydata", "dumpreplaydata {

| -a | }", false) { + // This is used to dump replay data from ciInstanceKlass, ciMethodData etc + // default file name is replay.txt, also if java crashes in compiler + // thread, this file will be dumped in error processing. + public void doit(Tokens t) { + if (t.countTokens() != 1) { + usage(); + return; + } + String name = t.nextToken(); + Address a = null; + try { + a = VM.getVM().getDebugger().parseAddress(name); + } catch (NumberFormatException e) { } + if (a != null) { + // only nmethod, Method, MethodData and InstanceKlass needed to + // dump replay data + + CodeBlob cb = VM.getVM().getCodeCache().findBlob(a); + if (cb != null && (cb instanceof NMethod)) { + ((NMethod)cb).dumpReplayData(out); + return; + } + // assume it is Metadata + Metadata meta = Metadata.instantiateWrapperFor(a); + if (meta != null) { + meta.dumpReplayData(out); + } else { + usage(); + return; + } + } + // Not an address + boolean all = name.equals("-a"); + Threads threads = VM.getVM().getThreads(); + for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + thread.printThreadIDOn(new PrintStream(bos)); + if (all || bos.toString().equals(name)) { + if (thread instanceof CompilerThread) { + CompilerThread ct = (CompilerThread)thread; + ciEnv env = ct.env(); + if (env != null) { + env.dumpReplayData(out); + } + } + } + } + } + }, + new Command("buildreplayjars", "buildreplayjars [ all | app | boot ] | [ prefix ]", false) { + // This is used to dump jar files of all the classes + // loaded in the core. Everything on the bootclasspath + // will go in boot.jar and everything else will go in + // app.jar. Then the classes can be loaded by the replay + // jvm using -Xbootclasspath/p:boot.jar -cp app.jar. boot.jar usually + // not needed, unless changed by jvmti. + public void doit(Tokens t) { + int tcount = t.countTokens(); + if (tcount > 2) { + usage(); + return; + } + try { + String prefix = ""; + String option = "all"; // default + switch(tcount) { + case 0: + break; + case 1: + option = t.nextToken(); + if (!option.equalsIgnoreCase("all") && !option.equalsIgnoreCase("app") && + !option.equalsIgnoreCase("root")) { + prefix = option; + option = "all"; + } + break; + case 2: + option = t.nextToken(); + prefix = t.nextToken(); + break; + default: + usage(); + return; + } + if (!option.equalsIgnoreCase("all") && !option.equalsIgnoreCase("app") && + !option.equalsIgnoreCase("boot")) { + usage(); + return; + } + ClassDump cd = new ClassDump(); + if (option.equalsIgnoreCase("all") || option.equalsIgnoreCase("boot")) { + cd.setClassFilter(new BootFilter()); + cd.setJarOutput(prefix + "boot.jar"); + cd.run(); + } + if (option.equalsIgnoreCase("all") || option.equalsIgnoreCase("app")) { + cd.setClassFilter(new NonBootFilter()); + cd.setJarOutput(prefix + "app.jar"); + cd.run(); + } + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + }, new Command("findpc", "findpc address", false) { public void doit(Tokens t) { if (t.countTokens() != 1) { diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciBaseObject.java Tue Nov 20 20:27:40 2012 -0500 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -50,4 +50,8 @@ public ciBaseObject(Address addr) { super(addr); } + + public void dumpReplayData(PrintStream out) { + out.println("# Unknown ci type " + getAddress().getAddressAt(0)); + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java Tue Nov 20 20:27:40 2012 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -60,4 +60,8 @@ public ciConstant(Address addr) { super(addr); } + + public void dumpReplayData(PrintStream out) { + // Nothing to be done + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java Tue Nov 20 20:27:40 2012 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -74,4 +74,29 @@ public CompileTask task() { return new CompileTask(taskField.getValue(this.getAddress())); } + + public void dumpReplayData(PrintStream out) { + out.println("JvmtiExport can_access_local_variables " + + (JvmtiExport.canAccessLocalVariables() ? '1' : '0')); + out.println("JvmtiExport can_hotswap_or_post_breakpoint " + + (JvmtiExport.canHotswapOrPostBreakpoint() ? '1' : '0')); + out.println("JvmtiExport can_post_on_exceptions " + + (JvmtiExport.canPostOnExceptions() ? '1' : '0')); + + GrowableArray objects = factory().objects(); + out.println("# " + objects.length() + " ciObject found"); + for (int i = 0; i < objects.length(); i++) { + ciMetadata o = objects.at(i); + out.println("# ciMetadata" + i + " @ " + o); + o.dumpReplayData(out); + } + CompileTask task = task(); + Method method = task.method(); + int entryBci = task.osrBci(); + Klass holder = method.getMethodHolder(); + out.println("compile " + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + entryBci); + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java Tue Nov 20 20:27:40 2012 -0500 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -80,4 +80,84 @@ public boolean isInitialized() { return initState() == CLASS_STATE_FULLY_INITIALIZED; } + + public void dumpReplayData(PrintStream out) { + InstanceKlass ik = (InstanceKlass)getMetadata(); + ConstantPool cp = ik.getConstants(); + + // Try to record related loaded classes + Klass sub = ik.getSubklassKlass(); + while (sub != null) { + if (sub instanceof InstanceKlass) { + out.println("instanceKlass " + sub.getName().asString()); + } + sub = sub.getNextSiblingKlass(); + } + + final int length = (int) cp.getLength(); + out.print("ciInstanceKlass " + name() + " " + (isLinked() ? 1 : 0) + " " + (isInitialized() ? 1 : 0) + " " + length); + for (int index = 1; index < length; index++) { + out.print(" " + cp.getTags().at(index)); + } + out.println(); + if (isInitialized()) { + Field[] staticFields = ik.getStaticFields(); + for (int i = 0; i < staticFields.length; i++) { + Field f = staticFields[i]; + Oop mirror = ik.getJavaMirror(); + if (f.isFinal() && !f.hasInitialValue()) { + out.print("staticfield " + name() + " " + + OopUtilities.escapeString(f.getID().getName()) + " " + + f.getFieldType().getSignature().asString() + " "); + if (f instanceof ByteField) { + ByteField bf = (ByteField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof BooleanField) { + BooleanField bf = (BooleanField)f; + out.println(bf.getValue(mirror) ? 1 : 0); + } else if (f instanceof ShortField) { + ShortField bf = (ShortField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof CharField) { + CharField bf = (CharField)f; + out.println(bf.getValue(mirror) & 0xffff); + } else if (f instanceof IntField) { + IntField bf = (IntField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof LongField) { + LongField bf = (LongField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof FloatField) { + FloatField bf = (FloatField)f; + out.println(Float.floatToRawIntBits(bf.getValue(mirror))); + } else if (f instanceof DoubleField) { + DoubleField bf = (DoubleField)f; + out.println(Double.doubleToRawLongBits(bf.getValue(mirror))); + } else if (f instanceof OopField) { + OopField bf = (OopField)f; + Oop value = bf.getValue(mirror); + if (value == null) { + out.println("null"); + } else if (value.isInstance()) { + Instance inst = (Instance)value; + if (inst.isA(SystemDictionary.getStringKlass())) { + out.println("\"" + OopUtilities.stringOopToEscapedString(inst) + "\""); + } else { + out.println(inst.getKlass().getName().asString()); + } + } else if (value.isObjArray()) { + ObjArray oa = (ObjArray)value; + Klass ek = (ObjArrayKlass)oa.getKlass(); + out.println(oa.getLength() + " " + ek.getName().asString()); + } else if (value.isTypeArray()) { + TypeArray ta = (TypeArray)value; + out.println(ta.getLength()); + } else { + out.println(value); + } + } + } + } + } + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Tue Nov 20 20:27:40 2012 -0500 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -88,4 +88,19 @@ st.printf(" %s::%s", method.getMethodHolder().getName().asString().replace('/', '.'), method.getName().asString()); } + + public void dumpReplayData(PrintStream out) { + Method method = (Method)getMetadata(); + NMethod nm = method.getNativeMethod(); + Klass holder = method.getMethodHolder(); + out.println("ciMethod " + + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + method.getInvocationCounter() + " " + + method.getBackedgeCounter() + " " + + interpreterInvocationCount() + " " + + interpreterThrowoutCount() + " " + + instructionsSize()); + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java Tue Nov 20 20:27:40 2012 -0500 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. * */ @@ -174,4 +174,52 @@ } } + public void dumpReplayData(PrintStream out) { + MethodData mdo = (MethodData)getMetadata(); + Method method = mdo.getMethod(); + Klass holder = method.getMethodHolder(); + out.print("ciMethodData " + + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + state() + " " + currentMileage()); + byte[] orig = orig(); + out.print(" orig " + orig.length); + for (int i = 0; i < orig.length; i++) { + out.print(" " + (orig[i] & 0xff)); + } + + long[] data = data(); + out.print(" data " + data.length); + for (int i = 0; i < data.length; i++) { + out.print(" 0x" + Long.toHexString(data[i])); + } + int count = 0; + for (int round = 0; round < 2; round++) { + if (round == 1) out.print(" oops " + count); + ProfileData pdata = firstData(); + for ( ; isValid(pdata); pdata = nextData(pdata)) { + if (pdata instanceof ciReceiverTypeData) { + ciReceiverTypeData vdata = (ciReceiverTypeData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + ciKlass k = vdata.receiverAt(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + ((vdata.dp() + vdata.cellOffset(vdata.receiverCellIndex(i))) / MethodData.cellSize) + " " + k.name()); + } + } + } else if (pdata instanceof ciVirtualCallData) { + ciVirtualCallData vdata = (ciVirtualCallData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + ciKlass k = vdata.receiverAt(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + ((vdata.dp() + vdata.cellOffset(vdata.receiverCellIndex(i))) / MethodData.cellSize + " " + k.name())); + } + } + } + } + } + out.println(); + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java --- a/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Tue Nov 20 20:27:40 2012 -0500 @@ -498,6 +498,42 @@ method.getSignature().asString(); } + public void dumpReplayData(PrintStream out) { + HashMap h = new HashMap(); + for (int i = 1; i < getMetadataLength(); i++) { + Metadata meta = Metadata.instantiateWrapperFor(getMetadataAt(i)); + System.err.println(meta); + if (h.get(meta) != null) continue; + h.put(meta, meta); + if (meta instanceof InstanceKlass) { + ((InstanceKlass)meta).dumpReplayData(out); + } else if (meta instanceof Method) { + ((Method)meta).dumpReplayData(out); + MethodData mdo = ((Method)meta).getMethodData(); + if (mdo != null) { + mdo.dumpReplayData(out); + } + } + } + Method method = getMethod(); + if (h.get(method) == null) { + method.dumpReplayData(out); + MethodData mdo = method.getMethodData(); + if (mdo != null) { + mdo.dumpReplayData(out); + } + } + if (h.get(method.getMethodHolder()) == null) { + ((InstanceKlass)method.getMethodHolder()).dumpReplayData(out); + } + Klass holder = method.getMethodHolder(); + out.println("compile " + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + getEntryBCI()); + + } + //-------------------------------------------------------------------------------- // Internals only below this point // diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java --- a/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java Tue Nov 20 20:27:40 2012 -0500 @@ -56,7 +56,7 @@ } public Method method() { - Address oh = methodField.getValue(getAddress()).getAddressAt(0); + Address oh = methodField.getValue(getAddress()); return (Method)Metadata.instantiateWrapperFor(oh); } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java Tue Nov 20 20:27:40 2012 -0500 @@ -86,7 +86,7 @@ public void printValueOn(PrintStream tty) { - tty.print("ConstantPoolCache for " + getConstants().getPoolHolder().getName().asString()); + tty.print("ConstantPoolCache for " + getConstants().getPoolHolder().getName().asString() + " address = " + getAddress() + " offset = " + baseOffset); } public int getLength() { diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/oops/Field.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java Tue Nov 20 20:27:40 2012 -0500 @@ -110,6 +110,8 @@ public Symbol getSignature() { return signature; } public Symbol getGenericSignature() { return genericSignature; } + public boolean hasInitialValue() { return holder.getFieldInitialValueIndex(fieldIndex) != 0; } + // // Following acccessors are for named, non-VM fields only // diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Tue Nov 20 20:27:40 2012 -0500 @@ -278,7 +278,7 @@ } public short getFieldGenericSignatureIndex(int index) { - int len = getFields().length(); + // int len = getFields().length(); int allFieldsCount = getAllFieldsCount(); int generic_signature_slot = allFieldsCount * FIELD_SLOTS; for (int i = 0; i < allFieldsCount; i++) { @@ -325,7 +325,7 @@ public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); } public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } public int getAllFieldsCount() { - int len = getFields().length(); + int len = getFields().length(); int allFieldsCount = 0; for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) { short flags = getFieldAccessFlags(allFieldsCount); @@ -581,6 +581,19 @@ } } + public Field[] getStaticFields() { + U2Array fields = getFields(); + int length = getJavaFieldsCount(); + ArrayList result = new ArrayList(); + for (int index = 0; index < length; index++) { + Field f = newField(index); + if (f.isStatic()) { + result.add(f); + } + } + return (Field[])result.toArray(new Field[result.size()]); + } + public void iterateNonStaticFields(OopVisitor visitor, Oop obj) { if (getSuper() != null) { ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj); @@ -979,4 +992,84 @@ } return -1; } + + public void dumpReplayData(PrintStream out) { + ConstantPool cp = getConstants(); + + // Try to record related loaded classes + Klass sub = getSubklassKlass(); + while (sub != null) { + if (sub instanceof InstanceKlass) { + out.println("instanceKlass " + sub.getName().asString()); + } + sub = sub.getNextSiblingKlass(); + } + + final int length = (int) cp.getLength(); + out.print("ciInstanceKlass " + getName().asString() + " " + (isLinked() ? 1 : 0) + " " + (isInitialized() ? 1 : 0) + " " + length); + for (int index = 1; index < length; index++) { + out.print(" " + cp.getTags().at(index)); + } + out.println(); + if (isInitialized()) { + Field[] staticFields = getStaticFields(); + for (int i = 0; i < staticFields.length; i++) { + Field f = staticFields[i]; + Oop mirror = getJavaMirror(); + if (f.isFinal() && !f.hasInitialValue()) { + out.print("staticfield " + getName().asString() + " " + + OopUtilities.escapeString(f.getID().getName()) + " " + + f.getFieldType().getSignature().asString() + " "); + if (f instanceof ByteField) { + ByteField bf = (ByteField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof BooleanField) { + BooleanField bf = (BooleanField)f; + out.println(bf.getValue(mirror) ? 1 : 0); + } else if (f instanceof ShortField) { + ShortField bf = (ShortField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof CharField) { + CharField bf = (CharField)f; + out.println(bf.getValue(mirror) & 0xffff); + } else if (f instanceof IntField) { + IntField bf = (IntField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof LongField) { + LongField bf = (LongField)f; + out.println(bf.getValue(mirror)); + } else if (f instanceof FloatField) { + FloatField bf = (FloatField)f; + out.println(Float.floatToRawIntBits(bf.getValue(mirror))); + } else if (f instanceof DoubleField) { + DoubleField bf = (DoubleField)f; + out.println(Double.doubleToRawLongBits(bf.getValue(mirror))); + } else if (f instanceof OopField) { + OopField bf = (OopField)f; + + Oop value = bf.getValue(mirror); + if (value == null) { + out.println("null"); + } else if (value.isInstance()) { + Instance inst = (Instance)value; + if (inst.isA(SystemDictionary.getStringKlass())) { + out.println("\"" + OopUtilities.stringOopToEscapedString(inst) + "\""); + } else { + out.println(inst.getKlass().getName().asString()); + } + } else if (value.isObjArray()) { + ObjArray oa = (ObjArray)value; + Klass ek = (ObjArrayKlass)oa.getKlass(); + out.println(oa.getLength() + " " + ek.getName().asString()); + } else if (value.isTypeArray()) { + TypeArray ta = (TypeArray)value; + out.println(ta.getLength()); + } else { + out.println(value); + } + } + } + } + } + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/Metadata.java Tue Nov 20 20:27:40 2012 -0500 @@ -79,4 +79,7 @@ } abstract public void printValueOn(PrintStream tty); + public void dumpReplayData(PrintStream out) { + out.println("# Unknown Metadata"); + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/oops/Method.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Tue Nov 20 20:27:40 2012 -0500 @@ -358,6 +358,25 @@ buf.append(")"); return buf.toString().replace('/', '.'); } + + public void dumpReplayData(PrintStream out) { + NMethod nm = getNativeMethod(); + int code_size = 0; + if (nm != null) { + code_size = (int)nm.codeEnd().minus(nm.getVerifiedEntryPoint()); + } + Klass holder = getMethodHolder(); + out.println("ciMethod " + + holder.getName().asString() + " " + + OopUtilities.escapeString(getName().asString()) + " " + + getSignature().asString() + " " + + getInvocationCounter() + " " + + getBackedgeCounter() + " " + + interpreterInvocationCount() + " " + + interpreterThrowoutCount() + " " + + code_size); + } + public int interpreterThrowoutCount() { return (int) interpreterThrowoutCountField.getValue(this); } diff -r 49cbd3e25ba9 -r 3ed6de6e139b agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java Fri Nov 16 09:05:19 2012 -0500 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java Tue Nov 20 20:27:40 2012 -0500 @@ -332,4 +332,59 @@ public int currentMileage() { return 20000; } + + public void dumpReplayData(PrintStream out) { + Method method = getMethod(); + Klass holder = method.getMethodHolder(); + out.print("ciMethodData " + + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + "2" + " " + + currentMileage()); + byte[] orig = orig(); + out.print(" orig " + orig.length); + for (int i = 0; i < orig.length; i++) { + out.print(" " + (orig[i] & 0xff)); + } + + long[] data = data(); + out.print(" data " + data.length); + for (int i = 0; i < data.length; i++) { + out.print(" 0x" + Long.toHexString(data[i])); + } + int count = 0; + for (int round = 0; round < 2; round++) { + if (round == 1) out.print(" oops " + count); + ProfileData pdata = firstData(); + for ( ; isValid(pdata); pdata = nextData(pdata)) { + if (pdata instanceof ReceiverTypeData) { + ReceiverTypeData vdata = (ReceiverTypeData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + Klass k = vdata.receiver(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + + (dpToDi(vdata.dp() + + vdata.cellOffset(vdata.receiverCellIndex(i))) / cellSize) + " " + + k.getName().asString()); + } + } + } else if (pdata instanceof VirtualCallData) { + VirtualCallData vdata = (VirtualCallData)pdata; + for (int i = 0; i < vdata.rowLimit(); i++) { + Klass k = vdata.receiver(i); + if (k != null) { + if (round == 0) count++; + else out.print(" " + + (dpToDi(vdata.dp() + + vdata.cellOffset(vdata.receiverCellIndex(i))) / cellSize) + " " + + k.getName().asString()); + } + } + } + } + } + out.println(); + } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b make/hotspot_version --- a/make/hotspot_version Fri Nov 16 09:05:19 2012 -0500 +++ b/make/hotspot_version Tue Nov 20 20:27:40 2012 -0500 @@ -35,7 +35,7 @@ HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=09 +HS_BUILD_NUMBER=11 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 diff -r 49cbd3e25ba9 -r 3ed6de6e139b make/linux/makefiles/defs.make --- a/make/linux/makefiles/defs.make Fri Nov 16 09:05:19 2012 -0500 +++ b/make/linux/makefiles/defs.make Tue Nov 20 20:27:40 2012 -0500 @@ -170,68 +170,70 @@ # overridden in some situations, e.g., a BUILD_FLAVOR != product # build. - ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) - else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 - endif - _JUNK_ := $(shell \ - echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") - # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later + # Due to the multiple sub-make processes that occur this logic gets + # executed multiple times. We reduce the noise by at least checking that + # BUILD_FLAVOR has been set. + ifneq ($(BUILD_FLAVOR),) + ifeq ($(BUILD_FLAVOR), product) + FULL_DEBUG_SYMBOLS ?= 1 + ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) + else + # debug variants always get Full Debug Symbols (if available) + ENABLE_FULL_DEBUG_SYMBOLS = 1 + endif + _JUNK_ := $(shell \ + echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") + # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # Default OBJCOPY comes from GNU Binutils on Linux: - DEF_OBJCOPY=/usr/bin/objcopy - ifdef CROSS_COMPILE_ARCH - # don't try to generate .debuginfo files when cross compiling - _JUNK_ := $(shell \ - echo >&2 "INFO: cross compiling for ARCH $(CROSS_COMPILE_ARCH)," \ - "skipping .debuginfo generation.") - OBJCOPY= - else + ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) + # Default OBJCOPY comes from GNU Binutils on Linux + ifeq ($(CROSS_COMPILE_ARCH),) + DEF_OBJCOPY=/usr/bin/objcopy + else + # Assume objcopy is part of the cross-compilation toolset + ifneq ($(ALT_COMPILER_PATH),) + DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy + endif + endif OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) ifneq ($(ALT_OBJCOPY),) _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)") OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) endif - endif - else - OBJCOPY= - endif - ifeq ($(OBJCOPY),) - _JUNK_ := $(shell \ - echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.") - ENABLE_FULL_DEBUG_SYMBOLS=0 - _JUNK_ := $(shell \ - echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") - else - _JUNK_ := $(shell \ - echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.") + ifeq ($(OBJCOPY),) + _JUNK_ := $(shell \ + echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files. You may need to set ALT_OBJCOPY.") + ENABLE_FULL_DEBUG_SYMBOLS=0 + _JUNK_ := $(shell \ + echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") + else + _JUNK_ := $(shell \ + echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.") - # Library stripping policies for .debuginfo configs: - # all_strip - strips everything from the library - # min_strip - strips most stuff from the library; leaves minimum symbols - # no_strip - does not strip the library at all - # - # Oracle security policy requires "all_strip". A waiver was granted on - # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. - # - # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled. - # - STRIP_POLICY ?= min_strip + # Library stripping policies for .debuginfo configs: + # all_strip - strips everything from the library + # min_strip - strips most stuff from the library; leaves minimum symbols + # no_strip - does not strip the library at all + # + # Oracle security policy requires "all_strip". A waiver was granted on + # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. + # + # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled. + # + STRIP_POLICY ?= min_strip - _JUNK_ := $(shell \ - echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)") + _JUNK_ := $(shell \ + echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)") - ZIP_DEBUGINFO_FILES ?= 1 + ZIP_DEBUGINFO_FILES ?= 1 - _JUNK_ := $(shell \ - echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)") - endif -endif + _JUNK_ := $(shell \ + echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)") + endif + endif # ENABLE_FULL_DEBUG_SYMBOLS=1 + endif # BUILD_FLAVOR +endif # JDK_6_OR_EARLIER JDK_INCLUDE_SUBDIR=linux diff -r 49cbd3e25ba9 -r 3ed6de6e139b make/linux/makefiles/vm.make --- a/make/linux/makefiles/vm.make Fri Nov 16 09:05:19 2012 -0500 +++ b/make/linux/makefiles/vm.make Tue Nov 20 20:27:40 2012 -0500 @@ -336,24 +336,23 @@ fi \ fi \ } -ifeq ($(CROSS_COMPILE_ARCH),) - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) + +ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) + ifeq ($(STRIP_POLICY),all_strip) $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) + else + ifeq ($(STRIP_POLICY),min_strip) $(QUIETLY) $(STRIP) -g $@ - # implied else here is no stripping at all - endif + # implied else here is no stripping at all endif + endif $(QUIETLY) [ -f $(LIBJVM_G_DEBUGINFO) ] || ln -s $(LIBJVM_DEBUGINFO) $(LIBJVM_G_DEBUGINFO) - ifeq ($(ZIP_DEBUGINFO_FILES),1) + ifeq ($(ZIP_DEBUGINFO_FILES),1) $(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) $(LIBJVM_G_DEBUGINFO) $(RM) $(LIBJVM_DEBUGINFO) $(LIBJVM_G_DEBUGINFO) [ -f $(LIBJVM_G_DIZ) ] || { ln -s $(LIBJVM_DIZ) $(LIBJVM_G_DIZ); } - endif endif endif diff -r 49cbd3e25ba9 -r 3ed6de6e139b make/solaris/makefiles/defs.make --- a/make/solaris/makefiles/defs.make Fri Nov 16 09:05:19 2012 -0500 +++ b/make/solaris/makefiles/defs.make Tue Nov 20 20:27:40 2012 -0500 @@ -109,60 +109,63 @@ # overridden in some situations, e.g., a BUILD_FLAVOR != product # build. - ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) - else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 - endif - _JUNK_ := $(shell \ - echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") - # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # Default OBJCOPY comes from the SUNWbinutils package: - DEF_OBJCOPY=/usr/sfw/bin/gobjcopy - OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) - ifneq ($(ALT_OBJCOPY),) - _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)") - OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) + # Due to the multiple sub-make processes that occur this logic gets + # executed multiple times. We reduce the noise by at least checking that + # BUILD_FLAVOR has been set. + ifneq ($(BUILD_FLAVOR),) + ifeq ($(BUILD_FLAVOR), product) + FULL_DEBUG_SYMBOLS ?= 1 + ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) + else + # debug variants always get Full Debug Symbols (if available) + ENABLE_FULL_DEBUG_SYMBOLS = 1 endif - else - OBJCOPY= - endif - - ifeq ($(OBJCOPY),) - _JUNK_ := $(shell \ - echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.") - ENABLE_FULL_DEBUG_SYMBOLS=0 _JUNK_ := $(shell \ echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") - else - _JUNK_ := $(shell \ - echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.") + # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later + + ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) + # Default OBJCOPY comes from the SUNWbinutils package: + DEF_OBJCOPY=/usr/sfw/bin/gobjcopy + OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) + ifneq ($(ALT_OBJCOPY),) + _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)") + OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) + endif + + ifeq ($(OBJCOPY),) + _JUNK_ := $(shell \ + echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.") + ENABLE_FULL_DEBUG_SYMBOLS=0 + _JUNK_ := $(shell \ + echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") + else + _JUNK_ := $(shell \ + echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.") - # Library stripping policies for .debuginfo configs: - # all_strip - strips everything from the library - # min_strip - strips most stuff from the library; leaves minimum symbols - # no_strip - does not strip the library at all - # - # Oracle security policy requires "all_strip". A waiver was granted on - # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. - # - # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled. - # - STRIP_POLICY ?= min_strip + # Library stripping policies for .debuginfo configs: + # all_strip - strips everything from the library + # min_strip - strips most stuff from the library; leaves minimum symbols + # no_strip - does not strip the library at all + # + # Oracle security policy requires "all_strip". A waiver was granted on + # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. + # + # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled. + # + STRIP_POLICY ?= min_strip - _JUNK_ := $(shell \ - echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)") + _JUNK_ := $(shell \ + echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)") - ZIP_DEBUGINFO_FILES ?= 1 + ZIP_DEBUGINFO_FILES ?= 1 - _JUNK_ := $(shell \ - echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)") - endif -endif + _JUNK_ := $(shell \ + echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)") + endif + endif # ENABLE_FULL_DEBUG_SYMBOLS=1 + endif # BUILD_FLAVOR +endif # JDK_6_OR_EARLIER JDK_INCLUDE_SUBDIR=solaris diff -r 49cbd3e25ba9 -r 3ed6de6e139b make/windows/makefiles/defs.make --- a/make/windows/makefiles/defs.make Fri Nov 16 09:05:19 2012 -0500 +++ b/make/windows/makefiles/defs.make Tue Nov 20 20:27:40 2012 -0500 @@ -131,23 +131,29 @@ # overridden in some situations, e.g., a BUILD_FLAVOR != product # build. -ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) -else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 +# Due to the multiple sub-make processes that occur this logic gets +# executed multiple times. We reduce the noise by at least checking that +# BUILD_FLAVOR has been set. +ifneq ($(BUILD_FLAVOR),) + ifeq ($(BUILD_FLAVOR), product) + FULL_DEBUG_SYMBOLS ?= 1 + ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) + else + # debug variants always get Full Debug Symbols (if available) + ENABLE_FULL_DEBUG_SYMBOLS = 1 + endif + _JUNK_ := $(shell \ + echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") + MAKE_ARGS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) + + ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) + ZIP_DEBUGINFO_FILES ?= 1 + else + ZIP_DEBUGINFO_FILES=0 + endif + MAKE_ARGS += ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) endif -_JUNK_ := $(shell \ - echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") -MAKE_ARGS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ZIP_DEBUGINFO_FILES ?= 1 -else - ZIP_DEBUGINFO_FILES=0 -endif -MAKE_ARGS += ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) MAKE_ARGS += RM="$(RM)" MAKE_ARGS += ZIPEXE=$(ZIPEXE) diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/cpu/x86/vm/vm_version_x86.cpp --- a/src/cpu/x86/vm/vm_version_x86.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/cpu/x86/vm/vm_version_x86.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -488,8 +488,8 @@ } // The AES intrinsic stubs require AES instruction support (of course) - // but also require AVX mode for misaligned SSE access - if (UseAES && (UseAVX > 0)) { + // but also require AVX and sse3 modes for instructions it use. + if (UseAES && (UseAVX > 0) && (UseSSE > 2)) { if (FLAG_IS_DEFAULT(UseAESIntrinsics)) { UseAESIntrinsics = true; } diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/os/bsd/vm/os_bsd.cpp --- a/src/os/bsd/vm/os_bsd.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/os/bsd/vm/os_bsd.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1198,19 +1198,20 @@ return os::stat(filename, &statbuf) == 0; } -void os::dll_build_name(char* buffer, size_t buflen, +bool os::dll_build_name(char* buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; // Copied from libhpi const size_t pnamelen = pname ? strlen(pname) : 0; - // Quietly truncate on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + strlen(JNI_LIB_PREFIX) + strlen(JNI_LIB_SUFFIX) + 2 > buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { snprintf(buffer, buflen, JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1222,6 +1223,7 @@ snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pelements[i], fname); if (file_exists(buffer)) { + retval = true; break; } } @@ -1236,7 +1238,9 @@ } } else { snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname); + retval = true; } + return retval; } const char* os::get_current_directory(char *buf, int buflen) { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/os/linux/vm/os_linux.cpp --- a/src/os/linux/vm/os_linux.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/os/linux/vm/os_linux.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1650,19 +1650,20 @@ return os::stat(filename, &statbuf) == 0; } -void os::dll_build_name(char* buffer, size_t buflen, +bool os::dll_build_name(char* buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; // Copied from libhpi const size_t pnamelen = pname ? strlen(pname) : 0; - // Quietly truncate on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + 10 > (size_t) buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { snprintf(buffer, buflen, "lib%s.so", fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1673,6 +1674,7 @@ } snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname); if (file_exists(buffer)) { + retval = true; break; } } @@ -1687,7 +1689,9 @@ } } else { snprintf(buffer, buflen, "%s/lib%s.so", pname, fname); - } + retval = true; + } + return retval; } const char* os::get_current_directory(char *buf, int buflen) { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/os/solaris/vm/os_solaris.cpp --- a/src/os/solaris/vm/os_solaris.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/os/solaris/vm/os_solaris.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1894,18 +1894,19 @@ return os::stat(filename, &statbuf) == 0; } -void os::dll_build_name(char* buffer, size_t buflen, +bool os::dll_build_name(char* buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; const size_t pnamelen = pname ? strlen(pname) : 0; - // Quietly truncate on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + 10 > (size_t) buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { snprintf(buffer, buflen, "lib%s.so", fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1916,6 +1917,7 @@ } snprintf(buffer, buflen, "%s/lib%s.so", pelements[i], fname); if (file_exists(buffer)) { + retval = true; break; } } @@ -1930,7 +1932,9 @@ } } else { snprintf(buffer, buflen, "%s/lib%s.so", pname, fname); - } + retval = true; + } + return retval; } const char* os::get_current_directory(char *buf, int buflen) { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/os/windows/vm/os_windows.cpp --- a/src/os/windows/vm/os_windows.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/os/windows/vm/os_windows.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1132,21 +1132,23 @@ return GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES; } -void os::dll_build_name(char *buffer, size_t buflen, +bool os::dll_build_name(char *buffer, size_t buflen, const char* pname, const char* fname) { + bool retval = false; const size_t pnamelen = pname ? strlen(pname) : 0; const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0; - // Quietly truncates on buffer overflow. Should be an error. + // Return error on buffer overflow. if (pnamelen + strlen(fname) + 10 > buflen) { - *buffer = '\0'; - return; + return retval; } if (pnamelen == 0) { jio_snprintf(buffer, buflen, "%s.dll", fname); + retval = true; } else if (c == ':' || c == '\\') { jio_snprintf(buffer, buflen, "%s%s.dll", pname, fname); + retval = true; } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); @@ -1164,6 +1166,7 @@ jio_snprintf(buffer, buflen, "%s\\%s.dll", path, fname); } if (file_exists(buffer)) { + retval = true; break; } } @@ -1178,7 +1181,9 @@ } } else { jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname); - } + retval = true; + } + return retval; } // Needs to be in os specific directory because windows requires another diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/c1/c1_GraphBuilder.cpp --- a/src/share/vm/c1/c1_GraphBuilder.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1836,7 +1836,7 @@ // check if we could do inlining if (!PatchALot && Inline && klass->is_loaded() && (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) - && target->will_link(klass, callee_holder, code)) { + && target->is_loaded()) { // callee is known => check if we have static binding assert(target->is_loaded(), "callee must be known"); if (code == Bytecodes::_invokestatic || diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/bcEscapeAnalyzer.cpp --- a/src/share/vm/ci/bcEscapeAnalyzer.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/bcEscapeAnalyzer.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -282,7 +282,7 @@ ciMethod* inline_target = NULL; if (target->is_loaded() && klass->is_loaded() && (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) - && target->will_link(klass, callee_holder, code)) { + && target->is_loaded()) { if (code == Bytecodes::_invokestatic || code == Bytecodes::_invokespecial || code == Bytecodes::_invokevirtual && target->is_final_method()) { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciClassList.hpp --- a/src/share/vm/ci/ciClassList.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciClassList.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -106,6 +106,7 @@ friend class ciArray; \ friend class ciObjArray; \ friend class ciMetadata; \ +friend class ciReplay; \ friend class ciTypeArray; \ friend class ciType; \ friend class ciReturnAddress; \ diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciEnv.cpp --- a/src/share/vm/ci/ciEnv.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciEnv.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -30,6 +30,7 @@ #include "ci/ciInstanceKlass.hpp" #include "ci/ciMethod.hpp" #include "ci/ciNullObject.hpp" +#include "ci/ciReplay.hpp" #include "ci/ciUtilities.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" @@ -772,6 +773,11 @@ : !m->method_holder()->is_loaded())) { m = NULL; } +#ifdef ASSERT + if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) { + m = NULL; + } +#endif if (m != NULL) { // We found the method. return get_method(m); @@ -1144,3 +1150,43 @@ // If memory is low, we stop compiling methods. record_method_not_compilable("out of memory"); } + +fileStream* ciEnv::_replay_data_stream = NULL; + +void ciEnv::dump_replay_data() { + VM_ENTRY_MARK; + MutexLocker ml(Compile_lock); + if (_replay_data_stream == NULL) { + _replay_data_stream = new (ResourceObj::C_HEAP, mtCompiler) fileStream(ReplayDataFile); + if (_replay_data_stream == NULL) { + fatal(err_msg("Can't open %s for replay data", ReplayDataFile)); + } + } + dump_replay_data(_replay_data_stream); +} + + +void ciEnv::dump_replay_data(outputStream* out) { + ASSERT_IN_VM; + +#if INCLUDE_JVMTI + out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables); + out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint); + out->print_cr("JvmtiExport can_post_on_exceptions %d", _jvmti_can_post_on_exceptions); +#endif // INCLUDE_JVMTI + + GrowableArray* objects = _factory->get_ci_metadata(); + out->print_cr("# %d ciObject found", objects->length()); + for (int i = 0; i < objects->length(); i++) { + objects->at(i)->dump_replay_data(out); + } + Method* method = task()->method(); + int entry_bci = task()->osr_bci(); + // Klass holder = method->method_holder(); + out->print_cr("compile %s %s %s %d", + method->klass_name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii(), + entry_bci); + out->flush(); +} diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciEnv.hpp --- a/src/share/vm/ci/ciEnv.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciEnv.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -46,6 +46,8 @@ friend class CompileBroker; friend class Dependencies; // for get_object, during logging + static fileStream* _replay_data_stream; + private: Arena* _arena; // Alias for _ciEnv_arena except in init_shared_objects() Arena _ciEnv_arena; @@ -448,6 +450,13 @@ // RedefineClasses support void metadata_do(void f(Metadata*)) { _factory->metadata_do(f); } + + // Dump the compilation replay data for this ciEnv to + // ReplayDataFile, creating the file if needed. + void dump_replay_data(); + + // Dump the compilation replay data for the ciEnv to the stream. + void dump_replay_data(outputStream* out); }; #endif // SHARE_VM_CI_CIENV_HPP diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciInstanceKlass.cpp --- a/src/share/vm/ci/ciInstanceKlass.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciInstanceKlass.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -561,3 +561,114 @@ } return impl; } + +// Utility class for printing of the contents of the static fields for +// use by compilation replay. It only prints out the information that +// could be consumed by the compiler, so for primitive types it prints +// out the actual value. For Strings it's the actual string value. +// For array types it it's first level array size since that's the +// only value which statically unchangeable. For all other reference +// types it simply prints out the dynamic type. + +class StaticFinalFieldPrinter : public FieldClosure { + outputStream* _out; + const char* _holder; + public: + StaticFinalFieldPrinter(outputStream* out, const char* holder) : + _out(out), + _holder(holder) { + } + void do_field(fieldDescriptor* fd) { + if (fd->is_final() && !fd->has_initial_value()) { + oop mirror = fd->field_holder()->java_mirror(); + _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii()); + switch (fd->field_type()) { + case T_BYTE: _out->print_cr("%d", mirror->byte_field(fd->offset())); break; + case T_BOOLEAN: _out->print_cr("%d", mirror->bool_field(fd->offset())); break; + case T_SHORT: _out->print_cr("%d", mirror->short_field(fd->offset())); break; + case T_CHAR: _out->print_cr("%d", mirror->char_field(fd->offset())); break; + case T_INT: _out->print_cr("%d", mirror->int_field(fd->offset())); break; + case T_LONG: _out->print_cr(INT64_FORMAT, mirror->long_field(fd->offset())); break; + case T_FLOAT: { + float f = mirror->float_field(fd->offset()); + _out->print_cr("%d", *(int*)&f); + break; + } + case T_DOUBLE: { + double d = mirror->double_field(fd->offset()); + _out->print_cr(INT64_FORMAT, *(jlong*)&d); + break; + } + case T_ARRAY: { + oop value = mirror->obj_field_acquire(fd->offset()); + if (value == NULL) { + _out->print_cr("null"); + } else { + typeArrayOop ta = (typeArrayOop)value; + _out->print("%d", ta->length()); + if (value->is_objArray()) { + objArrayOop oa = (objArrayOop)value; + const char* klass_name = value->klass()->name()->as_quoted_ascii(); + _out->print(" %s", klass_name); + } + _out->cr(); + } + break; + } + case T_OBJECT: { + oop value = mirror->obj_field_acquire(fd->offset()); + if (value == NULL) { + _out->print_cr("null"); + } else if (value->is_instance()) { + if (value->is_a(SystemDictionary::String_klass())) { + _out->print("\""); + _out->print_raw(java_lang_String::as_quoted_ascii(value)); + _out->print_cr("\""); + } else { + const char* klass_name = value->klass()->name()->as_quoted_ascii(); + _out->print_cr(klass_name); + } + } else { + ShouldNotReachHere(); + } + break; + } + default: + ShouldNotReachHere(); + } + } + } +}; + + +void ciInstanceKlass::dump_replay_data(outputStream* out) { + ASSERT_IN_VM; + InstanceKlass* ik = get_instanceKlass(); + ConstantPool* cp = ik->constants(); + + // Try to record related loaded classes + Klass* sub = ik->subklass(); + while (sub != NULL) { + if (sub->oop_is_instance()) { + out->print_cr("instanceKlass %s", sub->name()->as_quoted_ascii()); + } + sub = sub->next_sibling(); + } + + // Dump out the state of the constant pool tags. During replay the + // tags will be validated for things which shouldn't change and + // classes will be resolved if the tags indicate that they were + // resolved at compile time. + out->print("ciInstanceKlass %s %d %d %d", ik->name()->as_quoted_ascii(), + is_linked(), is_initialized(), cp->length()); + for (int index = 1; index < cp->length(); index++) { + out->print(" %d", cp->tags()->at(index)); + } + out->cr(); + if (is_initialized()) { + // Dump out the static final fields in case the compilation relies + // on their value for correct replay. + StaticFinalFieldPrinter sffp(out, ik->name()->as_quoted_ascii()); + ik->do_local_static_fields(&sffp); + } +} diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciInstanceKlass.hpp --- a/src/share/vm/ci/ciInstanceKlass.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciInstanceKlass.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -230,6 +230,9 @@ // What kind of ciObject is this? bool is_instance_klass() const { return true; } bool is_java_klass() const { return true; } + + // Dump the current state of this klass for compilation replay. + virtual void dump_replay_data(outputStream* out); }; #endif // SHARE_VM_CI_CIINSTANCEKLASS_HPP diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciMetadata.hpp --- a/src/share/vm/ci/ciMetadata.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciMetadata.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -61,6 +61,7 @@ virtual bool is_array_klass() const { return false; } virtual bool is_obj_array_klass() const { return false; } virtual bool is_type_array_klass() const { return false; } + virtual void dump_replay_data(outputStream* st) { /* do nothing */ } ciMethod* as_method() { assert(is_method(), "bad cast"); diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciMethod.cpp --- a/src/share/vm/ci/ciMethod.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciMethod.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -31,6 +31,7 @@ #include "ci/ciMethodData.hpp" #include "ci/ciStreams.hpp" #include "ci/ciSymbol.hpp" +#include "ci/ciReplay.hpp" #include "ci/ciUtilities.hpp" #include "classfile/systemDictionary.hpp" #include "compiler/abstractCompiler.hpp" @@ -139,6 +140,12 @@ } if (_interpreter_invocation_count == 0) _interpreter_invocation_count = 1; + _instructions_size = -1; +#ifdef ASSERT + if (ReplayCompiles) { + ciReplay::initialize(this); + } +#endif } @@ -161,7 +168,8 @@ #if defined(COMPILER2) || defined(SHARK) , _flow( NULL), - _bcea( NULL) + _bcea( NULL), + _instructions_size(-1) #endif // COMPILER2 || SHARK { // Usually holder and accessor are the same type but in some cases @@ -868,25 +876,6 @@ } // ------------------------------------------------------------------ -// ciMethod::will_link -// -// Will this method link in a specific calling context? -bool ciMethod::will_link(ciKlass* accessing_klass, - ciKlass* declared_method_holder, - Bytecodes::Code bc) { - if (!is_loaded()) { - // Method lookup failed. - return false; - } - - // The link checks have been front-loaded into the get_method - // call. This method (ciMethod::will_link()) will be removed - // in the future. - - return true; -} - -// ------------------------------------------------------------------ // ciMethod::should_exclude // // Should this method be excluded from compilation? @@ -1000,8 +989,7 @@ // ------------------------------------------------------------------ // ciMethod::has_compiled_code bool ciMethod::has_compiled_code() { - VM_ENTRY_MARK; - return get_Method()->code() != NULL; + return instructions_size() > 0; } int ciMethod::comp_level() { @@ -1039,14 +1027,18 @@ // junk like exception handler, stubs, and constant table, which are // not highly relevant to an inlined method. So we use the more // specific accessor nmethod::insts_size. -int ciMethod::instructions_size(int comp_level) { - GUARDED_VM_ENTRY( - nmethod* code = get_Method()->code(); - if (code != NULL && (comp_level == CompLevel_any || comp_level == code->comp_level())) { - return code->insts_end() - code->verified_entry_point(); - } - return 0; - ) +int ciMethod::instructions_size() { + if (_instructions_size == -1) { + GUARDED_VM_ENTRY( + nmethod* code = get_Method()->code(); + if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) { + _instructions_size = code->insts_end() - code->verified_entry_point(); + } else { + _instructions_size = 0; + } + ); + } + return _instructions_size; } // ------------------------------------------------------------------ @@ -1166,6 +1158,20 @@ #undef FETCH_FLAG_FROM_VM +void ciMethod::dump_replay_data(outputStream* st) { + ASSERT_IN_VM; + Method* method = get_Method(); + Klass* holder = method->method_holder(); + st->print_cr("ciMethod %s %s %s %d %d %d %d %d", + holder->name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii(), + method->invocation_counter()->raw_counter(), + method->backedge_counter()->raw_counter(), + interpreter_invocation_count(), + interpreter_throwout_count(), + _instructions_size); +} // ------------------------------------------------------------------ // ciMethod::print_codes diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciMethod.hpp --- a/src/share/vm/ci/ciMethod.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciMethod.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -51,6 +51,7 @@ friend class ciExceptionHandlerStream; friend class ciBytecodeStream; friend class ciMethodHandle; + friend class ciReplay; private: // General method information. @@ -69,6 +70,7 @@ int _handler_count; int _interpreter_invocation_count; int _interpreter_throwout_count; + int _instructions_size; bool _uses_monitors; bool _balanced_monitors; @@ -239,9 +241,6 @@ int resolve_vtable_index(ciKlass* caller, ciKlass* receiver); // Compilation directives - bool will_link(ciKlass* accessing_klass, - ciKlass* declared_method_holder, - Bytecodes::Code bc); bool should_exclude(); bool should_inline(); bool should_not_inline(); @@ -252,7 +251,6 @@ bool can_be_osr_compiled(int entry_bci); void set_not_compilable(); bool has_compiled_code(); - int instructions_size(int comp_level = CompLevel_any); void log_nmethod_identity(xmlStream* log); bool is_not_reached(int bci); bool was_executed_more_than(int times); @@ -260,6 +258,7 @@ bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const; bool check_call(int refinfo_index, bool is_static) const; bool ensure_method_data(); // make sure it exists in the VM also + int instructions_size(); int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC // JSR 292 support @@ -291,6 +290,7 @@ bool is_accessor () const; bool is_initializer () const; bool can_be_statically_bound() const { return _can_be_statically_bound; } + void dump_replay_data(outputStream* st); // Print the bytecodes of this method. void print_codes_on(outputStream* st); diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciMethodData.cpp --- a/src/share/vm/ci/ciMethodData.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciMethodData.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "ci/ciMetadata.hpp" #include "ci/ciMethodData.hpp" +#include "ci/ciReplay.hpp" #include "ci/ciUtilities.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" @@ -115,6 +116,11 @@ _arg_local = mdo->arg_local(); _arg_stack = mdo->arg_stack(); _arg_returned = mdo->arg_returned(); +#ifndef PRODUCT + if (ReplayCompiles) { + ciReplay::initialize(this); + } +#endif } void ciReceiverTypeData::translate_receiver_data_from(ProfileData* data) { @@ -366,6 +372,79 @@ ciMetadata::print_impl(st); } +void ciMethodData::dump_replay_data(outputStream* out) { + ASSERT_IN_VM; + MethodData* mdo = get_MethodData(); + Method* method = mdo->method(); + Klass* holder = method->method_holder(); + out->print("ciMethodData %s %s %s %d %d", + holder->name()->as_quoted_ascii(), + method->name()->as_quoted_ascii(), + method->signature()->as_quoted_ascii(), + _state, + current_mileage()); + + // dump the contents of the MDO header as raw data + unsigned char* orig = (unsigned char*)&_orig; + int length = sizeof(_orig); + out->print(" orig %d", length); + for (int i = 0; i < length; i++) { + out->print(" %d", orig[i]); + } + + // dump the MDO data as raw data + int elements = data_size() / sizeof(intptr_t); + out->print(" data %d", elements); + for (int i = 0; i < elements; i++) { + // We could use INTPTR_FORMAT here but that's a zero justified + // which makes comparing it with the SA version of this output + // harder. +#ifdef _LP64 + out->print(" 0x%" FORMAT64_MODIFIER "x", data()[i]); +#else + out->print(" 0x%x", data()[i]); +#endif + } + + // The MDO contained oop references as ciObjects, so scan for those + // and emit pairs of offset and klass name so that they can be + // reconstructed at runtime. The first round counts the number of + // oop references and the second actually emits them. + int count = 0; + for (int round = 0; round < 2; round++) { + if (round == 1) out->print(" oops %d", count); + ProfileData* pdata = first_data(); + for ( ; is_valid(pdata); pdata = next_data(pdata)) { + if (pdata->is_ReceiverTypeData()) { + ciReceiverTypeData* vdata = (ciReceiverTypeData*)pdata; + for (uint i = 0; i < vdata->row_limit(); i++) { + ciKlass* k = vdata->receiver(i); + if (k != NULL) { + if (round == 0) { + count++; + } else { + out->print(" %d %s", dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t), k->name()->as_quoted_ascii()); + } + } + } + } else if (pdata->is_VirtualCallData()) { + ciVirtualCallData* vdata = (ciVirtualCallData*)pdata; + for (uint i = 0; i < vdata->row_limit(); i++) { + ciKlass* k = vdata->receiver(i); + if (k != NULL) { + if (round == 0) { + count++; + } else { + out->print(" %d %s", dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t), k->name()->as_quoted_ascii()); + } + } + } + } + } + } + out->cr(); +} + #ifndef PRODUCT void ciMethodData::print() { print_data_on(tty); diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciMethodData.hpp --- a/src/share/vm/ci/ciMethodData.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciMethodData.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -144,6 +144,7 @@ class ciMethodData : public ciMetadata { CI_PACKAGE_ACCESS + friend class ciReplay; private: // Size in bytes @@ -320,6 +321,7 @@ void print(); void print_data_on(outputStream* st); #endif + void dump_replay_data(outputStream* out); }; #endif // SHARE_VM_CI_CIMETHODDATA_HPP diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciObject.hpp --- a/src/share/vm/ci/ciObject.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciObject.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -131,6 +131,7 @@ // Is this a type or value which has no associated class? // It is true of primitive types and null objects. virtual bool is_classless() const { return false; } + virtual void dump_replay_data(outputStream* st) { /* do nothing */ } // Note: some ciObjects refer to oops which have yet to be created. // We refer to these as "unloaded". Specifically, there are diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciObjectFactory.hpp --- a/src/share/vm/ci/ciObjectFactory.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciObjectFactory.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -137,6 +137,7 @@ ciReturnAddress* get_return_address(int bci); + GrowableArray* get_ci_metadata() const { return _ci_metadata; } // RedefineClasses support void metadata_do(void f(Metadata*)); diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciReplay.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/ci/ciReplay.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -0,0 +1,942 @@ +/* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "ci/ciMethodData.hpp" +#include "ci/ciReplay.hpp" +#include "ci/ciUtilities.hpp" +#include "compiler/compileBroker.hpp" +#include "memory/allocation.inline.hpp" +#include "memory/oopFactory.hpp" +#include "memory/resourceArea.hpp" +#include "utilities/copy.hpp" + +#ifdef ASSERT + +// ciReplay + +typedef struct _ciMethodDataRecord { + const char* klass; + const char* method; + const char* signature; + int state; + int current_mileage; + intptr_t* data; + int data_length; + char* orig_data; + int orig_data_length; + int oops_length; + jobject* oops_handles; + int* oops_offsets; +} ciMethodDataRecord; + +typedef struct _ciMethodRecord { + const char* klass; + const char* method; + const char* signature; + int instructions_size; + int interpreter_invocation_count; + int interpreter_throwout_count; + int invocation_counter; + int backedge_counter; +} ciMethodRecord; + +class CompileReplay; +static CompileReplay* replay_state; + +class CompileReplay : public StackObj { + private: + FILE* stream; + Thread* thread; + Handle protection_domain; + Handle loader; + + GrowableArray ci_method_records; + GrowableArray ci_method_data_records; + + const char* _error_message; + + char* bufptr; + char* buffer; + int buffer_length; + int buffer_end; + int line_no; + + public: + CompileReplay(const char* filename, TRAPS) { + thread = THREAD; + loader = Handle(thread, SystemDictionary::java_system_loader()); + stream = fopen(filename, "rt"); + if (stream == NULL) { + fprintf(stderr, "Can't open replay file %s\n", filename); + } + buffer_length = 32; + buffer = NEW_RESOURCE_ARRAY(char, buffer_length); + _error_message = NULL; + + test(); + } + + ~CompileReplay() { + if (stream != NULL) fclose(stream); + } + + void test() { + strcpy(buffer, "1 2 foo 4 bar 0x9 \"this is it\""); + bufptr = buffer; + assert(parse_int("test") == 1, "what"); + assert(parse_int("test") == 2, "what"); + assert(strcmp(parse_string(), "foo") == 0, "what"); + assert(parse_int("test") == 4, "what"); + assert(strcmp(parse_string(), "bar") == 0, "what"); + assert(parse_intptr_t("test") == 9, "what"); + assert(strcmp(parse_quoted_string(), "this is it") == 0, "what"); + } + + bool had_error() { + return _error_message != NULL || thread->has_pending_exception(); + } + + bool can_replay() { + return !(stream == NULL || had_error()); + } + + void report_error(const char* msg) { + _error_message = msg; + // Restore the buffer contents for error reporting + for (int i = 0; i < buffer_end; i++) { + if (buffer[i] == '\0') buffer[i] = ' '; + } + } + + int parse_int(const char* label) { + if (had_error()) { + return 0; + } + + int v = 0; + int read; + if (sscanf(bufptr, "%i%n", &v, &read) != 1) { + report_error(label); + } else { + bufptr += read; + } + return v; + } + + intptr_t parse_intptr_t(const char* label) { + if (had_error()) { + return 0; + } + + intptr_t v = 0; + int read; + if (sscanf(bufptr, INTPTR_FORMAT "%n", &v, &read) != 1) { + report_error(label); + } else { + bufptr += read; + } + return v; + } + + void skip_ws() { + // Skip any leading whitespace + while (*bufptr == ' ' || *bufptr == '\t') { + bufptr++; + } + } + + + char* scan_and_terminate(char delim) { + char* str = bufptr; + while (*bufptr != delim && *bufptr != '\0') { + bufptr++; + } + if (*bufptr != '\0') { + *bufptr++ = '\0'; + } + if (bufptr == str) { + // nothing here + return NULL; + } + return str; + } + + char* parse_string() { + if (had_error()) return NULL; + + skip_ws(); + return scan_and_terminate(' '); + } + + char* parse_quoted_string() { + if (had_error()) return NULL; + + skip_ws(); + + if (*bufptr == '"') { + bufptr++; + return scan_and_terminate('"'); + } else { + return scan_and_terminate(' '); + } + } + + const char* parse_escaped_string() { + char* result = parse_quoted_string(); + if (result != NULL) { + unescape_string(result); + } + return result; + } + + // Look for the tag 'tag' followed by an + bool parse_tag_and_count(const char* tag, int& length) { + const char* t = parse_string(); + if (t == NULL) { + return false; + } + + if (strcmp(tag, t) != 0) { + report_error(tag); + return false; + } + length = parse_int("parse_tag_and_count"); + return !had_error(); + } + + // Parse a sequence of raw data encoded as bytes and return the + // resulting data. + char* parse_data(const char* tag, int& length) { + if (!parse_tag_and_count(tag, length)) { + return NULL; + } + + char * result = NEW_RESOURCE_ARRAY(char, length); + for (int i = 0; i < length; i++) { + int val = parse_int("data"); + result[i] = val; + } + return result; + } + + // Parse a standard chunk of data emitted as: + // 'tag' # # ... + // Where each # is an intptr_t item + intptr_t* parse_intptr_data(const char* tag, int& length) { + if (!parse_tag_and_count(tag, length)) { + return NULL; + } + + intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length); + for (int i = 0; i < length; i++) { + skip_ws(); + intptr_t val = parse_intptr_t("data"); + result[i] = val; + } + return result; + } + + // Parse a possibly quoted version of a symbol into a symbolOop + Symbol* parse_symbol(TRAPS) { + const char* str = parse_escaped_string(); + if (str != NULL) { + Symbol* sym = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL); + return sym; + } + return NULL; + } + + // Parse a valid klass name and look it up + Klass* parse_klass(TRAPS) { + const char* str = parse_escaped_string(); + Symbol* klass_name = SymbolTable::lookup(str, (int)strlen(str), CHECK_NULL); + if (klass_name != NULL) { + Klass* k = SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, THREAD); + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + report_error(str); + return NULL; + } + return k; + } + return NULL; + } + + // Lookup a klass + Klass* resolve_klass(const char* klass, TRAPS) { + Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL); + return SystemDictionary::resolve_or_fail(klass_name, loader, protection_domain, true, CHECK_NULL); + } + + // Parse the standard tuple of + Method* parse_method(TRAPS) { + InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK_NULL); + Symbol* method_name = parse_symbol(CHECK_NULL); + Symbol* method_signature = parse_symbol(CHECK_NULL); + Method* m = k->find_method(method_name, method_signature); + if (m == NULL) { + report_error("can't find method"); + } + return m; + } + + // Process each line of the replay file executing each command until + // the file ends. + void process(TRAPS) { + line_no = 1; + int pos = 0; + int c = getc(stream); + while(c != EOF) { + if (pos + 1 >= buffer_length) { + int newl = buffer_length * 2; + char* newb = NEW_RESOURCE_ARRAY(char, newl); + memcpy(newb, buffer, pos); + buffer = newb; + buffer_length = newl; + } + if (c == '\n') { + // null terminate it, reset the pointer and process the line + buffer[pos] = '\0'; + buffer_end = pos++; + bufptr = buffer; + process_command(CHECK); + if (had_error()) { + tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message); + tty->print_cr("%s", buffer); + assert(false, "error"); + return; + } + pos = 0; + buffer_end = 0; + line_no++; + } else if (c == '\r') { + // skip LF + } else { + buffer[pos++] = c; + } + c = getc(stream); + } + } + + void process_command(TRAPS) { + char* cmd = parse_string(); + if (cmd == NULL) { + return; + } + if (strcmp("#", cmd) == 0) { + // ignore + } else if (strcmp("compile", cmd) == 0) { + process_compile(CHECK); + } else if (strcmp("ciMethod", cmd) == 0) { + process_ciMethod(CHECK); + } else if (strcmp("ciMethodData", cmd) == 0) { + process_ciMethodData(CHECK); + } else if (strcmp("staticfield", cmd) == 0) { + process_staticfield(CHECK); + } else if (strcmp("ciInstanceKlass", cmd) == 0) { + process_ciInstanceKlass(CHECK); + } else if (strcmp("instanceKlass", cmd) == 0) { + process_instanceKlass(CHECK); +#if INCLUDE_JVMTI + } else if (strcmp("JvmtiExport", cmd) == 0) { + process_JvmtiExport(CHECK); +#endif // INCLUDE_JVMTI + } else { + report_error("unknown command"); + } + } + + // compile + void process_compile(TRAPS) { + // methodHandle method; + Method* method = parse_method(CHECK); + int entry_bci = parse_int("entry_bci"); + Klass* k = method->method_holder(); + ((InstanceKlass*)k)->initialize(THREAD); + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + if (ReplayIgnoreInitErrors) { + CLEAR_PENDING_EXCEPTION; + ((InstanceKlass*)k)->set_init_state(InstanceKlass::fully_initialized); + } else { + return; + } + } + // Make sure the existence of a prior compile doesn't stop this one + nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, CompLevel_full_optimization, true) : method->code(); + if (nm != NULL) { + nm->make_not_entrant(); + } + replay_state = this; + CompileBroker::compile_method(method, entry_bci, CompLevel_full_optimization, + methodHandle(), 0, "replay", THREAD); + replay_state = NULL; + reset(); + } + + // ciMethod + // + // + void process_ciMethod(TRAPS) { + Method* method = parse_method(CHECK); + ciMethodRecord* rec = new_ciMethod(method); + rec->invocation_counter = parse_int("invocation_counter"); + rec->backedge_counter = parse_int("backedge_counter"); + rec->interpreter_invocation_count = parse_int("interpreter_invocation_count"); + rec->interpreter_throwout_count = parse_int("interpreter_throwout_count"); + rec->instructions_size = parse_int("instructions_size"); + } + + // ciMethodData orig # # ... data # # ... oops + void process_ciMethodData(TRAPS) { + Method* method = parse_method(CHECK); + /* jsut copied from Method, to build interpret data*/ + if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) { + return; + } + // methodOopDesc::build_interpreter_method_data(method, CHECK); + { + // Grab a lock here to prevent multiple + // MethodData*s from being created. + MutexLocker ml(MethodData_lock, THREAD); + if (method->method_data() == NULL) { + ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); + MethodData* method_data = MethodData::allocate(loader_data, method, CHECK); + method->set_method_data(method_data); + } + } + + // collect and record all the needed information for later + ciMethodDataRecord* rec = new_ciMethodData(method); + rec->state = parse_int("state"); + rec->current_mileage = parse_int("current_mileage"); + + rec->orig_data = parse_data("orig", rec->orig_data_length); + if (rec->orig_data == NULL) { + return; + } + rec->data = parse_intptr_data("data", rec->data_length); + if (rec->data == NULL) { + return; + } + if (!parse_tag_and_count("oops", rec->oops_length)) { + return; + } + rec->oops_handles = NEW_RESOURCE_ARRAY(jobject, rec->oops_length); + rec->oops_offsets = NEW_RESOURCE_ARRAY(int, rec->oops_length); + for (int i = 0; i < rec->oops_length; i++) { + int offset = parse_int("offset"); + if (had_error()) { + return; + } + Klass* k = parse_klass(CHECK); + rec->oops_offsets[i] = offset; + rec->oops_handles[i] = (jobject)(new KlassHandle(THREAD, k)); + } + } + + // instanceKlass + // + // Loads and initializes the klass 'name'. This can be used to + // create particular class loading environments + void process_instanceKlass(TRAPS) { + // just load the referenced class + Klass* k = parse_klass(CHECK); + } + + // ciInstanceKlass tag # # # ... + // + // Load the klass 'name' and link or initialize it. Verify that the + // constant pool is the same length as 'length' and make sure the + // constant pool tags are in the same state. + void process_ciInstanceKlass(TRAPS) { + InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK); + int is_linked = parse_int("is_linked"); + int is_initialized = parse_int("is_initialized"); + int length = parse_int("length"); + if (is_initialized) { + k->initialize(THREAD); + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + if (ReplayIgnoreInitErrors) { + CLEAR_PENDING_EXCEPTION; + k->set_init_state(InstanceKlass::fully_initialized); + } else { + return; + } + } + } else if (is_linked) { + k->link_class(CHECK); + } + ConstantPool* cp = k->constants(); + if (length != cp->length()) { + report_error("constant pool length mismatch: wrong class files?"); + return; + } + + int parsed_two_word = 0; + for (int i = 1; i < length; i++) { + int tag = parse_int("tag"); + if (had_error()) { + return; + } + switch (cp->tag_at(i).value()) { + case JVM_CONSTANT_UnresolvedClass: { + if (tag == JVM_CONSTANT_Class) { + tty->print_cr("Resolving klass %s at %d", cp->unresolved_klass_at(i)->as_utf8(), i); + Klass* k = cp->klass_at(i, CHECK); + } + break; + } + case JVM_CONSTANT_Long: + case JVM_CONSTANT_Double: + parsed_two_word = i + 1; + + case JVM_CONSTANT_ClassIndex: + case JVM_CONSTANT_StringIndex: + case JVM_CONSTANT_String: + case JVM_CONSTANT_UnresolvedClassInError: + case JVM_CONSTANT_Fieldref: + case JVM_CONSTANT_Methodref: + case JVM_CONSTANT_InterfaceMethodref: + case JVM_CONSTANT_NameAndType: + case JVM_CONSTANT_Utf8: + case JVM_CONSTANT_Integer: + case JVM_CONSTANT_Float: + if (tag != cp->tag_at(i).value()) { + report_error("tag mismatch: wrong class files?"); + return; + } + break; + + case JVM_CONSTANT_Class: + if (tag == JVM_CONSTANT_Class) { + } else if (tag == JVM_CONSTANT_UnresolvedClass) { + tty->print_cr("Warning: entry was unresolved in the replay data"); + } else { + report_error("Unexpected tag"); + return; + } + break; + + case 0: + if (parsed_two_word == i) continue; + + default: + ShouldNotReachHere(); + break; + } + + } + } + + // Initialize a class and fill in the value for a static field. + // This is useful when the compile was dependent on the value of + // static fields but it's impossible to properly rerun the static + // initiailizer. + void process_staticfield(TRAPS) { + InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK); + + if (ReplaySuppressInitializers == 0 || + ReplaySuppressInitializers == 2 && k->class_loader() == NULL) { + return; + } + + assert(k->is_initialized(), "must be"); + + const char* field_name = parse_escaped_string();; + const char* field_signature = parse_string(); + fieldDescriptor fd; + Symbol* name = SymbolTable::lookup(field_name, (int)strlen(field_name), CHECK); + Symbol* sig = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK); + if (!k->find_local_field(name, sig, &fd) || + !fd.is_static() || + fd.has_initial_value()) { + report_error(field_name); + return; + } + + oop java_mirror = k->java_mirror(); + if (field_signature[0] == '[') { + int length = parse_int("array length"); + oop value = NULL; + + if (field_signature[1] == '[') { + // multi dimensional array + ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK); + int rank = 0; + while (field_signature[rank] == '[') { + rank++; + } + int* dims = NEW_RESOURCE_ARRAY(int, rank); + dims[0] = length; + for (int i = 1; i < rank; i++) { + dims[i] = 1; // These aren't relevant to the compiler + } + value = kelem->multi_allocate(rank, dims, CHECK); + } else { + if (strcmp(field_signature, "[B") == 0) { + value = oopFactory::new_byteArray(length, CHECK); + } else if (strcmp(field_signature, "[Z") == 0) { + value = oopFactory::new_boolArray(length, CHECK); + } else if (strcmp(field_signature, "[C") == 0) { + value = oopFactory::new_charArray(length, CHECK); + } else if (strcmp(field_signature, "[S") == 0) { + value = oopFactory::new_shortArray(length, CHECK); + } else if (strcmp(field_signature, "[F") == 0) { + value = oopFactory::new_singleArray(length, CHECK); + } else if (strcmp(field_signature, "[D") == 0) { + value = oopFactory::new_doubleArray(length, CHECK); + } else if (strcmp(field_signature, "[I") == 0) { + value = oopFactory::new_intArray(length, CHECK); + } else if (strcmp(field_signature, "[J") == 0) { + value = oopFactory::new_longArray(length, CHECK); + } else if (field_signature[0] == '[' && field_signature[1] == 'L') { + KlassHandle kelem = resolve_klass(field_signature + 1, CHECK); + value = oopFactory::new_objArray(kelem(), length, CHECK); + } else { + report_error("unhandled array staticfield"); + } + } + java_mirror->obj_field_put(fd.offset(), value); + } else { + const char* string_value = parse_escaped_string(); + if (strcmp(field_signature, "I") == 0) { + int value = atoi(string_value); + java_mirror->int_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "B") == 0) { + int value = atoi(string_value); + java_mirror->byte_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "C") == 0) { + int value = atoi(string_value); + java_mirror->char_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "S") == 0) { + int value = atoi(string_value); + java_mirror->short_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "Z") == 0) { + int value = atol(string_value); + java_mirror->bool_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "J") == 0) { + jlong value; + if (sscanf(string_value, INT64_FORMAT, &value) != 1) { + fprintf(stderr, "Error parsing long: %s\n", string_value); + return; + } + java_mirror->long_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "F") == 0) { + float value = atof(string_value); + java_mirror->float_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "D") == 0) { + double value = atof(string_value); + java_mirror->double_field_put(fd.offset(), value); + } else if (strcmp(field_signature, "Ljava/lang/String;") == 0) { + Handle value = java_lang_String::create_from_str(string_value, CHECK); + java_mirror->obj_field_put(fd.offset(), value()); + } else if (field_signature[0] == 'L') { + Symbol* klass_name = SymbolTable::lookup(field_signature, (int)strlen(field_signature), CHECK); + KlassHandle kelem = resolve_klass(field_signature, CHECK); + oop value = ((InstanceKlass*)kelem())->allocate_instance(CHECK); + java_mirror->obj_field_put(fd.offset(), value); + } else { + report_error("unhandled staticfield"); + } + } + } + +#if INCLUDE_JVMTI + void process_JvmtiExport(TRAPS) { + const char* field = parse_string(); + bool value = parse_int("JvmtiExport flag") != 0; + if (strcmp(field, "can_access_local_variables") == 0) { + JvmtiExport::set_can_access_local_variables(value); + } else if (strcmp(field, "can_hotswap_or_post_breakpoint") == 0) { + JvmtiExport::set_can_hotswap_or_post_breakpoint(value); + } else if (strcmp(field, "can_post_on_exceptions") == 0) { + JvmtiExport::set_can_post_on_exceptions(value); + } else { + report_error("Unrecognized JvmtiExport directive"); + } + } +#endif // INCLUDE_JVMTI + + // Create and initialize a record for a ciMethod + ciMethodRecord* new_ciMethod(Method* method) { + ciMethodRecord* rec = NEW_RESOURCE_OBJ(ciMethodRecord); + rec->klass = method->method_holder()->name()->as_utf8(); + rec->method = method->name()->as_utf8(); + rec->signature = method->signature()->as_utf8(); + ci_method_records.append(rec); + return rec; + } + + // Lookup data for a ciMethod + ciMethodRecord* find_ciMethodRecord(Method* method) { + const char* klass_name = method->method_holder()->name()->as_utf8(); + const char* method_name = method->name()->as_utf8(); + const char* signature = method->signature()->as_utf8(); + for (int i = 0; i < ci_method_records.length(); i++) { + ciMethodRecord* rec = ci_method_records.at(i); + if (strcmp(rec->klass, klass_name) == 0 && + strcmp(rec->method, method_name) == 0 && + strcmp(rec->signature, signature) == 0) { + return rec; + } + } + return NULL; + } + + // Create and initialize a record for a ciMethodData + ciMethodDataRecord* new_ciMethodData(Method* method) { + ciMethodDataRecord* rec = NEW_RESOURCE_OBJ(ciMethodDataRecord); + rec->klass = method->method_holder()->name()->as_utf8(); + rec->method = method->name()->as_utf8(); + rec->signature = method->signature()->as_utf8(); + ci_method_data_records.append(rec); + return rec; + } + + // Lookup data for a ciMethodData + ciMethodDataRecord* find_ciMethodDataRecord(Method* method) { + const char* klass_name = method->method_holder()->name()->as_utf8(); + const char* method_name = method->name()->as_utf8(); + const char* signature = method->signature()->as_utf8(); + for (int i = 0; i < ci_method_data_records.length(); i++) { + ciMethodDataRecord* rec = ci_method_data_records.at(i); + if (strcmp(rec->klass, klass_name) == 0 && + strcmp(rec->method, method_name) == 0 && + strcmp(rec->signature, signature) == 0) { + return rec; + } + } + return NULL; + } + + const char* error_message() { + return _error_message; + } + + void reset() { + _error_message = NULL; + ci_method_records.clear(); + ci_method_data_records.clear(); + } + + // Take an ascii string contain \u#### escapes and convert it to utf8 + // in place. + static void unescape_string(char* value) { + char* from = value; + char* to = value; + while (*from != '\0') { + if (*from != '\\') { + *from++ = *to++; + } else { + switch (from[1]) { + case 'u': { + from += 2; + jchar value=0; + for (int i=0; i<4; i++) { + char c = *from++; + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + value = (value << 4) + c - '0'; + break; + case 'a': case 'b': case 'c': + case 'd': case 'e': case 'f': + value = (value << 4) + 10 + c - 'a'; + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + value = (value << 4) + 10 + c - 'A'; + break; + default: + ShouldNotReachHere(); + } + } + UNICODE::convert_to_utf8(&value, 1, to); + to++; + break; + } + case 't': *to++ = '\t'; from += 2; break; + case 'n': *to++ = '\n'; from += 2; break; + case 'r': *to++ = '\r'; from += 2; break; + case 'f': *to++ = '\f'; from += 2; break; + default: + ShouldNotReachHere(); + } + } + } + *from = *to; + } +}; + +void ciReplay::replay(TRAPS) { + int exit_code = replay_impl(THREAD); + + Threads::destroy_vm(); + + vm_exit(exit_code); +} + +int ciReplay::replay_impl(TRAPS) { + HandleMark hm; + ResourceMark rm; + // Make sure we don't run with background compilation + BackgroundCompilation = false; + + if (ReplaySuppressInitializers > 2) { + // ReplaySuppressInitializers > 2 means that we want to allow + // normal VM bootstrap but once we get into the replay itself + // don't allow any intializers to be run. + ReplaySuppressInitializers = 1; + } + + // Load and parse the replay data + CompileReplay rp(ReplayDataFile, THREAD); + int exit_code = 0; + if (rp.can_replay()) { + rp.process(THREAD); + } else { + exit_code = 1; + return exit_code; + } + + if (HAS_PENDING_EXCEPTION) { + oop throwable = PENDING_EXCEPTION; + CLEAR_PENDING_EXCEPTION; + java_lang_Throwable::print(throwable, tty); + tty->cr(); + java_lang_Throwable::print_stack_trace(throwable, tty); + tty->cr(); + exit_code = 2; + } + + if (rp.had_error()) { + tty->print_cr("Failed on %s", rp.error_message()); + exit_code = 1; + } + return exit_code; +} + + +void ciReplay::initialize(ciMethodData* m) { + if (replay_state == NULL) { + return; + } + + ASSERT_IN_VM; + ResourceMark rm; + + Method* method = m->get_MethodData()->method(); + ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method); + if (rec == NULL) { + // This indicates some mismatch with the original environment and + // the replay environment though it's not always enough to + // interfere with reproducing a bug + tty->print_cr("Warning: requesting ciMethodData record for method with no data: "); + method->print_name(tty); + tty->cr(); + } else { + m->_state = rec->state; + m->_current_mileage = rec->current_mileage; + if (rec->data_length != 0) { + assert(m->_data_size == rec->data_length * (int)sizeof(rec->data[0]), "must agree"); + + // Write the correct ciObjects back into the profile data + ciEnv* env = ciEnv::current(); + for (int i = 0; i < rec->oops_length; i++) { + KlassHandle *h = (KlassHandle *)rec->oops_handles[i]; + *(ciMetadata**)(rec->data + rec->oops_offsets[i]) = + env->get_metadata((*h)()); + } + // Copy the updated profile data into place as intptr_ts +#ifdef _LP64 + Copy::conjoint_jlongs_atomic((jlong *)rec->data, (jlong *)m->_data, rec->data_length); +#else + Copy::conjoint_jints_atomic((jint *)rec->data, (jint *)m->_data, rec->data_length); +#endif + } + + // copy in the original header + Copy::conjoint_jbytes(rec->orig_data, (char*)&m->_orig, rec->orig_data_length); + } +} + + +bool ciReplay::should_not_inline(ciMethod* method) { + if (replay_state == NULL) { + return false; + } + + VM_ENTRY_MARK; + // ciMethod without a record shouldn't be inlined. + return replay_state->find_ciMethodRecord(method->get_Method()) == NULL; +} + + +void ciReplay::initialize(ciMethod* m) { + if (replay_state == NULL) { + return; + } + + ASSERT_IN_VM; + ResourceMark rm; + + Method* method = m->get_Method(); + ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); + if (rec == NULL) { + // This indicates some mismatch with the original environment and + // the replay environment though it's not always enough to + // interfere with reproducing a bug + tty->print_cr("Warning: requesting ciMethod record for method with no data: "); + method->print_name(tty); + tty->cr(); + } else { + // m->_instructions_size = rec->instructions_size; + m->_instructions_size = -1; + m->_interpreter_invocation_count = rec->interpreter_invocation_count; + m->_interpreter_throwout_count = rec->interpreter_throwout_count; + method->invocation_counter()->_counter = rec->invocation_counter; + method->backedge_counter()->_counter = rec->backedge_counter; + } +} + +bool ciReplay::is_loaded(Method* method) { + if (replay_state == NULL) { + return true; + } + + ASSERT_IN_VM; + ResourceMark rm; + + ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); + return rec != NULL; +} +#endif diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciReplay.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/ci/ciReplay.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_CI_CIREPLAY_HPP +#define SHARE_VM_CI_CIREPLAY_HPP + +#include "ci/ciMethod.hpp" + +// ciReplay + +class ciReplay { + CI_PACKAGE_ACCESS + +#ifdef ASSERT + private: + static int replay_impl(TRAPS); + + public: + static void replay(TRAPS); + + // These are used by the CI to fill in the cached data from the + // replay file when replaying compiles. + static void initialize(ciMethodData* method); + static void initialize(ciMethod* method); + + static bool is_loaded(Method* method); + static bool is_loaded(Klass* klass); + + static bool should_not_inline(ciMethod* method); + +#endif +}; + +#endif // SHARE_VM_CI_CIREPLAY_HPP diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciSymbol.cpp --- a/src/share/vm/ci/ciSymbol.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciSymbol.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -63,6 +63,11 @@ return s->as_utf8(); } +// The text of the symbol as a null-terminated C string. +const char* ciSymbol::as_quoted_ascii() { + GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_quoted_ascii();) +} + // ------------------------------------------------------------------ // ciSymbol::base const jbyte* ciSymbol::base() { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciSymbol.hpp --- a/src/share/vm/ci/ciSymbol.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciSymbol.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -73,6 +73,9 @@ const char* as_utf8(); int utf8_length(); + // The text of the symbol as ascii with all non-printable characters quoted as \u#### + const char* as_quoted_ascii(); + // Return the i-th utf8 byte, where i < utf8_length int byte_at(int i); diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/ci/ciUtilities.hpp --- a/src/share/vm/ci/ciUtilities.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/ci/ciUtilities.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,6 +80,9 @@ #define GUARDED_VM_ENTRY(action) \ {if (IS_IN_VM) { action } else { VM_ENTRY_MARK; { action }}} +#define GUARDED_VM_QUICK_ENTRY(action) \ + {if (IS_IN_VM) { action } else { VM_QUICK_ENTRY_MARK; { action }}} + // Redefine this later. #define KILL_COMPILE_ON_FATAL_(result) \ THREAD); \ diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/classfile/classLoader.cpp --- a/src/share/vm/classfile/classLoader.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/classfile/classLoader.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -605,8 +605,10 @@ // Load zip library char path[JVM_MAXPATHLEN]; char ebuf[1024]; - os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip"); - void* handle = os::dll_load(path, ebuf, sizeof ebuf); + void* handle = NULL; + if (os::dll_build_name(path, sizeof(path), Arguments::get_dll_dir(), "zip")) { + handle = os::dll_load(path, ebuf, sizeof ebuf); + } if (handle == NULL) { vm_exit_during_initialization("Unable to load ZIP library", path); } diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/classfile/javaClasses.cpp --- a/src/share/vm/classfile/javaClasses.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/classfile/javaClasses.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -348,6 +348,22 @@ return java_lang_String::to_hash(value->char_at_addr(offset), length); } +char* java_lang_String::as_quoted_ascii(oop java_string) { + typeArrayOop value = java_lang_String::value(java_string); + int offset = java_lang_String::offset(java_string); + int length = java_lang_String::length(java_string); + + jchar* base = (length == 0) ? NULL : value->char_at_addr(offset); + if (base == NULL) return NULL; + + int result_length = UNICODE::quoted_ascii_length(base, length) + 1; + char* result = NEW_RESOURCE_ARRAY(char, result_length); + UNICODE::as_quoted_ascii(base, length, result, result_length); + assert(result_length >= length + 1, "must not be shorter"); + assert(result_length == (int)strlen(result) + 1, "must match"); + return result; +} + unsigned int java_lang_String::hash_string(oop java_string) { int length = java_lang_String::length(java_string); // Zero length string doesn't hash necessarily hash to zero. diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/classfile/javaClasses.hpp --- a/src/share/vm/classfile/javaClasses.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/classfile/javaClasses.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -154,6 +154,8 @@ static char* as_utf8_string(oop java_string, int start, int len); static char* as_platform_dependent_str(Handle java_string, TRAPS); static jchar* as_unicode_string(oop java_string, int& length); + // produce an ascii string with all other values quoted using \u#### + static char* as_quoted_ascii(oop java_string); // Compute the hash value for a java.lang.String object which would // contain the characters passed in. diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/code/dependencies.cpp --- a/src/share/vm/code/dependencies.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/code/dependencies.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -569,6 +569,7 @@ void Dependencies::DepStream::log_dependency(Klass* witness) { if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime + ResourceMark rm; int nargs = argument_count(); DepArgument args[max_arg_count]; for (int j = 0; j < nargs; j++) { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/interpreter/interpreterRuntime.cpp --- a/src/share/vm/interpreter/interpreterRuntime.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -733,12 +733,7 @@ get_index_u2_cpcache(thread, bytecode), bytecode, CHECK); } // end JvmtiHideSingleStepping - cache_entry(thread)->set_method_handle( - pool, - info.resolved_method(), - info.resolved_appendix(), - info.resolved_method_type(), - pool->resolved_references()); + cache_entry(thread)->set_method_handle(pool, info); } IRT_END @@ -762,12 +757,7 @@ } // end JvmtiHideSingleStepping ConstantPoolCacheEntry* cp_cache_entry = pool->invokedynamic_cp_cache_entry_at(index); - cp_cache_entry->set_dynamic_call( - pool, - info.resolved_method(), - info.resolved_appendix(), - info.resolved_method_type(), - pool->resolved_references()); + cp_cache_entry->set_dynamic_call(pool, info); } IRT_END diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/interpreter/invocationCounter.hpp --- a/src/share/vm/interpreter/invocationCounter.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/interpreter/invocationCounter.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ class InvocationCounter VALUE_OBJ_CLASS_SPEC { friend class VMStructs; + friend class ciReplay; private: // bit no: |31 3| 2 | 1 0 | unsigned int _counter; // format: [count|carry|state] @@ -85,6 +86,8 @@ void set_carry(); // set the sticky carry bit void set_carry_flag() { _counter |= carry_mask; } + int raw_counter() { return _counter; } + // Accessors State state() const { return (State)(_counter & state_mask); } bool carry() const { return (_counter & carry_mask) != 0; } diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/memory/binaryTreeDictionary.cpp --- a/src/share/vm/memory/binaryTreeDictionary.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/memory/binaryTreeDictionary.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -239,7 +239,7 @@ } else { if (nextTC == NULL) { // Removing chunk at tail of list - link_tail(prevFC); + this->link_tail(prevFC); } // Chunk is interior to the list prevFC->link_after(nextTC); @@ -296,7 +296,7 @@ Chunk_t* fc = tail(); fc->link_after(chunk); - link_tail(chunk); + this->link_tail(chunk); assert(!tail() || size() == tail()->size(), "Wrong sized chunk in list"); FreeList_t::increment_count(); @@ -323,7 +323,7 @@ chunk->link_after(fc); } else { assert(tail() == NULL, "List is inconsistent"); - link_tail(chunk); + this->link_tail(chunk); } head()->link_after(chunk); assert(!head() || size() == head()->size(), "Wrong sized chunk in list"); @@ -940,7 +940,7 @@ void do_tree(TreeList* tl) { if (tl != NULL) { do_tree(tl->left()); - do_list(tl); + this->do_list(tl); do_tree(tl->right()); } } @@ -952,7 +952,7 @@ void do_tree(TreeList* tl) { if (tl != NULL) { do_tree(tl->right()); - do_list(tl); + this->do_list(tl); do_tree(tl->left()); } } @@ -1022,7 +1022,7 @@ bool do_tree(TreeList* tl) { if (tl != NULL) { if (do_tree(tl->right())) return true; - if (do_list(tl)) return true; + if (this->do_list(tl)) return true; if (do_tree(tl->left())) return true; } return false; diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/memory/metaspace.cpp --- a/src/share/vm/memory/metaspace.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/memory/metaspace.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -42,6 +42,10 @@ typedef BinaryTreeDictionary BlockTreeDictionary; typedef BinaryTreeDictionary ChunkTreeDictionary; +// Define this macro to enable slow integrity checking of +// the free chunk lists +const bool metaspace_slow_verify = false; + // Parameters for stress mode testing const uint metadata_deallocate_a_lot_block = 10; @@ -161,7 +165,17 @@ size_t sum_free_chunks_count(); void locked_verify_free_chunks_total(); + void slow_locked_verify_free_chunks_total() { + if (metaspace_slow_verify) { + locked_verify_free_chunks_total(); + } + } void locked_verify_free_chunks_count(); + void slow_locked_verify_free_chunks_count() { + if (metaspace_slow_verify) { + locked_verify_free_chunks_count(); + } + } void verify_free_chunks_count(); public: @@ -201,7 +215,17 @@ // Debug support void verify(); + void slow_verify() { + if (metaspace_slow_verify) { + verify(); + } + } void locked_verify(); + void slow_locked_verify() { + if (metaspace_slow_verify) { + locked_verify(); + } + } void verify_free_chunks_total(); void locked_print_free_chunks(outputStream* st); @@ -1507,7 +1531,7 @@ if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) { MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); - locked_verify_free_chunks_total(); + slow_locked_verify_free_chunks_total(); } #endif return _free_chunks_total; @@ -1524,10 +1548,10 @@ Mutex::_no_safepoint_check_flag); // This lock is only needed in debug because the verification // of the _free_chunks_totals walks the list of free chunks - locked_verify_free_chunks_count(); + slow_locked_verify_free_chunks_count(); } #endif - return _free_chunks_count; + return _free_chunks_count; } void ChunkManager::locked_verify_free_chunks_total() { @@ -1561,14 +1585,9 @@ } void ChunkManager::verify() { -#ifdef ASSERT - if (!UseConcMarkSweepGC) { - MutexLockerEx cl(SpaceManager::expand_lock(), - Mutex::_no_safepoint_check_flag); - locked_verify_free_chunks_total(); - locked_verify_free_chunks_count(); - } -#endif + MutexLockerEx cl(SpaceManager::expand_lock(), + Mutex::_no_safepoint_check_flag); + locked_verify(); } void ChunkManager::locked_verify() { @@ -1642,7 +1661,7 @@ free_list->set_head(chunk); // chunk is being returned to the chunk free list inc_free_chunks_total(chunk->capacity_word_size()); - locked_verify(); + slow_locked_verify(); } void ChunkManager::chunk_freelist_deallocate(Metachunk* chunk) { @@ -1650,8 +1669,8 @@ // manangement code for a Metaspace and does not hold the // lock. assert(chunk != NULL, "Deallocating NULL"); - // MutexLockerEx fcl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); - locked_verify(); + assert_lock_strong(SpaceManager::expand_lock()); + slow_locked_verify(); if (TraceMetadataChunkAllocation) { tty->print_cr("ChunkManager::chunk_freelist_deallocate: chunk " PTR_FORMAT " size " SIZE_FORMAT, @@ -1663,7 +1682,7 @@ Metachunk* ChunkManager::free_chunks_get(size_t word_size) { assert_lock_strong(SpaceManager::expand_lock()); - locked_verify(); + slow_locked_verify(); Metachunk* chunk = NULL; if (!SpaceManager::is_humongous(word_size)) { @@ -1708,13 +1727,13 @@ #endif } } - locked_verify(); + slow_locked_verify(); return chunk; } Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) { assert_lock_strong(SpaceManager::expand_lock()); - locked_verify(); + slow_locked_verify(); // Take from the beginning of the list Metachunk* chunk = free_chunks_get(word_size); @@ -1959,7 +1978,7 @@ ChunkManager* chunk_manager = vs_list()->chunk_manager(); - chunk_manager->locked_verify(); + chunk_manager->slow_locked_verify(); if (TraceMetadataChunkAllocation && Verbose) { gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this); @@ -2015,7 +2034,7 @@ humongous_chunks = next_humongous_chunks; } set_chunks_in_use(HumongousIndex, NULL); - chunk_manager->locked_verify(); + chunk_manager->slow_locked_verify(); } void SpaceManager::deallocate(MetaWord* p, size_t word_size) { @@ -2330,8 +2349,7 @@ ChunkManager* chunk = (mdtype == Metaspace::ClassType) ? Metaspace::class_space_list()->chunk_manager() : Metaspace::space_list()->chunk_manager(); - - chunk->verify_free_chunks_total(); + chunk->slow_verify(); return chunk->free_chunks_total(); } @@ -2435,6 +2453,11 @@ print_waste(out); } +void MetaspaceAux::verify_free_chunks() { + Metaspace::space_list()->chunk_manager()->verify(); + Metaspace::class_space_list()->chunk_manager()->verify(); +} + // Metaspace methods size_t Metaspace::_first_chunk_word_size = 0; diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/memory/metaspace.hpp --- a/src/share/vm/memory/metaspace.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/memory/metaspace.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -189,6 +189,7 @@ static void print_waste(outputStream* out); static void dump(outputStream* out); + static void verify_free_chunks(); }; // Metaspace are deallocated when their class loader are GC'ed. diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/memory/universe.cpp --- a/src/share/vm/memory/universe.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/memory/universe.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1304,6 +1304,8 @@ if (!silent) gclog_or_tty->print("cldg "); ClassLoaderDataGraph::verify(); #endif + if (!silent) gclog_or_tty->print("metaspace chunks "); + MetaspaceAux::verify_free_chunks(); if (!silent) gclog_or_tty->print("hand "); JNIHandles::verify(); if (!silent) gclog_or_tty->print("C-heap "); diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/oops/cpCache.cpp --- a/src/share/vm/oops/cpCache.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/oops/cpCache.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -243,25 +243,17 @@ } -void ConstantPoolCacheEntry::set_method_handle(constantPoolHandle cpool, - methodHandle adapter, - Handle appendix, Handle method_type, - objArrayHandle resolved_references) { - set_method_handle_common(cpool, Bytecodes::_invokehandle, adapter, appendix, method_type, resolved_references); +void ConstantPoolCacheEntry::set_method_handle(constantPoolHandle cpool, const CallInfo &call_info) { + set_method_handle_common(cpool, Bytecodes::_invokehandle, call_info); } -void ConstantPoolCacheEntry::set_dynamic_call(constantPoolHandle cpool, - methodHandle adapter, - Handle appendix, Handle method_type, - objArrayHandle resolved_references) { - set_method_handle_common(cpool, Bytecodes::_invokedynamic, adapter, appendix, method_type, resolved_references); +void ConstantPoolCacheEntry::set_dynamic_call(constantPoolHandle cpool, const CallInfo &call_info) { + set_method_handle_common(cpool, Bytecodes::_invokedynamic, call_info); } void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool, Bytecodes::Code invoke_code, - methodHandle adapter, - Handle appendix, Handle method_type, - objArrayHandle resolved_references) { + const CallInfo &call_info) { // NOTE: This CPCE can be the subject of data races. // There are three words to update: flags, refs[f2], f1 (in that order). // Writers must store all other values before f1. @@ -276,6 +268,9 @@ return; } + const methodHandle adapter = call_info.resolved_method(); + const Handle appendix = call_info.resolved_appendix(); + const Handle method_type = call_info.resolved_method_type(); const bool has_appendix = appendix.not_null(); const bool has_method_type = method_type.not_null(); @@ -315,6 +310,7 @@ // This allows us to create fewer method oops, while keeping type safety. // + objArrayHandle resolved_references = cpool->resolved_references(); // Store appendix, if any. if (has_appendix) { const int appendix_index = f2_as_index() + _indy_resolved_references_appendix_offset; diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/oops/cpCache.hpp --- a/src/share/vm/oops/cpCache.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/oops/cpCache.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -117,6 +117,8 @@ // The fields are volatile so that they are stored in the order written in the // source code. The _indices field with the bytecode must be written last. +class CallInfo; + class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { friend class VMStructs; friend class constantPoolCacheKlass; @@ -223,18 +225,12 @@ void set_method_handle( constantPoolHandle cpool, // holding constant pool (required for locking) - methodHandle method, // adapter for invokeExact, etc. - Handle appendix, // stored in refs[f2+0]; could be a java.lang.invoke.MethodType - Handle method_type, // stored in refs[f2+1]; is a java.lang.invoke.MethodType - objArrayHandle resolved_references + const CallInfo &call_info // Call link information ); void set_dynamic_call( constantPoolHandle cpool, // holding constant pool (required for locking) - methodHandle method, // adapter for this call site - Handle appendix, // stored in refs[f2+0]; could be a java.lang.invoke.CallSite - Handle method_type, // stored in refs[f2+1]; is a java.lang.invoke.MethodType - objArrayHandle resolved_references + const CallInfo &call_info // Call link information ); // Common code for invokedynamic and MH invocations. @@ -255,10 +251,7 @@ void set_method_handle_common( constantPoolHandle cpool, // holding constant pool (required for locking) Bytecodes::Code invoke_code, // _invokehandle or _invokedynamic - methodHandle adapter, // invoker method (f1) - Handle appendix, // appendix such as CallSite, MethodType, etc. (refs[f2+0]) - Handle method_type, // MethodType (refs[f2+1]) - objArrayHandle resolved_references + const CallInfo &call_info // Call link information ); // invokedynamic and invokehandle call sites have two entries in the diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/oops/instanceKlass.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1052,6 +1052,13 @@ } void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_oop, TRAPS) { + if (ReplayCompiles && + (ReplaySuppressInitializers == 1 || + ReplaySuppressInitializers >= 2 && this_oop->class_loader() != NULL)) { + // Hide the existence of the initializer for the purpose of replaying the compile + return; + } + methodHandle h_method(THREAD, this_oop->class_initializer()); assert(!this_oop->is_initialized(), "we cannot initialize twice"); if (TraceClassInitialization) { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/oops/instanceKlass.hpp --- a/src/share/vm/oops/instanceKlass.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/oops/instanceKlass.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -133,6 +133,7 @@ class InstanceKlass: public Klass { friend class VMStructs; friend class ClassFileParser; + friend class CompileReplay; protected: // Constructor diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/oops/symbol.cpp --- a/src/share/vm/oops/symbol.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/oops/symbol.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -153,17 +153,15 @@ void Symbol::print_symbol_on(outputStream* st) const { st = st ? st : tty; - int length = UTF8::unicode_length((const char*)bytes(), utf8_length()); - const char *ptr = (const char *)bytes(); - jchar value; - for (int index = 0; index < length; index++) { - ptr = UTF8::next(ptr, &value); - if (value >= 32 && value < 127 || value == '\'' || value == '\\') { - st->put(value); - } else { - st->print("\\u%04x", value); - } - } + st->print("%s", as_quoted_ascii()); +} + +char* Symbol::as_quoted_ascii() const { + const char *ptr = (const char *)&_body[0]; + int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length()); + char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1); + UTF8::as_quoted_ascii(ptr, result, quoted_length + 1); + return result; } jchar* Symbol::as_unicode(int& length) const { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/oops/symbol.hpp --- a/src/share/vm/oops/symbol.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/oops/symbol.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -189,6 +189,8 @@ // Use buf if needed buffer length is <= size. char* as_C_string_flexible_buffer(Thread* t, char* buf, int size) const; + // Returns an escaped form of a Java string. + char* as_quoted_ascii() const; // Returns a null terminated utf8 string in a resource array char* as_utf8() const { return as_C_string(); } diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/opto/bytecodeInfo.cpp --- a/src/share/vm/opto/bytecodeInfo.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/opto/bytecodeInfo.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "ci/ciReplay.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compileBroker.hpp" @@ -150,7 +151,7 @@ } else { // Not hot. Check for medium-sized pre-existing nmethod at cold sites. if (callee_method->has_compiled_code() && - callee_method->instructions_size(CompLevel_full_optimization) > inline_small_code_size) + callee_method->instructions_size() > inline_small_code_size) return "already compiled into a medium method"; } if (size > max_inline_size) { @@ -192,7 +193,7 @@ } if (callee_method->has_compiled_code() && - callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode) { + callee_method->instructions_size() > InlineSmallCode) { wci_result->set_profit(wci_result->profit() * 0.1); // %%% adjust wci_result->size()? } @@ -216,7 +217,7 @@ // Now perform checks which are heuristic if (callee_method->has_compiled_code() && - callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode) { + callee_method->instructions_size() > InlineSmallCode) { return "already compiled into a big method"; } @@ -235,6 +236,12 @@ return "disallowed by CompilerOracle"; } +#ifndef PRODUCT + if (ciReplay::should_not_inline(callee_method)) { + return "disallowed by ciReplay"; + } +#endif + if (UseStringCache) { // Do not inline StringCache::profile() method used only at the beginning. if (callee_method->name() == ciSymbol::profile_name() && diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/opto/doCall.cpp --- a/src/share/vm/opto/doCall.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/opto/doCall.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -334,7 +334,7 @@ return true; } - assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility"); + assert(dest_method->is_loaded(), "dest_method: typeflow responsibility"); return false; } diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/opto/escape.cpp --- a/src/share/vm/opto/escape.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/opto/escape.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1386,12 +1386,12 @@ // Non-escaped allocation returned from Java or runtime call have // unknown values in fields. for (EdgeIterator i(pta); i.has_next(); i.next()) { - PointsToNode* ptn = i.get(); - if (ptn->is_Field() && ptn->as_Field()->is_oop()) { - if (add_edge(ptn, phantom_obj)) { + PointsToNode* field = i.get(); + if (field->is_Field() && field->as_Field()->is_oop()) { + if (add_edge(field, phantom_obj)) { // New edge was added new_edges++; - add_field_uses_to_worklist(ptn->as_Field()); + add_field_uses_to_worklist(field->as_Field()); } } } @@ -1413,30 +1413,30 @@ // captured by Initialize node. // for (EdgeIterator i(pta); i.has_next(); i.next()) { - PointsToNode* ptn = i.get(); // Field (AddP) - if (!ptn->is_Field() || !ptn->as_Field()->is_oop()) + PointsToNode* field = i.get(); // Field (AddP) + if (!field->is_Field() || !field->as_Field()->is_oop()) continue; // Not oop field - int offset = ptn->as_Field()->offset(); + int offset = field->as_Field()->offset(); if (offset == Type::OffsetBot) { if (!visited_bottom_offset) { // OffsetBot is used to reference array's element, // always add reference to NULL to all Field nodes since we don't // known which element is referenced. - if (add_edge(ptn, null_obj)) { + if (add_edge(field, null_obj)) { // New edge was added new_edges++; - add_field_uses_to_worklist(ptn->as_Field()); + add_field_uses_to_worklist(field->as_Field()); visited_bottom_offset = true; } } } else { // Check only oop fields. - const Type* adr_type = ptn->ideal_node()->as_AddP()->bottom_type(); + const Type* adr_type = field->ideal_node()->as_AddP()->bottom_type(); if (adr_type->isa_rawptr()) { #ifdef ASSERT // Raw pointers are used for initializing stores so skip it // since it should be recorded already - Node* base = get_addp_base(ptn->ideal_node()); + Node* base = get_addp_base(field->ideal_node()); assert(adr_type->isa_rawptr() && base->is_Proj() && (base->in(0) == alloc),"unexpected pointer type"); #endif @@ -1446,10 +1446,54 @@ offsets_worklist.append(offset); Node* value = NULL; if (ini != NULL) { - BasicType ft = UseCompressedOops ? T_NARROWOOP : T_OBJECT; - Node* store = ini->find_captured_store(offset, type2aelembytes(ft), phase); - if (store != NULL && store->is_Store()) { + // StoreP::memory_type() == T_ADDRESS + BasicType ft = UseCompressedOops ? T_NARROWOOP : T_ADDRESS; + Node* store = ini->find_captured_store(offset, type2aelembytes(ft, true), phase); + // Make sure initializing store has the same type as this AddP. + // This AddP may reference non existing field because it is on a + // dead branch of bimorphic call which is not eliminated yet. + if (store != NULL && store->is_Store() && + store->as_Store()->memory_type() == ft) { value = store->in(MemNode::ValueIn); +#ifdef ASSERT + if (VerifyConnectionGraph) { + // Verify that AddP already points to all objects the value points to. + PointsToNode* val = ptnode_adr(value->_idx); + assert((val != NULL), "should be processed already"); + PointsToNode* missed_obj = NULL; + if (val->is_JavaObject()) { + if (!field->points_to(val->as_JavaObject())) { + missed_obj = val; + } + } else { + if (!val->is_LocalVar() || (val->edge_count() == 0)) { + tty->print_cr("----------init store has invalid value -----"); + store->dump(); + val->dump(); + assert(val->is_LocalVar() && (val->edge_count() > 0), "should be processed already"); + } + for (EdgeIterator j(val); j.has_next(); j.next()) { + PointsToNode* obj = j.get(); + if (obj->is_JavaObject()) { + if (!field->points_to(obj->as_JavaObject())) { + missed_obj = obj; + break; + } + } + } + } + if (missed_obj != NULL) { + tty->print_cr("----------field---------------------------------"); + field->dump(); + tty->print_cr("----------missed referernce to object-----------"); + missed_obj->dump(); + tty->print_cr("----------object referernced by init store -----"); + store->dump(); + val->dump(); + assert(!field->points_to(missed_obj->as_JavaObject()), "missed JavaObject reference"); + } + } +#endif } else { // There could be initializing stores which follow allocation. // For example, a volatile field store is not collected @@ -1462,10 +1506,10 @@ } if (value == NULL) { // A field's initializing value was not recorded. Add NULL. - if (add_edge(ptn, null_obj)) { + if (add_edge(field, null_obj)) { // New edge was added new_edges++; - add_field_uses_to_worklist(ptn->as_Field()); + add_field_uses_to_worklist(field->as_Field()); } } } @@ -1607,7 +1651,26 @@ } // Verify that all fields have initializing values. if (field->edge_count() == 0) { + tty->print_cr("----------field does not have references----------"); field->dump(); + for (BaseIterator i(field); i.has_next(); i.next()) { + PointsToNode* base = i.get(); + tty->print_cr("----------field has next base---------------------"); + base->dump(); + if (base->is_JavaObject() && (base != phantom_obj) && (base != null_obj)) { + tty->print_cr("----------base has fields-------------------------"); + for (EdgeIterator j(base); j.has_next(); j.next()) { + j.get()->dump(); + } + tty->print_cr("----------base has references---------------------"); + for (UseIterator j(base); j.has_next(); j.next()) { + j.get()->dump(); + } + } + } + for (UseIterator i(field); i.has_next(); i.next()) { + i.get()->dump(); + } assert(field->edge_count() > 0, "sanity"); } } @@ -1967,7 +2030,7 @@ if (is_JavaObject()) { return (this == ptn); } - assert(is_LocalVar(), "sanity"); + assert(is_LocalVar() || is_Field(), "sanity"); for (EdgeIterator i(this); i.has_next(); i.next()) { if (i.get() == ptn) return true; @@ -3127,10 +3190,14 @@ EscapeState fields_es = fields_escape_state(); tty->print("%s(%s) ", esc_names[(int)es], esc_names[(int)fields_es]); if (nt == PointsToNode::JavaObject && !this->scalar_replaceable()) - tty->print("NSR"); + tty->print("NSR "); } if (is_Field()) { FieldNode* f = (FieldNode*)this; + if (f->is_oop()) + tty->print("oop "); + if (f->offset() > 0) + tty->print("+%d ", f->offset()); tty->print("("); for (BaseIterator i(f); i.has_next(); i.next()) { PointsToNode* b = i.get(); diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/prims/jni.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "ci/ciReplay.hpp" #include "classfile/altHashing.hpp" #include "classfile/classLoader.hpp" #include "classfile/javaClasses.hpp" @@ -5151,6 +5152,7 @@ // Check if we should compile all classes on bootclasspath NOT_PRODUCT(if (CompileTheWorld) ClassLoader::compile_the_world();) + NOT_PRODUCT(if (ReplayCompiles) ciReplay::replay(thread);) // Since this is not a JVM_ENTRY we have to set the thread state manually before leaving. ThreadStateTransition::transition_and_fence(thread, _thread_in_vm, _thread_in_native); } else { diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/prims/jvmtiExport.cpp --- a/src/share/vm/prims/jvmtiExport.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/prims/jvmtiExport.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -2177,7 +2177,7 @@ jint JvmtiExport::load_agent_library(AttachOperation* op, outputStream* st) { char ebuf[1024]; char buffer[JVM_MAXPATHLEN]; - void* library; + void* library = NULL; jint result = JNI_ERR; // get agent name and options @@ -2196,13 +2196,16 @@ library = os::dll_load(agent, ebuf, sizeof ebuf); } else { // Try to load the agent from the standard dll directory - os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), agent); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + agent)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } if (library == NULL) { // not found - try local path char ns[1] = {0}; - os::dll_build_name(buffer, sizeof(buffer), ns, agent); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), ns, agent)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } } } diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/prims/jvmtiExport.hpp --- a/src/share/vm/prims/jvmtiExport.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/prims/jvmtiExport.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -64,6 +64,8 @@ // class JvmtiExport : public AllStatic { friend class VMStructs; + friend class CompileReplay; + private: #if INCLUDE_JVMTI diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/runtime/compilationPolicy.cpp --- a/src/share/vm/runtime/compilationPolicy.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/runtime/compilationPolicy.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -97,6 +97,9 @@ // This is intended to force compiles for methods (usually for // debugging) that would otherwise be interpreted for some reason. bool CompilationPolicy::must_be_compiled(methodHandle m, int comp_level) { + // Don't allow Xcomp to cause compiles in replay mode + if (ReplayCompiles) return false; + if (m->has_compiled_code()) return false; // already compiled if (!can_be_compiled(m, comp_level)) return false; @@ -322,6 +325,16 @@ return NULL; } } + if (CompileTheWorld || ReplayCompiles) { + // Don't trigger other compiles in testing mode + if (bci == InvocationEntryBci) { + reset_counter_for_invocation_event(method); + } else { + reset_counter_for_back_branch_event(method); + } + return NULL; + } + if (bci == InvocationEntryBci) { // when code cache is full, compilation gets switched off, UseCompiler // is set to false diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/runtime/globals.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -3189,6 +3189,26 @@ product(ccstrlist, CompileCommand, "", \ "Prepend to .hotspot_compiler; e.g. log,java/lang/String.") \ \ + develop(bool, ReplayCompiles, false, \ + "Enable replay of compilations from ReplayDataFile") \ + \ + develop(ccstr, ReplayDataFile, "replay.txt", \ + "file containing compilation replay information") \ + \ + develop(intx, ReplaySuppressInitializers, 2, \ + "Controls handling of class initialization during replay" \ + "0 - don't do anything special" \ + "1 - treat all class initializers as empty" \ + "2 - treat class initializers for application classes as empty" \ + "3 - allow all class initializers to run during bootstrap but" \ + " pretend they are empty after starting replay") \ + \ + develop(bool, ReplayIgnoreInitErrors, false, \ + "Ignore exceptions thrown during initialization for replay") \ + \ + develop(bool, DumpReplayDataOnError, true, \ + "record replay data for crashing compiler threads") \ + \ product(bool, CICompilerCountPerCPU, false, \ "1 compiler thread for log(N CPUs)") \ \ diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/runtime/os.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -397,12 +397,16 @@ // Try to load verify dll first. In 1.3 java dll depends on it and is not // always able to find it when the loading executable is outside the JDK. // In order to keep working with 1.2 we ignore any loading errors. - dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify"); - dll_load(buffer, ebuf, sizeof(ebuf)); + if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + "verify")) { + dll_load(buffer, ebuf, sizeof(ebuf)); + } // Load java dll - dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java"); - _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf)); + if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + "java")) { + _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf)); + } if (_native_java_library == NULL) { vm_exit_during_initialization("Unable to load native library", ebuf); } @@ -410,8 +414,10 @@ #if defined(__OpenBSD__) // Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so // ignore errors - dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "net"); - dll_load(buffer, ebuf, sizeof(ebuf)); + if (dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + "net")) { + dll_load(buffer, ebuf, sizeof(ebuf)); + } #endif } static jboolean onLoaded = JNI_FALSE; @@ -1158,7 +1164,7 @@ if (inpath == NULL) { return NULL; } - strncpy(inpath, path, strlen(path)); + strcpy(inpath, path); int count = 1; char* p = strchr(inpath, psepchar); // Get a count of elements to allocate memory diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/runtime/os.hpp --- a/src/share/vm/runtime/os.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/runtime/os.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -479,7 +479,8 @@ static const char* get_current_directory(char *buf, int buflen); // Builds a platform-specific full library path given a ld path and lib name - static void dll_build_name(char* buffer, size_t size, + // Returns true if buffer contains full path to existing file, false otherwise + static bool dll_build_name(char* buffer, size_t size, const char* pathname, const char* fname); // Symbol lookup, find nearest function name; basically it implements diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/runtime/thread.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -3753,8 +3753,10 @@ } } else { // Try to load the agent from the standard dll directory - os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), name); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), + name)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } #ifdef KERNEL // Download instrument dll if (library == NULL && strcmp(name, "instrument") == 0) { @@ -3779,8 +3781,9 @@ #endif // KERNEL if (library == NULL) { // Try the local directory char ns[1] = {0}; - os::dll_build_name(buffer, sizeof(buffer), ns, name); - library = os::dll_load(buffer, ebuf, sizeof ebuf); + if (os::dll_build_name(buffer, sizeof(buffer), ns, name)) { + library = os::dll_load(buffer, ebuf, sizeof ebuf); + } if (library == NULL) { const char *sub_msg = " on the library path, with error: "; size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1; diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/runtime/vmStructs.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -993,6 +993,7 @@ \ nonstatic_field(ciMethod, _interpreter_invocation_count, int) \ nonstatic_field(ciMethod, _interpreter_throwout_count, int) \ + nonstatic_field(ciMethod, _instructions_size, int) \ \ nonstatic_field(ciMethodData, _data_size, int) \ nonstatic_field(ciMethodData, _state, u_char) \ diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/utilities/array.hpp --- a/src/share/vm/utilities/array.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/utilities/array.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -353,9 +353,9 @@ // sort the array. bool contains(const T& x) const { return index_of(x) >= 0; } - T at(int i) const { return _data[i]; } - void at_put(const int i, const T& x) { _data[i] = x; } - T* adr_at(const int i) { return &_data[i]; } + T at(int i) const { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return _data[i]; } + void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); _data[i] = x; } + T* adr_at(const int i) { assert(i >= 0 && i< _length, err_msg_res("oob: 0 <= %d < %d", i, _length)); return &_data[i]; } int find(const T& x) { return index_of(x); } T at_acquire(const int which) { return OrderAccess::load_acquire(adr_at(which)); } diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/utilities/utf8.cpp --- a/src/share/vm/utilities/utf8.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/utilities/utf8.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -147,7 +147,7 @@ void UTF8::convert_to_unicode(const char* utf8_str, jchar* unicode_str, int unicode_length) { unsigned char ch; - const char *ptr = (const char *)utf8_str; + const char *ptr = utf8_str; int index = 0; /* ASCII case loop optimization */ @@ -162,6 +162,119 @@ } } +// returns the quoted ascii length of a 0-terminated utf8 string +int UTF8::quoted_ascii_length(const char* utf8_str, int utf8_length) { + const char *ptr = utf8_str; + const char* end = ptr + utf8_length; + int result = 0; + while (ptr < end) { + jchar c; + ptr = UTF8::next(ptr, &c); + if (c >= 32 && c < 127) { + result++; + } else { + result += 6; + } + } + return result; +} + +// converts a utf8 string to quoted ascii +void UTF8::as_quoted_ascii(const char* utf8_str, char* buf, int buflen) { + const char *ptr = utf8_str; + char* p = buf; + char* end = buf + buflen; + while (*ptr != '\0') { + jchar c; + ptr = UTF8::next(ptr, &c); + if (c >= 32 && c < 127) { + if (p + 1 >= end) break; // string is truncated + *p++ = (char)c; + } else { + if (p + 6 >= end) break; // string is truncated + sprintf(p, "\\u%04x", c); + p += 6; + } + } + *p = '\0'; +} + + +const char* UTF8::from_quoted_ascii(const char* quoted_ascii_str) { + const char *ptr = quoted_ascii_str; + char* result = NULL; + while (*ptr != '\0') { + char c = *ptr; + if (c < 32 || c >= 127) break; + } + if (*ptr == '\0') { + // nothing to do so return original string + return quoted_ascii_str; + } + // everything up to this point was ok. + int length = ptr - quoted_ascii_str; + char* buffer = NULL; + for (int round = 0; round < 2; round++) { + while (*ptr != '\0') { + if (*ptr != '\\') { + if (buffer != NULL) { + buffer[length] = *ptr; + } + length++; + } else { + switch (ptr[1]) { + case 'u': { + ptr += 2; + jchar value=0; + for (int i=0; i<4; i++) { + char c = *ptr++; + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + value = (value << 4) + c - '0'; + break; + case 'a': case 'b': case 'c': + case 'd': case 'e': case 'f': + value = (value << 4) + 10 + c - 'a'; + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + value = (value << 4) + 10 + c - 'A'; + break; + default: + ShouldNotReachHere(); + } + } + if (buffer == NULL) { + char utf8_buffer[4]; + char* next = (char*)utf8_write((u_char*)utf8_buffer, value); + length += next - utf8_buffer; + } else { + char* next = (char*)utf8_write((u_char*)&buffer[length], value); + length += next - &buffer[length]; + } + break; + } + case 't': if (buffer != NULL) buffer[length] = '\t'; ptr += 2; length++; break; + case 'n': if (buffer != NULL) buffer[length] = '\n'; ptr += 2; length++; break; + case 'r': if (buffer != NULL) buffer[length] = '\r'; ptr += 2; length++; break; + case 'f': if (buffer != NULL) buffer[length] = '\f'; ptr += 2; length++; break; + default: + ShouldNotReachHere(); + } + } + } + if (round == 0) { + buffer = NEW_RESOURCE_ARRAY(char, length + 1); + ptr = quoted_ascii_str; + } else { + buffer[length] = '\0'; + } + } + return buffer; +} + + // Returns NULL if 'c' it not found. This only works as long // as 'c' is an ASCII character const jbyte* UTF8::strrchr(const jbyte* base, int length, jbyte c) { @@ -242,3 +355,35 @@ } *utf8_buffer = '\0'; } + +// returns the quoted ascii length of a unicode string +int UNICODE::quoted_ascii_length(jchar* base, int length) { + int result = 0; + for (int i = 0; i < length; i++) { + jchar c = base[i]; + if (c >= 32 && c < 127) { + result++; + } else { + result += 6; + } + } + return result; +} + +// converts a utf8 string to quoted ascii +void UNICODE::as_quoted_ascii(const jchar* base, int length, char* buf, int buflen) { + char* p = buf; + char* end = buf + buflen; + for (int index = 0; index < length; index++) { + jchar c = base[index]; + if (c >= 32 && c < 127) { + if (p + 1 >= end) break; // string is truncated + *p++ = (char)c; + } else { + if (p + 6 >= end) break; // string is truncated + sprintf(p, "\\u%04x", c); + p += 6; + } + } + *p = '\0'; +} diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/utilities/utf8.hpp --- a/src/share/vm/utilities/utf8.hpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/utilities/utf8.hpp Tue Nov 20 20:27:40 2012 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,22 +32,32 @@ class UTF8 : AllStatic { public: - // returns the unicode length of a 0-terminated uft8 string - static int unicode_length(const char* uft8_str); + // returns the unicode length of a 0-terminated utf8 string + static int unicode_length(const char* utf8_str); - // returns the unicode length of a non-0-terminated uft8 string - static int unicode_length(const char* uft8_str, int len); + // returns the unicode length of a non-0-terminated utf8 string + static int unicode_length(const char* utf8_str, int len); - // converts a uft8 string to a unicode string + // converts a utf8 string to a unicode string static void convert_to_unicode(const char* utf8_str, jchar* unicode_buffer, int unicode_length); + // returns the quoted ascii length of a utf8 string + static int quoted_ascii_length(const char* utf8_str, int utf8_length); + + // converts a utf8 string to quoted ascii + static void as_quoted_ascii(const char* utf8_str, char* buf, int buflen); + + // converts a quoted ascii string to utf8 string. returns the original + // string unchanged if nothing needs to be done. + static const char* from_quoted_ascii(const char* quoted_ascii_string); + // decodes the current utf8 character, stores the result in value, - // and returns the end of the current uft8 chararacter. + // and returns the end of the current utf8 chararacter. static char* next(const char* str, jchar* value); // decodes the current utf8 character, gets the supplementary character instead of // the surrogate pair when seeing a supplementary character in string, - // stores the result in value, and returns the end of the current uft8 chararacter. + // stores the result in value, and returns the end of the current utf8 chararacter. static char* next_character(const char* str, jint* value); // Utility methods @@ -79,6 +89,12 @@ // in resource area unless a buffer is provided. static char* as_utf8(jchar* base, int length); static char* as_utf8(jchar* base, int length, char* buf, int buflen); + + // returns the quoted ascii length of a unicode string + static int quoted_ascii_length(jchar* base, int length); + + // converts a utf8 string to quoted ascii + static void as_quoted_ascii(const jchar* base, int length, char* buf, int buflen); }; #endif // SHARE_VM_UTILITIES_UTF8_HPP diff -r 49cbd3e25ba9 -r 3ed6de6e139b src/share/vm/utilities/vmError.cpp --- a/src/share/vm/utilities/vmError.cpp Fri Nov 16 09:05:19 2012 -0500 +++ b/src/share/vm/utilities/vmError.cpp Tue Nov 20 20:27:40 2012 -0500 @@ -1009,6 +1009,15 @@ OnError = NULL; } + static bool skip_replay = false; + if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { + skip_replay = true; + ciEnv* env = ciEnv::current(); + if (env != NULL) { + env->dump_replay_data(); + } + } + static bool skip_bug_url = !should_report_bug(first_error->_id); if (!skip_bug_url) { skip_bug_url = true; diff -r 49cbd3e25ba9 -r 3ed6de6e139b test/compiler/8002069/Test8002069.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/8002069/Test8002069.java Tue Nov 20 20:27:40 2012 -0500 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8002069 + * @summary Assert failed in C2: assert(field->edge_count() > 0) failed: sanity + * + * @run main/othervm -Xmx32m -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:CompileCommand=exclude,Test8002069.dummy Test8002069 + */ + +abstract class O { + int f; + public O() { f = 5; } + abstract void put(int i); + public int foo(int i) { + put(i); + return i; + } +}; + +class A extends O { + int[] a; + public A(int s) { + a = new int[s]; + } + public void put(int i) { + a[i%a.length] = i; + } +} + +class B extends O { + int sz; + int[] a; + public B(int s) { + sz = s; + a = new int[s]; + } + public void put(int i) { + a[i%sz] = i; + } +} + +public class Test8002069 { + public static void main(String args[]) { + int sum = 0; + for (int i=0; i<8000; i++) { + sum += test1(i); + } + for (int i=0; i<100000; i++) { + sum += test2(i); + } + System.out.println("PASSED. sum = " + sum); + } + + private O o; + + private int foo(int i) { + return o.foo(i); + } + static int test1(int i) { + Test8002069 t = new Test8002069(); + t.o = new A(5); + return t.foo(i); + } + static int test2(int i) { + Test8002069 t = new Test8002069(); + t.o = new B(5); + dummy(i); + return t.foo(i); + } + + static int dummy(int i) { + return i*2; + } +} +