diff --git a/.hgtags b/.hgtags index 84575326d76..af6c6de7c88 100644 --- a/.hgtags +++ b/.hgtags @@ -48,3 +48,5 @@ bca2225b66d78c4bf4d9801f54cac7715a598650 jdk7-b68 c5d39b6be65cba0effb5f466ea48fe43764d0e0c jdk7-b71 df4bcd06e1d0ab306efa5a44f24a409dc0c0c742 jdk7-b72 ce74bd35ce948d629a356e168797f44b593b1578 jdk7-b73 +4e7661eaa211e186674f6cbefec4aef1144ac2a0 jdk7-b74 +946518568340c4e511549318f19f47f06b7f5f9b jdk7-b75 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 4511932e4a5..a3ac772f914 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -48,3 +48,5 @@ e1b972ff53cd58f825791f8ed9b2deffd16e768c jdk7-b68 4c36e9853dda27bdac5ef4839a610509fbe31d34 jdk7-b71 0d7e03b426df27c21dcc44ffb9178eacd1b04f10 jdk7-b72 3ac6dcf7823205546fbbc3d4ea59f37358d0b0d4 jdk7-b73 +2c88089b6e1c053597418099a14232182c387edc jdk7-b74 +d1516b9f23954b29b8e76e6f4efc467c08c78133 jdk7-b75 diff --git a/README-builds.html b/README-builds.html index 414403b2ee3..1f7aae288aa 100644 --- a/README-builds.html +++ b/README-builds.html @@ -545,7 +545,11 @@
  • Windows: - Make sure you start your build inside a bash/sh/ksh shell. + Make sure you start your build inside a bash/sh/ksh shell + and are using a make.exe utility built for that + environment (a cygwin make.exe is not the same + as a make.exe built for something like + MKS).
    WARNING: Watch out for make version 3.81, it may not work due to a lack of support for MS-DOS drive letter paths @@ -826,7 +830,8 @@ All OpenJDK builds require access to the previously released JDK 6, this is often called a bootstrap JDK. The JDK 6 binaries can be downloaded from Sun's - JDK 6 download site. + JDK 6 download site. For build performance reasons is very important that this bootstrap JDK be made available on the local disk of the machine doing the build. diff --git a/corba/.hgtags b/corba/.hgtags index d5a056ab705..98a13b65b6a 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -48,3 +48,5 @@ a12ea7c7b497b4ba7830550095ef633bd6f43971 jdk7-b67 3f1ef7f899ea2aec189c4fb67e5c8fa374437c50 jdk7-b71 c793a31209263fbb867c23c752599d85c21abb73 jdk7-b72 b751c528c55560cf2adeaeef24b39ca1f4d1cbf7 jdk7-b73 +5d0cf59a3203b9f57aceebc33ae656b884987955 jdk7-b74 +0fb137085952c8e47878e240d1cb40f14de463c4 jdk7-b75 diff --git a/corba/make/common/Defs-linux.gmk b/corba/make/common/Defs-linux.gmk index a8ad4c354bc..46a965e16ea 100644 --- a/corba/make/common/Defs-linux.gmk +++ b/corba/make/common/Defs-linux.gmk @@ -99,8 +99,16 @@ CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9 LDFLAGS_COMMON_sparcv9 += -m64 -mcpu=v9 CFLAGS_REQUIRED_sparc += -m32 -mcpu=v9 LDFLAGS_COMMON_sparc += -m32 -mcpu=v9 -CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH)) -LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH)) +ifeq ($(ZERO_BUILD), true) + CFLAGS_REQUIRED = $(ZERO_ARCHFLAG) + ifeq ($(ZERO_ENDIANNESS), little) + CFLAGS_REQUIRED += -D_LITTLE_ENDIAN + endif + LDFLAGS_COMMON += $(ZERO_ARCHFLAG) +else + CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH)) + LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH)) +endif # Add in platform specific optimizations for all opt levels CC_HIGHEST_OPT += $(_OPT_$(ARCH)) @@ -196,7 +204,7 @@ endif EXTRA_LIBS += -lc -LDFLAGS_DEFS_OPTION = -z defs +LDFLAGS_DEFS_OPTION = -Xlinker -z -Xlinker defs LDFLAGS_COMMON += $(LDFLAGS_DEFS_OPTION) # diff --git a/corba/make/common/shared/Compiler-gcc.gmk b/corba/make/common/shared/Compiler-gcc.gmk index 5fc30edb995..92c1be2697c 100644 --- a/corba/make/common/shared/Compiler-gcc.gmk +++ b/corba/make/common/shared/Compiler-gcc.gmk @@ -70,6 +70,11 @@ ifeq ($(PLATFORM), linux) else CXX = $(COMPILER_PATH)g++ endif + ifeq ($(ZERO_BUILD), true) + # zero + REQUIRED_CC_VER = 3.2 + REQUIRED_GCC_VER = 3.2.* + else ifneq ("$(findstring sparc,$(ARCH))", "") # sparc or sparcv9 REQUIRED_CC_VER = 4.0 @@ -88,6 +93,7 @@ ifeq ($(PLATFORM), linux) endif endif endif + endif # Option used to create a shared library SHARED_LIBRARY_FLAG = -shared -mimpure-text SUN_COMP_VER := $(shell $(CC) --verbose 2>&1 ) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 92383ca276a..b8ce5272692 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -48,3 +48,5 @@ d07e68298d4e17ebf93d8299e43fcc3ded26472a jdk7-b68 50a95aa4a247f0cbbf66df285a8b1d78ffb153d9 jdk7-b71 a94714c550658fd6741793ef036cb9625dc2ab1a jdk7-b72 faf94d94786b621f8e13cbcc941ca69c6d967c3f jdk7-b73 +f4b900403d6e4b0af51447bd13bbe23fe3a1dac7 jdk7-b74 +d8dd291a362acb656026a9c0a9da48501505a1e7 jdk7-b75 diff --git a/hotspot/agent/make/saenv.sh b/hotspot/agent/make/saenv.sh index 81faf5e3c94..ae121dddcb7 100644 --- a/hotspot/agent/make/saenv.sh +++ b/hotspot/agent/make/saenv.sh @@ -48,8 +48,16 @@ if [ "$OS" = "Linux" ]; then CPU=i386 fi else - LD_AUDIT_32=$STARTDIR/../src/os/solaris/proc/`uname -p`/libsaproc_audit.so - export LD_AUDIT_32 + # configure audit helper library if SA_ALTROOT is set + if [ -n "$SA_ALTROOT" ]; then + LD_AUDIT_32=$STARTDIR/../src/os/solaris/proc/`uname -p`/libsaproc_audit.so + export LD_AUDIT_32 + if [ ! -f $LD_AUDIT_32 ]; then + echo "SA_ALTROOT is set and can't find libsaproc_audit.so." + echo "Make sure to build it with 'make natives'." + exit 1 + fi + fi SA_LIBPATH=$STARTDIR/../src/os/solaris/proc/`uname -p`:$STARTDIR/solaris/`uname -p` OPTIONS="-Dsa.library.path=$SA_LIBPATH -Dsun.jvm.hotspot.debugger.useProcDebugger" CPU=sparc diff --git a/hotspot/agent/make/saenv64.sh b/hotspot/agent/make/saenv64.sh index 6990c4f5a0b..e86f3dd6121 100644 --- a/hotspot/agent/make/saenv64.sh +++ b/hotspot/agent/make/saenv64.sh @@ -43,8 +43,16 @@ else fi fi -LD_AUDIT_64=$STARTDIR/../src/os/solaris/proc/$CPU/libsaproc_audit.so -export LD_AUDIT_64 +# configure audit helper library if SA_ALTROOT is set +if [ -n "$SA_ALTROOT" ]; then + LD_AUDIT_64=$STARTDIR/../src/os/solaris/proc/$CPU/libsaproc_audit.so + export LD_AUDIT_64 + if [ ! -f $LD_AUDIT_64 ]; then + echo "SA_ALTROOT is set and can't find libsaproc_audit.so." + echo "Make sure to build it with 'make natives'." + exit 1 + fi +fi SA_LIBPATH=$STARTDIR/../src/os/solaris/proc/$CPU:$STARTDIR/solaris/$CPU OPTIONS="-Dsa.library.path=$SA_LIBPATH -Dsun.jvm.hotspot.debugger.useProcDebugger" diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java index bb3dba9ea33..a8d802f2fec 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java @@ -926,6 +926,28 @@ public class CommandProcessor { } } }, + new Command("dumpcodecache", "dumpcodecache", false) { + public void doit(Tokens t) { + if (t.countTokens() != 0) { + usage(); + } else { + final PrintStream fout = out; + final HTMLGenerator gen = new HTMLGenerator(false); + CodeCacheVisitor v = new CodeCacheVisitor() { + public void prologue(Address start, Address end) { + } + public void visit(CodeBlob blob) { + fout.println(gen.genHTML(blob.instructionsBegin())); + } + public void epilogue() { + } + + + }; + VM.getVM().getCodeCache().iterate(v); + } + } + }, new Command("where", "where { -a | id }", false) { public void doit(Tokens t) { if (t.countTokens() != 1) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java index 9fc04f5dfb5..065c41e97b7 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java @@ -173,7 +173,8 @@ public class CodeCache { CodeBlob lastBlob = null; while (ptr != null && ptr.lessThan(end)) { try { - CodeBlob blob = findBlobUnsafe(ptr); + // Use findStart to get a pointer inside blob other findBlob asserts + CodeBlob blob = findBlobUnsafe(heap.findStart(ptr)); if (blob != null) { visitor.visit(blob); if (blob == lastBlob) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java index 7f48d5807ee..011ca78cc26 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java @@ -42,7 +42,7 @@ public class NMethod extends CodeBlob { /** To support simple linked-list chaining of nmethods */ private static AddressField osrLinkField; private static AddressField scavengeRootLinkField; - private static CIntegerField scavengeRootStateField; + private static JByteField scavengeRootStateField; /** Offsets for different nmethod parts */ private static CIntegerField exceptionOffsetField; @@ -92,7 +92,7 @@ public class NMethod extends CodeBlob { entryBCIField = type.getCIntegerField("_entry_bci"); osrLinkField = type.getAddressField("_osr_link"); scavengeRootLinkField = type.getAddressField("_scavenge_root_link"); - scavengeRootStateField = type.getCIntegerField("_scavenge_root_state"); + scavengeRootStateField = type.getJByteField("_scavenge_root_state"); exceptionOffsetField = type.getCIntegerField("_exception_offset"); deoptOffsetField = type.getCIntegerField("_deoptimize_offset"); @@ -274,7 +274,7 @@ public class NMethod extends CodeBlob { if (Assert.ASSERTS_ENABLED) { Assert.that(pd != null, "scope must be present"); } - return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getReexecute()); + return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute()); } /** This is only for use by the debugging system, and is only @@ -306,11 +306,11 @@ public class NMethod extends CodeBlob { public ScopeDesc getScopeDescNearDbg(Address pc) { PCDesc pd = getPCDescNearDbg(pc); if (pd == null) return null; - return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getReexecute()); + return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute()); } - public Map/**/ getSafepoints() { - Map safepoints = new HashMap(); // Map + public Map/**/ getSafepoints() { + Map safepoints = new HashMap(); // Map sun.jvm.hotspot.debugger.Address p = null; for (p = scopesPCsBegin(); p.lessThan(scopesPCsEnd()); p = p.addOffsetTo(pcDescSize)) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java index e28afc51db3..b0586d71cd5 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java @@ -36,6 +36,7 @@ import sun.jvm.hotspot.types.*; public class PCDesc extends VMObject { private static CIntegerField pcOffsetField; private static CIntegerField scopeDecodeOffsetField; + private static CIntegerField objDecodeOffsetField; private static CIntegerField pcFlagsField; static { @@ -51,6 +52,7 @@ public class PCDesc extends VMObject { pcOffsetField = type.getCIntegerField("_pc_offset"); scopeDecodeOffsetField = type.getCIntegerField("_scope_decode_offset"); + objDecodeOffsetField = type.getCIntegerField("_obj_decode_offset"); pcFlagsField = type.getCIntegerField("_flags"); } @@ -68,6 +70,10 @@ public class PCDesc extends VMObject { return ((int) scopeDecodeOffsetField.getValue(addr)); } + public int getObjDecodeOffset() { + return ((int) objDecodeOffsetField.getValue(addr)); + } + public Address getRealPC(NMethod code) { return code.instructionsBegin().addOffsetTo(getPCOffset()); } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java index ebac4a2358e..941a0e18e67 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java @@ -51,11 +51,10 @@ public class ScopeDesc { /** Scalar replaced bjects pool */ private List objects; // ArrayList - - public ScopeDesc(NMethod code, int decodeOffset, boolean reexecute) { + private ScopeDesc(NMethod code, int decodeOffset, List objects, boolean reexecute) { this.code = code; this.decodeOffset = decodeOffset; - this.objects = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL); + this.objects = objects; this.reexecute = reexecute; // Decode header @@ -108,7 +107,7 @@ public class ScopeDesc { return decodeMonitorValues(monitorsDecodeOffset); } - /** Returns a List<MonitorValue> */ + /** Returns a List<ObjectValue> */ public List getObjects() { return objects; } @@ -119,7 +118,7 @@ public class ScopeDesc { return null; } - return new ScopeDesc(code, senderDecodeOffset, false); + return new ScopeDesc(code, senderDecodeOffset, objects, false); } /** Returns where the scope was decoded */ diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java index 0be7fad5ab6..c7d29d7d2e5 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java @@ -807,6 +807,9 @@ public class HTMLGenerator implements /* imports */ ClassConstants { Interpreter interp = VM.getVM().getInterpreter(); if (interp.contains(pc)) { InterpreterCodelet codelet = interp.getCodeletContaining(pc); + if (codelet == null) { + return "Unknown location in the Interpreter: " + pc; + } return genHTML(codelet); } return genHTML(blob); @@ -969,16 +972,24 @@ public class HTMLGenerator implements /* imports */ ClassConstants { } protected String genSafepointInfo(NMethod nm, PCDesc pcDesc) { - ScopeDesc sd = nm.getScopeDescAt(pcDesc.getRealPC(nm)); - Formatter buf = new Formatter(genHTML); - Formatter tabs = new Formatter(genHTML); + ScopeDesc sd = nm.getScopeDescAt(pcDesc.getRealPC(nm)); + Formatter buf = new Formatter(genHTML); + Formatter tabs = new Formatter(genHTML); + tabs.append(tab + tab + tab); // Initial indent for debug info - buf.beginTag("pre"); - genScope(buf, tabs, sd); - buf.endTag("pre"); - buf.append(genOopMapInfo(nm, pcDesc)); + buf.beginTag("pre"); + genScope(buf, tabs, sd); - return buf.toString(); + // Reset indent for scalar replaced objects + tabs = new Formatter(genHTML); + tabs.append(tab + tab + tab); // Initial indent for debug info + + genScObjInfo(buf, tabs, sd); + buf.endTag("pre"); + + buf.append(genOopMapInfo(nm, pcDesc)); + + return buf.toString(); } protected void genScope(Formatter buf, Formatter tabs, ScopeDesc sd) { @@ -1022,8 +1033,95 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.append(genHTMLForMonitors(sd, monitors)); } - tabs.append(tab); buf.br(); + tabs.append(tab); + } + + protected void genScObjInfo(Formatter buf, Formatter tabs, ScopeDesc sd) { + if (sd == null) { + return; + } + + List objects = sd.getObjects(); + if (objects == null) { + return; + } + int length = objects.size(); + for (int i = 0; i < length; i++) { + buf.append(tabs); + ObjectValue ov = (ObjectValue)objects.get(i); + buf.append("ScObj" + i); + ScopeValue sv = ov.getKlass(); + if (Assert.ASSERTS_ENABLED) { + Assert.that(sv.isConstantOop(), "scalar replaced object klass must be constant oop"); + } + ConstantOopReadValue klv = (ConstantOopReadValue)sv; + OopHandle klHandle = klv.getValue(); + if (Assert.ASSERTS_ENABLED) { + Assert.that(klHandle != null, "scalar replaced object klass must be not NULL"); + } + Oop obj = VM.getVM().getObjectHeap().newOop(klHandle); + if (obj instanceof InstanceKlass) { + InstanceKlass kls = (InstanceKlass) obj; + buf.append(" " + kls.getName().asString() + "={"); + int flen = ov.fieldsSize(); + + TypeArray klfields = kls.getFields(); + int klen = (int) klfields.getLength(); + + ConstantPool cp = kls.getConstants(); + int findex = 0; + for (int index = 0; index < klen; index += kls.NEXT_OFFSET) { + int accsFlags = klfields.getShortAt(index + kls.ACCESS_FLAGS_OFFSET); + int nameIndex = klfields.getShortAt(index + kls.NAME_INDEX_OFFSET); + AccessFlags access = new AccessFlags(accsFlags); + if (!access.isStatic()) { + ScopeValue svf = ov.getFieldAt(findex++); + String fstr = scopeValueAsString(sd, svf); + Symbol f_name = cp.getSymbolAt(nameIndex); + buf.append(" [" + f_name.asString() + " :"+ index + "]=(#" + fstr + ")"); + } + } + buf.append(" }"); + } else { + buf.append(" "); + int flen = ov.fieldsSize(); + if (obj instanceof TypeArrayKlass) { + TypeArrayKlass kls = (TypeArrayKlass) obj; + buf.append(kls.getElementTypeName() + "[" + flen + "]"); + } else if (obj instanceof ObjArrayKlass) { + ObjArrayKlass kls = (ObjArrayKlass) obj; + Klass elobj = kls.getBottomKlass(); + if (elobj instanceof InstanceKlass) { + buf.append(elobj.getName().asString()); + } else if (elobj instanceof TypeArrayKlass) { + TypeArrayKlass elkls = (TypeArrayKlass) elobj; + buf.append(elkls.getElementTypeName()); + } else { + if (Assert.ASSERTS_ENABLED) { + Assert.that(false, "unknown scalar replaced object klass!"); + } + } + buf.append("[" + flen + "]"); + int ndim = (int) kls.getDimension(); + while (--ndim > 0) { + buf.append("[]"); + } + } else { + if (Assert.ASSERTS_ENABLED) { + Assert.that(false, "unknown scalar replaced object klass!"); + } + } + buf.append("={"); + for (int findex = 0; findex < flen; findex++) { + ScopeValue svf = ov.getFieldAt(findex); + String fstr = scopeValueAsString(sd, svf); + buf.append(" [" + findex + "]=(#" + fstr + ")"); + } + buf.append(" }"); + } + buf.br(); + } } protected String genHTMLForOopMap(OopMap map) { @@ -1037,8 +1135,6 @@ public class HTMLGenerator implements /* imports */ ClassConstants { tmpBuf.beginTag("tr"); tmpBuf.beginTag("td"); tmpBuf.append(type); - tmpBuf.endTag("td"); - tmpBuf.endTag("tr"); for (; ! oms.isDone(); oms.next()) { OopMapValue omv = oms.getCurrent(); if (omv == null) { @@ -1048,7 +1144,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { VMReg vmReg = omv.getReg(); int reg = vmReg.getValue(); if (reg < stack0) { - tmpBuf.append(VMRegImpl.getRegisterName(vmReg.getValue())); + tmpBuf.append(VMRegImpl.getRegisterName(reg)); } else { tmpBuf.append('['); tmpBuf.append(Integer.toString((reg - stack0) * 4)); @@ -1058,7 +1154,13 @@ public class HTMLGenerator implements /* imports */ ClassConstants { tmpBuf.append(" = "); VMReg vmContentReg = omv.getContentReg(); int contentReg = vmContentReg.getValue(); - tmpBuf.append(VMRegImpl.getRegisterName(vmContentReg.getValue())); + if (contentReg < stack0) { + tmpBuf.append(VMRegImpl.getRegisterName(contentReg)); + } else { + tmpBuf.append('['); + tmpBuf.append(Integer.toString((contentReg - stack0) * 4)); + tmpBuf.append(']'); + } } tmpBuf.append(spaces); } @@ -1072,19 +1174,19 @@ public class HTMLGenerator implements /* imports */ ClassConstants { OopMapValueIterator omvIterator = new OopMapValueIterator(); OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.OOP_VALUE); - buf.append(omvIterator.iterate(oms, "Oop:", false)); - - oms = new OopMapStream(map, OopMapValue.OopTypes.VALUE_VALUE); - buf.append(omvIterator.iterate(oms, "Value:", false)); + buf.append(omvIterator.iterate(oms, "Oops:", false)); oms = new OopMapStream(map, OopMapValue.OopTypes.NARROWOOP_VALUE); - buf.append(omvIterator.iterate(oms, "Oop:", false)); + buf.append(omvIterator.iterate(oms, "narrowOops:", false)); + + oms = new OopMapStream(map, OopMapValue.OopTypes.VALUE_VALUE); + buf.append(omvIterator.iterate(oms, "Values:", false)); oms = new OopMapStream(map, OopMapValue.OopTypes.CALLEE_SAVED_VALUE); buf.append(omvIterator.iterate(oms, "Callee saved:", true)); oms = new OopMapStream(map, OopMapValue.OopTypes.DERIVED_OOP_VALUE); - buf.append(omvIterator.iterate(oms, "Derived oop:", true)); + buf.append(omvIterator.iterate(oms, "Derived oops:", true)); buf.endTag("table"); return buf.toString(); @@ -1093,6 +1195,8 @@ public class HTMLGenerator implements /* imports */ ClassConstants { protected String genOopMapInfo(NMethod nmethod, PCDesc pcDesc) { OopMapSet mapSet = nmethod.getOopMaps(); + if (mapSet == null || (mapSet.getSize() <= 0)) + return ""; int pcOffset = pcDesc.getPCOffset(); OopMap map = mapSet.findMapAtOffset(pcOffset, VM.getVM().isDebugging()); if (map == null) { @@ -1106,6 +1210,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { Formatter buf = new Formatter(genHTML); buf.beginTag("pre"); buf.append("OopMap: "); + buf.br(); buf.append(genHTMLForOopMap(map)); buf.endTag("pre"); @@ -1154,7 +1259,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { return buf.toString(); } - private String scopeValueAsString(ScopeValue sv) { + private String scopeValueAsString(ScopeDesc sd, ScopeValue sv) { Formatter buf = new Formatter(genHTML); if (sv.isConstantInt()) { buf.append("int "); @@ -1187,6 +1292,11 @@ public class HTMLGenerator implements /* imports */ ClassConstants { } else { buf.append("null"); } + } else if (sv.isObject()) { + ObjectValue ov = (ObjectValue)sv; + buf.append("#ScObj" + sd.getObjects().indexOf(ov)); + } else { + buf.append("unknown scope value " + sv); } return buf.toString(); } @@ -1219,7 +1329,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { } buf.append(", "); - buf.append(scopeValueAsString(sv)); + buf.append(scopeValueAsString(sd, sv)); buf.append(") "); } @@ -1246,7 +1356,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.append("(owner = "); ScopeValue owner = mv.owner(); if (owner != null) { - buf.append(scopeValueAsString(owner)); + buf.append(scopeValueAsString(sd, owner)); } else { buf.append("null"); } @@ -1324,11 +1434,11 @@ public class HTMLGenerator implements /* imports */ ClassConstants { buf.append(instr.asString(currentPc, symFinder)); } + buf.br(); if (isSafepoint && !prevWasCall) { - buf.append(genSafepointInfo(nmethod, pcDesc)); + buf.append(genSafepointInfo(nmethod, pcDesc)); } - buf.br(); prevWasCall = instr.isCall(); } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js index 226e793e78b..78754094ea2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js @@ -1047,7 +1047,7 @@ while (tmp.itr.hasNext()) { } else { // some type names have ':'. replace to make it as a // JavaScript identifier - tmp.name = tmp.name.replace(':', '_'); + tmp.name = tmp.name.replace(':', '_').replace('<', '_').replace('>', '_').replace('*', '_').replace(' ', '_'); eval("function read" + tmp.name + "(addr) {" + " return readVMType('" + tmp.name + "', addr);}"); eval("function print" + tmp.name + "(addr) {" + diff --git a/hotspot/make/Makefile b/hotspot/make/Makefile index bd2744180ce..6186b3fead8 100644 --- a/hotspot/make/Makefile +++ b/hotspot/make/Makefile @@ -84,6 +84,7 @@ endif C1_VM_TARGETS=product1 fastdebug1 optimized1 jvmg1 C2_VM_TARGETS=product fastdebug optimized jvmg KERNEL_VM_TARGETS=productkernel fastdebugkernel optimizedkernel jvmgkernel +ZERO_VM_TARGETS=productzero fastdebugzero optimizedzero jvmgzero # JDK directory list JDK_DIRS=bin include jre lib demo @@ -94,6 +95,12 @@ all_fastdebug: fastdebug fastdebug1 fastdebugkernel docs export_fastdebug all_debug: jvmg jvmg1 jvmgkernel docs export_debug all_optimized: optimized optimized1 optimizedkernel docs export_optimized +allzero: all_productzero all_fastdebugzero +all_productzero: productzero docs export_product +all_fastdebugzero: fastdebugzero docs export_fastdebug +all_debugzero: jvmgzero docs export_debug +all_optimizedzero: optimizedzero docs export_optimized + # Do everything world: all create_jdk @@ -120,6 +127,10 @@ $(KERNEL_VM_TARGETS): $(CD) $(GAMMADIR)/make; \ $(MAKE) VM_TARGET=$@ generic_buildkernel $(ALT_OUT) +$(ZERO_VM_TARGETS): + $(CD) $(GAMMADIR)/make; \ + $(MAKE) VM_TARGET=$@ generic_buildzero $(ALT_OUT) + # Build compiler1 (client) rule, different for platforms generic_build1: $(MKDIR) -p $(OUTPUTDIR) @@ -180,6 +191,12 @@ else @$(ECHO) "No kernel ($(VM_TARGET)) for OS_NAME=$(OSNAME)" endif +generic_buildzero: + $(MKDIR) -p $(OUTPUTDIR) + $(CD) $(OUTPUTDIR); \ + $(MAKE) -f $(ABS_OS_MAKEFILE) \ + $(MAKE_ARGS) $(VM_TARGET) + # Export file rule generic_export: $(EXPORT_LIST) export_product: @@ -210,11 +227,17 @@ DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs C1_BASE_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1 C2_BASE_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2 KERNEL_BASE_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_kernel +ZERO_BASE_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_zero C1_DIR=$(C1_BASE_DIR)/$(VM_SUBDIR) C2_DIR=$(C2_BASE_DIR)/$(VM_SUBDIR) KERNEL_DIR=$(KERNEL_BASE_DIR)/$(VM_SUBDIR) +ZERO_DIR=$(ZERO_BASE_DIR)/$(VM_SUBDIR) # Misc files and generated files need to come from C1 or C2 area +ifeq ($(ZERO_BUILD), true) + MISC_DIR=$(ZERO_DIR) + GEN_DIR=$(ZERO_BASE_DIR)/generated +else ifeq ($(ARCH_DATA_MODEL), 32) MISC_DIR=$(C1_DIR) GEN_DIR=$(C1_BASE_DIR)/generated @@ -222,6 +245,7 @@ else MISC_DIR=$(C2_DIR) GEN_DIR=$(C2_BASE_DIR)/generated endif +endif # Bin files (windows) ifeq ($(OSNAME),windows) @@ -265,6 +289,12 @@ endif # Shared Library ifneq ($(OSNAME),windows) + ifeq ($(ZERO_BUILD), true) +$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(ZERO_DIR)/%.so + $(install-file) +$(EXPORT_SERVER_DIR)/%.so: $(ZERO_DIR)/%.so + $(install-file) + else $(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(C2_DIR)/%.so $(install-file) $(EXPORT_CLIENT_DIR)/%.so: $(C1_DIR)/%.so @@ -275,6 +305,7 @@ $(EXPORT_SERVER_DIR)/%.so: $(C2_DIR)/%.so $(install-file) $(EXPORT_SERVER_DIR)/64/%.so: $(C2_DIR)/%.so $(install-file) + endif endif # Jar file (sa-jdi.jar) @@ -313,6 +344,7 @@ clean_build: $(RM) -r $(C1_DIR) $(RM) -r $(C2_DIR) $(RM) -r $(KERNEL_DIR) + $(RM) -r $(ZERO_DIR) clean_export: $(RM) -r $(EXPORT_PATH) clean_jdk: @@ -335,8 +367,10 @@ $(JDK_IMAGE_DIR)/jre/lib/rt.jar: ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -) test_jdk: - ifeq ($(ARCH_DATA_MODEL), 32) + ifneq ($(ZERO_BUILD), true) + ifeq ($(ARCH_DATA_MODEL), 32) $(JDK_IMAGE_DIR)/bin/java -client -version + endif endif $(JDK_IMAGE_DIR)/bin/java -server -version diff --git a/hotspot/make/defs.make b/hotspot/make/defs.make index 5e94726b3f3..83ddd1a9678 100644 --- a/hotspot/make/defs.make +++ b/hotspot/make/defs.make @@ -192,13 +192,14 @@ ifneq ($(OSNAME),windows) # Use uname output for SRCARCH, but deal with platform differences. If ARCH # is not explicitly listed below, it is treated as x86. - SRCARCH = $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64,$(ARCH))) + SRCARCH = $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 zero,$(ARCH))) ARCH/ = x86 ARCH/sparc = sparc ARCH/sparc64= sparc ARCH/ia64 = ia64 ARCH/amd64 = x86 ARCH/x86_64 = x86 + ARCH/zero = zero # BUILDARCH is usually the same as SRCARCH, except for sparcv9 BUILDARCH = $(SRCARCH) @@ -222,8 +223,9 @@ ifneq ($(OSNAME),windows) LIBARCH/sparc = sparc LIBARCH/sparcv9 = sparcv9 LIBARCH/ia64 = ia64 + LIBARCH/zero = $(ZERO_LIBARCH) - LP64_ARCH = sparcv9 amd64 ia64 + LP64_ARCH = sparcv9 amd64 ia64 zero endif # Required make macro settings for all platforms diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index 480b8edfc1a..5da770b9f1e 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2009 HS_MAJOR_VER=17 HS_MINOR_VER=0 -HS_BUILD_NUMBER=03 +HS_BUILD_NUMBER=05 JDK_MAJOR_VER=1 JDK_MINOR_VER=7 diff --git a/hotspot/make/jprt.gmk b/hotspot/make/jprt.gmk index e43f7638c1e..044dd528ea6 100644 --- a/hotspot/make/jprt.gmk +++ b/hotspot/make/jprt.gmk @@ -29,17 +29,24 @@ ifdef JPRT_BUILD_VERSION MILESTONE=$(JPRT_BUILD_VERSION) endif +ifeq ($(OSNAME),windows) + ZIPFLAGS=-q +else + # store symbolic links as the link + ZIPFLAGS=-q -y +endif + jprt_build_product: all_product copy_product_jdk export_product_jdk ( $(CD) $(JDK_IMAGE_DIR) && \ - $(ZIPEXE) -q -r $(JPRT_ARCHIVE_BUNDLE) . ) + $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . ) jprt_build_fastdebug: all_fastdebug copy_fastdebug_jdk export_fastdebug_jdk ( $(CD) $(JDK_IMAGE_DIR)/fastdebug && \ - $(ZIPEXE) -q -r $(JPRT_ARCHIVE_BUNDLE) . ) + $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . ) jprt_build_debug: all_debug copy_debug_jdk export_debug_jdk ( $(CD) $(JDK_IMAGE_DIR)/debug && \ - $(ZIPEXE) -q -r $(JPRT_ARCHIVE_BUNDLE) . ) + $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . ) .PHONY: jprt_build_product jprt_build_fastdebug jprt_build_debug diff --git a/hotspot/make/linux/Makefile b/hotspot/make/linux/Makefile index 21f2b3d7f5a..8c86ed287fe 100644 --- a/hotspot/make/linux/Makefile +++ b/hotspot/make/linux/Makefile @@ -132,6 +132,9 @@ ifeq ($(OSNAME),solaris) endif +# BUILDARCH is set to "zero" for Zero builds. VARIANTARCH +# is used to give the build directories meaningful names. +VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH)) # There is a (semi-) regular correspondence between make targets and actions: # @@ -158,6 +161,13 @@ endif # profiledcore core __core/profiled # productcore core __core/product # +# debugzero zero __zero/debug +# fastdebugzero zero __zero/fastdebug +# jvmgzero zero __zero/jvmg +# optimizedzero zero __zero/optimized +# profiledzero zero __zero/profiled +# productzero zero __zero/product +# # What you get with each target: # # debug* - "thin" libjvm_g - debug info linked into the gamma_g launcher @@ -171,16 +181,22 @@ endif # in the build.sh script: TARGETS = debug jvmg fastdebug optimized profiled product -SUBDIR_DOCS = $(OSNAME)_$(BUILDARCH)_docs +ifeq ($(ZERO_BUILD), true) + SUBDIR_DOCS = $(OSNAME)_$(VARIANTARCH)_docs +else + SUBDIR_DOCS = $(OSNAME)_$(BUILDARCH)_docs +endif SUBDIRS_C1 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS)) SUBDIRS_C2 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS)) SUBDIRS_TIERED = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS)) SUBDIRS_CORE = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS)) +SUBDIRS_ZERO = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS)) TARGETS_C2 = $(TARGETS) TARGETS_C1 = $(addsuffix 1,$(TARGETS)) TARGETS_TIERED = $(addsuffix tiered,$(TARGETS)) TARGETS_CORE = $(addsuffix core,$(TARGETS)) +TARGETS_ZERO = $(addsuffix zero,$(TARGETS)) BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) ARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) @@ -196,6 +212,7 @@ all: @echo " $(TARGETS_C2)" @echo " $(TARGETS_C1)" @echo " $(TARGETS_CORE)" + @echo " $(TARGETS_ZERO)" checks: check_os_version check_j2se_version @@ -245,6 +262,13 @@ $(SUBDIRS_CORE): $(BUILDTREE_MAKE) $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks $(BUILDTREE) VARIANT=core +$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero + $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks + $(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH) + +platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in + $(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@ + # Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME $(TARGETS_C2): $(SUBDIRS_C2) @@ -275,10 +299,18 @@ ifdef INSTALL cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install endif +$(TARGETS_ZERO): $(SUBDIRS_ZERO) + cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) + cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && ./test_gamma +ifdef INSTALL + cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install +endif + # Just build the tree, and nothing else: tree: $(SUBDIRS_C2) tree1: $(SUBDIRS_C1) treecore: $(SUBDIRS_CORE) +treezero: $(SUBDIRS_ZERO) # Doc target. This is the same for all build options. # Hence create a docs directory beside ...$(ARCH)_[...] @@ -293,20 +325,22 @@ compiler1: jvmg1 product1 core: jvmgcore productcore +zero: jvmgzero productzero + clean_docs: rm -rf $(SUBDIR_DOCS) -clean_compiler1 clean_compiler2 clean_core: +clean_compiler1 clean_compiler2 clean_core clean_zero: rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@) -clean: clean_compiler2 clean_compiler1 clean_core clean_docs +clean: clean_compiler2 clean_compiler1 clean_core clean_zero clean_docs include $(GAMMADIR)/make/$(OSNAME)/makefiles/cscope.make #------------------------------------------------------------------------------- -.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) -.PHONY: tree tree1 treecore -.PHONY: all compiler1 compiler2 core -.PHONY: clean clean_compiler1 clean_compiler2 clean_core docs clean_docs +.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) +.PHONY: tree tree1 treecore treezero +.PHONY: all compiler1 compiler2 core zero +.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero docs clean_docs .PHONY: checks check_os_version check_j2se_version diff --git a/hotspot/make/linux/makefiles/buildtree.make b/hotspot/make/linux/makefiles/buildtree.make index 005ef37cd42..0e2b55d2907 100644 --- a/hotspot/make/linux/makefiles/buildtree.make +++ b/hotspot/make/linux/makefiles/buildtree.make @@ -63,20 +63,30 @@ QUIETLY$(MAKE_VERBOSE) = @ # For now, until the compiler is less wobbly: TESTFLAGS = -Xbatch -showversion -ifdef USE_SUNCC -PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc +ifeq ($(ZERO_BUILD), true) + PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero else -PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH) + ifdef USE_SUNCC + PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc + else + PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH) + endif +endif + +# Allow overriding of the arch part of the directory but default +# to BUILDARCH if nothing is specified +ifeq ($(VARIANTARCH),) + VARIANTARCH=$(BUILDARCH) endif ifdef FORCE_TIERED ifeq ($(VARIANT),tiered) -PLATFORM_DIR = $(OS_FAMILY)_$(BUILDARCH)_compiler2 +PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_compiler2 else -PLATFORM_DIR = $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT) +PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) endif else -PLATFORM_DIR = $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT) +PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) endif # @@ -321,6 +331,7 @@ DATA_MODE/sparc = 32 DATA_MODE/sparcv9 = 64 DATA_MODE/amd64 = 64 DATA_MODE/ia64 = 64 +DATA_MODE/zero = $(ARCH_DATA_MODEL) JAVA_FLAG/32 = -d32 JAVA_FLAG/64 = -d64 diff --git a/hotspot/make/linux/makefiles/defs.make b/hotspot/make/linux/makefiles/defs.make index 2925654e677..69f91cc171a 100644 --- a/hotspot/make/linux/makefiles/defs.make +++ b/hotspot/make/linux/makefiles/defs.make @@ -37,6 +37,17 @@ else ARCH_DATA_MODEL ?= 32 endif +# zero +ifeq ($(ZERO_BUILD), true) + ifeq ($(ARCH_DATA_MODEL), 64) + MAKE_ARGS += LP64=1 + endif + PLATFORM = linux-zero + VM_PLATFORM = linux_$(subst i386,i486,$(ZERO_LIBARCH)) + HS_ARCH = zero + ARCH = zero +endif + # ia64 ifeq ($(ARCH), ia64) ARCH_DATA_MODEL = 64 @@ -93,21 +104,25 @@ JDK_INCLUDE_SUBDIR=linux VM_DEBUG=jvmg EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html + +# client and server subdirectories have symbolic links to ../libjsig.so +EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.so + EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt -EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjsig.so EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.so -ifeq ($(ARCH_DATA_MODEL), 32) - EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjsig.so - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so - EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so - EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar -else - ifeq ($(ARCH),ia64) - else - EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so - EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar +ifneq ($(ZERO_BUILD), true) + ifeq ($(ARCH_DATA_MODEL), 32) + EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client + EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt + EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so + EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so + EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar + else + ifeq ($(ARCH),ia64) + else + EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so + EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar endif + endif endif diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make index 537ce95ffa0..eeb7cd5dd16 100644 --- a/hotspot/make/linux/makefiles/gcc.make +++ b/hotspot/make/linux/makefiles/gcc.make @@ -52,6 +52,9 @@ VM_PICFLAG/LIBJVM = $(PICFLAG) VM_PICFLAG/AOUT = VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) +ifeq ($(ZERO_BUILD), true) +CFLAGS += $(LIBFFI_CFLAGS) +endif CFLAGS += $(VM_PICFLAG) CFLAGS += -fno-rtti CFLAGS += -fno-exceptions @@ -64,6 +67,7 @@ ARCHFLAG/amd64 = -m64 ARCHFLAG/ia64 = ARCHFLAG/sparc = -m32 -mcpu=v9 ARCHFLAG/sparcv9 = -m64 -mcpu=v9 +ARCHFLAG/zero = $(ZERO_ARCHFLAG) CFLAGS += $(ARCHFLAG) AOUT_FLAGS += $(ARCHFLAG) diff --git a/hotspot/make/linux/makefiles/sa.make b/hotspot/make/linux/makefiles/sa.make index 0b5b5ceff4c..4f3a3ff4ce9 100644 --- a/hotspot/make/linux/makefiles/sa.make +++ b/hotspot/make/linux/makefiles/sa.make @@ -52,10 +52,10 @@ SA_BUILD_VERSION_PROP = "sun.jvm.hotspot.runtime.VM.saBuildVersion=$(SA_BUILD_VE SA_PROPERTIES = $(SA_CLASSDIR)/sa.properties # if $(AGENT_DIR) does not exist, we don't build SA -# also, we don't build SA on Itanium. +# also, we don't build SA on Itanium or zero. all: - if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" ] ; then \ + if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" -a "$(SRCARCH)" != "zero" ] ; then \ $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \ fi diff --git a/hotspot/make/linux/makefiles/saproc.make b/hotspot/make/linux/makefiles/saproc.make index db05d137396..696157969ea 100644 --- a/hotspot/make/linux/makefiles/saproc.make +++ b/hotspot/make/linux/makefiles/saproc.make @@ -49,10 +49,10 @@ ifeq ($(DEBUG_BINARIES), true) endif # if $(AGENT_DIR) does not exist, we don't build SA -# also, we don't build SA on Itanium. +# also, we don't build SA on Itanium or zero. checkAndBuildSA: - $(QUIETLY) if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" ] ; then \ + $(QUIETLY) if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" -a "$(SRCARCH)" != "zero" ] ; then \ $(MAKE) -f vm.make $(LIBSAPROC); \ fi diff --git a/hotspot/make/linux/makefiles/top.make b/hotspot/make/linux/makefiles/top.make index e8490fa0327..d85cc052f77 100644 --- a/hotspot/make/linux/makefiles/top.make +++ b/hotspot/make/linux/makefiles/top.make @@ -74,6 +74,7 @@ Include_DBs/CORE = $(VM)/includeDB_core $(Include_DBs/GC) \ Include_DBs/COMPILER1 = $(Include_DBs/CORE) $(VM)/includeDB_compiler1 Include_DBs/COMPILER2 = $(Include_DBs/CORE) $(VM)/includeDB_compiler2 Include_DBs/TIERED = $(Include_DBs/CORE) $(VM)/includeDB_compiler1 $(VM)/includeDB_compiler2 +Include_DBs/ZERO = $(Include_DBs/CORE) $(VM)/includeDB_zero Include_DBs = $(Include_DBs/$(TYPE)) Cached_plat = $(GENERATED)/platform.current diff --git a/hotspot/make/linux/makefiles/vm.make b/hotspot/make/linux/makefiles/vm.make index dc09e17b6ca..641d0d79514 100644 --- a/hotspot/make/linux/makefiles/vm.make +++ b/hotspot/make/linux/makefiles/vm.make @@ -40,7 +40,11 @@ GENERATED = ../generated include $(GENERATED)/Dependencies # read machine-specific adjustments (%%% should do this via buildtree.make?) -include $(MAKEFILES_DIR)/$(BUILDARCH).make +ifeq ($(ZERO_BUILD), true) + include $(MAKEFILES_DIR)/zeroshark.make +else + include $(MAKEFILES_DIR)/$(BUILDARCH).make +endif # set VPATH so make knows where to look for source files # Src_Dirs is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm @@ -124,7 +128,11 @@ mapfile_reorder : mapfile $(REORDERFILE) rm -f $@ cat $^ > $@ -STATIC_CXX = true +ifeq ($(ZERO_LIBARCH), ppc64) + STATIC_CXX = false +else + STATIC_CXX = true +endif ifeq ($(LINK_INTO),AOUT) LIBJVM.o = @@ -148,6 +156,9 @@ else LIBS_VM += $(LIBS) endif +ifeq ($(ZERO_BUILD), true) + LIBS_VM += $(LIBFFI_LIBS) +endif LINK_VM = $(LINK_LIB.c) diff --git a/jaxws/src/share/classes/com/sun/xml/internal/bind/v2/schemagen/Messages.properties b/hotspot/make/linux/makefiles/zero.make similarity index 74% rename from jaxws/src/share/classes/com/sun/xml/internal/bind/v2/schemagen/Messages.properties rename to hotspot/make/linux/makefiles/zero.make index b682ad241d6..fba4cd58131 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/bind/v2/schemagen/Messages.properties +++ b/hotspot/make/linux/makefiles/zero.make @@ -1,12 +1,11 @@ # -# Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2009 Red Hat, Inc. # 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. Sun designates this -# particular file as subject to the "Classpath" exception as provided -# by Sun in the LICENSE file that accompanied this code. +# 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 @@ -21,6 +20,13 @@ # 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. +# # -ANONYMOUS_TYPE_CYCLE=Anonymous types form an infinite cycle: {0} +# Setup for Zero (non-Shark) version of VM + +# Select which includeDB files to use (in top.make) +TYPE = ZERO + +# Install libjvm.so, etc in in server directory. +VM_SUBDIR = server diff --git a/jaxws/src/share/classes/javax/xml/bind/util/Messages.properties b/hotspot/make/linux/makefiles/zeroshark.make similarity index 55% rename from jaxws/src/share/classes/javax/xml/bind/util/Messages.properties rename to hotspot/make/linux/makefiles/zeroshark.make index 4a396143d95..a16cb0ec85a 100644 --- a/jaxws/src/share/classes/javax/xml/bind/util/Messages.properties +++ b/hotspot/make/linux/makefiles/zeroshark.make @@ -1,12 +1,11 @@ # -# Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. +# Copyright 2007, 2008 Red Hat, Inc. # 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. Sun designates this -# particular file as subject to the "Classpath" exception as provided -# by Sun in the LICENSE file that accompanied this code. +# 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 @@ -22,21 +21,23 @@ # CA 95054 USA or visit www.sun.com if you need additional information or # have any questions. # +# -ValidationEventCollector.UnrecognizedSeverity = \ - Unrecognized event severity field "{0}" +# Setup common to Zero (non-Shark) and Shark versions of VM -JAXBResult.NullContext = \ - JAXBContext can not be null +# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized +OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) +# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized +OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) -JAXBResult.NullUnmarshaller = \ - Unmarshaller can not be null +# Specify that the CPU is little endian, if necessary +ifeq ($(ZERO_ENDIANNESS), little) + CFLAGS += -DVM_LITTLE_ENDIAN +endif -JAXBSource.NullContext = \ - JAXBContext can not be null +# Specify that the CPU is 64 bit, if necessary +ifeq ($(ARCH_DATA_MODEL), 64) + CFLAGS += -D_LP64=1 +endif -JAXBSource.NullContent = \ - Content object can not be null - -JAXBSource.NullMarshaller = \ - Marshaller can not be null +OPT_CFLAGS/compactingPermGenGen.o = -O1 diff --git a/hotspot/make/linux/platform_zero.in b/hotspot/make/linux/platform_zero.in new file mode 100644 index 00000000000..404ad3f9b58 --- /dev/null +++ b/hotspot/make/linux/platform_zero.in @@ -0,0 +1,17 @@ +os_family = linux + +arch = zero + +arch_model = zero + +os_arch = linux_zero + +os_arch_model = linux_zero + +lib_arch = zero + +compiler = gcc + +gnu_dis_arch = zero + +sysdefs = -DLINUX -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\" diff --git a/hotspot/make/solaris/makefiles/defs.make b/hotspot/make/solaris/makefiles/defs.make index 625399a72b3..bf62108680e 100644 --- a/hotspot/make/solaris/makefiles/defs.make +++ b/hotspot/make/solaris/makefiles/defs.make @@ -65,16 +65,18 @@ JDK_INCLUDE_SUBDIR=solaris VM_DEBUG=jvmg EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html + +# client and server subdirectories have symbolic links to ../libjsig.so +EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.so + EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt -EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjsig.so EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.so EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.so EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.so ifeq ($(ARCH_DATA_MODEL), 32) EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjsig.so EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.so EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.so diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp index 5899e4e9ae9..e4799550fd8 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp @@ -2631,13 +2631,13 @@ void MacroAssembler::regcon_inc_ptr( RegisterOrConstant& dest, RegisterOrConstan (src.is_register() && src.as_register() == G0)) { // do nothing } else if (dest.is_register()) { - add(dest.as_register(), ensure_rs2(src, temp), dest.as_register()); + add(dest.as_register(), ensure_simm13_or_reg(src, temp), dest.as_register()); } else if (src.is_constant()) { intptr_t res = dest.as_constant() + src.as_constant(); dest = RegisterOrConstant(res); // side effect seen by caller } else { assert(temp != noreg, "cannot handle constant += register"); - add(src.as_register(), ensure_rs2(dest, temp), temp); + add(src.as_register(), ensure_simm13_or_reg(dest, temp), temp); dest = RegisterOrConstant(temp); // side effect seen by caller } } @@ -2710,7 +2710,7 @@ void MacroAssembler::lookup_interface_method(Register recv_klass, RegisterOrConstant itable_offset = itable_index; regcon_sll_ptr(itable_offset, exact_log2(itableMethodEntry::size() * wordSize)); regcon_inc_ptr(itable_offset, itableMethodEntry::method_offset_in_bytes()); - add(recv_klass, ensure_rs2(itable_offset, sethi_temp), recv_klass); + add(recv_klass, ensure_simm13_or_reg(itable_offset, sethi_temp), recv_klass); // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) { // if (scan->interface() == intf) { diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp index 163c59783b1..1e184bd4584 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp @@ -1279,6 +1279,7 @@ public: // 171 + inline void ldf(FloatRegisterImpl::Width w, Register s1, RegisterOrConstant s2, FloatRegister d); inline void ldf(FloatRegisterImpl::Width w, Register s1, Register s2, FloatRegister d); inline void ldf(FloatRegisterImpl::Width w, Register s1, int simm13a, FloatRegister d, RelocationHolder const& rspec = RelocationHolder()); @@ -1535,7 +1536,8 @@ public: // pp 222 - inline void stf( FloatRegisterImpl::Width w, FloatRegister d, Register s1, Register s2 ); + inline void stf( FloatRegisterImpl::Width w, FloatRegister d, Register s1, RegisterOrConstant s2); + inline void stf( FloatRegisterImpl::Width w, FloatRegister d, Register s1, Register s2); inline void stf( FloatRegisterImpl::Width w, FloatRegister d, Register s1, int simm13a); inline void stf( FloatRegisterImpl::Width w, FloatRegister d, const Address& a, int offset = 0); @@ -2049,12 +2051,13 @@ public: Register temp = noreg ); void regcon_sll_ptr( RegisterOrConstant& dest, RegisterOrConstant src, Register temp = noreg ); - RegisterOrConstant ensure_rs2(RegisterOrConstant rs2, Register sethi_temp) { - guarantee(sethi_temp != noreg, "constant offset overflow"); - if (is_simm13(rs2.constant_or_zero())) - return rs2; // register or short constant - set(rs2.as_constant(), sethi_temp); - return sethi_temp; + + RegisterOrConstant ensure_simm13_or_reg(RegisterOrConstant roc, Register Rtemp) { + guarantee(Rtemp != noreg, "constant offset overflow"); + if (is_simm13(roc.constant_or_zero())) + return roc; // register or short constant + set(roc.as_constant(), Rtemp); + return RegisterOrConstant(Rtemp); } // -------------------------------------------------- diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp index b9708ffb2b3..6ec0d8d2ed3 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp @@ -99,6 +99,11 @@ inline void Assembler::flush( Register s1, int simm13a) { emit_data( op(arith_op inline void Assembler::jmpl( Register s1, Register s2, Register d ) { emit_long( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | rs2(s2)); has_delay_slot(); } inline void Assembler::jmpl( Register s1, int simm13a, Register d, RelocationHolder const& rspec ) { emit_data( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec); has_delay_slot(); } +inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, RegisterOrConstant s2, FloatRegister d) { + if (s2.is_register()) ldf(w, s1, s2.as_register(), d); + else ldf(w, s1, s2.as_constant(), d); +} + inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, Register s2, FloatRegister d) { emit_long( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | rs2(s2) ); } inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, int simm13a, FloatRegister d, RelocationHolder const& rspec) { emit_data( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec); } @@ -224,6 +229,11 @@ inline void Assembler::sethi( int imm22a, Register d, RelocationHolder const& rs // pp 222 +inline void Assembler::stf( FloatRegisterImpl::Width w, FloatRegister d, Register s1, RegisterOrConstant s2) { + if (s2.is_register()) stf(w, d, s1, s2.as_register()); + else stf(w, d, s1, s2.as_constant()); +} + inline void Assembler::stf( FloatRegisterImpl::Width w, FloatRegister d, Register s1, Register s2) { emit_long( op(ldst_op) | fd(d, w) | alt_op3(stf_op3, w) | rs1(s1) | rs2(s2) ); } inline void Assembler::stf( FloatRegisterImpl::Width w, FloatRegister d, Register s1, int simm13a) { emit_data( op(ldst_op) | fd(d, w) | alt_op3(stf_op3, w) | rs1(s1) | immed(true) | simm(simm13a, 13)); } @@ -284,6 +294,7 @@ inline void Assembler::stx(Register d, const Address& a, int offset) { inline void Assembler::stb(Register d, Register s1, RegisterOrConstant s2) { stb(d, Address(s1, s2)); } inline void Assembler::sth(Register d, Register s1, RegisterOrConstant s2) { sth(d, Address(s1, s2)); } +inline void Assembler::stw(Register d, Register s1, RegisterOrConstant s2) { stw(d, Address(s1, s2)); } inline void Assembler::stx(Register d, Register s1, RegisterOrConstant s2) { stx(d, Address(s1, s2)); } inline void Assembler::std(Register d, Register s1, RegisterOrConstant s2) { std(d, Address(s1, s2)); } inline void Assembler::st( Register d, Register s1, RegisterOrConstant s2) { st( d, Address(s1, s2)); } diff --git a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp index 6dd0a1feb85..19cd413d043 100644 --- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp @@ -107,7 +107,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ // are saved in register windows - I's and L's in the caller's frame and O's in the stub frame // (as the stub's I's) when the runtime routine called by the stub creates its frame. int i; - // Always make the frame size 16 bytr aligned. + // Always make the frame size 16 byte aligned. int frame_size = round_to(additional_frame_words + register_save_size, 16); // OopMap frame size is in c2 stack slots (sizeof(jint)) not bytes or words int frame_size_in_slots = frame_size / sizeof(jint); @@ -201,15 +201,14 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ __ stx(G5, SP, ccr_offset+STACK_BIAS); __ stxfsr(SP, fsr_offset+STACK_BIAS); - // Save all the FP registers + // Save all the FP registers: 32 doubles (32 floats correspond to the 2 halves of the first 16 doubles) int offset = d00_offset; - for( int i=0; i<64; i+=2 ) { + for( int i=0; iset_callee_saved(VMRegImpl::stack2reg(offset>>2), f->as_VMReg()); - if (true) { - map->set_callee_saved(VMRegImpl::stack2reg((offset + sizeof(float))>>2), f->as_VMReg()->next()); - } + map->set_callee_saved(VMRegImpl::stack2reg((offset + sizeof(float))>>2), f->as_VMReg()->next()); offset += sizeof(double); } @@ -224,7 +223,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ void RegisterSaver::restore_live_registers(MacroAssembler* masm) { // Restore all the FP registers - for( int i=0; i<64; i+=2 ) { + for( int i=0; ias_FloatRegister()); #else @@ -1109,8 +1105,9 @@ void AdapterGenerator::gen_i2c_adapter( // Convert stack slot to an SP offset int st_off = reg2offset(regs[i].first()) + STACK_BIAS; // Store down the shuffled stack word. Target address _is_ aligned. - if (!r_2->is_valid()) __ stf(FloatRegisterImpl::S, r_1->as_FloatRegister(), SP, st_off); - else __ stf(FloatRegisterImpl::D, r_1->as_FloatRegister(), SP, st_off); + RegisterOrConstant slot = __ ensure_simm13_or_reg(st_off, Rdisp); + if (!r_2->is_valid()) __ stf(FloatRegisterImpl::S, r_1->as_FloatRegister(), SP, slot); + else __ stf(FloatRegisterImpl::D, r_1->as_FloatRegister(), SP, slot); } } bool made_space = false; @@ -3216,9 +3213,8 @@ void SharedRuntime::generate_deopt_blob() { Register Oreturn0 = O0; Register Oreturn1 = O1; Register O2UnrollBlock = O2; - Register O3tmp = O3; - Register I5exception_tmp = I5; - Register G4exception_tmp = G4_scratch; + Register L0deopt_mode = L0; + Register G4deopt_mode = G4_scratch; int frame_size_words; Address saved_Freturn0_addr(FP, -sizeof(double) + STACK_BIAS); #if !defined(_LP64) && defined(COMPILER2) @@ -3268,7 +3264,7 @@ void SharedRuntime::generate_deopt_blob() { map = RegisterSaver::save_live_registers(masm, 0, &frame_size_words); __ ba(false, cont); - __ delayed()->mov(Deoptimization::Unpack_deopt, I5exception_tmp); + __ delayed()->mov(Deoptimization::Unpack_deopt, L0deopt_mode); int exception_offset = __ offset() - start; @@ -3319,7 +3315,7 @@ void SharedRuntime::generate_deopt_blob() { #endif __ ba(false, cont); - __ delayed()->mov(Deoptimization::Unpack_exception, I5exception_tmp);; + __ delayed()->mov(Deoptimization::Unpack_exception, L0deopt_mode);; // // Reexecute entry, similar to c2 uncommon trap @@ -3329,7 +3325,7 @@ void SharedRuntime::generate_deopt_blob() { // No need to update oop_map as each call to save_live_registers will produce identical oopmap (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_words); - __ mov(Deoptimization::Unpack_reexecute, I5exception_tmp); + __ mov(Deoptimization::Unpack_reexecute, L0deopt_mode); __ bind(cont); @@ -3352,14 +3348,14 @@ void SharedRuntime::generate_deopt_blob() { // NOTE: we know that only O0/O1 will be reloaded by restore_result_registers // so this move will survive - __ mov(I5exception_tmp, G4exception_tmp); + __ mov(L0deopt_mode, G4deopt_mode); __ mov(O0, O2UnrollBlock->after_save()); RegisterSaver::restore_result_registers(masm); Label noException; - __ cmp(G4exception_tmp, Deoptimization::Unpack_exception); // Was exception pending? + __ cmp(G4deopt_mode, Deoptimization::Unpack_exception); // Was exception pending? __ br(Assembler::notEqual, false, Assembler::pt, noException); __ delayed()->nop(); @@ -3393,10 +3389,10 @@ void SharedRuntime::generate_deopt_blob() { } #endif __ set_last_Java_frame(SP, noreg); - __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames), G2_thread, G4exception_tmp); + __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames), G2_thread, G4deopt_mode); #else // LP64 uses g4 in set_last_Java_frame - __ mov(G4exception_tmp, O1); + __ mov(G4deopt_mode, O1); __ set_last_Java_frame(SP, G0); __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, Deoptimization::unpack_frames), G2_thread, O1); #endif @@ -3449,7 +3445,6 @@ void SharedRuntime::generate_uncommon_trap_blob() { #endif MacroAssembler* masm = new MacroAssembler(&buffer); Register O2UnrollBlock = O2; - Register O3tmp = O3; Register O2klass_index = O2; // diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 4852ee53210..2c56575e09f 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -193,38 +193,38 @@ reg_def R_F31( SOC, SOC, Op_RegF, 31, F31->as_VMReg()); // I believe we can't handle callee-save doubles D32 and up until // the place in the sparc stack crawler that asserts on the 255 is // fixed up. -reg_def R_D32x(SOC, SOC, Op_RegD,255, F32->as_VMReg()); -reg_def R_D32 (SOC, SOC, Op_RegD, 1, F32->as_VMReg()->next()); -reg_def R_D34x(SOC, SOC, Op_RegD,255, F34->as_VMReg()); -reg_def R_D34 (SOC, SOC, Op_RegD, 3, F34->as_VMReg()->next()); -reg_def R_D36x(SOC, SOC, Op_RegD,255, F36->as_VMReg()); -reg_def R_D36 (SOC, SOC, Op_RegD, 5, F36->as_VMReg()->next()); -reg_def R_D38x(SOC, SOC, Op_RegD,255, F38->as_VMReg()); -reg_def R_D38 (SOC, SOC, Op_RegD, 7, F38->as_VMReg()->next()); -reg_def R_D40x(SOC, SOC, Op_RegD,255, F40->as_VMReg()); -reg_def R_D40 (SOC, SOC, Op_RegD, 9, F40->as_VMReg()->next()); -reg_def R_D42x(SOC, SOC, Op_RegD,255, F42->as_VMReg()); -reg_def R_D42 (SOC, SOC, Op_RegD, 11, F42->as_VMReg()->next()); -reg_def R_D44x(SOC, SOC, Op_RegD,255, F44->as_VMReg()); -reg_def R_D44 (SOC, SOC, Op_RegD, 13, F44->as_VMReg()->next()); -reg_def R_D46x(SOC, SOC, Op_RegD,255, F46->as_VMReg()); -reg_def R_D46 (SOC, SOC, Op_RegD, 15, F46->as_VMReg()->next()); -reg_def R_D48x(SOC, SOC, Op_RegD,255, F48->as_VMReg()); -reg_def R_D48 (SOC, SOC, Op_RegD, 17, F48->as_VMReg()->next()); -reg_def R_D50x(SOC, SOC, Op_RegD,255, F50->as_VMReg()); -reg_def R_D50 (SOC, SOC, Op_RegD, 19, F50->as_VMReg()->next()); -reg_def R_D52x(SOC, SOC, Op_RegD,255, F52->as_VMReg()); -reg_def R_D52 (SOC, SOC, Op_RegD, 21, F52->as_VMReg()->next()); -reg_def R_D54x(SOC, SOC, Op_RegD,255, F54->as_VMReg()); -reg_def R_D54 (SOC, SOC, Op_RegD, 23, F54->as_VMReg()->next()); -reg_def R_D56x(SOC, SOC, Op_RegD,255, F56->as_VMReg()); -reg_def R_D56 (SOC, SOC, Op_RegD, 25, F56->as_VMReg()->next()); -reg_def R_D58x(SOC, SOC, Op_RegD,255, F58->as_VMReg()); -reg_def R_D58 (SOC, SOC, Op_RegD, 27, F58->as_VMReg()->next()); -reg_def R_D60x(SOC, SOC, Op_RegD,255, F60->as_VMReg()); -reg_def R_D60 (SOC, SOC, Op_RegD, 29, F60->as_VMReg()->next()); -reg_def R_D62x(SOC, SOC, Op_RegD,255, F62->as_VMReg()); -reg_def R_D62 (SOC, SOC, Op_RegD, 31, F62->as_VMReg()->next()); +reg_def R_D32 (SOC, SOC, Op_RegD, 1, F32->as_VMReg()); +reg_def R_D32x(SOC, SOC, Op_RegD,255, F32->as_VMReg()->next()); +reg_def R_D34 (SOC, SOC, Op_RegD, 3, F34->as_VMReg()); +reg_def R_D34x(SOC, SOC, Op_RegD,255, F34->as_VMReg()->next()); +reg_def R_D36 (SOC, SOC, Op_RegD, 5, F36->as_VMReg()); +reg_def R_D36x(SOC, SOC, Op_RegD,255, F36->as_VMReg()->next()); +reg_def R_D38 (SOC, SOC, Op_RegD, 7, F38->as_VMReg()); +reg_def R_D38x(SOC, SOC, Op_RegD,255, F38->as_VMReg()->next()); +reg_def R_D40 (SOC, SOC, Op_RegD, 9, F40->as_VMReg()); +reg_def R_D40x(SOC, SOC, Op_RegD,255, F40->as_VMReg()->next()); +reg_def R_D42 (SOC, SOC, Op_RegD, 11, F42->as_VMReg()); +reg_def R_D42x(SOC, SOC, Op_RegD,255, F42->as_VMReg()->next()); +reg_def R_D44 (SOC, SOC, Op_RegD, 13, F44->as_VMReg()); +reg_def R_D44x(SOC, SOC, Op_RegD,255, F44->as_VMReg()->next()); +reg_def R_D46 (SOC, SOC, Op_RegD, 15, F46->as_VMReg()); +reg_def R_D46x(SOC, SOC, Op_RegD,255, F46->as_VMReg()->next()); +reg_def R_D48 (SOC, SOC, Op_RegD, 17, F48->as_VMReg()); +reg_def R_D48x(SOC, SOC, Op_RegD,255, F48->as_VMReg()->next()); +reg_def R_D50 (SOC, SOC, Op_RegD, 19, F50->as_VMReg()); +reg_def R_D50x(SOC, SOC, Op_RegD,255, F50->as_VMReg()->next()); +reg_def R_D52 (SOC, SOC, Op_RegD, 21, F52->as_VMReg()); +reg_def R_D52x(SOC, SOC, Op_RegD,255, F52->as_VMReg()->next()); +reg_def R_D54 (SOC, SOC, Op_RegD, 23, F54->as_VMReg()); +reg_def R_D54x(SOC, SOC, Op_RegD,255, F54->as_VMReg()->next()); +reg_def R_D56 (SOC, SOC, Op_RegD, 25, F56->as_VMReg()); +reg_def R_D56x(SOC, SOC, Op_RegD,255, F56->as_VMReg()->next()); +reg_def R_D58 (SOC, SOC, Op_RegD, 27, F58->as_VMReg()); +reg_def R_D58x(SOC, SOC, Op_RegD,255, F58->as_VMReg()->next()); +reg_def R_D60 (SOC, SOC, Op_RegD, 29, F60->as_VMReg()); +reg_def R_D60x(SOC, SOC, Op_RegD,255, F60->as_VMReg()->next()); +reg_def R_D62 (SOC, SOC, Op_RegD, 31, F62->as_VMReg()); +reg_def R_D62x(SOC, SOC, Op_RegD,255, F62->as_VMReg()->next()); // ---------------------------- @@ -3016,7 +3016,7 @@ enc_class enc_Array_Equals(o0RegP ary1, o1RegP ary2, g3RegP tmp1, notemp_iRegI r // return true if the same array __ cmp(ary1_reg, ary2_reg); - __ br(Assembler::equal, true, Assembler::pn, Ldone); + __ brx(Assembler::equal, true, Assembler::pn, Ldone); __ delayed()->add(G0, 1, result_reg); // equal __ br_null(ary1_reg, true, Assembler::pn, Ldone); @@ -9419,8 +9419,9 @@ instruct countLeadingZerosI(iRegI dst, iRegI src, iRegI tmp, flagsReg cr) %{ // x |= (x >> 8); // x |= (x >> 16); // return (WORDBITS - popc(x)); - format %{ "SRL $src,1,$dst\t! count leading zeros (int)\n\t" - "OR $src,$tmp,$dst\n\t" + format %{ "SRL $src,1,$tmp\t! count leading zeros (int)\n\t" + "SRL $src,0,$dst\t! 32-bit zero extend\n\t" + "OR $dst,$tmp,$dst\n\t" "SRL $dst,2,$tmp\n\t" "OR $dst,$tmp,$dst\n\t" "SRL $dst,4,$tmp\n\t" @@ -9437,7 +9438,8 @@ instruct countLeadingZerosI(iRegI dst, iRegI src, iRegI tmp, flagsReg cr) %{ Register Rsrc = $src$$Register; Register Rtmp = $tmp$$Register; __ srl(Rsrc, 1, Rtmp); - __ or3(Rsrc, Rtmp, Rdst); + __ srl(Rsrc, 0, Rdst); + __ or3(Rdst, Rtmp, Rdst); __ srl(Rdst, 2, Rtmp); __ or3(Rdst, Rtmp, Rdst); __ srl(Rdst, 4, Rtmp); @@ -9465,7 +9467,7 @@ instruct countLeadingZerosL(iRegI dst, iRegL src, iRegL tmp, flagsReg cr) %{ // x |= (x >> 16); // x |= (x >> 32); // return (WORDBITS - popc(x)); - format %{ "SRLX $src,1,$dst\t! count leading zeros (long)\n\t" + format %{ "SRLX $src,1,$tmp\t! count leading zeros (long)\n\t" "OR $src,$tmp,$dst\n\t" "SRLX $dst,2,$tmp\n\t" "OR $dst,$tmp,$dst\n\t" diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index b742a5a36a7..aa93bc8f23c 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -8214,6 +8214,15 @@ void MacroAssembler::store_heap_oop(Address dst, Register src) { } } +// Used for storing NULLs. +void MacroAssembler::store_heap_oop_null(Address dst) { + if (UseCompressedOops) { + movl(dst, (int32_t)NULL_WORD); + } else { + movslq(dst, (int32_t)NULL_WORD); + } +} + // Algorithm must match oop.inline.hpp encode_heap_oop. void MacroAssembler::encode_heap_oop(Register r) { assert (UseCompressedOops, "should be compressed"); @@ -8634,8 +8643,10 @@ void MacroAssembler::char_arrays_equals(bool is_array_equ, Register ary1, Regist if (is_array_equ) { // Need additional checks for arrays_equals. - andptr(ary1, ary2); - jcc(Assembler::zero, FALSE_LABEL); // One pointer is NULL + testptr(ary1, ary1); + jcc(Assembler::zero, FALSE_LABEL); + testptr(ary2, ary2); + jcc(Assembler::zero, FALSE_LABEL); // Check the lengths movl(limit, Address(ary1, length_offset)); diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index 2d61a3cf0aa..7aa0d0877a4 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1682,6 +1682,17 @@ class MacroAssembler: public Assembler { void load_heap_oop(Register dst, Address src); void store_heap_oop(Address dst, Register src); + + // This dummy is to prevent a call to store_heap_oop from + // converting a zero (like NULL) into a Register by giving + // the compiler two choices it can't resolve + + void store_heap_oop(Address dst, void* dummy); + + // Used for storing NULL. All other oop constants should be + // stored using routines that take a jobject. + void store_heap_oop_null(Address dst); + void encode_heap_oop(Register r); void decode_heap_oop(Register r); void encode_heap_oop_not_null(Register r); diff --git a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp index a45af4ad321..a682a81b833 100644 --- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp +++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp @@ -271,9 +271,15 @@ void MethodHandles::remove_arg_slots(MacroAssembler* _masm, void trace_method_handle_stub(const char* adaptername, oopDesc* mh, intptr_t* entry_sp, - intptr_t* saved_sp) { + intptr_t* saved_sp, + intptr_t* saved_bp) { // called as a leaf from native code: do not block the JVM! - printf("MH %s "PTR_FORMAT" "PTR_FORMAT" "INTX_FORMAT"\n", adaptername, (void*)mh, entry_sp, entry_sp - saved_sp); + intptr_t* last_sp = (intptr_t*) saved_bp[frame::interpreter_frame_last_sp_offset]; + intptr_t* base_sp = (intptr_t*) saved_bp[frame::interpreter_frame_monitor_block_top_offset]; + printf("MH %s mh="INTPTR_FORMAT" sp=("INTPTR_FORMAT"+"INTX_FORMAT") stack_size="INTX_FORMAT" bp="INTPTR_FORMAT"\n", + adaptername, (intptr_t)mh, (intptr_t)entry_sp, (intptr_t)(saved_sp - entry_sp), (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp); + if (last_sp != saved_sp) + printf("*** last_sp="INTPTR_FORMAT"\n", (intptr_t)last_sp); } #endif //PRODUCT @@ -293,6 +299,10 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan Register rbx_temp = rbx; Register rdx_temp = rdx; + // This guy is set up by prepare_to_jump_from_interpreted (from interpreted calls) + // and gen_c2i_adapter (from compiled calls): + Register saved_last_sp = LP64_ONLY(r13) NOT_LP64(rsi); + guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets"); // some handy addresses @@ -315,6 +325,8 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan assert(tag_offset = wordSize, "stack grows as expected"); } + const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes(); + if (have_entry(ek)) { __ nop(); // empty stubs make SG sick return; @@ -328,45 +340,65 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ push(rax); __ push(rbx); __ push(rcx); __ push(rdx); __ push(rsi); __ push(rdi); __ lea(rax, Address(rsp, wordSize*6)); // entry_sp // arguments: + __ push(rbp); // interpreter frame pointer __ push(rsi); // saved_sp __ push(rax); // entry_sp __ push(rcx); // mh __ push(rcx); __ movptr(Address(rsp, 0), (intptr_t)entry_name(ek)); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub), 4); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub), 5); __ pop(rdi); __ pop(rsi); __ pop(rdx); __ pop(rcx); __ pop(rbx); __ pop(rax); } #endif //PRODUCT switch ((int) ek) { - case _check_mtype: + case _raise_exception: { - // this stub is special, because it requires a live mtype argument - Register rax_mtype = rax; + // Not a real MH entry, but rather shared code for raising an exception. + // Extra local arguments are pushed on stack, as required type at TOS+8, + // failing object (or NULL) at TOS+4, failing bytecode type at TOS. + // Beyond those local arguments are the PC, of course. + Register rdx_code = rdx_temp; + Register rcx_fail = rcx_recv; + Register rax_want = rax_argslot; + Register rdi_pc = rdi; + __ pop(rdx_code); // TOS+0 + __ pop(rcx_fail); // TOS+4 + __ pop(rax_want); // TOS+8 + __ pop(rdi_pc); // caller PC - // emit WrongMethodType path first, to enable jccb back-branch - Label wrong_method_type; - __ bind(wrong_method_type); - __ movptr(rdx_temp, ExternalAddress((address) &_entries[_wrong_method_type])); - __ jmp(Address(rdx_temp, MethodHandleEntry::from_interpreted_entry_offset_in_bytes())); - __ hlt(); + __ mov(rsp, rsi); // cut the stack back to where the caller started - interp_entry = __ pc(); - __ check_method_handle_type(rax_mtype, rcx_recv, rdx_temp, wrong_method_type); - // now rax_mtype is dead; subsequent stubs will use it as a temp + // Repush the arguments as if coming from the interpreter. + if (TaggedStackInterpreter) __ push(frame::tag_for_basic_type(T_INT)); + __ push(rdx_code); + if (TaggedStackInterpreter) __ push(frame::tag_for_basic_type(T_OBJECT)); + __ push(rcx_fail); + if (TaggedStackInterpreter) __ push(frame::tag_for_basic_type(T_OBJECT)); + __ push(rax_want); - __ jump_to_method_handle_entry(rcx_recv, rdx_temp); - } - break; + Register rbx_method = rbx_temp; + Label no_method; + // FIXME: fill in _raise_exception_method with a suitable sun.dyn method + __ movptr(rbx_method, ExternalAddress((address) &_raise_exception_method)); + __ testptr(rbx_method, rbx_method); + __ jcc(Assembler::zero, no_method); + int jobject_oop_offset = 0; + __ movptr(rbx_method, Address(rbx_method, jobject_oop_offset)); // dereference the jobject + __ testptr(rbx_method, rbx_method); + __ jcc(Assembler::zero, no_method); + __ verify_oop(rbx_method); + __ push(rdi_pc); // and restore caller PC + __ jmp(rbx_method_fie); - case _wrong_method_type: - { - // this stub is special, because it requires a live mtype argument - Register rax_mtype = rax; - - interp_entry = __ pc(); - __ push(rax_mtype); // required mtype - __ push(rcx_recv); // random mh (1st stacked argument) + // If we get here, the Java runtime did not do its job of creating the exception. + // Do something that is at least causes a valid throw from the interpreter. + __ bind(no_method); + __ pop(rax_want); + if (TaggedStackInterpreter) __ pop(rcx_fail); + __ pop(rcx_fail); + __ push(rax_want); + __ push(rcx_fail); __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry())); } break; @@ -442,7 +474,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ load_klass(rax_klass, rcx_recv); __ verify_oop(rax_klass); - Register rcx_temp = rcx_recv; + Register rdi_temp = rdi; Register rbx_method = rbx_index; // get interface klass @@ -451,7 +483,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ lookup_interface_method(rax_klass, rdx_intf, // note: next two args must be the same: rbx_index, rbx_method, - rcx_temp, + rdi_temp, no_such_interface); __ verify_oop(rbx_method); @@ -461,7 +493,10 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ bind(no_such_interface); // Throw an exception. // For historical reasons, it will be IncompatibleClassChangeError. - __ should_not_reach_here(); // %%% FIXME NYI + __ pushptr(Address(rdx_intf, java_mirror_offset)); // required interface + __ push(rcx_recv); // bad receiver + __ push((int)Bytecodes::_invokeinterface); // who is complaining? + __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); } break; @@ -524,6 +559,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan break; case _adapter_retype_only: + case _adapter_retype_raw: // immediately jump to the next MH layer: __ movptr(rcx_recv, rcx_mh_vmtarget); __ verify_oop(rcx_recv); @@ -545,10 +581,6 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ movptr(rbx_klass, rcx_amh_argument); // this is a Class object! __ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes())); - // get the new MH: - __ movptr(rcx_recv, rcx_mh_vmtarget); - // (now we are done with the old MH) - Label done; __ movptr(rdx_temp, vmarg); __ testl(rdx_temp, rdx_temp); @@ -558,17 +590,23 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan // live at this point: // - rbx_klass: klass required by the target method // - rdx_temp: argument klass to test - // - rcx_recv: method handle to invoke (after cast succeeds) + // - rcx_recv: adapter method handle __ check_klass_subtype(rdx_temp, rbx_klass, rax_argslot, done); // If we get here, the type check failed! // Call the wrong_method_type stub, passing the failing argument type in rax. Register rax_mtype = rax_argslot; - __ push(rbx_klass); // missed klass (required type) - __ push(rdx_temp); // bad actual type (1st stacked argument) - __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry())); + __ movl(rax_argslot, rcx_amh_vmargslot); // reload argslot field + __ movptr(rdx_temp, vmarg); + + __ pushptr(rcx_amh_argument); // required class + __ push(rdx_temp); // bad object + __ push((int)Bytecodes::_checkcast); // who is complaining? + __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); __ bind(done); + // get the new MH: + __ movptr(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } break; @@ -1107,11 +1145,17 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ bind(bad_array_klass); UNPUSH_RSI_RDI; - __ stop("bad array klass NYI"); + __ pushptr(Address(rdx_array_klass, java_mirror_offset)); // required type + __ pushptr(vmarg); // bad array + __ push((int)Bytecodes::_aaload); // who is complaining? + __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); __ bind(bad_array_length); UNPUSH_RSI_RDI; - __ stop("bad array length NYI"); + __ push(rcx_recv); // AMH requiring a certain length + __ pushptr(vmarg); // bad array + __ push((int)Bytecodes::_arraylength); // who is complaining? + __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); #undef UNPUSH_RSI_RDI } diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index 1f20ee4b894..b78f0e2a066 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -92,8 +92,7 @@ address TemplateInterpreterGenerator::generate_ClassCastException_handler() { return entry; } -// Arguments are: required type at TOS+8, failing object (or NULL) at TOS+4. -// pc at TOS (just for debugging) +// Arguments are: required type at TOS+4, failing object (or NULL) at TOS. address TemplateInterpreterGenerator::generate_WrongMethodType_handler() { address entry = __ pc(); diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp index 48285f46ddd..1180227b59f 100644 --- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp @@ -139,7 +139,7 @@ static void do_oop_store(InterpreterMacroAssembler* _masm, } __ g1_write_barrier_pre(rdx, r8, rbx, val != noreg); if (val == noreg) { - __ store_heap_oop(Address(rdx, 0), NULL_WORD); + __ store_heap_oop_null(Address(rdx, 0)); } else { __ store_heap_oop(Address(rdx, 0), val); __ g1_write_barrier_post(rdx, val, r8, rbx); @@ -152,7 +152,7 @@ static void do_oop_store(InterpreterMacroAssembler* _masm, case BarrierSet::CardTableExtension: { if (val == noreg) { - __ store_heap_oop(obj, NULL_WORD); + __ store_heap_oop_null(obj); } else { __ store_heap_oop(obj, val); // flatten object address if needed @@ -168,7 +168,7 @@ static void do_oop_store(InterpreterMacroAssembler* _masm, case BarrierSet::ModRef: case BarrierSet::Other: if (val == noreg) { - __ store_heap_oop(obj, NULL_WORD); + __ store_heap_oop_null(obj); } else { __ store_heap_oop(obj, val); } diff --git a/hotspot/src/cpu/zero/vm/assembler_zero.cpp b/hotspot/src/cpu/zero/vm/assembler_zero.cpp new file mode 100644 index 00000000000..808069a5825 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/assembler_zero.cpp @@ -0,0 +1,77 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_assembler_zero.cpp.incl" + +int AbstractAssembler::code_fill_byte() { + return 0; +} + +void Assembler::pd_patch_instruction(address branch, address target) { + ShouldNotCallThis(); +} + +#ifndef PRODUCT +void Assembler::pd_print_patched_instruction(address branch) { + ShouldNotCallThis(); +} +#endif // PRODUCT + +void MacroAssembler::align(int modulus) { + while (offset() % modulus != 0) + emit_byte(AbstractAssembler::code_fill_byte()); +} + +void MacroAssembler::bang_stack_with_offset(int offset) { + ShouldNotCallThis(); +} + +void MacroAssembler::advance(int bytes) { + _code_pos += bytes; + sync(); +} + +RegisterOrConstant MacroAssembler::delayed_value_impl( + intptr_t* delayed_value_addr, Register tmpl, int offset) { + ShouldNotCallThis(); +} + +void MacroAssembler::store_oop(jobject obj) { + code_section()->relocate(pc(), oop_Relocation::spec_for_immediate()); + emit_address((address) obj); +} + +static void should_not_call() { + report_should_not_call(__FILE__, __LINE__); +} + +address ShouldNotCallThisStub() { + return (address) should_not_call; +} + +address ShouldNotCallThisEntry() { + return (address) should_not_call; +} diff --git a/hotspot/src/cpu/zero/vm/assembler_zero.hpp b/hotspot/src/cpu/zero/vm/assembler_zero.hpp new file mode 100644 index 00000000000..bf2227768cb --- /dev/null +++ b/hotspot/src/cpu/zero/vm/assembler_zero.hpp @@ -0,0 +1,64 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +// In normal, CPU-specific ports of HotSpot these two classes are used +// for generating assembly language. We don't do any of this in zero, +// of course, but we do sneak entry points around in CodeBuffers so we +// generate those here. + +class Assembler : public AbstractAssembler { + public: + Assembler(CodeBuffer* code) : AbstractAssembler(code) {} + + public: + void pd_patch_instruction(address branch, address target); +#ifndef PRODUCT + static void pd_print_patched_instruction(address branch); +#endif // PRODUCT +}; + +class MacroAssembler : public Assembler { + public: + MacroAssembler(CodeBuffer* code) : Assembler(code) {} + + public: + void align(int modulus); + void bang_stack_with_offset(int offset); + bool needs_explicit_null_check(intptr_t offset); + RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr, + Register tmp, int offset); + public: + void advance(int bytes); + void store_oop(jobject obj); +}; + +#ifdef ASSERT +inline bool AbstractAssembler::pd_check_instruction_mark() { + ShouldNotCallThis(); +} +#endif + +address ShouldNotCallThisStub(); +address ShouldNotCallThisEntry(); diff --git a/jdk/test/javax/management/mxbean/customtypes/CustomMXBean.java b/hotspot/src/cpu/zero/vm/assembler_zero.inline.hpp similarity index 83% rename from jdk/test/javax/management/mxbean/customtypes/CustomMXBean.java rename to hotspot/src/cpu/zero/vm/assembler_zero.inline.hpp index 0664827ca7b..1fba6011651 100644 --- a/jdk/test/javax/management/mxbean/customtypes/CustomMXBean.java +++ b/hotspot/src/cpu/zero/vm/assembler_zero.inline.hpp @@ -1,5 +1,6 @@ /* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,12 +20,7 @@ * 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. + * */ -// CustomMXBean.java - see CustomTypeTest - -package customtypes; - -public interface CustomMXBean { - public Integer getX(); -} +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp new file mode 100644 index 00000000000..d9bef216880 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_cppInterpreter_zero.cpp.incl" + +#ifdef CC_INTERP + +const char *BytecodeInterpreter::name_of_field_at_address(address addr) { +#define DO(member) {if (addr == (address) &(member)) return XSTR(member);} + DO(_thread); + DO(_bcp); + DO(_locals); + DO(_constants); + DO(_method); + DO(_mdx); + DO(_stack); + DO(_msg); + DO(_result); + DO(_prev_link); + DO(_oop_temp); + DO(_stack_base); + DO(_stack_limit); + DO(_monitor_base); + DO(_self_link); +#undef DO + if (addr > (address) &_result && addr < (address) (&_result + 1)) + return "_result)"; + return NULL; +} + +#endif // CC_INTERP diff --git a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp new file mode 100644 index 00000000000..33649b20b96 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp @@ -0,0 +1,148 @@ +/* + * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +// Platform specific for C++ based Interpreter + +#if defined(PPC) || defined(SPARC) || defined(IA64) +#define LOTS_OF_REGS // Use plenty of registers +#else +#undef LOTS_OF_REGS // Loser platforms +#endif + + private: + interpreterState _self_link; + + public: + inline void set_locals(intptr_t* new_locals) { + _locals = new_locals; + } + inline void set_method(methodOop new_method) { + _method = new_method; + } + inline interpreterState self_link() { + return _self_link; + } + inline void set_self_link(interpreterState new_self_link) { + _self_link = new_self_link; + } + inline interpreterState prev_link() { + return _prev_link; + } + inline void set_prev_link(interpreterState new_prev_link) { + _prev_link = new_prev_link; + } + inline void set_stack_limit(intptr_t* new_stack_limit) { + _stack_limit = new_stack_limit; + } + inline void set_stack_base(intptr_t* new_stack_base) { + _stack_base = new_stack_base; + } + inline void set_monitor_base(BasicObjectLock *new_monitor_base) { + _monitor_base = new_monitor_base; + } + inline void set_thread(JavaThread* new_thread) { + _thread = new_thread; + } + inline void set_constants(constantPoolCacheOop new_constants) { + _constants = new_constants; + } + inline oop oop_temp() { + return _oop_temp; + } + inline oop *oop_temp_addr() { + return &_oop_temp; + } + inline void set_oop_temp(oop new_oop_temp) { + _oop_temp = new_oop_temp; + } + inline address callee_entry_point() { + return _result._to_call._callee_entry_point; + } + inline address osr_buf() { + return _result._osr._osr_buf; + } + inline address osr_entry() { + return _result._osr._osr_entry; + } + + public: + const char *name_of_field_at_address(address addr); + +// The frame manager handles this +#define SET_LAST_JAVA_FRAME() +#define RESET_LAST_JAVA_FRAME() + +// ZeroStack Implementation + +#undef STACK_INT +#undef STACK_FLOAT +#undef STACK_ADDR +#undef STACK_OBJECT +#undef STACK_DOUBLE +#undef STACK_LONG + +#define GET_STACK_SLOT(offset) (*((intptr_t*) &topOfStack[-(offset)])) +#define STACK_SLOT(offset) ((address) &topOfStack[-(offset)]) +#define STACK_ADDR(offset) (*((address *) &topOfStack[-(offset)])) +#define STACK_INT(offset) (*((jint*) &topOfStack[-(offset)])) +#define STACK_FLOAT(offset) (*((jfloat *) &topOfStack[-(offset)])) +#define STACK_OBJECT(offset) (*((oop *) &topOfStack [-(offset)])) +#define STACK_DOUBLE(offset) (((VMJavaVal64*) &topOfStack[-(offset)])->d) +#define STACK_LONG(offset) (((VMJavaVal64 *) &topOfStack[-(offset)])->l) + +#define SET_STACK_SLOT(value, offset) (*(intptr_t*)&topOfStack[-(offset)] = *(intptr_t*)(value)) +#define SET_STACK_ADDR(value, offset) (*((address *)&topOfStack[-(offset)]) = (value)) +#define SET_STACK_INT(value, offset) (*((jint *)&topOfStack[-(offset)]) = (value)) +#define SET_STACK_FLOAT(value, offset) (*((jfloat *)&topOfStack[-(offset)]) = (value)) +#define SET_STACK_OBJECT(value, offset) (*((oop *)&topOfStack[-(offset)]) = (value)) +#define SET_STACK_DOUBLE(value, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->d = (value)) +#define SET_STACK_DOUBLE_FROM_ADDR(addr, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->d = \ + ((VMJavaVal64*)(addr))->d) +#define SET_STACK_LONG(value, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->l = (value)) +#define SET_STACK_LONG_FROM_ADDR(addr, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->l = \ + ((VMJavaVal64*)(addr))->l) +// JavaLocals implementation + +#define LOCALS_SLOT(offset) ((intptr_t*)&locals[-(offset)]) +#define LOCALS_ADDR(offset) ((address)locals[-(offset)]) +#define LOCALS_INT(offset) (*((jint*)&locals[-(offset)])) +#define LOCALS_FLOAT(offset) (*((jfloat*)&locals[-(offset)])) +#define LOCALS_OBJECT(offset) ((oop)locals[-(offset)]) +#define LOCALS_DOUBLE(offset) (((VMJavaVal64*)&locals[-((offset) + 1)])->d) +#define LOCALS_LONG(offset) (((VMJavaVal64*)&locals[-((offset) + 1)])->l) +#define LOCALS_LONG_AT(offset) (((address)&locals[-((offset) + 1)])) +#define LOCALS_DOUBLE_AT(offset) (((address)&locals[-((offset) + 1)])) + +#define SET_LOCALS_SLOT(value, offset) (*(intptr_t*)&locals[-(offset)] = *(intptr_t *)(value)) +#define SET_LOCALS_ADDR(value, offset) (*((address *)&locals[-(offset)]) = (value)) +#define SET_LOCALS_INT(value, offset) (*((jint *)&locals[-(offset)]) = (value)) +#define SET_LOCALS_FLOAT(value, offset) (*((jfloat *)&locals[-(offset)]) = (value)) +#define SET_LOCALS_OBJECT(value, offset) (*((oop *)&locals[-(offset)]) = (value)) +#define SET_LOCALS_DOUBLE(value, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->d = (value)) +#define SET_LOCALS_LONG(value, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->l = (value)) +#define SET_LOCALS_DOUBLE_FROM_ADDR(addr, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->d = \ + ((VMJavaVal64*)(addr))->d) +#define SET_LOCALS_LONG_FROM_ADDR(addr, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->l = \ + ((VMJavaVal64*)(addr))->l) diff --git a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.inline.hpp b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.inline.hpp new file mode 100644 index 00000000000..33b5d0a931b --- /dev/null +++ b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.inline.hpp @@ -0,0 +1,301 @@ +/* + * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +// Inline interpreter functions for zero + +inline jfloat BytecodeInterpreter::VMfloatAdd(jfloat op1, jfloat op2) { + return op1 + op2; +} + +inline jfloat BytecodeInterpreter::VMfloatSub(jfloat op1, jfloat op2) { + return op1 - op2; +} + +inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) { + return op1 * op2; +} + +inline jfloat BytecodeInterpreter::VMfloatDiv(jfloat op1, jfloat op2) { + return op1 / op2; +} + +inline jfloat BytecodeInterpreter::VMfloatRem(jfloat op1, jfloat op2) { + return fmod(op1, op2); +} + +inline jfloat BytecodeInterpreter::VMfloatNeg(jfloat op) { + return -op; +} + +inline int32_t BytecodeInterpreter::VMfloatCompare(jfloat op1, + jfloat op2, + int32_t direction) { + return ( op1 < op2 ? -1 : + op1 > op2 ? 1 : + op1 == op2 ? 0 : + (direction == -1 || direction == 1) ? direction : 0); + +} + +inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2], + const uint32_t from[2]) { + *(uint64_t *) to = *(uint64_t *) from; +} + +inline jlong BytecodeInterpreter::VMlongAdd(jlong op1, jlong op2) { + return op1 + op2; +} + +inline jlong BytecodeInterpreter::VMlongAnd(jlong op1, jlong op2) { + return op1 & op2; +} + +inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) { + /* it's possible we could catch this special case implicitly */ + if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return op1; + else return op1 / op2; +} + +inline jlong BytecodeInterpreter::VMlongMul(jlong op1, jlong op2) { + return op1 * op2; +} + +inline jlong BytecodeInterpreter::VMlongOr(jlong op1, jlong op2) { + return op1 | op2; +} + +inline jlong BytecodeInterpreter::VMlongSub(jlong op1, jlong op2) { + return op1 - op2; +} + +inline jlong BytecodeInterpreter::VMlongXor(jlong op1, jlong op2) { + return op1 ^ op2; +} + +inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) { + /* it's possible we could catch this special case implicitly */ + if (op1 == (jlong) 0x8000000000000000LL && op2 == -1) return 0; + else return op1 % op2; +} + +inline jlong BytecodeInterpreter::VMlongUshr(jlong op1, jint op2) { + return ((unsigned long long) op1) >> (op2 & 0x3F); +} + +inline jlong BytecodeInterpreter::VMlongShr(jlong op1, jint op2) { + return op1 >> (op2 & 0x3F); +} + +inline jlong BytecodeInterpreter::VMlongShl(jlong op1, jint op2) { + return op1 << (op2 & 0x3F); +} + +inline jlong BytecodeInterpreter::VMlongNeg(jlong op) { + return -op; +} + +inline jlong BytecodeInterpreter::VMlongNot(jlong op) { + return ~op; +} + +inline int32_t BytecodeInterpreter::VMlongLtz(jlong op) { + return (op <= 0); +} + +inline int32_t BytecodeInterpreter::VMlongGez(jlong op) { + return (op >= 0); +} + +inline int32_t BytecodeInterpreter::VMlongEqz(jlong op) { + return (op == 0); +} + +inline int32_t BytecodeInterpreter::VMlongEq(jlong op1, jlong op2) { + return (op1 == op2); +} + +inline int32_t BytecodeInterpreter::VMlongNe(jlong op1, jlong op2) { + return (op1 != op2); +} + +inline int32_t BytecodeInterpreter::VMlongGe(jlong op1, jlong op2) { + return (op1 >= op2); +} + +inline int32_t BytecodeInterpreter::VMlongLe(jlong op1, jlong op2) { + return (op1 <= op2); +} + +inline int32_t BytecodeInterpreter::VMlongLt(jlong op1, jlong op2) { + return (op1 < op2); +} + +inline int32_t BytecodeInterpreter::VMlongGt(jlong op1, jlong op2) { + return (op1 > op2); +} + +inline int32_t BytecodeInterpreter::VMlongCompare(jlong op1, jlong op2) { + return (VMlongLt(op1, op2) ? -1 : VMlongGt(op1, op2) ? 1 : 0); +} + +// Long conversions + +inline jdouble BytecodeInterpreter::VMlong2Double(jlong val) { + return (jdouble) val; +} + +inline jfloat BytecodeInterpreter::VMlong2Float(jlong val) { + return (jfloat) val; +} + +inline jint BytecodeInterpreter::VMlong2Int(jlong val) { + return (jint) val; +} + +// Double Arithmetic + +inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) { + return op1 + op2; +} + +inline jdouble BytecodeInterpreter::VMdoubleDiv(jdouble op1, jdouble op2) { + // Divide by zero... QQQ + return op1 / op2; +} + +inline jdouble BytecodeInterpreter::VMdoubleMul(jdouble op1, jdouble op2) { + return op1 * op2; +} + +inline jdouble BytecodeInterpreter::VMdoubleNeg(jdouble op) { + return -op; +} + +inline jdouble BytecodeInterpreter::VMdoubleRem(jdouble op1, jdouble op2) { + return fmod(op1, op2); +} + +inline jdouble BytecodeInterpreter::VMdoubleSub(jdouble op1, jdouble op2) { + return op1 - op2; +} + +inline int32_t BytecodeInterpreter::VMdoubleCompare(jdouble op1, + jdouble op2, + int32_t direction) { + return ( op1 < op2 ? -1 : + op1 > op2 ? 1 : + op1 == op2 ? 0 : + (direction == -1 || direction == 1) ? direction : 0); +} + +// Double Conversions + +inline jfloat BytecodeInterpreter::VMdouble2Float(jdouble val) { + return (jfloat) val; +} + +// Float Conversions + +inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) { + return (jdouble) op; +} + +// Integer Arithmetic + +inline jint BytecodeInterpreter::VMintAdd(jint op1, jint op2) { + return op1 + op2; +} + +inline jint BytecodeInterpreter::VMintAnd(jint op1, jint op2) { + return op1 & op2; +} + +inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) { + /* it's possible we could catch this special case implicitly */ + if (op1 == (jint) 0x80000000 && op2 == -1) return op1; + else return op1 / op2; +} + +inline jint BytecodeInterpreter::VMintMul(jint op1, jint op2) { + return op1 * op2; +} + +inline jint BytecodeInterpreter::VMintNeg(jint op) { + return -op; +} + +inline jint BytecodeInterpreter::VMintOr(jint op1, jint op2) { + return op1 | op2; +} + +inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) { + /* it's possible we could catch this special case implicitly */ + if (op1 == (jint) 0x80000000 && op2 == -1) return 0; + else return op1 % op2; +} + +inline jint BytecodeInterpreter::VMintShl(jint op1, jint op2) { + return op1 << (op2 & 0x1F); +} + +inline jint BytecodeInterpreter::VMintShr(jint op1, jint op2) { + return op1 >> (op2 & 0x1F); +} + +inline jint BytecodeInterpreter::VMintSub(jint op1, jint op2) { + return op1 - op2; +} + +inline jint BytecodeInterpreter::VMintUshr(jint op1, jint op2) { + return ((juint) op1) >> (op2 & 0x1F); +} + +inline jint BytecodeInterpreter::VMintXor(jint op1, jint op2) { + return op1 ^ op2; +} + +inline jdouble BytecodeInterpreter::VMint2Double(jint val) { + return (jdouble) val; +} + +inline jfloat BytecodeInterpreter::VMint2Float(jint val) { + return (jfloat) val; +} + +inline jlong BytecodeInterpreter::VMint2Long(jint val) { + return (jlong) val; +} + +inline jchar BytecodeInterpreter::VMint2Char(jint val) { + return (jchar) val; +} + +inline jshort BytecodeInterpreter::VMint2Short(jint val) { + return (jshort) val; +} + +inline jbyte BytecodeInterpreter::VMint2Byte(jint val) { + return (jbyte) val; +} diff --git a/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp b/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp new file mode 100644 index 00000000000..471c0202c87 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_bytecodes_zero.cpp.incl" + +void Bytecodes::pd_initialize() { + // No zero specific initialization +} diff --git a/jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/Location.java b/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp similarity index 73% rename from jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/Location.java rename to hotspot/src/cpu/zero/vm/bytecodes_zero.hpp index 14a3ac50cc0..1fba6011651 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/Location.java +++ b/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,7 +20,7 @@ * 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. + * */ -package com.sun.xml.internal.rngom.ast.om; -public interface Location { } +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/bytes_zero.hpp b/hotspot/src/cpu/zero/vm/bytes_zero.hpp new file mode 100644 index 00000000000..d69c28e28af --- /dev/null +++ b/hotspot/src/cpu/zero/vm/bytes_zero.hpp @@ -0,0 +1,164 @@ +/* + * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +typedef union unaligned { + u4 u; + u2 us; + u8 ul; +} __attribute__((packed)) unaligned; + +class Bytes: AllStatic { + public: + // Returns true if the byte ordering used by Java is different + // from the native byte ordering of the underlying machine. + static inline bool is_Java_byte_ordering_different() { +#ifdef VM_LITTLE_ENDIAN + return true; +#else + return false; +#endif + } + + // Efficient reading and writing of unaligned unsigned data in + // platform-specific byte ordering. + static inline u2 get_native_u2(address p){ + unaligned *up = (unaligned *) p; + return up->us; + } + + static inline u4 get_native_u4(address p) { + unaligned *up = (unaligned *) p; + return up->u; + } + + static inline u8 get_native_u8(address p) { + unaligned *up = (unaligned *) p; + return up->ul; + } + + static inline void put_native_u2(address p, u2 x) { + unaligned *up = (unaligned *) p; + up->us = x; + } + + static inline void put_native_u4(address p, u4 x) { + unaligned *up = (unaligned *) p; + up->u = x; + } + + static inline void put_native_u8(address p, u8 x) { + unaligned *up = (unaligned *) p; + up->ul = x; + } + + // Efficient reading and writing of unaligned unsigned data in Java + // byte ordering (i.e. big-endian ordering). +#ifdef VM_LITTLE_ENDIAN + // Byte-order reversal is needed + static inline u2 get_Java_u2(address p) { + return (u2(p[0]) << 8) | + (u2(p[1]) ); + } + static inline u4 get_Java_u4(address p) { + return (u4(p[0]) << 24) | + (u4(p[1]) << 16) | + (u4(p[2]) << 8) | + (u4(p[3]) ); + } + static inline u8 get_Java_u8(address p) { + u4 hi, lo; + hi = (u4(p[0]) << 24) | + (u4(p[1]) << 16) | + (u4(p[2]) << 8) | + (u4(p[3]) ); + lo = (u4(p[4]) << 24) | + (u4(p[5]) << 16) | + (u4(p[6]) << 8) | + (u4(p[7]) ); + return u8(lo) | (u8(hi) << 32); + } + + static inline void put_Java_u2(address p, u2 x) { + p[0] = x >> 8; + p[1] = x; + } + static inline void put_Java_u4(address p, u4 x) { + p[0] = x >> 24; + p[1] = x >> 16; + p[2] = x >> 8; + p[3] = x; + } + static inline void put_Java_u8(address p, u8 x) { + u4 hi, lo; + lo = x; + hi = x >> 32; + p[0] = hi >> 24; + p[1] = hi >> 16; + p[2] = hi >> 8; + p[3] = hi; + p[4] = lo >> 24; + p[5] = lo >> 16; + p[6] = lo >> 8; + p[7] = lo; + } + + // Efficient swapping of byte ordering + static inline u2 swap_u2(u2 x); + static inline u4 swap_u4(u4 x); + static inline u8 swap_u8(u8 x); +#else + // No byte-order reversal is needed + static inline u2 get_Java_u2(address p) { + return get_native_u2(p); + } + static inline u4 get_Java_u4(address p) { + return get_native_u4(p); + } + static inline u8 get_Java_u8(address p) { + return get_native_u8(p); + } + + static inline void put_Java_u2(address p, u2 x) { + put_native_u2(p, x); + } + static inline void put_Java_u4(address p, u4 x) { + put_native_u4(p, x); + } + static inline void put_Java_u8(address p, u8 x) { + put_native_u8(p, x); + } + + // No byte-order reversal is needed + static inline u2 swap_u2(u2 x) { return x; } + static inline u4 swap_u4(u4 x) { return x; } + static inline u8 swap_u8(u8 x) { return x; } +#endif // VM_LITTLE_ENDIAN +}; + +#ifdef VM_LITTLE_ENDIAN +// The following header contains the implementations of swap_u2, +// swap_u4, and swap_u8 +#include "incls/_bytes_pd.inline.hpp.incl" +#endif // VM_LITTLE_ENDIAN diff --git a/hotspot/src/cpu/zero/vm/codeBuffer_zero.hpp b/hotspot/src/cpu/zero/vm/codeBuffer_zero.hpp new file mode 100644 index 00000000000..b89764ac65b --- /dev/null +++ b/hotspot/src/cpu/zero/vm/codeBuffer_zero.hpp @@ -0,0 +1,27 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + + private: + void pd_initialize() {} diff --git a/hotspot/src/cpu/zero/vm/copy_zero.hpp b/hotspot/src/cpu/zero/vm/copy_zero.hpp new file mode 100644 index 00000000000..f8824eb300f --- /dev/null +++ b/hotspot/src/cpu/zero/vm/copy_zero.hpp @@ -0,0 +1,178 @@ +/* + * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +// Inline functions for memory copy and fill. + +static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { + memmove(to, from, count * HeapWordSize); +} + +static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { + switch (count) { + case 8: to[7] = from[7]; + case 7: to[6] = from[6]; + case 6: to[5] = from[5]; + case 5: to[4] = from[4]; + case 4: to[3] = from[3]; + case 3: to[2] = from[2]; + case 2: to[1] = from[1]; + case 1: to[0] = from[0]; + case 0: break; + default: + memcpy(to, from, count * HeapWordSize); + break; + } +} + +static void pd_disjoint_words_atomic(HeapWord* from, + HeapWord* to, + size_t count) { + switch (count) { + case 8: to[7] = from[7]; + case 7: to[6] = from[6]; + case 6: to[5] = from[5]; + case 5: to[4] = from[4]; + case 4: to[3] = from[3]; + case 3: to[2] = from[2]; + case 2: to[1] = from[1]; + case 1: to[0] = from[0]; + case 0: break; + default: + while (count-- > 0) { + *to++ = *from++; + } + break; + } +} + +static void pd_aligned_conjoint_words(HeapWord* from, + HeapWord* to, + size_t count) { + memmove(to, from, count * HeapWordSize); +} + +static void pd_aligned_disjoint_words(HeapWord* from, + HeapWord* to, + size_t count) { + pd_disjoint_words(from, to, count); +} + +static void pd_conjoint_bytes(void* from, void* to, size_t count) { + memmove(to, from, count); +} + +static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) { + memmove(to, from, count); +} + +static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { + _Copy_conjoint_jshorts_atomic(from, to, count); +} + +static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) { + _Copy_conjoint_jints_atomic(from, to, count); +} + +static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { + _Copy_conjoint_jlongs_atomic(from, to, count); +} + +static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) { +#ifdef _LP64 + assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); + _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count); +#else + assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size"); + _Copy_conjoint_jints_atomic((jint*)from, (jint*)to, count); +#endif // _LP64 +} + +static void pd_arrayof_conjoint_bytes(HeapWord* from, + HeapWord* to, + size_t count) { + _Copy_arrayof_conjoint_bytes(from, to, count); +} + +static void pd_arrayof_conjoint_jshorts(HeapWord* from, + HeapWord* to, + size_t count) { + _Copy_arrayof_conjoint_jshorts(from, to, count); +} + +static void pd_arrayof_conjoint_jints(HeapWord* from, + HeapWord* to, + size_t count) { + _Copy_arrayof_conjoint_jints(from, to, count); +} + +static void pd_arrayof_conjoint_jlongs(HeapWord* from, + HeapWord* to, + size_t count) { + _Copy_arrayof_conjoint_jlongs(from, to, count); +} + +static void pd_arrayof_conjoint_oops(HeapWord* from, + HeapWord* to, + size_t count) { +#ifdef _LP64 + assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); + _Copy_arrayof_conjoint_jlongs(from, to, count); +#else + assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size"); + _Copy_arrayof_conjoint_jints(from, to, count); +#endif // _LP64 +} + +static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) { +#ifdef _LP64 + julong* to = (julong*) tohw; + julong v = ((julong) value << 32) | value; +#else + juint* to = (juint*) tohw; + juint v = value; +#endif // _LP64 + + while (count-- > 0) { + *to++ = v; + } +} + +static void pd_fill_to_aligned_words(HeapWord* tohw, + size_t count, + juint value) { + pd_fill_to_words(tohw, count, value); +} + +static void pd_fill_to_bytes(void* to, size_t count, jubyte value) { + memset(to, value, count); +} + +static void pd_zero_to_words(HeapWord* tohw, size_t count) { + pd_fill_to_words(tohw, count, 0); +} + +static void pd_zero_to_bytes(void* to, size_t count) { + memset(to, 0, count); +} diff --git a/jaxws/src/share/classes/com/sun/xml/internal/ws/wsdl/writer/document/http/package-info.java b/hotspot/src/cpu/zero/vm/cppInterpreterGenerator_zero.hpp similarity index 67% rename from jaxws/src/share/classes/com/sun/xml/internal/ws/wsdl/writer/document/http/package-info.java rename to hotspot/src/cpu/zero/vm/cppInterpreterGenerator_zero.hpp index df0d58a996f..7861f3aa5d8 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/ws/wsdl/writer/document/http/package-info.java +++ b/hotspot/src/cpu/zero/vm/cppInterpreterGenerator_zero.hpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008, 2009 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,13 +20,18 @@ * 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. - */ - - - -/** * - * @author WS Development Team */ -@com.sun.xml.internal.txw2.annotation.XmlNamespace("http://schemas.xmlsoap.org/wsdl/http/") -package com.sun.xml.internal.ws.wsdl.writer.document.http; + + protected: + MacroAssembler* assembler() const { + return _masm; + } + + protected: + address generate_entry(address entry_point) { + ZeroEntry *entry = (ZeroEntry *) assembler()->pc(); + assembler()->advance(sizeof(ZeroEntry)); + entry->set_entry_point(entry_point); + return (address) entry; + } diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp new file mode 100644 index 00000000000..8c99fbf4556 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp @@ -0,0 +1,946 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_cppInterpreter_zero.cpp.incl" + +#ifdef CC_INTERP + +#define fixup_after_potential_safepoint() \ + method = istate->method() + +#define CALL_VM_NOCHECK(func) \ + thread->set_last_Java_frame(); \ + func; \ + thread->reset_last_Java_frame(); \ + fixup_after_potential_safepoint() + +void CppInterpreter::normal_entry(methodOop method, intptr_t UNUSED, TRAPS) { + JavaThread *thread = (JavaThread *) THREAD; + ZeroStack *stack = thread->zero_stack(); + + // Adjust the caller's stack frame to accomodate any additional + // local variables we have contiguously with our parameters. + int extra_locals = method->max_locals() - method->size_of_parameters(); + if (extra_locals > 0) { + if (extra_locals > stack->available_words()) { + Unimplemented(); + } + for (int i = 0; i < extra_locals; i++) + stack->push(0); + } + + // Allocate and initialize our frame. + InterpreterFrame *frame = InterpreterFrame::build(stack, method, thread); + thread->push_zero_frame(frame); + + // Execute those bytecodes! + main_loop(0, THREAD); +} + +void CppInterpreter::main_loop(int recurse, TRAPS) { + JavaThread *thread = (JavaThread *) THREAD; + ZeroStack *stack = thread->zero_stack(); + + // If we are entering from a deopt we may need to call + // ourself a few times in order to get to our frame. + if (recurse) + main_loop(recurse - 1, THREAD); + + InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame(); + interpreterState istate = frame->interpreter_state(); + methodOop method = istate->method(); + + intptr_t *result = NULL; + int result_slots = 0; + + // Check we're not about to run out of stack + if (stack_overflow_imminent(thread)) { + CALL_VM_NOCHECK(InterpreterRuntime::throw_StackOverflowError(thread)); + goto unwind_and_return; + } + + while (true) { + // We can set up the frame anchor with everything we want at + // this point as we are thread_in_Java and no safepoints can + // occur until we go to vm mode. We do have to clear flags + // on return from vm but that is it. + thread->set_last_Java_frame(); + + // Call the interpreter + if (JvmtiExport::can_post_interpreter_events()) + BytecodeInterpreter::runWithChecks(istate); + else + BytecodeInterpreter::run(istate); + fixup_after_potential_safepoint(); + + // Clear the frame anchor + thread->reset_last_Java_frame(); + + // Examine the message from the interpreter to decide what to do + if (istate->msg() == BytecodeInterpreter::call_method) { + methodOop callee = istate->callee(); + + // Trim back the stack to put the parameters at the top + stack->set_sp(istate->stack() + 1); + + // Make the call + Interpreter::invoke_method(callee, istate->callee_entry_point(), THREAD); + fixup_after_potential_safepoint(); + + // Convert the result + istate->set_stack(stack->sp() - 1); + + // Restore the stack + stack->set_sp(istate->stack_limit() + 1); + + // Resume the interpreter + istate->set_msg(BytecodeInterpreter::method_resume); + } + else if (istate->msg() == BytecodeInterpreter::more_monitors) { + int monitor_words = frame::interpreter_frame_monitor_size(); + + // Allocate the space + if (monitor_words > stack->available_words()) { + Unimplemented(); + } + stack->alloc(monitor_words * wordSize); + + // Move the expression stack contents + for (intptr_t *p = istate->stack() + 1; p < istate->stack_base(); p++) + *(p - monitor_words) = *p; + + // Move the expression stack pointers + istate->set_stack_limit(istate->stack_limit() - monitor_words); + istate->set_stack(istate->stack() - monitor_words); + istate->set_stack_base(istate->stack_base() - monitor_words); + + // Zero the new monitor so the interpreter can find it. + ((BasicObjectLock *) istate->stack_base())->set_obj(NULL); + + // Resume the interpreter + istate->set_msg(BytecodeInterpreter::got_monitors); + } + else if (istate->msg() == BytecodeInterpreter::return_from_method) { + // Copy the result into the caller's frame + result_slots = type2size[method->result_type()]; + assert(result_slots >= 0 && result_slots <= 2, "what?"); + result = istate->stack() + result_slots; + break; + } + else if (istate->msg() == BytecodeInterpreter::throwing_exception) { + assert(HAS_PENDING_EXCEPTION, "should do"); + break; + } + else if (istate->msg() == BytecodeInterpreter::do_osr) { + // Unwind the current frame + thread->pop_zero_frame(); + + // Remove any extension of the previous frame + int extra_locals = method->max_locals() - method->size_of_parameters(); + stack->set_sp(stack->sp() + extra_locals); + + // Jump into the OSR method + Interpreter::invoke_osr( + method, istate->osr_entry(), istate->osr_buf(), THREAD); + return; + } + else { + ShouldNotReachHere(); + } + } + + unwind_and_return: + + // Unwind the current frame + thread->pop_zero_frame(); + + // Pop our local variables + stack->set_sp(stack->sp() + method->max_locals()); + + // Push our result + for (int i = 0; i < result_slots; i++) + stack->push(result[-i]); +} + +void CppInterpreter::native_entry(methodOop method, intptr_t UNUSED, TRAPS) { + // Make sure method is native and not abstract + assert(method->is_native() && !method->is_abstract(), "should be"); + + JavaThread *thread = (JavaThread *) THREAD; + ZeroStack *stack = thread->zero_stack(); + + // Allocate and initialize our frame + InterpreterFrame *frame = InterpreterFrame::build(stack, method, thread); + thread->push_zero_frame(frame); + interpreterState istate = frame->interpreter_state(); + intptr_t *locals = istate->locals(); + + // Check we're not about to run out of stack + if (stack_overflow_imminent(thread)) { + CALL_VM_NOCHECK(InterpreterRuntime::throw_StackOverflowError(thread)); + goto unwind_and_return; + } + + // Lock if necessary + BasicObjectLock *monitor; + monitor = NULL; + if (method->is_synchronized()) { + monitor = (BasicObjectLock*) istate->stack_base(); + oop lockee = monitor->obj(); + markOop disp = lockee->mark()->set_unlocked(); + + monitor->lock()->set_displaced_header(disp); + if (Atomic::cmpxchg_ptr(monitor, lockee->mark_addr(), disp) != disp) { + if (thread->is_lock_owned((address) disp->clear_lock_bits())) { + monitor->lock()->set_displaced_header(NULL); + } + else { + CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor)); + if (HAS_PENDING_EXCEPTION) + goto unwind_and_return; + } + } + } + + // Get the signature handler + InterpreterRuntime::SignatureHandler *handler; { + address handlerAddr = method->signature_handler(); + if (handlerAddr == NULL) { + CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method)); + if (HAS_PENDING_EXCEPTION) + goto unwind_and_return; + + handlerAddr = method->signature_handler(); + assert(handlerAddr != NULL, "eh?"); + } + if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) { + CALL_VM_NOCHECK(handlerAddr = + InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL)); + if (HAS_PENDING_EXCEPTION) + goto unwind_and_return; + } + handler = \ + InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr); + } + + // Get the native function entry point + address function; + function = method->native_function(); + assert(function != NULL, "should be set if signature handler is"); + + // Build the argument list + if (handler->argument_count() * 2 > stack->available_words()) { + Unimplemented(); + } + void **arguments; + void *mirror; { + arguments = + (void **) stack->alloc(handler->argument_count() * sizeof(void **)); + void **dst = arguments; + + void *env = thread->jni_environment(); + *(dst++) = &env; + + if (method->is_static()) { + istate->set_oop_temp( + method->constants()->pool_holder()->klass_part()->java_mirror()); + mirror = istate->oop_temp_addr(); + *(dst++) = &mirror; + } + + intptr_t *src = locals; + for (int i = dst - arguments; i < handler->argument_count(); i++) { + ffi_type *type = handler->argument_type(i); + if (type == &ffi_type_pointer) { + if (*src) { + stack->push((intptr_t) src); + *(dst++) = stack->sp(); + } + else { + *(dst++) = src; + } + src--; + } + else if (type->size == 4) { + *(dst++) = src--; + } + else if (type->size == 8) { + src--; + *(dst++) = src--; + } + else { + ShouldNotReachHere(); + } + } + } + + // Set up the Java frame anchor + thread->set_last_Java_frame(); + + // Change the thread state to _thread_in_native + ThreadStateTransition::transition_from_java(thread, _thread_in_native); + + // Make the call + intptr_t result[4 - LogBytesPerWord]; + ffi_call(handler->cif(), (void (*)()) function, result, arguments); + + // Change the thread state back to _thread_in_Java. + // ThreadStateTransition::transition_from_native() cannot be used + // here because it does not check for asynchronous exceptions. + // We have to manage the transition ourself. + thread->set_thread_state(_thread_in_native_trans); + + // Make sure new state is visible in the GC thread + if (os::is_MP()) { + if (UseMembar) { + OrderAccess::fence(); + } + else { + InterfaceSupport::serialize_memory(thread); + } + } + + // Handle safepoint operations, pending suspend requests, + // and pending asynchronous exceptions. + if (SafepointSynchronize::do_call_back() || + thread->has_special_condition_for_native_trans()) { + JavaThread::check_special_condition_for_native_trans(thread); + CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops()); + } + + // Finally we can change the thread state to _thread_in_Java. + thread->set_thread_state(_thread_in_Java); + fixup_after_potential_safepoint(); + + // Clear the frame anchor + thread->reset_last_Java_frame(); + + // If the result was an oop then unbox it and store it in + // oop_temp where the garbage collector can see it before + // we release the handle it might be protected by. + if (handler->result_type() == &ffi_type_pointer) { + if (result[0]) + istate->set_oop_temp(*(oop *) result[0]); + else + istate->set_oop_temp(NULL); + } + + // Reset handle block + thread->active_handles()->clear(); + + // Unlock if necessary. It seems totally wrong that this + // is skipped in the event of an exception but apparently + // the template interpreter does this so we do too. + if (monitor && !HAS_PENDING_EXCEPTION) { + BasicLock *lock = monitor->lock(); + markOop header = lock->displaced_header(); + oop rcvr = monitor->obj(); + monitor->set_obj(NULL); + + if (header != NULL) { + if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) { + monitor->set_obj(rcvr); { + HandleMark hm(thread); + CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(thread, monitor)); + } + } + } + } + + unwind_and_return: + + // Unwind the current activation + thread->pop_zero_frame(); + + // Pop our parameters + stack->set_sp(stack->sp() + method->size_of_parameters()); + + // Push our result + if (!HAS_PENDING_EXCEPTION) { + stack->set_sp(stack->sp() - type2size[method->result_type()]); + + switch (method->result_type()) { + case T_VOID: + break; + + case T_BOOLEAN: +#ifndef VM_LITTLE_ENDIAN + result[0] <<= (BitsPerWord - BitsPerByte); +#endif + SET_LOCALS_INT(*(jboolean *) result != 0, 0); + break; + + case T_CHAR: +#ifndef VM_LITTLE_ENDIAN + result[0] <<= (BitsPerWord - BitsPerShort); +#endif + SET_LOCALS_INT(*(jchar *) result, 0); + break; + + case T_BYTE: +#ifndef VM_LITTLE_ENDIAN + result[0] <<= (BitsPerWord - BitsPerByte); +#endif + SET_LOCALS_INT(*(jbyte *) result, 0); + break; + + case T_SHORT: +#ifndef VM_LITTLE_ENDIAN + result[0] <<= (BitsPerWord - BitsPerShort); +#endif + SET_LOCALS_INT(*(jshort *) result, 0); + break; + + case T_INT: +#ifndef VM_LITTLE_ENDIAN + result[0] <<= (BitsPerWord - BitsPerInt); +#endif + SET_LOCALS_INT(*(jint *) result, 0); + break; + + case T_LONG: + SET_LOCALS_LONG(*(jlong *) result, 0); + break; + + case T_FLOAT: + SET_LOCALS_FLOAT(*(jfloat *) result, 0); + break; + + case T_DOUBLE: + SET_LOCALS_DOUBLE(*(jdouble *) result, 0); + break; + + case T_OBJECT: + case T_ARRAY: + SET_LOCALS_OBJECT(istate->oop_temp(), 0); + break; + + default: + ShouldNotReachHere(); + } + } +} + +void CppInterpreter::accessor_entry(methodOop method, intptr_t UNUSED, TRAPS) { + JavaThread *thread = (JavaThread *) THREAD; + ZeroStack *stack = thread->zero_stack(); + intptr_t *locals = stack->sp(); + + // Drop into the slow path if we need a safepoint check + if (SafepointSynchronize::do_call_back()) { + normal_entry(method, 0, THREAD); + return; + } + + // Load the object pointer and drop into the slow path + // if we have a NullPointerException + oop object = LOCALS_OBJECT(0); + if (object == NULL) { + normal_entry(method, 0, THREAD); + return; + } + + // Read the field index from the bytecode, which looks like this: + // 0: aload_0 + // 1: getfield + // 2: index + // 3: index + // 4: ireturn/areturn + // NB this is not raw bytecode: index is in machine order + u1 *code = method->code_base(); + assert(code[0] == Bytecodes::_aload_0 && + code[1] == Bytecodes::_getfield && + (code[4] == Bytecodes::_ireturn || + code[4] == Bytecodes::_areturn), "should do"); + u2 index = Bytes::get_native_u2(&code[2]); + + // Get the entry from the constant pool cache, and drop into + // the slow path if it has not been resolved + constantPoolCacheOop cache = method->constants()->cache(); + ConstantPoolCacheEntry* entry = cache->entry_at(index); + if (!entry->is_resolved(Bytecodes::_getfield)) { + normal_entry(method, 0, THREAD); + return; + } + + // Get the result and push it onto the stack + switch (entry->flag_state()) { + case ltos: + case dtos: + if (stack->available_words() < 1) { + Unimplemented(); + } + stack->alloc(wordSize); + break; + } + if (entry->is_volatile()) { + switch (entry->flag_state()) { + case ctos: + SET_LOCALS_INT(object->char_field_acquire(entry->f2()), 0); + break; + + case btos: + SET_LOCALS_INT(object->byte_field_acquire(entry->f2()), 0); + break; + + case stos: + SET_LOCALS_INT(object->short_field_acquire(entry->f2()), 0); + break; + + case itos: + SET_LOCALS_INT(object->int_field_acquire(entry->f2()), 0); + break; + + case ltos: + SET_LOCALS_LONG(object->long_field_acquire(entry->f2()), 0); + break; + + case ftos: + SET_LOCALS_FLOAT(object->float_field_acquire(entry->f2()), 0); + break; + + case dtos: + SET_LOCALS_DOUBLE(object->double_field_acquire(entry->f2()), 0); + break; + + case atos: + SET_LOCALS_OBJECT(object->obj_field_acquire(entry->f2()), 0); + break; + + default: + ShouldNotReachHere(); + } + } + else { + switch (entry->flag_state()) { + case ctos: + SET_LOCALS_INT(object->char_field(entry->f2()), 0); + break; + + case btos: + SET_LOCALS_INT(object->byte_field(entry->f2()), 0); + break; + + case stos: + SET_LOCALS_INT(object->short_field(entry->f2()), 0); + break; + + case itos: + SET_LOCALS_INT(object->int_field(entry->f2()), 0); + break; + + case ltos: + SET_LOCALS_LONG(object->long_field(entry->f2()), 0); + break; + + case ftos: + SET_LOCALS_FLOAT(object->float_field(entry->f2()), 0); + break; + + case dtos: + SET_LOCALS_DOUBLE(object->double_field(entry->f2()), 0); + break; + + case atos: + SET_LOCALS_OBJECT(object->obj_field(entry->f2()), 0); + break; + + default: + ShouldNotReachHere(); + } + } +} + +void CppInterpreter::empty_entry(methodOop method, intptr_t UNUSED, TRAPS) { + JavaThread *thread = (JavaThread *) THREAD; + ZeroStack *stack = thread->zero_stack(); + + // Drop into the slow path if we need a safepoint check + if (SafepointSynchronize::do_call_back()) { + normal_entry(method, 0, THREAD); + return; + } + + // Pop our parameters + stack->set_sp(stack->sp() + method->size_of_parameters()); +} + +bool CppInterpreter::stack_overflow_imminent(JavaThread *thread) { + // How is the ABI stack? + address stack_top = thread->stack_base() - thread->stack_size(); + int free_stack = os::current_stack_pointer() - stack_top; + if (free_stack < StackShadowPages * os::vm_page_size()) { + return true; + } + + // How is the Zero stack? + // Throwing a StackOverflowError involves a VM call, which means + // we need a frame on the stack. We should be checking here to + // ensure that methods we call have enough room to install the + // largest possible frame, but that's more than twice the size + // of the entire Zero stack we get by default, so we just check + // we have *some* space instead... + free_stack = thread->zero_stack()->available_words() * wordSize; + if (free_stack < StackShadowPages * os::vm_page_size()) { + return true; + } + + return false; +} + +InterpreterFrame *InterpreterFrame::build(ZeroStack* stack, + const methodOop method, + JavaThread* thread) { + int monitor_words = + method->is_synchronized() ? frame::interpreter_frame_monitor_size() : 0; + int stack_words = method->is_native() ? 0 : method->max_stack(); + + if (header_words + monitor_words + stack_words > stack->available_words()) { + Unimplemented(); + } + + intptr_t *locals; + if (method->is_native()) + locals = stack->sp() + (method->size_of_parameters() - 1); + else + locals = stack->sp() + (method->max_locals() - 1); + + stack->push(0); // next_frame, filled in later + intptr_t *fp = stack->sp(); + assert(fp - stack->sp() == next_frame_off, "should be"); + + stack->push(INTERPRETER_FRAME); + assert(fp - stack->sp() == frame_type_off, "should be"); + + interpreterState istate = + (interpreterState) stack->alloc(sizeof(BytecodeInterpreter)); + assert(fp - stack->sp() == istate_off, "should be"); + + istate->set_locals(locals); + istate->set_method(method); + istate->set_self_link(istate); + istate->set_prev_link(NULL); + istate->set_thread(thread); + istate->set_bcp(method->is_native() ? NULL : method->code_base()); + istate->set_constants(method->constants()->cache()); + istate->set_msg(BytecodeInterpreter::method_entry); + istate->set_oop_temp(NULL); + istate->set_mdx(NULL); + istate->set_callee(NULL); + + istate->set_monitor_base((BasicObjectLock *) stack->sp()); + if (method->is_synchronized()) { + BasicObjectLock *monitor = + (BasicObjectLock *) stack->alloc(monitor_words * wordSize); + oop object; + if (method->is_static()) + object = method->constants()->pool_holder()->klass_part()->java_mirror(); + else + object = (oop) locals[0]; + monitor->set_obj(object); + } + + istate->set_stack_base(stack->sp()); + istate->set_stack(stack->sp() - 1); + if (stack_words) + stack->alloc(stack_words * wordSize); + istate->set_stack_limit(stack->sp() - 1); + + return (InterpreterFrame *) fp; +} + +int AbstractInterpreter::BasicType_as_index(BasicType type) { + int i = 0; + switch (type) { + case T_BOOLEAN: i = 0; break; + case T_CHAR : i = 1; break; + case T_BYTE : i = 2; break; + case T_SHORT : i = 3; break; + case T_INT : i = 4; break; + case T_LONG : i = 5; break; + case T_VOID : i = 6; break; + case T_FLOAT : i = 7; break; + case T_DOUBLE : i = 8; break; + case T_OBJECT : i = 9; break; + case T_ARRAY : i = 9; break; + default : ShouldNotReachHere(); + } + assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, + "index out of bounds"); + return i; +} + +address InterpreterGenerator::generate_empty_entry() { + if (!UseFastEmptyMethods) + return NULL; + + return generate_entry((address) CppInterpreter::empty_entry); +} + +address InterpreterGenerator::generate_accessor_entry() { + if (!UseFastAccessorMethods) + return NULL; + + return generate_entry((address) CppInterpreter::accessor_entry); +} + +address InterpreterGenerator::generate_native_entry(bool synchronized) { + assert(synchronized == false, "should be"); + + return generate_entry((address) CppInterpreter::native_entry); +} + +address InterpreterGenerator::generate_normal_entry(bool synchronized) { + assert(synchronized == false, "should be"); + + return generate_entry((address) CppInterpreter::normal_entry); +} + +address AbstractInterpreterGenerator::generate_method_entry( + AbstractInterpreter::MethodKind kind) { + address entry_point = NULL; + + switch (kind) { + case Interpreter::zerolocals: + case Interpreter::zerolocals_synchronized: + break; + + case Interpreter::native: + entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); + break; + + case Interpreter::native_synchronized: + entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); + break; + + case Interpreter::empty: + entry_point = ((InterpreterGenerator*) this)->generate_empty_entry(); + break; + + case Interpreter::accessor: + entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry(); + break; + + case Interpreter::abstract: + entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry(); + break; + + case Interpreter::method_handle: + entry_point = ((InterpreterGenerator*) this)->generate_method_handle_entry(); + break; + + case Interpreter::java_lang_math_sin: + case Interpreter::java_lang_math_cos: + case Interpreter::java_lang_math_tan: + case Interpreter::java_lang_math_abs: + case Interpreter::java_lang_math_log: + case Interpreter::java_lang_math_log10: + case Interpreter::java_lang_math_sqrt: + entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind); + break; + + default: + ShouldNotReachHere(); + } + + if (entry_point == NULL) + entry_point = ((InterpreterGenerator*) this)->generate_normal_entry(false); + + return entry_point; +} + +InterpreterGenerator::InterpreterGenerator(StubQueue* code) + : CppInterpreterGenerator(code) { + generate_all(); +} + +// Deoptimization helpers + +InterpreterFrame *InterpreterFrame::build(ZeroStack* stack, int size) { + int size_in_words = size >> LogBytesPerWord; + assert(size_in_words * wordSize == size, "unaligned"); + assert(size_in_words >= header_words, "too small"); + + if (size_in_words > stack->available_words()) { + Unimplemented(); + } + + stack->push(0); // next_frame, filled in later + intptr_t *fp = stack->sp(); + assert(fp - stack->sp() == next_frame_off, "should be"); + + stack->push(INTERPRETER_FRAME); + assert(fp - stack->sp() == frame_type_off, "should be"); + + interpreterState istate = + (interpreterState) stack->alloc(sizeof(BytecodeInterpreter)); + assert(fp - stack->sp() == istate_off, "should be"); + istate->set_self_link(NULL); // mark invalid + + stack->alloc((size_in_words - header_words) * wordSize); + + return (InterpreterFrame *) fp; +} + +int AbstractInterpreter::layout_activation(methodOop method, + int tempcount, + int popframe_extra_args, + int moncount, + int callee_param_count, + int callee_locals, + frame* caller, + frame* interpreter_frame, + bool is_top_frame) { + assert(popframe_extra_args == 0, "what to do?"); + assert(!is_top_frame || (!callee_locals && !callee_param_count), + "top frame should have no caller") + + // This code must exactly match what InterpreterFrame::build + // does (the full InterpreterFrame::build, that is, not the + // one that creates empty frames for the deoptimizer). + // + // If interpreter_frame is not NULL then it will be filled in. + // It's size is determined by a previous call to this method, + // so it should be correct. + // + // Note that tempcount is the current size of the expression + // stack. For top most frames we will allocate a full sized + // expression stack and not the trimmed version that non-top + // frames have. + + int header_words = InterpreterFrame::header_words; + int monitor_words = moncount * frame::interpreter_frame_monitor_size(); + int stack_words = is_top_frame ? method->max_stack() : tempcount; + int callee_extra_locals = callee_locals - callee_param_count; + + if (interpreter_frame) { + intptr_t *locals = interpreter_frame->sp() + method->max_locals(); + interpreterState istate = interpreter_frame->get_interpreterState(); + intptr_t *monitor_base = (intptr_t*) istate; + intptr_t *stack_base = monitor_base - monitor_words; + intptr_t *stack = stack_base - tempcount - 1; + + BytecodeInterpreter::layout_interpreterState(istate, + caller, + NULL, + method, + locals, + stack, + stack_base, + monitor_base, + NULL, + is_top_frame); + } + return header_words + monitor_words + stack_words + callee_extra_locals; +} + +void BytecodeInterpreter::layout_interpreterState(interpreterState istate, + frame* caller, + frame* current, + methodOop method, + intptr_t* locals, + intptr_t* stack, + intptr_t* stack_base, + intptr_t* monitor_base, + intptr_t* frame_bottom, + bool is_top_frame) { + istate->set_locals(locals); + istate->set_method(method); + istate->set_self_link(istate); + istate->set_prev_link(NULL); + // thread will be set by a hacky repurposing of frame::patch_pc() + // bcp will be set by vframeArrayElement::unpack_on_stack() + istate->set_constants(method->constants()->cache()); + istate->set_msg(BytecodeInterpreter::method_resume); + istate->set_bcp_advance(0); + istate->set_oop_temp(NULL); + istate->set_mdx(NULL); + if (caller->is_interpreted_frame()) { + interpreterState prev = caller->get_interpreterState(); + prev->set_callee(method); + if (*prev->bcp() == Bytecodes::_invokeinterface) + prev->set_bcp_advance(5); + else + prev->set_bcp_advance(3); + } + istate->set_callee(NULL); + istate->set_monitor_base((BasicObjectLock *) monitor_base); + istate->set_stack_base(stack_base); + istate->set_stack(stack); + istate->set_stack_limit(stack_base - method->max_stack() - 1); +} + +address CppInterpreter::return_entry(TosState state, int length) { + ShouldNotCallThis(); +} + +address CppInterpreter::deopt_entry(TosState state, int length) { + return NULL; +} + +// Helper for (runtime) stack overflow checks + +int AbstractInterpreter::size_top_interpreter_activation(methodOop method) { + return 0; +} + +// Helper for figuring out if frames are interpreter frames + +bool CppInterpreter::contains(address pc) { +#ifdef PRODUCT + ShouldNotCallThis(); +#else + return false; // make frame::print_value_on work +#endif // !PRODUCT +} + +// Result handlers and convertors + +address CppInterpreterGenerator::generate_result_handler_for( + BasicType type) { + assembler()->advance(1); + return ShouldNotCallThisStub(); +} + +address CppInterpreterGenerator::generate_tosca_to_stack_converter( + BasicType type) { + assembler()->advance(1); + return ShouldNotCallThisStub(); +} + +address CppInterpreterGenerator::generate_stack_to_stack_converter( + BasicType type) { + assembler()->advance(1); + return ShouldNotCallThisStub(); +} + +address CppInterpreterGenerator::generate_stack_to_native_abi_converter( + BasicType type) { + assembler()->advance(1); + return ShouldNotCallThisStub(); +} + +#endif // CC_INTERP diff --git a/jaxws/src/share/classes/com/sun/xml/internal/bind/v2/model/runtime/RuntimeAttributePropertyInfo.java b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp similarity index 56% rename from jaxws/src/share/classes/com/sun/xml/internal/bind/v2/model/runtime/RuntimeAttributePropertyInfo.java rename to hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp index efd529edeab..18b9891e937 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/bind/v2/model/runtime/RuntimeAttributePropertyInfo.java +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,18 +20,24 @@ * 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. + * */ -package com.sun.xml.internal.bind.v2.model.runtime; + protected: + // Size of interpreter code + const static int InterpreterCodeSize = 6 * K; -import java.lang.reflect.Type; + public: + // Method entries + static void normal_entry(methodOop method, intptr_t UNUSED, TRAPS); + static void native_entry(methodOop method, intptr_t UNUSED, TRAPS); + static void accessor_entry(methodOop method, intptr_t UNUSED, TRAPS); + static void empty_entry(methodOop method, intptr_t UNUSED, TRAPS); -import com.sun.xml.internal.bind.v2.model.core.AttributePropertyInfo; + public: + // Main loop of normal_entry + static void main_loop(int recurse, TRAPS); -/** - * @author Kohsuke Kawaguchi - */ -public interface RuntimeAttributePropertyInfo extends AttributePropertyInfo, RuntimePropertyInfo, RuntimeNonElementRef { - // refinement - RuntimeNonElement getTarget(); -} + private: + // Stack overflow checks + static bool stack_overflow_imminent(JavaThread *thread); diff --git a/jdk/test/javax/management/mxbean/customtypes/package-info.java b/hotspot/src/cpu/zero/vm/debug_zero.cpp similarity index 80% rename from jdk/test/javax/management/mxbean/customtypes/package-info.java rename to hotspot/src/cpu/zero/vm/debug_zero.cpp index c9e213dcb29..de6f077707a 100644 --- a/jdk/test/javax/management/mxbean/customtypes/package-info.java +++ b/hotspot/src/cpu/zero/vm/debug_zero.cpp @@ -1,5 +1,6 @@ /* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,9 +20,12 @@ * 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. + * */ -// package-info.java - test package annotations for custom types +#include "incls/_precompiled.incl" +#include "incls/_debug_zero.cpp.incl" -@javax.management.openmbean.MXBeanMappingFactoryClass(IntegerIsStringFactory.class) -package customtypes; +void pd_ps(frame f) { + ShouldNotCallThis(); +} diff --git a/hotspot/src/cpu/zero/vm/depChecker_zero.cpp b/hotspot/src/cpu/zero/vm/depChecker_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/depChecker_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/depChecker_zero.hpp b/hotspot/src/cpu/zero/vm/depChecker_zero.hpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/depChecker_zero.hpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/disassembler_zero.cpp b/hotspot/src/cpu/zero/vm/disassembler_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/disassembler_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/ParsedNameClass.java b/hotspot/src/cpu/zero/vm/disassembler_zero.hpp similarity index 71% rename from jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/ParsedNameClass.java rename to hotspot/src/cpu/zero/vm/disassembler_zero.hpp index 57f5f3cd652..b4036c43d17 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/ParsedNameClass.java +++ b/hotspot/src/cpu/zero/vm/disassembler_zero.hpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,7 +20,16 @@ * 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. + * */ -package com.sun.xml.internal.rngom.ast.om; -public interface ParsedNameClass { } +// The disassembler prints out zero code annotated +// with Java specific information. + + static int pd_instruction_alignment() { + ShouldNotCallThis(); + } + + static const char* pd_cpu_opts() { + ShouldNotCallThis(); + } diff --git a/jaxws/src/share/classes/com/sun/tools/internal/ws/api/wsdl/TWSDLExtension.java b/hotspot/src/cpu/zero/vm/dump_zero.cpp similarity index 59% rename from jaxws/src/share/classes/com/sun/tools/internal/ws/api/wsdl/TWSDLExtension.java rename to hotspot/src/cpu/zero/vm/dump_zero.cpp index 1cca601e943..648a081efc1 100644 --- a/jaxws/src/share/classes/com/sun/tools/internal/ws/api/wsdl/TWSDLExtension.java +++ b/hotspot/src/cpu/zero/vm/dump_zero.cpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,19 +20,17 @@ * 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. - */ - -package com.sun.tools.internal.ws.api.wsdl; - -/** - * A WSDL extension * - * @author Vivek Pandey - * @deprecated This interface is deprecated, will be removed in JAX-WS 2.2 RI. */ -public interface TWSDLExtension { - /** - * Gives Parent {@link TWSDLExtensible} element - */ - TWSDLExtensible getParent(); + +#include "incls/_precompiled.incl" +#include "incls/_dump_zero.cpp.incl" + +void CompactingPermGenGen::generate_vtable_methods(void** vtbl_list, + void** vtable, + char** md_top, + char* md_end, + char** mc_top, + char* mc_end) { + ShouldNotCallThis(); } diff --git a/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp b/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp new file mode 100644 index 00000000000..03bd78102a4 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp @@ -0,0 +1,65 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Red Hat, Inc. + * 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 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. + * + */ + +// | ... | +// +--------------------+ ------------------ +// | parameter n-1 | low addresses +// | ... | +// | parameter 0 | +// | call_wrapper | +// | frame_type | +// | next_frame | high addresses +// +--------------------+ ------------------ +// | ... | + +class EntryFrame : public ZeroFrame { + private: + EntryFrame() : ZeroFrame() { + ShouldNotCallThis(); + } + + protected: + enum Layout { + call_wrapper_off = jf_header_words, + header_words + }; + + public: + static EntryFrame *build(ZeroStack* stack, + const intptr_t* parameters, + int parameter_words, + JavaCallWrapper* call_wrapper); + public: + JavaCallWrapper *call_wrapper() const { + return (JavaCallWrapper *) value_of_word(call_wrapper_off); + } + + public: + void identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const; +}; diff --git a/hotspot/src/cpu/zero/vm/entry_zero.hpp b/hotspot/src/cpu/zero/vm/entry_zero.hpp new file mode 100644 index 00000000000..12f7e554b1a --- /dev/null +++ b/hotspot/src/cpu/zero/vm/entry_zero.hpp @@ -0,0 +1,64 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +class ZeroEntry { + public: + ZeroEntry() { + ShouldNotCallThis(); + } + + private: + address _entry_point; + + public: + address entry_point() const { + return _entry_point; + } + void set_entry_point(address entry_point) { + _entry_point = entry_point; + } + + private: + typedef void (*NormalEntryFunc)(methodOop method, + intptr_t base_pc, + TRAPS); + typedef void (*OSREntryFunc)(methodOop method, + address osr_buf, + intptr_t base_pc, + TRAPS); + + public: + void invoke(methodOop method, TRAPS) const { + ((NormalEntryFunc) entry_point())(method, (intptr_t) this, THREAD); + } + void invoke_osr(methodOop method, address osr_buf, TRAPS) const { + ((OSREntryFunc) entry_point())(method, osr_buf, (intptr_t) this, THREAD); + } + + public: + static ByteSize entry_point_offset() { + return byte_offset_of(ZeroEntry, _entry_point); + } +}; diff --git a/hotspot/src/cpu/zero/vm/fakeStubFrame_zero.hpp b/hotspot/src/cpu/zero/vm/fakeStubFrame_zero.hpp new file mode 100644 index 00000000000..ec3054019ff --- /dev/null +++ b/hotspot/src/cpu/zero/vm/fakeStubFrame_zero.hpp @@ -0,0 +1,53 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Red Hat, Inc. + * 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 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. + * + */ + +// | ... | +// +--------------------+ ------------------ +// | frame_type | low addresses +// | next_frame | high addresses +// +--------------------+ ------------------ +// | ... | + +class FakeStubFrame : public ZeroFrame { + private: + FakeStubFrame() : ZeroFrame() { + ShouldNotCallThis(); + } + + protected: + enum Layout { + header_words = jf_header_words + }; + + public: + static FakeStubFrame *build(ZeroStack* stack); + + public: + void identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const {} +}; diff --git a/hotspot/src/cpu/zero/vm/frame_zero.cpp b/hotspot/src/cpu/zero/vm/frame_zero.cpp new file mode 100644 index 00000000000..1b3cafdc589 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/frame_zero.cpp @@ -0,0 +1,414 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_frame_zero.cpp.incl" + +#ifdef ASSERT +void RegisterMap::check_location_valid() { + ShouldNotCallThis(); +} +#endif + +bool frame::is_interpreted_frame() const { + return zeroframe()->is_interpreter_frame(); +} + +bool frame::is_fake_stub_frame() const { + return zeroframe()->is_fake_stub_frame(); +} + +frame frame::sender_for_entry_frame(RegisterMap *map) const { + assert(map != NULL, "map must be set"); + assert(!entry_frame_is_first(), "next Java fp must be non zero"); + assert(entry_frame_call_wrapper()->anchor()->last_Java_sp() == sender_sp(), + "sender should be next Java frame"); + map->clear(); + assert(map->include_argument_oops(), "should be set by clear"); + return frame(sender_sp(), sp() + 1); +} + +frame frame::sender_for_interpreter_frame(RegisterMap *map) const { + return frame(sender_sp(), sp() + 1); +} + +frame frame::sender_for_compiled_frame(RegisterMap *map) const { + return frame(sender_sp(), sp() + 1); +} + +frame frame::sender_for_fake_stub_frame(RegisterMap *map) const { + return frame(sender_sp(), sp() + 1); +} + +frame frame::sender(RegisterMap* map) const { + // Default is not to follow arguments; the various + // sender_for_xxx methods update this accordingly. + map->set_include_argument_oops(false); + + if (is_entry_frame()) + return sender_for_entry_frame(map); + + if (is_interpreted_frame()) + return sender_for_interpreter_frame(map); + + if (is_compiled_frame()) + return sender_for_compiled_frame(map); + + if (is_fake_stub_frame()) + return sender_for_fake_stub_frame(map); + + ShouldNotReachHere(); +} + +#ifdef CC_INTERP +BasicObjectLock* frame::interpreter_frame_monitor_begin() const { + return get_interpreterState()->monitor_base(); +} + +BasicObjectLock* frame::interpreter_frame_monitor_end() const { + return (BasicObjectLock*) get_interpreterState()->stack_base(); +} +#endif // CC_INTERP + +void frame::patch_pc(Thread* thread, address pc) { + // We borrow this call to set the thread pointer in the interpreter + // state; the hook to set up deoptimized frames isn't supplied it. + assert(pc == NULL, "should be"); + get_interpreterState()->set_thread((JavaThread *) thread); +} + +bool frame::safe_for_sender(JavaThread *thread) { + ShouldNotCallThis(); +} + +void frame::pd_gc_epilog() { +} + +bool frame::is_interpreted_frame_valid(JavaThread *thread) const { + ShouldNotCallThis(); +} + +BasicType frame::interpreter_frame_result(oop* oop_result, + jvalue* value_result) { + assert(is_interpreted_frame(), "interpreted frame expected"); + methodOop method = interpreter_frame_method(); + BasicType type = method->result_type(); + intptr_t* tos_addr = (intptr_t *) interpreter_frame_tos_address(); + oop obj; + + switch (type) { + case T_VOID: + break; + case T_BOOLEAN: + value_result->z = *(jboolean *) tos_addr; + break; + case T_BYTE: + value_result->b = *(jbyte *) tos_addr; + break; + case T_CHAR: + value_result->c = *(jchar *) tos_addr; + break; + case T_SHORT: + value_result->s = *(jshort *) tos_addr; + break; + case T_INT: + value_result->i = *(jint *) tos_addr; + break; + case T_LONG: + value_result->j = *(jlong *) tos_addr; + break; + case T_FLOAT: + value_result->f = *(jfloat *) tos_addr; + break; + case T_DOUBLE: + value_result->d = *(jdouble *) tos_addr; + break; + + case T_OBJECT: + case T_ARRAY: + if (method->is_native()) { + obj = get_interpreterState()->oop_temp(); + } + else { + oop* obj_p = (oop *) tos_addr; + obj = (obj_p == NULL) ? (oop) NULL : *obj_p; + } + assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); + *oop_result = obj; + break; + + default: + ShouldNotReachHere(); + } + + return type; +} + +int frame::frame_size(RegisterMap* map) const { +#ifdef PRODUCT + ShouldNotCallThis(); +#else + return 0; // make javaVFrame::print_value work +#endif // PRODUCT +} + +intptr_t* frame::interpreter_frame_tos_at(jint offset) const { + int index = (Interpreter::expr_offset_in_bytes(offset) / wordSize); + return &interpreter_frame_tos_address()[index]; +} + +void frame::zero_print_on_error(int frame_index, + outputStream* st, + char* buf, + int buflen) const { + // Divide the buffer between the field and the value + buflen >>= 1; + char *fieldbuf = buf; + char *valuebuf = buf + buflen; + + // Print each word of the frame + for (intptr_t *addr = fp(); addr <= sp(); addr++) { + int offset = sp() - addr; + + // Fill in default values, then try and improve them + snprintf(fieldbuf, buflen, "word[%d]", offset); + snprintf(valuebuf, buflen, PTR_FORMAT, *addr); + zeroframe()->identify_word(frame_index, offset, fieldbuf, valuebuf, buflen); + fieldbuf[buflen - 1] = '\0'; + valuebuf[buflen - 1] = '\0'; + + // Print the result + st->print_cr(" " PTR_FORMAT ": %-21s = %s", addr, fieldbuf, valuebuf); + } +} + +void ZeroFrame::identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const { + switch (offset) { + case next_frame_off: + strncpy(fieldbuf, "next_frame", buflen); + break; + + case frame_type_off: + strncpy(fieldbuf, "frame_type", buflen); + if (is_entry_frame()) + strncpy(valuebuf, "ENTRY_FRAME", buflen); + else if (is_interpreter_frame()) + strncpy(valuebuf, "INTERPRETER_FRAME", buflen); + else if (is_shark_frame()) + strncpy(valuebuf, "SHARK_FRAME", buflen); + else if (is_fake_stub_frame()) + strncpy(valuebuf, "FAKE_STUB_FRAME", buflen); + break; + + default: + if (is_entry_frame()) { + as_entry_frame()->identify_word( + frame_index, offset, fieldbuf, valuebuf, buflen); + } + else if (is_interpreter_frame()) { + as_interpreter_frame()->identify_word( + frame_index, offset, fieldbuf, valuebuf, buflen); + } + else if (is_shark_frame()) { + as_shark_frame()->identify_word( + frame_index, offset, fieldbuf, valuebuf, buflen); + } + else if (is_fake_stub_frame()) { + as_fake_stub_frame()->identify_word( + frame_index, offset, fieldbuf, valuebuf, buflen); + } + } +} + +void EntryFrame::identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const { + switch (offset) { + case call_wrapper_off: + strncpy(fieldbuf, "call_wrapper", buflen); + break; + + default: + snprintf(fieldbuf, buflen, "local[%d]", offset - 3); + } +} + +void InterpreterFrame::identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const { + interpreterState istate = interpreter_state(); + bool is_valid = istate->self_link() == istate; + intptr_t *addr = addr_of_word(offset); + + // Fixed part + if (addr >= (intptr_t *) istate) { + const char *field = istate->name_of_field_at_address((address) addr); + if (field) { + if (is_valid && !strcmp(field, "_method")) { + istate->method()->name_and_sig_as_C_string(valuebuf, buflen); + } + else if (is_valid && !strcmp(field, "_bcp") && istate->bcp()) { + snprintf(valuebuf, buflen, PTR_FORMAT " (bci %d)", + (intptr_t) istate->bcp(), + istate->method()->bci_from(istate->bcp())); + } + snprintf(fieldbuf, buflen, "%sistate->%s", + field[strlen(field) - 1] == ')' ? "(": "", field); + } + else if (addr == (intptr_t *) istate) { + strncpy(fieldbuf, "(vtable for istate)", buflen); + } + return; + } + + // Variable part + if (!is_valid) + return; + + // JNI stuff + if (istate->method()->is_native() && addr < istate->stack_base()) { + address hA = istate->method()->signature_handler(); + if (hA != NULL) { + if (hA != (address) InterpreterRuntime::slow_signature_handler) { + InterpreterRuntime::SignatureHandler *handler = + InterpreterRuntime::SignatureHandler::from_handlerAddr(hA); + + intptr_t *params = istate->stack_base() - handler->argument_count(); + if (addr >= params) { + int param = addr - params; + const char *desc = ""; + if (param == 0) + desc = " (JNIEnv)"; + else if (param == 1) { + if (istate->method()->is_static()) + desc = " (mirror)"; + else + desc = " (this)"; + } + snprintf(fieldbuf, buflen, "parameter[%d]%s", param, desc); + return; + } + + for (int i = 0; i < handler->argument_count(); i++) { + if (params[i] == (intptr_t) addr) { + snprintf(fieldbuf, buflen, "unboxed parameter[%d]", i); + return; + } + } + } + } + return; + } + + // Monitors and stack + identify_vp_word(frame_index, addr, + (intptr_t *) istate->monitor_base(), + istate->stack_base(), + fieldbuf, buflen); +} + +void SharkFrame::identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const { + // Fixed part + switch (offset) { + case pc_off: + strncpy(fieldbuf, "pc", buflen); + if (method()->is_oop()) { + nmethod *code = method()->code(); + if (code && code->pc_desc_at(pc())) { + SimpleScopeDesc ssd(code, pc()); + snprintf(valuebuf, buflen, PTR_FORMAT " (bci %d)", + (intptr_t) pc(), ssd.bci()); + } + } + return; + + case unextended_sp_off: + strncpy(fieldbuf, "unextended_sp", buflen); + return; + + case method_off: + strncpy(fieldbuf, "method", buflen); + if (method()->is_oop()) { + method()->name_and_sig_as_C_string(valuebuf, buflen); + } + return; + + case oop_tmp_off: + strncpy(fieldbuf, "oop_tmp", buflen); + return; + } + + // Variable part + if (method()->is_oop()) { + identify_vp_word(frame_index, addr_of_word(offset), + addr_of_word(header_words + 1), + unextended_sp() + method()->max_stack(), + fieldbuf, buflen); + } +} + +void ZeroFrame::identify_vp_word(int frame_index, + intptr_t* addr, + intptr_t* monitor_base, + intptr_t* stack_base, + char* fieldbuf, + int buflen) const { + // Monitors + if (addr >= stack_base && addr < monitor_base) { + int monitor_size = frame::interpreter_frame_monitor_size(); + int last_index = (monitor_base - stack_base) / monitor_size - 1; + int index = last_index - (addr - stack_base) / monitor_size; + intptr_t monitor = (intptr_t) ( + (BasicObjectLock *) monitor_base - 1 - index); + intptr_t offset = (intptr_t) addr - monitor; + + if (offset == BasicObjectLock::obj_offset_in_bytes()) + snprintf(fieldbuf, buflen, "monitor[%d]->_obj", index); + else if (offset == BasicObjectLock::lock_offset_in_bytes()) + snprintf(fieldbuf, buflen, "monitor[%d]->_lock", index); + + return; + } + + // Expression stack + if (addr < stack_base) { + snprintf(fieldbuf, buflen, "%s[%d]", + frame_index == 0 ? "stack_word" : "local", + (int) (stack_base - addr - 1)); + return; + } +} diff --git a/hotspot/src/cpu/zero/vm/frame_zero.hpp b/hotspot/src/cpu/zero/vm/frame_zero.hpp new file mode 100644 index 00000000000..81b6314571d --- /dev/null +++ b/hotspot/src/cpu/zero/vm/frame_zero.hpp @@ -0,0 +1,77 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +// A frame represents a physical stack frame on the Zero stack. + + public: + enum { + pc_return_offset = 0 + }; + + // Constructor + public: + frame(intptr_t* sp, intptr_t* fp); + + // The sp of a Zero frame is the address of the highest word in + // that frame. We keep track of the lowest address too, so the + // boundaries of the frame are available for debug printing. + private: + intptr_t* _fp; + + public: + intptr_t* fp() const { + return _fp; + } + +#ifdef CC_INTERP + inline interpreterState get_interpreterState() const; +#endif // CC_INTERP + + public: + const ZeroFrame *zeroframe() const { + return (ZeroFrame *) sp(); + } + + const EntryFrame *zero_entryframe() const { + return zeroframe()->as_entry_frame(); + } + const InterpreterFrame *zero_interpreterframe() const { + return zeroframe()->as_interpreter_frame(); + } + const SharkFrame *zero_sharkframe() const { + return zeroframe()->as_shark_frame(); + } + + public: + bool is_fake_stub_frame() const; + + public: + frame sender_for_fake_stub_frame(RegisterMap* map) const; + + public: + void zero_print_on_error(int index, + outputStream* st, + char* buf, + int buflen) const; diff --git a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp new file mode 100644 index 00000000000..2751117f897 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp @@ -0,0 +1,151 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +// Constructors + +inline frame::frame() { + _sp = NULL; + _fp = NULL; + _pc = NULL; + _cb = NULL; + _deopt_state = unknown; +} + +inline frame::frame(intptr_t* sp, intptr_t* fp) { + _sp = sp; + _fp = fp; + switch (zeroframe()->type()) { + case ZeroFrame::ENTRY_FRAME: + _pc = StubRoutines::call_stub_return_pc(); + _cb = NULL; + break; + + case ZeroFrame::INTERPRETER_FRAME: + _pc = NULL; + _cb = NULL; + break; + + case ZeroFrame::SHARK_FRAME: + _pc = zero_sharkframe()->pc(); + _cb = CodeCache::find_blob_unsafe(pc()); + break; + + case ZeroFrame::FAKE_STUB_FRAME: + _pc = NULL; + _cb = NULL; + break; + + default: + ShouldNotReachHere(); + } + _deopt_state = not_deoptimized; +} + +// Accessors + +inline intptr_t* frame::sender_sp() const { + return (intptr_t *) zeroframe()->next(); +} + +inline intptr_t* frame::link() const { + ShouldNotCallThis(); +} + +#ifdef CC_INTERP +inline interpreterState frame::get_interpreterState() const { + return zero_interpreterframe()->interpreter_state(); +} + +inline intptr_t** frame::interpreter_frame_locals_addr() const { + return &(get_interpreterState()->_locals); +} + +inline intptr_t* frame::interpreter_frame_bcx_addr() const { + return (intptr_t*) &(get_interpreterState()->_bcp); +} + +inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const { + return &(get_interpreterState()->_constants); +} + +inline methodOop* frame::interpreter_frame_method_addr() const { + return &(get_interpreterState()->_method); +} + +inline intptr_t* frame::interpreter_frame_mdx_addr() const { + return (intptr_t*) &(get_interpreterState()->_mdx); +} + +inline intptr_t* frame::interpreter_frame_tos_address() const { + return get_interpreterState()->_stack + 1; +} +#endif // CC_INTERP + +inline int frame::interpreter_frame_monitor_size() { + return BasicObjectLock::size(); +} + +inline intptr_t* frame::interpreter_frame_expression_stack() const { + intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end(); + return monitor_end - 1; +} + +inline jint frame::interpreter_frame_expression_stack_direction() { + return -1; +} + +// Return a unique id for this frame. The id must have a value where +// we can distinguish identity and younger/older relationship. NULL +// represents an invalid (incomparable) frame. +inline intptr_t* frame::id() const { + return sp(); +} + +inline JavaCallWrapper* frame::entry_frame_call_wrapper() const { + return zero_entryframe()->call_wrapper(); +} + +inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { + ShouldNotCallThis(); +} + +inline oop frame::saved_oop_result(RegisterMap* map) const { + ShouldNotCallThis(); +} + +inline bool frame::is_older(intptr_t* id) const { + ShouldNotCallThis(); +} + +inline intptr_t* frame::entry_frame_argument_at(int offset) const { + ShouldNotCallThis(); +} + +inline intptr_t* frame::unextended_sp() const { + if (zeroframe()->is_shark_frame()) + return zero_sharkframe()->unextended_sp(); + else + return (intptr_t *) -1; +} diff --git a/hotspot/src/cpu/zero/vm/globalDefinitions_zero.hpp b/hotspot/src/cpu/zero/vm/globalDefinitions_zero.hpp new file mode 100644 index 00000000000..90283f73762 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/globalDefinitions_zero.hpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +#include diff --git a/hotspot/src/cpu/zero/vm/globals_zero.hpp b/hotspot/src/cpu/zero/vm/globals_zero.hpp new file mode 100644 index 00000000000..89cf7077dee --- /dev/null +++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +// +// Set the default values for platform dependent flags used by the +// runtime system. See globals.hpp for details of what they do. +// + +define_pd_global(bool, ConvertSleepToYield, true); +define_pd_global(bool, ShareVtableStubs, true); +define_pd_global(bool, CountInterpCalls, true); +define_pd_global(bool, NeedsDeoptSuspend, false); + +define_pd_global(bool, ImplicitNullChecks, true); +define_pd_global(bool, UncommonNullCast, true); + +define_pd_global(intx, CodeEntryAlignment, 32); +define_pd_global(uintx, TLABSize, 0); +#ifdef _LP64 +define_pd_global(uintx, NewSize, ScaleForWordSize(2048 * K)); +#else +define_pd_global(uintx, NewSize, ScaleForWordSize(1024 * K)); +#endif // _LP64 +define_pd_global(intx, InlineFrequencyCount, 100); +define_pd_global(intx, InlineSmallCode, 1000); +define_pd_global(intx, PreInflateSpin, 10); + +define_pd_global(intx, StackYellowPages, 2); +define_pd_global(intx, StackRedPages, 1); +define_pd_global(intx, StackShadowPages, 3 LP64_ONLY(+3) DEBUG_ONLY(+3)); + +define_pd_global(bool, RewriteBytecodes, true); +define_pd_global(bool, RewriteFrequentPairs, true); diff --git a/jaxws/src/share/classes/com/sun/codemodel/internal/JAnonymousClass.java b/hotspot/src/cpu/zero/vm/icBuffer_zero.cpp similarity index 52% rename from jaxws/src/share/classes/com/sun/codemodel/internal/JAnonymousClass.java rename to hotspot/src/cpu/zero/vm/icBuffer_zero.cpp index 440d4001d6c..2a13793e937 100644 --- a/jaxws/src/share/classes/com/sun/codemodel/internal/JAnonymousClass.java +++ b/hotspot/src/cpu/zero/vm/icBuffer_zero.cpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,28 +20,30 @@ * 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. - */ -package com.sun.codemodel.internal; - -/** - * Anonymous class quick hack. * - * @author - * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ -class JAnonymousClass extends JDefinedClass { - /** - * Base interface/class from which this anonymous class is built. - */ - private final JClass base; +#include "incls/_precompiled.incl" +#include "incls/_icBuffer_zero.cpp.incl" - JAnonymousClass( JClass _base) { - super(_base.owner(), 0, null); - this.base = _base; - } - - public String fullName() { - return base.fullName(); - } +int InlineCacheBuffer::ic_stub_code_size() { + // NB set this once the functions below are implemented + return 4; +} + +void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin, + oop cached_oop, + address entry_point) { + // NB ic_stub_code_size() must return the size of the code we generate + ShouldNotCallThis(); +} + +address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) { + // NB ic_stub_code_size() must return the size of the code we generate + ShouldNotCallThis(); +} + +oop InlineCacheBuffer::ic_buffer_cached_oop(address code_begin) { + // NB ic_stub_code_size() must return the size of the code we generate + ShouldNotCallThis(); } diff --git a/jdk/test/javax/management/mxbean/customtypes/CustomLongMXBean.java b/hotspot/src/cpu/zero/vm/icache_zero.cpp similarity index 76% rename from jdk/test/javax/management/mxbean/customtypes/CustomLongMXBean.java rename to hotspot/src/cpu/zero/vm/icache_zero.cpp index 5c1e4aef60a..2ec44595b6a 100644 --- a/jdk/test/javax/management/mxbean/customtypes/CustomLongMXBean.java +++ b/hotspot/src/cpu/zero/vm/icache_zero.cpp @@ -1,5 +1,6 @@ /* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,13 +20,13 @@ * 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. + * */ -// CustomLongMXBean.java - see CustomTypeTest +#include "incls/_precompiled.incl" +#include "incls/_icache_zero.cpp.incl" -package customtypes; - -import javax.management.openmbean.MXBeanMappingFactoryClass; - -@MXBeanMappingFactoryClass(IntegerIsLongFactory.class) -public interface CustomLongMXBean extends CustomMXBean {} +void ICacheStubGenerator::generate_icache_flush( + ICache::flush_icache_stub_t* flush_icache_stub) { + ShouldNotCallThis(); +} diff --git a/hotspot/src/cpu/zero/vm/icache_zero.hpp b/hotspot/src/cpu/zero/vm/icache_zero.hpp new file mode 100644 index 00000000000..bd1f8a58556 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/icache_zero.hpp @@ -0,0 +1,36 @@ +/* + * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2009 Red Hat, Inc. + * 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 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. + * + */ + +// Interface for updating the instruction cache. Whenever the VM +// modifies code, part of the processor instruction cache potentially +// has to be flushed. This implementation is empty: Zero never deals +// with code, and LLVM handles cache flushing for Shark. + +class ICache : public AbstractICache { + public: + static void initialize() {} + static void invalidate_word(address addr) {} + static void invalidate_range(address start, int nbytes) {} +}; diff --git a/hotspot/src/cpu/zero/vm/interp_masm_zero.cpp b/hotspot/src/cpu/zero/vm/interp_masm_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/interp_masm_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/jaxws/src/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPStyle.java b/hotspot/src/cpu/zero/vm/interp_masm_zero.hpp similarity index 62% rename from jaxws/src/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPStyle.java rename to hotspot/src/cpu/zero/vm/interp_masm_zero.hpp index 4dc852eed8d..ee59ed22807 100644 --- a/jaxws/src/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPStyle.java +++ b/hotspot/src/cpu/zero/vm/interp_masm_zero.hpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,20 +20,19 @@ * 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. - */ - -package com.sun.tools.internal.ws.wsdl.document.soap; - -/** - * A SOAP "style" enumeration. * - * @author WS Development Team */ -public final class SOAPStyle { - public static final SOAPStyle RPC = new SOAPStyle(); - public static final SOAPStyle DOCUMENT = new SOAPStyle(); +// This file specializes the assember with interpreter-specific macros - private SOAPStyle() { - } -} +class InterpreterMacroAssembler : public MacroAssembler { + public: + InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {} + + public: + RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr, + Register tmp, + int offset) { + ShouldNotCallThis(); + } +}; diff --git a/hotspot/src/cpu/zero/vm/interpreterFrame_zero.hpp b/hotspot/src/cpu/zero/vm/interpreterFrame_zero.hpp new file mode 100644 index 00000000000..7c8199c05ce --- /dev/null +++ b/hotspot/src/cpu/zero/vm/interpreterFrame_zero.hpp @@ -0,0 +1,75 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Red Hat, Inc. + * 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 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. + * + */ + +#ifdef CC_INTERP +// | ... | +// +--------------------+ ------------------ +// | stack slot n-1 | low addresses +// | ... | +// | stack slot 0 | +// | monitor 0 (maybe) | +// | ... | +// | interpreter state | +// | ... | +// | frame_type | +// | next_frame | high addresses +// +--------------------+ ------------------ +// | ... | + +class InterpreterFrame : public ZeroFrame { + friend class AbstractInterpreter; + + private: + InterpreterFrame() : ZeroFrame() { + ShouldNotCallThis(); + } + + protected: + enum Layout { + istate_off = jf_header_words + + (align_size_up_(sizeof(BytecodeInterpreter), + wordSize) >> LogBytesPerWord) - 1, + header_words + }; + + public: + static InterpreterFrame *build(ZeroStack* stack, + const methodOop method, + JavaThread* thread); + static InterpreterFrame *build(ZeroStack* stack, int size); + + public: + interpreterState interpreter_state() const { + return (interpreterState) addr_of_word(istate_off); + } + + public: + void identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const; +}; +#endif // CC_INTERP diff --git a/jaxws/src/share/classes/com/sun/tools/internal/ws/wsdl/framework/EntityReferenceAction.java b/hotspot/src/cpu/zero/vm/interpreterGenerator_zero.hpp similarity index 63% rename from jaxws/src/share/classes/com/sun/tools/internal/ws/wsdl/framework/EntityReferenceAction.java rename to hotspot/src/cpu/zero/vm/interpreterGenerator_zero.hpp index 43d5bd6c7b3..4158460e756 100644 --- a/jaxws/src/share/classes/com/sun/tools/internal/ws/wsdl/framework/EntityReferenceAction.java +++ b/hotspot/src/cpu/zero/vm/interpreterGenerator_zero.hpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,17 +20,18 @@ * 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. - */ - -package com.sun.tools.internal.ws.wsdl.framework; - -import javax.xml.namespace.QName; - -/** - * An action operating on an entity reference composed of a kind and a QName. * - * @author WS Development Team */ -public interface EntityReferenceAction { - public void perform(Kind kind, QName name); -} + + // Generation of Interpreter + // + friend class AbstractInterpreterGenerator; + + private: + address generate_normal_entry(bool synchronized); + address generate_native_entry(bool synchronized); + address generate_abstract_entry(); + address generate_math_entry(AbstractInterpreter::MethodKind kind); + address generate_empty_entry(); + address generate_accessor_entry(); + address generate_method_handle_entry(); diff --git a/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp b/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp new file mode 100644 index 00000000000..912a8aeacc7 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp @@ -0,0 +1,162 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_interpreterRT_zero.cpp.incl" + +void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_int() { + push(T_INT); + _cif->nargs++; +} + +void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_long() { + push(T_LONG); + _cif->nargs++; +} + +void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_float() { + push(T_FLOAT); + _cif->nargs++; +} + +void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_double() { + push(T_DOUBLE); + _cif->nargs++; +} + +void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_object() { + push(T_OBJECT); + _cif->nargs++; +} + +void InterpreterRuntime::SignatureHandlerGeneratorBase::push(BasicType type) { + ffi_type *ftype; + switch (type) { + case T_VOID: + ftype = &ffi_type_void; + break; + + case T_BOOLEAN: + ftype = &ffi_type_uint8; + break; + + case T_CHAR: + ftype = &ffi_type_uint16; + break; + + case T_BYTE: + ftype = &ffi_type_sint8; + break; + + case T_SHORT: + ftype = &ffi_type_sint16; + break; + + case T_INT: + ftype = &ffi_type_sint32; + break; + + case T_LONG: + ftype = &ffi_type_sint64; + break; + + case T_FLOAT: + ftype = &ffi_type_float; + break; + + case T_DOUBLE: + ftype = &ffi_type_double; + break; + + case T_OBJECT: + case T_ARRAY: + ftype = &ffi_type_pointer; + break; + + default: + ShouldNotReachHere(); + } + push((intptr_t) ftype); +} + +// For fast signature handlers the "signature handler" is generated +// into a temporary buffer. It is then copied to its final location, +// and pd_set_handler is called on it. We have this two stage thing +// to accomodate this. + +void InterpreterRuntime::SignatureHandlerGeneratorBase::generate( + uint64_t fingerprint) { + + // Build the argument types list + pass_object(); + if (method()->is_static()) + pass_object(); + iterate(fingerprint); + + // Tack on the result type + push(method()->result_type()); +} + +void InterpreterRuntime::SignatureHandler::finalize() { + ffi_status status = + ffi_prep_cif(cif(), + FFI_DEFAULT_ABI, + argument_count(), + result_type(), + argument_types()); + + assert(status == FFI_OK, "should be"); +} + +IRT_ENTRY(address, + InterpreterRuntime::slow_signature_handler(JavaThread* thread, + methodOop method, + intptr_t* unused1, + intptr_t* unused2)) + ZeroStack *stack = thread->zero_stack(); + + int required_words = + (align_size_up(sizeof(ffi_cif), wordSize) >> LogBytesPerWord) + + (method->is_static() ? 2 : 1) + method->size_of_parameters() + 1; + if (required_words > stack->available_words()) { + Unimplemented(); + } + + intptr_t *buf = (intptr_t *) stack->alloc(required_words * wordSize); + SlowSignatureHandlerGenerator sshg(methodHandle(thread, method), buf); + sshg.generate(UCONST64(-1)); + + SignatureHandler *handler = sshg.handler(); + handler->finalize(); + + return (address) handler; +IRT_END + +void SignatureHandlerLibrary::pd_set_handler(address handlerAddr) { + InterpreterRuntime::SignatureHandler *handler = + InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr); + + handler->finalize(); +} diff --git a/hotspot/src/cpu/zero/vm/interpreterRT_zero.hpp b/hotspot/src/cpu/zero/vm/interpreterRT_zero.hpp new file mode 100644 index 00000000000..4bc1034756d --- /dev/null +++ b/hotspot/src/cpu/zero/vm/interpreterRT_zero.hpp @@ -0,0 +1,127 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +class SignatureHandler { + public: + static SignatureHandler *from_handlerAddr(address handlerAddr) { + return (SignatureHandler *) handlerAddr; + } + + public: + ffi_cif* cif() const { + return (ffi_cif *) this; + } + + int argument_count() const { + return cif()->nargs; + } + + ffi_type** argument_types() const { + return (ffi_type**) (cif() + 1); + } + + ffi_type* argument_type(int i) const { + return argument_types()[i]; + } + + ffi_type* result_type() const { + return *(argument_types() + argument_count()); + } + + protected: + friend class InterpreterRuntime; + friend class SignatureHandlerLibrary; + + void finalize(); +}; + +class SignatureHandlerGeneratorBase : public NativeSignatureIterator { + private: + ffi_cif* _cif; + + protected: + SignatureHandlerGeneratorBase(methodHandle method, ffi_cif *cif) + : NativeSignatureIterator(method), _cif(cif) { + _cif->nargs = 0; + } + + ffi_cif *cif() const { + return _cif; + } + + public: + void generate(uint64_t fingerprint); + + private: + void pass_int(); + void pass_long(); + void pass_float(); + void pass_double(); + void pass_object(); + + private: + void push(BasicType type); + virtual void push(intptr_t value) = 0; +}; + +class SignatureHandlerGenerator : public SignatureHandlerGeneratorBase { + private: + CodeBuffer* _cb; + + public: + SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) + : SignatureHandlerGeneratorBase(method, (ffi_cif *) buffer->code_end()), + _cb(buffer) { + _cb->set_code_end((address) (cif() + 1)); + } + + private: + void push(intptr_t value) { + intptr_t *dst = (intptr_t *) _cb->code_end(); + _cb->set_code_end((address) (dst + 1)); + *dst = value; + } +}; + +class SlowSignatureHandlerGenerator : public SignatureHandlerGeneratorBase { + private: + intptr_t *_dst; + + public: + SlowSignatureHandlerGenerator(methodHandle method, intptr_t* buf) + : SignatureHandlerGeneratorBase(method, (ffi_cif *) buf) { + _dst = (intptr_t *) (cif() + 1); + } + + private: + void push(intptr_t value) { + *(_dst++) = value; + } + + public: + SignatureHandler *handler() const { + return (SignatureHandler *) cif(); + } +}; diff --git a/hotspot/src/cpu/zero/vm/interpreter_zero.cpp b/hotspot/src/cpu/zero/vm/interpreter_zero.cpp new file mode 100644 index 00000000000..1ece7bbdffe --- /dev/null +++ b/hotspot/src/cpu/zero/vm/interpreter_zero.cpp @@ -0,0 +1,70 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_interpreter_zero.cpp.incl" + +address AbstractInterpreterGenerator::generate_slow_signature_handler() { + _masm->advance(1); + return (address) InterpreterRuntime::slow_signature_handler; +} + +address InterpreterGenerator::generate_math_entry( + AbstractInterpreter::MethodKind kind) { + if (!InlineIntrinsics) + return NULL; + + Unimplemented(); +} + +address InterpreterGenerator::generate_abstract_entry() { + return ShouldNotCallThisEntry(); +} + +address InterpreterGenerator::generate_method_handle_entry() { + return ShouldNotCallThisEntry(); +} + +int AbstractInterpreter::size_activation(methodOop method, + int tempcount, + int popframe_extra_args, + int moncount, + int callee_param_count, + int callee_locals, + bool is_top_frame) { + return layout_activation(method, + tempcount, + popframe_extra_args, + moncount, + callee_param_count, + callee_locals, + (frame*) NULL, + (frame*) NULL, + is_top_frame); +} + +void Deoptimization::unwind_callee_save_values(frame* f, + vframeArray* vframe_array) { +} diff --git a/hotspot/src/cpu/zero/vm/interpreter_zero.hpp b/hotspot/src/cpu/zero/vm/interpreter_zero.hpp new file mode 100644 index 00000000000..67cac47d9a2 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/interpreter_zero.hpp @@ -0,0 +1,61 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + + public: + static void invoke_method(methodOop method, address entry_point, TRAPS) { + ((ZeroEntry *) entry_point)->invoke(method, THREAD); + } + static void invoke_osr(methodOop method, + address entry_point, + address osr_buf, + TRAPS) { + ((ZeroEntry *) entry_point)->invoke_osr(method, osr_buf, THREAD); + } + + public: + static int expr_index_at(int i) { + return stackElementWords() * i; + } + static int expr_tag_index_at(int i) { + assert(TaggedStackInterpreter, "should not call this"); + Unimplemented(); + } + + static int expr_offset_in_bytes(int i) { + return stackElementSize() * i; + } + static int expr_tag_offset_in_bytes(int i) { + assert(TaggedStackInterpreter, "should not call this"); + Unimplemented(); + } + + static int local_index_at(int i) { + assert(i <= 0, "local direction already negated"); + return stackElementWords() * i + (value_offset_in_bytes() / wordSize); + } + static int local_tag_index_at(int i) { + assert(TaggedStackInterpreter, "should not call this"); + Unimplemented(); + } diff --git a/hotspot/src/cpu/zero/vm/javaFrameAnchor_zero.hpp b/hotspot/src/cpu/zero/vm/javaFrameAnchor_zero.hpp new file mode 100644 index 00000000000..e356cc91866 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/javaFrameAnchor_zero.hpp @@ -0,0 +1,72 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + + public: + // Each arch must define reset, save, restore + // These are used by objects that only care about: + // 1 - initializing a new state (thread creation, javaCalls) + // 2 - saving a current state (javaCalls) + // 3 - restoring an old state (javaCalls) + + void clear() { + // clearing _last_Java_sp must be first + _last_Java_sp = NULL; + // fence? + _last_Java_pc = NULL; + } + + void copy(JavaFrameAnchor* src) { + // In order to make sure the transition state is valid for "this" + // We must clear _last_Java_sp before copying the rest of the new + // data + // + // Hack Alert: Temporary bugfix for 4717480/4721647 To act like + // previous version (pd_cache_state) don't NULL _last_Java_sp + // unless the value is changing + // + if (_last_Java_sp != src->_last_Java_sp) + _last_Java_sp = NULL; + + _last_Java_pc = src->_last_Java_pc; + // Must be last so profiler will always see valid frame if + // has_last_frame() is true + _last_Java_sp = src->_last_Java_sp; + } + + bool walkable() { + return true; + } + + void make_walkable(JavaThread* thread) { + // nothing to do + } + + intptr_t* last_Java_sp() const { + return _last_Java_sp; + } + + void set_last_Java_sp(intptr_t* sp) { + _last_Java_sp = sp; + } diff --git a/hotspot/src/cpu/zero/vm/jniFastGetField_zero.cpp b/hotspot/src/cpu/zero/vm/jniFastGetField_zero.cpp new file mode 100644 index 00000000000..251903426c9 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/jniFastGetField_zero.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_jniFastGetField_zero.cpp.incl" + +address JNI_FastGetField::generate_fast_get_boolean_field() { + return (address) -1; +} + +address JNI_FastGetField::generate_fast_get_byte_field() { + return (address) -1; +} + +address JNI_FastGetField::generate_fast_get_char_field() { + return (address) -1; +} + +address JNI_FastGetField::generate_fast_get_short_field() { + return (address) -1; +} + +address JNI_FastGetField::generate_fast_get_int_field() { + return (address) -1; +} + +address JNI_FastGetField::generate_fast_get_long_field() { + return (address) -1; +} + +address JNI_FastGetField::generate_fast_get_float_field() { + return (address) -1; +} + +address JNI_FastGetField::generate_fast_get_double_field() { + return (address) -1; +} diff --git a/hotspot/src/cpu/zero/vm/jniTypes_zero.hpp b/hotspot/src/cpu/zero/vm/jniTypes_zero.hpp new file mode 100644 index 00000000000..24f1aab092e --- /dev/null +++ b/hotspot/src/cpu/zero/vm/jniTypes_zero.hpp @@ -0,0 +1,108 @@ +/* + * Copyright 1998-2002 Sun Microsystems, Inc. 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 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. + * + */ + +// This file holds platform-dependent routines used to write primitive jni +// types to the array of arguments passed into JavaCalls::call + +class JNITypes : AllStatic { + // These functions write a java primitive type (in native format) + // to a java stack slot array to be passed as an argument to JavaCalls:calls. + // I.e., they are functionally 'push' operations if they have a 'pos' + // formal parameter. Note that jlong's and jdouble's are written + // _in reverse_ of the order in which they appear in the interpreter + // stack. This is because call stubs (see stubGenerator_zero.cpp) + // reverse the argument list constructed by JavaCallArguments (see + // javaCalls.hpp). + +private: + // Helper routines. + static inline void put_int2 (jint *from, jint *to) { to[0] = from[0]; to[1] = from[1]; } + static inline void put_int2 (jint *from, jint *to, int& pos) { put_int2 (from, (jint *)((intptr_t *)to + pos)); pos += 2; } + static inline void put_int2r(jint *from, jint *to) { to[0] = from[1]; to[1] = from[0]; } + static inline void put_int2r(jint *from, jint *to, int& pos) { put_int2r(from, (jint *)((intptr_t *)to + pos)); pos += 2; } + +public: + // Ints are stored in native format in one JavaCallArgument slot at *to. + static inline void put_int(jint from, intptr_t *to) { *(jint *)(to + 0 ) = from; } + static inline void put_int(jint from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = from; } + static inline void put_int(jint *from, intptr_t *to, int& pos) { *(jint *)(to + pos++) = *from; } + +#ifdef _LP64 + // Longs are stored in native format in one JavaCallArgument slot at *(to+1). + static inline void put_long(jlong from, intptr_t *to) { *(jlong *)(to + 1 + 0) = from; } + static inline void put_long(jlong from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = from; pos += 2; } + static inline void put_long(jlong *from, intptr_t *to, int& pos) { *(jlong *)(to + 1 + pos) = *from; pos += 2; } +#else + // Longs are stored in reversed native word format in two JavaCallArgument slots at *to. + // The high half is in *(to+1) and the low half in *to. + static inline void put_long(jlong from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); } + static inline void put_long(jlong from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); } + static inline void put_long(jlong *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); } +#endif + + // Oops are stored in native format in one JavaCallArgument slot at *to. + static inline void put_obj(oop from, intptr_t *to) { *(oop *)(to + 0 ) = from; } + static inline void put_obj(oop from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = from; } + static inline void put_obj(oop *from, intptr_t *to, int& pos) { *(oop *)(to + pos++) = *from; } + + // Floats are stored in native format in one JavaCallArgument slot at *to. + static inline void put_float(jfloat from, intptr_t *to) { *(jfloat *)(to + 0 ) = from; } + static inline void put_float(jfloat from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = from; } + static inline void put_float(jfloat *from, intptr_t *to, int& pos) { *(jfloat *)(to + pos++) = *from; } + +#ifdef _LP64 + // Doubles are stored in native word format in one JavaCallArgument slot at *(to+1). + static inline void put_double(jdouble from, intptr_t *to) { *(jdouble *)(to + 1 + 0) = from; } + static inline void put_double(jdouble from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = from; pos += 2; } + static inline void put_double(jdouble *from, intptr_t *to, int& pos) { *(jdouble *)(to + 1 + pos) = *from; pos += 2; } +#else + // Doubles are stored in reversed native word format in two JavaCallArgument slots at *to. + static inline void put_double(jdouble from, intptr_t *to) { put_int2r((jint *)&from, (jint *)to); } + static inline void put_double(jdouble from, intptr_t *to, int& pos) { put_int2r((jint *)&from, (jint *)to, pos); } + static inline void put_double(jdouble *from, intptr_t *to, int& pos) { put_int2r((jint *) from, (jint *)to, pos); } +#endif + + // The get_xxx routines, on the other hand, actually _do_ fetch + // java primitive types from the interpreter stack. + static inline jint get_int(intptr_t *from) { return *(jint *)from; } + +#ifdef _LP64 + static inline jlong get_long(intptr_t *from) { return *(jlong *)from; } +#else + static inline jlong get_long(intptr_t *from) { return ((jlong)(*( signed int *)((jint *)from )) << 32) | + ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); } +#endif + + static inline oop get_obj(intptr_t *from) { return *(oop *)from; } + static inline jfloat get_float(intptr_t *from) { return *(jfloat *)from; } + +#ifdef _LP64 + static inline jdouble get_double(intptr_t *from) { return *(jdouble *)from; } +#else + static inline jdouble get_double(intptr_t *from) { jlong jl = ((jlong)(*( signed int *)((jint *)from )) << 32) | + ((jlong)(*(unsigned int *)((jint *)from + 1)) << 0); + return *(jdouble *)&jl; } +#endif + +}; diff --git a/jaxws/src/share/classes/com/sun/xml/internal/bind/v2/runtime/AttributeAccessor.java b/hotspot/src/cpu/zero/vm/jni_zero.h similarity index 81% rename from jaxws/src/share/classes/com/sun/xml/internal/bind/v2/runtime/AttributeAccessor.java rename to hotspot/src/cpu/zero/vm/jni_zero.h index f7f6179df74..40b52afbc52 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/bind/v2/runtime/AttributeAccessor.java +++ b/hotspot/src/cpu/zero/vm/jni_zero.h @@ -1,5 +1,6 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +24,15 @@ * have any questions. */ -package com.sun.xml.internal.bind.v2.runtime; +#define JNIEXPORT +#define JNIIMPORT +#define JNICALL -/** - * - * @author snajper - */ -public interface AttributeAccessor { +typedef int jint; +typedef signed char jbyte; - public boolean isNilIncluded(); -} +#ifdef _LP64 +typedef long jlong; +#else +typedef long long jlong; +#endif diff --git a/hotspot/src/cpu/zero/vm/methodHandles_zero.cpp b/hotspot/src/cpu/zero/vm/methodHandles_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/methodHandles_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/nativeInst_zero.cpp b/hotspot/src/cpu/zero/vm/nativeInst_zero.cpp new file mode 100644 index 00000000000..0d4f10b4ec9 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/nativeInst_zero.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_nativeInst_zero.cpp.incl" + +// This method is called by nmethod::make_not_entrant_or_zombie to +// insert a jump to SharedRuntime::get_handle_wrong_method_stub() +// (dest) at the start of a compiled method (verified_entry) to avoid +// a race where a method is invoked while being made non-entrant. +// +// In Shark, verified_entry is a pointer to a SharkEntry. We can +// handle this simply by changing it's entry point to point at the +// interpreter. This only works because the interpreter and Shark +// calling conventions are the same. + +void NativeJump::patch_verified_entry(address entry, + address verified_entry, + address dest) { + assert(dest == SharedRuntime::get_handle_wrong_method_stub(), "should be"); + +#ifdef CC_INTERP + ((ZeroEntry*) verified_entry)->set_entry_point( + (address) CppInterpreter::normal_entry); +#else + Unimplemented(); +#endif // CC_INTERP +} diff --git a/hotspot/src/cpu/zero/vm/nativeInst_zero.hpp b/hotspot/src/cpu/zero/vm/nativeInst_zero.hpp new file mode 100644 index 00000000000..3c650aa76c1 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/nativeInst_zero.hpp @@ -0,0 +1,185 @@ +/* + * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +// We have interfaces for the following instructions: +// - NativeInstruction +// - - NativeCall +// - - NativeMovConstReg +// - - NativeMovConstRegPatching +// - - NativeJump +// - - NativeIllegalOpCode +// - - NativeReturn +// - - NativeReturnX (return with argument) +// - - NativePushConst +// - - NativeTstRegMem + +// The base class for different kinds of native instruction abstractions. +// Provides the primitive operations to manipulate code relative to this. + +class NativeInstruction VALUE_OBJ_CLASS_SPEC { + public: + bool is_jump() { + ShouldNotCallThis(); + } + + bool is_safepoint_poll() { + ShouldNotCallThis(); + } +}; + +inline NativeInstruction* nativeInstruction_at(address address) { + ShouldNotCallThis(); +} + +class NativeCall : public NativeInstruction { + public: + enum zero_specific_constants { + instruction_size = 0 // not used within the interpreter + }; + + address instruction_address() const { + ShouldNotCallThis(); + } + + address next_instruction_address() const { + ShouldNotCallThis(); + } + + address return_address() const { + ShouldNotCallThis(); + } + + address destination() const { + ShouldNotCallThis(); + } + + void set_destination_mt_safe(address dest) { + ShouldNotCallThis(); + } + + void verify_alignment() { + ShouldNotCallThis(); + } + + void verify() { + ShouldNotCallThis(); + } + + static bool is_call_before(address return_address) { + ShouldNotCallThis(); + } +}; + +inline NativeCall* nativeCall_before(address return_address) { + ShouldNotCallThis(); +} + +inline NativeCall* nativeCall_at(address address) { + ShouldNotCallThis(); +} + +class NativeMovConstReg : public NativeInstruction { + public: + address next_instruction_address() const { + ShouldNotCallThis(); + } + + intptr_t data() const { + ShouldNotCallThis(); + } + + void set_data(intptr_t x) { + ShouldNotCallThis(); + } +}; + +inline NativeMovConstReg* nativeMovConstReg_at(address address) { + ShouldNotCallThis(); +} + +class NativeMovRegMem : public NativeInstruction { + public: + int offset() const { + ShouldNotCallThis(); + } + + void set_offset(intptr_t x) { + ShouldNotCallThis(); + } + + void add_offset_in_bytes(int add_offset) { + ShouldNotCallThis(); + } +}; + +inline NativeMovRegMem* nativeMovRegMem_at(address address) { + ShouldNotCallThis(); +} + +class NativeJump : public NativeInstruction { + public: + enum zero_specific_constants { + instruction_size = 0 // not used within the interpreter + }; + + address jump_destination() const { + ShouldNotCallThis(); + } + + void set_jump_destination(address dest) { + ShouldNotCallThis(); + } + + static void check_verified_entry_alignment(address entry, + address verified_entry) { + } + + static void patch_verified_entry(address entry, + address verified_entry, + address dest); +}; + +inline NativeJump* nativeJump_at(address address) { + ShouldNotCallThis(); +} + +class NativeGeneralJump : public NativeInstruction { + public: + address jump_destination() const { + ShouldNotCallThis(); + } + + static void insert_unconditional(address code_pos, address entry) { + ShouldNotCallThis(); + } + + static void replace_mt_safe(address instr_addr, address code_buffer) { + ShouldNotCallThis(); + } +}; + +inline NativeGeneralJump* nativeGeneralJump_at(address address) { + ShouldNotCallThis(); +} diff --git a/jaxws/src/share/classes/com/sun/tools/internal/xjc/generator/util/ExistingBlockReference.java b/hotspot/src/cpu/zero/vm/registerMap_zero.hpp similarity index 60% rename from jaxws/src/share/classes/com/sun/tools/internal/xjc/generator/util/ExistingBlockReference.java rename to hotspot/src/cpu/zero/vm/registerMap_zero.hpp index 7ad5d31f219..16a1de34bc7 100644 --- a/jaxws/src/share/classes/com/sun/tools/internal/xjc/generator/util/ExistingBlockReference.java +++ b/hotspot/src/cpu/zero/vm/registerMap_zero.hpp @@ -1,12 +1,10 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1998-2007 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,25 +19,21 @@ * 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. - */ -package com.sun.tools.internal.xjc.generator.util; - -import com.sun.codemodel.internal.JBlock; - -/** * - * @author - * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ -public class ExistingBlockReference implements BlockReference { - private final JBlock block; - public ExistingBlockReference( JBlock _block ) { - this.block = _block; - } + // machine-dependent implemention for register maps + friend class frame; - public JBlock get(boolean create) { - return block; - } + private: + // This is the hook for finding a register in an "well-known" location, + // such as a register block of a predetermined format. + // Since there is none, we just return NULL. + // See registerMap_sparc.hpp for an example of grabbing registers + // from register save areas of a standard layout. + address pd_location(VMReg reg) const { return NULL; } -} + // no PD state to clear or copy: + void pd_clear() {} + void pd_initialize() {} + void pd_initialize_from(const RegisterMap* map) {} diff --git a/hotspot/src/cpu/zero/vm/register_definitions_zero.cpp b/hotspot/src/cpu/zero/vm/register_definitions_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/register_definitions_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/register_zero.cpp b/hotspot/src/cpu/zero/vm/register_zero.cpp new file mode 100644 index 00000000000..a9590561fba --- /dev/null +++ b/hotspot/src/cpu/zero/vm/register_zero.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_register_zero.cpp.incl" + +const int ConcreteRegisterImpl::max_gpr = RegisterImpl::number_of_registers; +const int ConcreteRegisterImpl::max_fpr = + ConcreteRegisterImpl::max_gpr + FloatRegisterImpl::number_of_registers; + +const char* RegisterImpl::name() const { + ShouldNotCallThis(); +} + +const char* FloatRegisterImpl::name() const { + ShouldNotCallThis(); +} diff --git a/hotspot/src/cpu/zero/vm/register_zero.hpp b/hotspot/src/cpu/zero/vm/register_zero.hpp new file mode 100644 index 00000000000..abb7fc6ac8b --- /dev/null +++ b/hotspot/src/cpu/zero/vm/register_zero.hpp @@ -0,0 +1,110 @@ +/* + * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +class VMRegImpl; +typedef VMRegImpl* VMReg; + +// Use Register as shortcut +class RegisterImpl; +typedef RegisterImpl* Register; + +inline Register as_Register(int encoding) { + return (Register)(intptr_t) encoding; +} + +// The implementation of integer registers for the zero architecture +class RegisterImpl : public AbstractRegisterImpl { + public: + enum { + number_of_registers = 0 + }; + + // construction + inline friend Register as_Register(int encoding); + VMReg as_VMReg(); + + // derived registers, offsets, and addresses + Register successor() const { + return as_Register(encoding() + 1); + } + + // accessors + int encoding() const { + assert(is_valid(), "invalid register"); + return (intptr_t)this; + } + bool is_valid() const { + return 0 <= (intptr_t) this && (intptr_t)this < number_of_registers; + } + const char* name() const; +}; + +// Use FloatRegister as shortcut +class FloatRegisterImpl; +typedef FloatRegisterImpl* FloatRegister; + +inline FloatRegister as_FloatRegister(int encoding) { + return (FloatRegister)(intptr_t) encoding; +} + +// The implementation of floating point registers for the zero architecture +class FloatRegisterImpl : public AbstractRegisterImpl { + public: + enum { + number_of_registers = 0 + }; + + // construction + inline friend FloatRegister as_FloatRegister(int encoding); + VMReg as_VMReg(); + + // derived registers, offsets, and addresses + FloatRegister successor() const { + return as_FloatRegister(encoding() + 1); + } + + // accessors + int encoding() const { + assert(is_valid(), "invalid register"); + return (intptr_t)this; + } + bool is_valid() const { + return 0 <= (intptr_t) this && (intptr_t)this < number_of_registers; + } + const char* name() const; +}; + +class ConcreteRegisterImpl : public AbstractRegisterImpl { + public: + enum { + number_of_registers = RegisterImpl::number_of_registers + + FloatRegisterImpl::number_of_registers + }; + + static const int max_gpr; + static const int max_fpr; +}; + +CONSTANT_REGISTER_DECLARATION(Register, noreg, (-1)); diff --git a/hotspot/src/cpu/zero/vm/relocInfo_zero.cpp b/hotspot/src/cpu/zero/vm/relocInfo_zero.cpp new file mode 100644 index 00000000000..64c6bff58e4 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/relocInfo_zero.cpp @@ -0,0 +1,74 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2009 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_relocInfo_zero.cpp.incl" + +void Relocation::pd_set_data_value(address x, intptr_t o) { + ShouldNotCallThis(); +} + +address Relocation::pd_call_destination(address orig_addr) { + ShouldNotCallThis(); +} + +void Relocation::pd_set_call_destination(address x) { + ShouldNotCallThis(); +} + +address Relocation::pd_get_address_from_code() { + ShouldNotCallThis(); +} + +address* Relocation::pd_address_in_code() { + // Relocations in Shark are just stored directly + return (address *) addr(); +} + +int Relocation::pd_breakpoint_size() { + ShouldNotCallThis(); +} + +void Relocation::pd_swap_in_breakpoint(address x, + short* instrs, + int instrlen) { + ShouldNotCallThis(); +} + +void Relocation::pd_swap_out_breakpoint(address x, + short* instrs, + int instrlen) { + ShouldNotCallThis(); +} + +void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, + CodeBuffer* dst) { + ShouldNotCallThis(); +} + +void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, + CodeBuffer* dst) { + ShouldNotCallThis(); +} diff --git a/hotspot/src/cpu/zero/vm/relocInfo_zero.hpp b/hotspot/src/cpu/zero/vm/relocInfo_zero.hpp new file mode 100644 index 00000000000..afa47d041c4 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/relocInfo_zero.hpp @@ -0,0 +1,32 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + + // machine-dependent parts of class relocInfo + private: + enum { + // these constants mean nothing without an assembler + offset_unit = 1, + format_width = 1 + }; diff --git a/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp new file mode 100644 index 00000000000..7bb4614980f --- /dev/null +++ b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp @@ -0,0 +1,108 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_sharedRuntime_zero.cpp.incl" + +DeoptimizationBlob *SharedRuntime::_deopt_blob; +SafepointBlob *SharedRuntime::_polling_page_safepoint_handler_blob; +SafepointBlob *SharedRuntime::_polling_page_return_handler_blob; +RuntimeStub *SharedRuntime::_wrong_method_blob; +RuntimeStub *SharedRuntime::_ic_miss_blob; +RuntimeStub *SharedRuntime::_resolve_opt_virtual_call_blob; +RuntimeStub *SharedRuntime::_resolve_virtual_call_blob; +RuntimeStub *SharedRuntime::_resolve_static_call_blob; + +int SharedRuntime::java_calling_convention(const BasicType *sig_bt, + VMRegPair *regs, + int total_args_passed, + int is_outgoing) { + return 0; +} + +AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters( + MacroAssembler *masm, + int total_args_passed, + int comp_args_on_stack, + const BasicType *sig_bt, + const VMRegPair *regs) { + return new AdapterHandlerEntry( + ShouldNotCallThisStub(), + ShouldNotCallThisStub(), + ShouldNotCallThisStub()); +} + +nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, + methodHandle method, + int total_in_args, + int comp_args_on_stack, + BasicType *in_sig_bt, + VMRegPair *in_regs, + BasicType ret_type) { + ShouldNotCallThis(); +} + +int Deoptimization::last_frame_adjust(int callee_parameters, + int callee_locals) { + return 0; +} + +uint SharedRuntime::out_preserve_stack_slots() { + ShouldNotCallThis(); +} + +static RuntimeStub* generate_empty_runtime_stub(const char* name) { + CodeBuffer buffer(name, 0, 0); + return RuntimeStub::new_runtime_stub(name, &buffer, 0, 0, NULL, false); +} + +static SafepointBlob* generate_empty_safepoint_blob() { + CodeBuffer buffer("handler_blob", 0, 0); + return SafepointBlob::create(&buffer, NULL, 0); +} + +void SharedRuntime::generate_stubs() { + _wrong_method_blob = + generate_empty_runtime_stub("wrong_method_stub"); + _ic_miss_blob = + generate_empty_runtime_stub("ic_miss_stub"); + _resolve_opt_virtual_call_blob = + generate_empty_runtime_stub("resolve_opt_virtual_call"); + _resolve_virtual_call_blob = + generate_empty_runtime_stub("resolve_virtual_call"); + _resolve_static_call_blob = + generate_empty_runtime_stub("resolve_static_call"); + + _polling_page_safepoint_handler_blob = + generate_empty_safepoint_blob(); + _polling_page_return_handler_blob = + generate_empty_safepoint_blob(); +} + +int SharedRuntime::c_calling_convention(const BasicType *sig_bt, + VMRegPair *regs, + int total_args_passed) { + ShouldNotCallThis(); +} diff --git a/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp b/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp new file mode 100644 index 00000000000..3337219a370 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/sharkFrame_zero.hpp @@ -0,0 +1,79 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008 Red Hat, Inc. + * 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 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. + * + */ + +// | ... | +// +--------------------+ ------------------ +// | stack slot n-1 | low addresses +// | ... | +// | stack slot 0 | +// | monitor m-1 | +// | ... | +// | monitor 0 | +// | oop_tmp | +// | method | +// | unextended_sp | +// | pc | +// | frame_type | +// | next_frame | high addresses +// +--------------------+ ------------------ +// | ... | + +class SharkFrame : public ZeroFrame { + friend class SharkFunction; + + private: + SharkFrame() : ZeroFrame() { + ShouldNotCallThis(); + } + + protected: + enum Layout { + pc_off = jf_header_words, + unextended_sp_off, + method_off, + oop_tmp_off, + header_words + }; + + public: + address pc() const { + return (address) value_of_word(pc_off); + } + + intptr_t* unextended_sp() const { + return (intptr_t *) value_of_word(unextended_sp_off); + } + + methodOop method() const { + return (methodOop) value_of_word(method_off); + } + + public: + void identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const; +}; diff --git a/hotspot/src/cpu/zero/vm/stack_zero.hpp b/hotspot/src/cpu/zero/vm/stack_zero.hpp new file mode 100644 index 00000000000..daf0b92099a --- /dev/null +++ b/hotspot/src/cpu/zero/vm/stack_zero.hpp @@ -0,0 +1,197 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +class ZeroStack { + private: + intptr_t *_base; // the last available word + intptr_t *_top; // the word past the end of the stack + intptr_t *_sp; // the top word on the stack + + public: + ZeroStack() + : _base(NULL), _top(NULL), _sp(NULL) {} + + bool needs_setup() const { + return _base == NULL; + } + + void setup(void *mem, size_t size) { + assert(needs_setup(), "already set up"); + assert(!(size & WordAlignmentMask), "unaligned"); + + _base = (intptr_t *) mem; + _top = _base + (size >> LogBytesPerWord); + _sp = _top; + } + void teardown() { + assert(!needs_setup(), "not set up"); + assert(_sp == _top, "stuff on stack at teardown"); + + _base = NULL; + _top = NULL; + _sp = NULL; + } + + intptr_t *sp() const { + return _sp; + } + void set_sp(intptr_t *new_sp) { + assert(_top >= new_sp && new_sp >= _base, "bad stack pointer"); + _sp = new_sp; + } + + int available_words() const { + return _sp - _base; + } + + void push(intptr_t value) { + assert(_sp > _base, "stack overflow"); + *(--_sp) = value; + } + intptr_t pop() { + assert(_sp < _top, "stack underflow"); + return *(_sp++); + } + + void *alloc(size_t size) { + int count = align_size_up(size, wordSize) >> LogBytesPerWord; + assert(count <= available_words(), "stack overflow"); + return _sp -= count; + } + + public: + static ByteSize base_offset() { + return byte_offset_of(ZeroStack, _base); + } + static ByteSize top_offset() { + return byte_offset_of(ZeroStack, _top); + } + static ByteSize sp_offset() { + return byte_offset_of(ZeroStack, _sp); + } +}; + + +class EntryFrame; +class InterpreterFrame; +class SharkFrame; +class FakeStubFrame; + +// +// | ... | +// +--------------------+ ------------------ +// | ... | low addresses +// | frame_type | +// | next_frame | high addresses +// +--------------------+ ------------------ +// | ... | + +class ZeroFrame { + friend class frame; + friend class ZeroStackPrinter; + + protected: + ZeroFrame() { + ShouldNotCallThis(); + } + + enum Layout { + next_frame_off, + frame_type_off, + jf_header_words + }; + + enum FrameType { + ENTRY_FRAME = 1, + INTERPRETER_FRAME, + SHARK_FRAME, + FAKE_STUB_FRAME + }; + + protected: + intptr_t *addr_of_word(int offset) const { + return (intptr_t *) this - offset; + } + intptr_t value_of_word(int offset) const { + return *addr_of_word(offset); + } + + public: + ZeroFrame *next() const { + return (ZeroFrame *) value_of_word(next_frame_off); + } + + protected: + FrameType type() const { + return (FrameType) value_of_word(frame_type_off); + } + + public: + bool is_entry_frame() const { + return type() == ENTRY_FRAME; + } + bool is_interpreter_frame() const { + return type() == INTERPRETER_FRAME; + } + bool is_shark_frame() const { + return type() == SHARK_FRAME; + } + bool is_fake_stub_frame() const { + return type() == FAKE_STUB_FRAME; + } + + public: + EntryFrame *as_entry_frame() const { + assert(is_entry_frame(), "should be"); + return (EntryFrame *) this; + } + InterpreterFrame *as_interpreter_frame() const { + assert(is_interpreter_frame(), "should be"); + return (InterpreterFrame *) this; + } + SharkFrame *as_shark_frame() const { + assert(is_shark_frame(), "should be"); + return (SharkFrame *) this; + } + FakeStubFrame *as_fake_stub_frame() const { + assert(is_fake_stub_frame(), "should be"); + return (FakeStubFrame *) this; + } + + public: + void identify_word(int frame_index, + int offset, + char* fieldbuf, + char* valuebuf, + int buflen) const; + + protected: + void identify_vp_word(int frame_index, + intptr_t* addr, + intptr_t* monitor_base, + intptr_t* stack_base, + char* fieldbuf, + int buflen) const; +}; diff --git a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp new file mode 100644 index 00000000000..b8ab9bb558a --- /dev/null +++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp @@ -0,0 +1,251 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_stubGenerator_zero.cpp.incl" + +// Declaration and definition of StubGenerator (no .hpp file). +// For a more detailed description of the stub routine structure +// see the comment in stubRoutines.hpp + +class StubGenerator: public StubCodeGenerator { + private: + // The call stub is used to call Java from C + static void call_stub( + JavaCallWrapper *call_wrapper, + intptr_t* result, + BasicType result_type, + methodOop method, + address entry_point, + intptr_t* parameters, + int parameter_words, + TRAPS) { + JavaThread *thread = (JavaThread *) THREAD; + ZeroStack *stack = thread->zero_stack(); + + // Make sure we have no pending exceptions + assert(!HAS_PENDING_EXCEPTION, "call_stub called with pending exception"); + + // Set up the stack if necessary + bool stack_needs_teardown = false; + if (stack->needs_setup()) { + size_t stack_used = thread->stack_base() - (address) &stack_used; + size_t stack_free = thread->stack_size() - stack_used; + size_t zero_stack_size = align_size_down(stack_free / 2, wordSize); + + stack->setup(alloca(zero_stack_size), zero_stack_size); + stack_needs_teardown = true; + } + + // Allocate and initialize our frame + thread->push_zero_frame( + EntryFrame::build(stack, parameters, parameter_words, call_wrapper)); + + // Make the call + Interpreter::invoke_method(method, entry_point, THREAD); + + // Store result depending on type + if (!HAS_PENDING_EXCEPTION) { + switch (result_type) { + case T_INT: + *(jint *) result = *(jint *) stack->sp(); + break; + case T_LONG: + *(jlong *) result = *(jlong *) stack->sp(); + break; + case T_FLOAT: + *(jfloat *) result = *(jfloat *) stack->sp(); + break; + case T_DOUBLE: + *(jdouble *) result = *(jdouble *) stack->sp(); + break; + case T_OBJECT: + *(oop *) result = *(oop *) stack->sp(); + break; + default: + ShouldNotReachHere(); + } + } + + // Unwind our frame + thread->pop_zero_frame(); + + // Tear down the stack if necessary + if (stack_needs_teardown) + stack->teardown(); + } + + // These stubs get called from some dumb test routine. + // I'll write them properly when they're called from + // something that's actually doing something. + static void fake_arraycopy_stub(address src, address dst, int count) { + assert(count == 0, "huh?"); + } + + void generate_arraycopy_stubs() { + // Call the conjoint generation methods immediately after + // the disjoint ones so that short branches from the former + // to the latter can be generated. + StubRoutines::_jbyte_disjoint_arraycopy = (address) fake_arraycopy_stub; + StubRoutines::_jbyte_arraycopy = (address) fake_arraycopy_stub; + + StubRoutines::_jshort_disjoint_arraycopy = (address) fake_arraycopy_stub; + StubRoutines::_jshort_arraycopy = (address) fake_arraycopy_stub; + + StubRoutines::_jint_disjoint_arraycopy = (address) fake_arraycopy_stub; + StubRoutines::_jint_arraycopy = (address) fake_arraycopy_stub; + + StubRoutines::_jlong_disjoint_arraycopy = (address) fake_arraycopy_stub; + StubRoutines::_jlong_arraycopy = (address) fake_arraycopy_stub; + + StubRoutines::_oop_disjoint_arraycopy = ShouldNotCallThisStub(); + StubRoutines::_oop_arraycopy = ShouldNotCallThisStub(); + + StubRoutines::_checkcast_arraycopy = ShouldNotCallThisStub(); + StubRoutines::_unsafe_arraycopy = ShouldNotCallThisStub(); + StubRoutines::_generic_arraycopy = ShouldNotCallThisStub(); + + // We don't generate specialized code for HeapWord-aligned source + // arrays, so just use the code we've already generated + StubRoutines::_arrayof_jbyte_disjoint_arraycopy = + StubRoutines::_jbyte_disjoint_arraycopy; + StubRoutines::_arrayof_jbyte_arraycopy = + StubRoutines::_jbyte_arraycopy; + + StubRoutines::_arrayof_jshort_disjoint_arraycopy = + StubRoutines::_jshort_disjoint_arraycopy; + StubRoutines::_arrayof_jshort_arraycopy = + StubRoutines::_jshort_arraycopy; + + StubRoutines::_arrayof_jint_disjoint_arraycopy = + StubRoutines::_jint_disjoint_arraycopy; + StubRoutines::_arrayof_jint_arraycopy = + StubRoutines::_jint_arraycopy; + + StubRoutines::_arrayof_jlong_disjoint_arraycopy = + StubRoutines::_jlong_disjoint_arraycopy; + StubRoutines::_arrayof_jlong_arraycopy = + StubRoutines::_jlong_arraycopy; + + StubRoutines::_arrayof_oop_disjoint_arraycopy = + StubRoutines::_oop_disjoint_arraycopy; + StubRoutines::_arrayof_oop_arraycopy = + StubRoutines::_oop_arraycopy; + } + + void generate_initial() { + // Generates all stubs and initializes the entry points + + // entry points that exist in all platforms Note: This is code + // that could be shared among different platforms - however the + // benefit seems to be smaller than the disadvantage of having a + // much more complicated generator structure. See also comment in + // stubRoutines.hpp. + + StubRoutines::_forward_exception_entry = ShouldNotCallThisStub(); + StubRoutines::_call_stub_entry = (address) call_stub; + StubRoutines::_catch_exception_entry = ShouldNotCallThisStub(); + + // atomic calls + StubRoutines::_atomic_xchg_entry = ShouldNotCallThisStub(); + StubRoutines::_atomic_xchg_ptr_entry = ShouldNotCallThisStub(); + StubRoutines::_atomic_cmpxchg_entry = ShouldNotCallThisStub(); + StubRoutines::_atomic_cmpxchg_ptr_entry = ShouldNotCallThisStub(); + StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub(); + StubRoutines::_atomic_add_entry = ShouldNotCallThisStub(); + StubRoutines::_atomic_add_ptr_entry = ShouldNotCallThisStub(); + StubRoutines::_fence_entry = ShouldNotCallThisStub(); + + // amd64 does this here, sparc does it in generate_all() + StubRoutines::_handler_for_unsafe_access_entry = + ShouldNotCallThisStub(); + } + + void generate_all() { + // Generates all stubs and initializes the entry points + + // These entry points require SharedInfo::stack0 to be set up in + // non-core builds and need to be relocatable, so they each + // fabricate a RuntimeStub internally. + StubRoutines::_throw_AbstractMethodError_entry = + ShouldNotCallThisStub(); + + StubRoutines::_throw_ArithmeticException_entry = + ShouldNotCallThisStub(); + + StubRoutines::_throw_NullPointerException_entry = + ShouldNotCallThisStub(); + + StubRoutines::_throw_NullPointerException_at_call_entry = + ShouldNotCallThisStub(); + + StubRoutines::_throw_StackOverflowError_entry = + ShouldNotCallThisStub(); + + // support for verify_oop (must happen after universe_init) + StubRoutines::_verify_oop_subroutine_entry = + ShouldNotCallThisStub(); + + // arraycopy stubs used by compilers + generate_arraycopy_stubs(); + } + + public: + StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) { + if (all) { + generate_all(); + } else { + generate_initial(); + } + } +}; + +void StubGenerator_generate(CodeBuffer* code, bool all) { + StubGenerator g(code, all); +} + +EntryFrame *EntryFrame::build(ZeroStack* stack, + const intptr_t* parameters, + int parameter_words, + JavaCallWrapper* call_wrapper) { + if (header_words + parameter_words > stack->available_words()) { + Unimplemented(); + } + + stack->push(0); // next_frame, filled in later + intptr_t *fp = stack->sp(); + assert(fp - stack->sp() == next_frame_off, "should be"); + + stack->push(ENTRY_FRAME); + assert(fp - stack->sp() == frame_type_off, "should be"); + + stack->push((intptr_t) call_wrapper); + assert(fp - stack->sp() == call_wrapper_off, "should be"); + + for (int i = 0; i < parameter_words; i++) + stack->push(parameters[i]); + + return (EntryFrame *) fp; +} diff --git a/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp b/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp new file mode 100644 index 00000000000..eb697aac8e8 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_stubRoutines_zero.cpp.incl" + +#ifdef IA32 +address StubRoutines::x86::_call_stub_compiled_return = NULL; +#endif // IA32 diff --git a/jdk/test/javax/management/context/localizable/MBeanDescriptions_fr.java b/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp similarity index 55% rename from jdk/test/javax/management/context/localizable/MBeanDescriptions_fr.java rename to hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp index 3e1ec2d9e15..31cff0eddef 100644 --- a/jdk/test/javax/management/context/localizable/MBeanDescriptions_fr.java +++ b/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp @@ -1,5 +1,6 @@ /* - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,24 +20,32 @@ * 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. + * */ -package localizable; + // This file holds the platform specific parts of the StubRoutines + // definition. See stubRoutines.hpp for a description on how to + // extend it. -import java.util.ListResourceBundle; -import static localizable.WhatsitMBean.*; + public: + static address call_stub_return_pc() { + return (address) -1; + } -public class MBeanDescriptions_fr extends ListResourceBundle { - @Override - protected Object[][] getContents() { - String constrProp = "WhatsitMBean.constructor." + Whatsit.class.getName(); - return new Object[][] { - {"WhatsitMBean.mbean", frenchMBeanDescription}, - {"WhatsitMBean.attribute.Whatsit", frenchAttrDescription}, - {"WhatsitMBean.operation.frob", frenchOperDescription}, - {"WhatsitMBean.operation.frob.p1", frenchParamDescription}, - {constrProp, frenchConstrDescription}, - {constrProp + ".p1", frenchConstrParamDescription}, - }; - } -} + static bool returns_to_call_stub(address return_pc) { + return return_pc == call_stub_return_pc(); + } + + enum platform_dependent_constants { + code_size1 = 0, // The assembler will fail with a guarantee + code_size2 = 0 // if these are too small. Simply increase + }; // them if that happens. + +#ifdef IA32 + class x86 { + friend class VMStructs; + + private: + static address _call_stub_compiled_return; + }; +#endif // IA32 diff --git a/hotspot/src/cpu/zero/vm/templateInterpreterGenerator_zero.hpp b/hotspot/src/cpu/zero/vm/templateInterpreterGenerator_zero.hpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/templateInterpreterGenerator_zero.hpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/templateInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/templateInterpreter_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/templateInterpreter_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/templateInterpreter_zero.hpp b/hotspot/src/cpu/zero/vm/templateInterpreter_zero.hpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/templateInterpreter_zero.hpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/templateTable_zero.cpp b/hotspot/src/cpu/zero/vm/templateTable_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/templateTable_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/templateTable_zero.hpp b/hotspot/src/cpu/zero/vm/templateTable_zero.hpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/templateTable_zero.hpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/vmStructs_zero.hpp b/hotspot/src/cpu/zero/vm/vmStructs_zero.hpp new file mode 100644 index 00000000000..565a9b5c5ab --- /dev/null +++ b/hotspot/src/cpu/zero/vm/vmStructs_zero.hpp @@ -0,0 +1,52 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +// These are the CPU-specific fields, types and integer +// constants required by the Serviceability Agent. This file is +// referenced by vmStructs.cpp. + +#define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \ + + /* NOTE that we do not use the last_entry() macro here; it is used */ + /* in vmStructs__.hpp's VM_STRUCTS_OS_CPU macro (and must */ + /* be present there) */ + +#define VM_TYPES_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type, last_entry) \ + + /* NOTE that we do not use the last_entry() macro here; it is used */ + /* in vmStructs__.hpp's VM_TYPES_OS_CPU macro (and must */ + /* be present there) */ + +#define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \ + + /* NOTE that we do not use the last_entry() macro here; it is used */ + /* in vmStructs__.hpp's VM_INT_CONSTANTS_OS_CPU macro (and must */ + /* be present there) */ + +#define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \ + + /* NOTE that we do not use the last_entry() macro here; it is used */ + /* in vmStructs__.hpp's VM_LONG_CONSTANTS_OS_CPU macro (and must */ + /* be present there) */ diff --git a/hotspot/src/cpu/zero/vm/vm_version_zero.cpp b/hotspot/src/cpu/zero/vm/vm_version_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/vm_version_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/cpu/zero/vm/vm_version_zero.hpp b/hotspot/src/cpu/zero/vm/vm_version_zero.hpp new file mode 100644 index 00000000000..b971a8cc83b --- /dev/null +++ b/hotspot/src/cpu/zero/vm/vm_version_zero.hpp @@ -0,0 +1,31 @@ +/* + * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +class VM_Version : public Abstract_VM_Version { + public: + static const char* cpu_features() { + return ""; + } +}; diff --git a/hotspot/src/cpu/zero/vm/vmreg_zero.cpp b/hotspot/src/cpu/zero/vm/vmreg_zero.cpp new file mode 100644 index 00000000000..6e5ea470ec4 --- /dev/null +++ b/hotspot/src/cpu/zero/vm/vmreg_zero.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2006-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +#include "incls/_precompiled.incl" +#include "incls/_vmreg_zero.cpp.incl" + +void VMRegImpl::set_regName() { + int i = 0; + Register reg = ::as_Register(0); + for ( ; i < ConcreteRegisterImpl::max_gpr ; ) { + regName[i++] = reg->name(); + reg = reg->successor(); + } + FloatRegister freg = ::as_FloatRegister(0); + for ( ; i < ConcreteRegisterImpl::max_fpr ; ) { + regName[i++] = freg->name(); + freg = freg->successor(); + } + assert(i == ConcreteRegisterImpl::number_of_registers, "fix this"); +} + +bool VMRegImpl::is_Register() { + return value() >= 0 && + value() < ConcreteRegisterImpl::max_gpr; +} + +bool VMRegImpl::is_FloatRegister() { + return value() >= ConcreteRegisterImpl::max_gpr && + value() < ConcreteRegisterImpl::max_fpr; +} + +Register VMRegImpl::as_Register() { + assert(is_Register(), "must be"); + return ::as_Register(value()); +} + +FloatRegister VMRegImpl::as_FloatRegister() { + assert(is_FloatRegister(), "must be" ); + return ::as_FloatRegister(value() - ConcreteRegisterImpl::max_gpr); +} diff --git a/hotspot/src/cpu/zero/vm/vmreg_zero.hpp b/hotspot/src/cpu/zero/vm/vmreg_zero.hpp new file mode 100644 index 00000000000..61c4a932b6a --- /dev/null +++ b/hotspot/src/cpu/zero/vm/vmreg_zero.hpp @@ -0,0 +1,29 @@ +/* + * Copyright 2006 Sun Microsystems, Inc. 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 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. + * + */ + + bool is_Register(); + Register as_Register(); + + bool is_FloatRegister(); + FloatRegister as_FloatRegister(); diff --git a/jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/ParsedPattern.java b/hotspot/src/cpu/zero/vm/vmreg_zero.inline.hpp similarity index 72% rename from jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/ParsedPattern.java rename to hotspot/src/cpu/zero/vm/vmreg_zero.inline.hpp index 15fd9d5ddd4..5bda84f9f09 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/rngom/ast/om/ParsedPattern.java +++ b/hotspot/src/cpu/zero/vm/vmreg_zero.inline.hpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2006-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,7 +20,13 @@ * 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. + * */ -package com.sun.xml.internal.rngom.ast.om; -public interface ParsedPattern { } +inline VMReg RegisterImpl::as_VMReg() { + return VMRegImpl::as_VMReg(encoding()); +} + +inline VMReg FloatRegisterImpl::as_VMReg() { + return VMRegImpl::as_VMReg(encoding() + ConcreteRegisterImpl::max_gpr); +} diff --git a/jaxws/src/share/classes/com/sun/xml/internal/fastinfoset/stax/events/XMLConstants.java b/hotspot/src/cpu/zero/vm/vtableStubs_zero.cpp similarity index 63% rename from jaxws/src/share/classes/com/sun/xml/internal/fastinfoset/stax/events/XMLConstants.java rename to hotspot/src/cpu/zero/vm/vtableStubs_zero.cpp index 0fc46a35815..57ccc9460b5 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/fastinfoset/stax/events/XMLConstants.java +++ b/hotspot/src/cpu/zero/vm/vtableStubs_zero.cpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -22,16 +21,23 @@ * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. * - * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. */ +#include "incls/_precompiled.incl" +#include "incls/_vtableStubs_zero.cpp.incl" - -package com.sun.xml.internal.fastinfoset.stax.events; - - -public class XMLConstants { - - public static final String ENCODING = "UTF-8"; - public static final String XMLVERSION = "1.0"; +VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { + ShouldNotCallThis(); +} + +VtableStub* VtableStubs::create_itable_stub(int vtable_index) { + ShouldNotCallThis(); +} + +int VtableStub::pd_code_size_limit(bool is_vtable_stub) { + ShouldNotCallThis(); +} + +int VtableStub::pd_code_alignment() { + ShouldNotCallThis(); } diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index eb510b66701..281e81c264f 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -176,7 +176,9 @@ bool os::have_special_privileges() { #endif // Cpu architecture string -#if defined(IA64) +#if defined(ZERO) +static char cpu_arch[] = ZERO_LIBARCH; +#elif defined(IA64) static char cpu_arch[] = "ia64"; #elif defined(IA32) static char cpu_arch[] = "i386"; @@ -1743,7 +1745,14 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {EM_SPARC32PLUS, EM_SPARC, ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"}, {EM_SPARCV9, EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"}, {EM_PPC, EM_PPC, ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"}, - {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"} + {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"}, + {EM_ARM, EM_ARM, ELFCLASS32, ELFDATA2LSB, (char*)"ARM"}, + {EM_S390, EM_S390, ELFCLASSNONE, ELFDATA2MSB, (char*)"IBM System/390"}, + {EM_ALPHA, EM_ALPHA, ELFCLASS64, ELFDATA2LSB, (char*)"Alpha"}, + {EM_MIPS_RS3_LE, EM_MIPS_RS3_LE, ELFCLASS32, ELFDATA2LSB, (char*)"MIPSel"}, + {EM_MIPS, EM_MIPS, ELFCLASS32, ELFDATA2MSB, (char*)"MIPS"}, + {EM_PARISC, EM_PARISC, ELFCLASS32, ELFDATA2MSB, (char*)"PARISC"}, + {EM_68K, EM_68K, ELFCLASS32, ELFDATA2MSB, (char*)"M68k"} }; #if (defined IA32) @@ -1760,9 +1769,23 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) static Elf32_Half running_arch_code=EM_PPC64; #elif (defined __powerpc__) static Elf32_Half running_arch_code=EM_PPC; + #elif (defined ARM) + static Elf32_Half running_arch_code=EM_ARM; + #elif (defined S390) + static Elf32_Half running_arch_code=EM_S390; + #elif (defined ALPHA) + static Elf32_Half running_arch_code=EM_ALPHA; + #elif (defined MIPSEL) + static Elf32_Half running_arch_code=EM_MIPS_RS3_LE; + #elif (defined PARISC) + static Elf32_Half running_arch_code=EM_PARISC; + #elif (defined MIPS) + static Elf32_Half running_arch_code=EM_MIPS; + #elif (defined M68K) + static Elf32_Half running_arch_code=EM_68K; #else #error Method os::dll_load requires that one of following is defined:\ - IA32, AMD64, IA64, __sparc, __powerpc__ + IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K #endif // Identify compatability class for VM's architecture and library's architecture @@ -1794,10 +1817,12 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) return NULL; } +#ifndef S390 if (lib_arch.elf_class != arch_array[running_arch_index].elf_class) { ::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: architecture word width mismatch)"); return NULL; } +#endif // !S390 if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) { if ( lib_arch.name!=NULL ) { @@ -2586,7 +2611,9 @@ bool os::large_page_init() { // format has been changed), we'll use the largest page size supported by // the processor. +#ifndef ZERO _large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M); +#endif // ZERO FILE *fp = fopen("/proc/meminfo", "r"); if (fp) { diff --git a/hotspot/src/os_cpu/linux_zero/vm/assembler_linux_zero.cpp b/hotspot/src/os_cpu/linux_zero/vm/assembler_linux_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/assembler_linux_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp b/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp new file mode 100644 index 00000000000..ecd5b658775 --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp @@ -0,0 +1,293 @@ +/* + * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +// Implementation of class atomic + +#ifdef M68K + +/* + * __m68k_cmpxchg + * + * Atomically store newval in *ptr if *ptr is equal to oldval for user space. + * Returns newval on success and oldval if no exchange happened. + * This implementation is processor specific and works on + * 68020 68030 68040 and 68060. + * + * It will not work on ColdFire, 68000 and 68010 since they lack the CAS + * instruction. + * Using a kernelhelper would be better for arch complete implementation. + * + */ + +static inline int __m68k_cmpxchg(int oldval, int newval, volatile int *ptr) { + int ret; + __asm __volatile ("cas%.l %0,%2,%1" + : "=d" (ret), "+m" (*(ptr)) + : "d" (newval), "0" (oldval)); + return ret; +} + +/* Perform an atomic compare and swap: if the current value of `*PTR' + is OLDVAL, then write NEWVAL into `*PTR'. Return the contents of + `*PTR' before the operation.*/ +static inline int m68k_compare_and_swap(volatile int *ptr, + int oldval, + int newval) { + for (;;) { + int prev = *ptr; + if (prev != oldval) + return prev; + + if (__m68k_cmpxchg (prev, newval, ptr) == newval) + // Success. + return prev; + + // We failed even though prev == oldval. Try again. + } +} + +/* Atomically add an int to memory. */ +static inline int m68k_add_and_fetch(volatile int *ptr, int add_value) { + for (;;) { + // Loop until success. + + int prev = *ptr; + + if (__m68k_cmpxchg (prev, prev + add_value, ptr) == prev + add_value) + return prev + add_value; + } +} + +/* Atomically write VALUE into `*PTR' and returns the previous + contents of `*PTR'. */ +static inline int m68k_lock_test_and_set(volatile int *ptr, int newval) { + for (;;) { + // Loop until success. + int prev = *ptr; + + if (__m68k_cmpxchg (prev, newval, ptr) == prev) + return prev; + } +} +#endif // M68K + +#ifdef ARM + +/* + * __kernel_cmpxchg + * + * Atomically store newval in *ptr if *ptr is equal to oldval for user space. + * Return zero if *ptr was changed or non-zero if no exchange happened. + * The C flag is also set if *ptr was changed to allow for assembly + * optimization in the calling code. + * + */ + +typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr); +#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *) 0xffff0fc0) + + + +/* Perform an atomic compare and swap: if the current value of `*PTR' + is OLDVAL, then write NEWVAL into `*PTR'. Return the contents of + `*PTR' before the operation.*/ +static inline int arm_compare_and_swap(volatile int *ptr, + int oldval, + int newval) { + for (;;) { + int prev = *ptr; + if (prev != oldval) + return prev; + + if (__kernel_cmpxchg (prev, newval, ptr) == 0) + // Success. + return prev; + + // We failed even though prev == oldval. Try again. + } +} + +/* Atomically add an int to memory. */ +static inline int arm_add_and_fetch(volatile int *ptr, int add_value) { + for (;;) { + // Loop until a __kernel_cmpxchg succeeds. + + int prev = *ptr; + + if (__kernel_cmpxchg (prev, prev + add_value, ptr) == 0) + return prev + add_value; + } +} + +/* Atomically write VALUE into `*PTR' and returns the previous + contents of `*PTR'. */ +static inline int arm_lock_test_and_set(volatile int *ptr, int newval) { + for (;;) { + // Loop until a __kernel_cmpxchg succeeds. + int prev = *ptr; + + if (__kernel_cmpxchg (prev, newval, ptr) == 0) + return prev; + } +} +#endif // ARM + +inline void Atomic::store(jint store_value, volatile jint* dest) { + *dest = store_value; +} + +inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { + *dest = store_value; +} + +inline jint Atomic::add(jint add_value, volatile jint* dest) { +#ifdef ARM + return arm_add_and_fetch(dest, add_value); +#else +#ifdef M68K + return m68k_add_and_fetch(dest, add_value); +#else + return __sync_add_and_fetch(dest, add_value); +#endif // M68K +#endif // ARM +} + +inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { +#ifdef ARM + return arm_add_and_fetch(dest, add_value); +#else +#ifdef M68K + return m68k_add_and_fetch(dest, add_value); +#else + return __sync_add_and_fetch(dest, add_value); +#endif // M68K +#endif // ARM +} + +inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { + return (void *) add_ptr(add_value, (volatile intptr_t *) dest); +} + +inline void Atomic::inc(volatile jint* dest) { + add(1, dest); +} + +inline void Atomic::inc_ptr(volatile intptr_t* dest) { + add_ptr(1, dest); +} + +inline void Atomic::inc_ptr(volatile void* dest) { + add_ptr(1, dest); +} + +inline void Atomic::dec(volatile jint* dest) { + add(-1, dest); +} + +inline void Atomic::dec_ptr(volatile intptr_t* dest) { + add_ptr(-1, dest); +} + +inline void Atomic::dec_ptr(volatile void* dest) { + add_ptr(-1, dest); +} + +inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) { +#ifdef ARM + return arm_lock_test_and_set(dest, exchange_value); +#else +#ifdef M68K + return m68k_lock_test_and_set(dest, exchange_value); +#else + // __sync_lock_test_and_set is a bizarrely named atomic exchange + // operation. Note that some platforms only support this with the + // limitation that the only valid value to store is the immediate + // constant 1. There is a test for this in JNI_CreateJavaVM(). + return __sync_lock_test_and_set (dest, exchange_value); +#endif // M68K +#endif // ARM +} + +inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, + volatile intptr_t* dest) { +#ifdef ARM + return arm_lock_test_and_set(dest, exchange_value); +#else +#ifdef M68K + return m68k_lock_test_and_set(dest, exchange_value); +#else + return __sync_lock_test_and_set (dest, exchange_value); +#endif // M68K +#endif // ARM +} + +inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { + return (void *) xchg_ptr((intptr_t) exchange_value, + (volatile intptr_t*) dest); +} + +inline jint Atomic::cmpxchg(jint exchange_value, + volatile jint* dest, + jint compare_value) { +#ifdef ARM + return arm_compare_and_swap(dest, compare_value, exchange_value); +#else +#ifdef M68K + return m68k_compare_and_swap(dest, compare_value, exchange_value); +#else + return __sync_val_compare_and_swap(dest, compare_value, exchange_value); +#endif // M68K +#endif // ARM +} + +inline jlong Atomic::cmpxchg(jlong exchange_value, + volatile jlong* dest, + jlong compare_value) { + + return __sync_val_compare_and_swap(dest, compare_value, exchange_value); +} + +inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, + volatile intptr_t* dest, + intptr_t compare_value) { +#ifdef ARM + return arm_compare_and_swap(dest, compare_value, exchange_value); +#else +#ifdef M68K + return m68k_compare_and_swap(dest, compare_value, exchange_value); +#else + return __sync_val_compare_and_swap(dest, compare_value, exchange_value); +#endif // M68K +#endif // ARM +} + +inline void* Atomic::cmpxchg_ptr(void* exchange_value, + volatile void* dest, + void* compare_value) { + + return (void *) cmpxchg_ptr((intptr_t) exchange_value, + (volatile intptr_t*) dest, + (intptr_t) compare_value); +} diff --git a/jaxws/src/share/classes/com/sun/istack/internal/Builder.java b/hotspot/src/os_cpu/linux_zero/vm/bytes_linux_zero.inline.hpp similarity index 69% rename from jaxws/src/share/classes/com/sun/istack/internal/Builder.java rename to hotspot/src/os_cpu/linux_zero/vm/bytes_linux_zero.inline.hpp index a5b1a5af5f3..0f65dc3c111 100644 --- a/jaxws/src/share/classes/com/sun/istack/internal/Builder.java +++ b/hotspot/src/os_cpu/linux_zero/vm/bytes_linux_zero.inline.hpp @@ -1,12 +1,10 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,13 +19,22 @@ * 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. - */ -package com.sun.istack.internal; - -/** * - * @author Martin Grebac */ -public interface Builder { - T build(); + +// Efficient swapping of data bytes from Java byte +// ordering to native byte ordering and vice versa. + +#include + +inline u2 Bytes::swap_u2(u2 x) { + return bswap_16(x); +} + +inline u4 Bytes::swap_u4(u4 x) { + return bswap_32(x); +} + +inline u8 Bytes::swap_u8(u8 x) { + return bswap_64(x); } diff --git a/jaxp/src/share/classes/javax/xml/parsers/ParserConfigurationException.java b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp similarity index 53% rename from jaxp/src/share/classes/javax/xml/parsers/ParserConfigurationException.java rename to hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp index f7554654eb6..5c6587a0823 100644 --- a/jaxp/src/share/classes/javax/xml/parsers/ParserConfigurationException.java +++ b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp @@ -1,12 +1,11 @@ /* * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,36 +20,26 @@ * 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. - */ - -package javax.xml.parsers; - -/** - * Indicates a serious configuration error. * - * @author Jeff Suttor */ -public class ParserConfigurationException extends Exception { +// +// Set the default values for platform dependent flags used by the +// runtime system. See globals.hpp for details of what they do. +// - /** - * Create a new ParserConfigurationException with no - * detail mesage. - */ +define_pd_global(bool, DontYieldALot, false); +#ifdef _LP64 +define_pd_global(intx, ThreadStackSize, 1536); +define_pd_global(intx, VMThreadStackSize, 1024); +#else +define_pd_global(intx, ThreadStackSize, 1024); +define_pd_global(intx, VMThreadStackSize, 512); +#endif // _LP64 +define_pd_global(intx, SurvivorRatio, 8); +define_pd_global(intx, CompilerThreadStackSize, 0); +define_pd_global(uintx, JVMInvokeMethodSlack, 8192); - public ParserConfigurationException() { - super(); - } - - /** - * Create a new ParserConfigurationException with - * the String specified as an error message. - * - * @param msg The error message for the exception. - */ - - public ParserConfigurationException(String msg) { - super(msg); - } - -} +define_pd_global(bool, UseVectoredExceptions, false); +// Only used on 64 bit platforms +define_pd_global(uintx, HeapBaseMinAddress, 2*G); diff --git a/hotspot/src/os_cpu/linux_zero/vm/orderAccess_linux_zero.inline.hpp b/hotspot/src/os_cpu/linux_zero/vm/orderAccess_linux_zero.inline.hpp new file mode 100644 index 00000000000..b8970d0243d --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/orderAccess_linux_zero.inline.hpp @@ -0,0 +1,167 @@ +/* + * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + +#ifdef ARM + +/* + * ARM Kernel helper for memory barrier. + * Using __asm __volatile ("":::"memory") does not work reliable on ARM + * and gcc __sync_synchronize(); implementation does not use the kernel + * helper for all gcc versions so it is unreliable to use as well. + */ +typedef void (__kernel_dmb_t) (void); +#define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0) + +#define FULL_MEM_BARRIER __kernel_dmb() +#define READ_MEM_BARRIER __kernel_dmb() +#define WRITE_MEM_BARRIER __kernel_dmb() + +#else // ARM + +#define FULL_MEM_BARRIER __sync_synchronize() + +#ifdef PPC + +#define READ_MEM_BARRIER __asm __volatile ("isync":::"memory") +#ifdef __NO_LWSYNC__ +#define WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory") +#else +#define WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory") +#endif + +#else // PPC + +#define READ_MEM_BARRIER __asm __volatile ("":::"memory") +#define WRITE_MEM_BARRIER __asm __volatile ("":::"memory") + +#endif // PPC + +#endif // ARM + + +inline void OrderAccess::loadload() { acquire(); } +inline void OrderAccess::storestore() { release(); } +inline void OrderAccess::loadstore() { acquire(); } +inline void OrderAccess::storeload() { fence(); } + +inline void OrderAccess::acquire() { + READ_MEM_BARRIER; +} + +inline void OrderAccess::release() { + WRITE_MEM_BARRIER; +} + +inline void OrderAccess::fence() { + FULL_MEM_BARRIER; +} + +inline jbyte OrderAccess::load_acquire(volatile jbyte* p) { jbyte data = *p; acquire(); return data; } +inline jshort OrderAccess::load_acquire(volatile jshort* p) { jshort data = *p; acquire(); return data; } +inline jint OrderAccess::load_acquire(volatile jint* p) { jint data = *p; acquire(); return data; } +inline jlong OrderAccess::load_acquire(volatile jlong* p) { + jlong tmp; + os::atomic_copy64(p, &tmp); + acquire(); + return tmp; +} +inline jubyte OrderAccess::load_acquire(volatile jubyte* p) { jubyte data = *p; acquire(); return data; } +inline jushort OrderAccess::load_acquire(volatile jushort* p) { jushort data = *p; acquire(); return data; } +inline juint OrderAccess::load_acquire(volatile juint* p) { juint data = *p; acquire(); return data; } +inline julong OrderAccess::load_acquire(volatile julong* p) { + julong tmp; + os::atomic_copy64(p, &tmp); + acquire(); + return tmp; +} +inline jfloat OrderAccess::load_acquire(volatile jfloat* p) { jfloat data = *p; acquire(); return data; } +inline jdouble OrderAccess::load_acquire(volatile jdouble* p) { + jdouble tmp; + os::atomic_copy64(p, &tmp); + acquire(); + return tmp; +} + +inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t* p) { + intptr_t data = *p; + acquire(); + return data; +} +inline void* OrderAccess::load_ptr_acquire(volatile void* p) { + void *data = *(void* volatile *)p; + acquire(); + return data; +} +inline void* OrderAccess::load_ptr_acquire(const volatile void* p) { + void *data = *(void* const volatile *)p; + acquire(); + return data; +} + +inline void OrderAccess::release_store(volatile jbyte* p, jbyte v) { release(); *p = v; } +inline void OrderAccess::release_store(volatile jshort* p, jshort v) { release(); *p = v; } +inline void OrderAccess::release_store(volatile jint* p, jint v) { release(); *p = v; } +inline void OrderAccess::release_store(volatile jlong* p, jlong v) +{ release(); os::atomic_copy64(&v, p); } +inline void OrderAccess::release_store(volatile jubyte* p, jubyte v) { release(); *p = v; } +inline void OrderAccess::release_store(volatile jushort* p, jushort v) { release(); *p = v; } +inline void OrderAccess::release_store(volatile juint* p, juint v) { release(); *p = v; } +inline void OrderAccess::release_store(volatile julong* p, julong v) +{ release(); os::atomic_copy64(&v, p); } +inline void OrderAccess::release_store(volatile jfloat* p, jfloat v) { release(); *p = v; } +inline void OrderAccess::release_store(volatile jdouble* p, jdouble v) +{ release(); os::atomic_copy64(&v, p); } + +inline void OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { release(); *p = v; } +inline void OrderAccess::release_store_ptr(volatile void* p, void* v) +{ release(); *(void* volatile *)p = v; } + +inline void OrderAccess::store_fence(jbyte* p, jbyte v) { *p = v; fence(); } +inline void OrderAccess::store_fence(jshort* p, jshort v) { *p = v; fence(); } +inline void OrderAccess::store_fence(jint* p, jint v) { *p = v; fence(); } +inline void OrderAccess::store_fence(jlong* p, jlong v) { os::atomic_copy64(&v, p); fence(); } +inline void OrderAccess::store_fence(jubyte* p, jubyte v) { *p = v; fence(); } +inline void OrderAccess::store_fence(jushort* p, jushort v) { *p = v; fence(); } +inline void OrderAccess::store_fence(juint* p, juint v) { *p = v; fence(); } +inline void OrderAccess::store_fence(julong* p, julong v) { os::atomic_copy64(&v, p); fence(); } +inline void OrderAccess::store_fence(jfloat* p, jfloat v) { *p = v; fence(); } +inline void OrderAccess::store_fence(jdouble* p, jdouble v) { os::atomic_copy64(&v, p); fence(); } + +inline void OrderAccess::store_ptr_fence(intptr_t* p, intptr_t v) { *p = v; fence(); } +inline void OrderAccess::store_ptr_fence(void** p, void* v) { *p = v; fence(); } + +inline void OrderAccess::release_store_fence(volatile jbyte* p, jbyte v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile jshort* p, jshort v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile jint* p, jint v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile jlong* p, jlong v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile jubyte* p, jubyte v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile jushort* p, jushort v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile juint* p, juint v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile julong* p, julong v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile jfloat* p, jfloat v) { release_store(p, v); fence(); } +inline void OrderAccess::release_store_fence(volatile jdouble* p, jdouble v) { release_store(p, v); fence(); } + +inline void OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) { release_store_ptr(p, v); fence(); } +inline void OrderAccess::release_store_ptr_fence(volatile void* p, void* v) { release_store_ptr(p, v); fence(); } diff --git a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp new file mode 100644 index 00000000000..572702e7d6d --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp @@ -0,0 +1,456 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +// do not include precompiled header file +#include "incls/_os_linux_zero.cpp.incl" + +address os::current_stack_pointer() { + address dummy = (address) &dummy; + return dummy; +} + +frame os::get_sender_for_C_frame(frame* fr) { + ShouldNotCallThis(); +} + +frame os::current_frame() { + // The only thing that calls this is the stack printing code in + // VMError::report: + // - Step 110 (printing stack bounds) uses the sp in the frame + // to determine the amount of free space on the stack. We + // set the sp to a close approximation of the real value in + // order to allow this step to complete. + // - Step 120 (printing native stack) tries to walk the stack. + // The frame we create has a NULL pc, which is ignored as an + // invalid frame. + frame dummy = frame(); + dummy.set_sp((intptr_t *) current_stack_pointer()); + return dummy; +} + +char* os::non_memory_address_word() { + // Must never look like an address returned by reserve_memory, + // even in its subfields (as defined by the CPU immediate fields, + // if the CPU splits constants across multiple instructions). +#ifdef SPARC + // On SPARC, 0 != %hi(any real address), because there is no + // allocation in the first 1Kb of the virtual address space. + return (char *) 0; +#else + // This is the value for x86; works pretty well for PPC too. + return (char *) -1; +#endif // SPARC +} + +void os::initialize_thread() { + // Nothing to do. +} + +address os::Linux::ucontext_get_pc(ucontext_t* uc) { + ShouldNotCallThis(); +} + +ExtendedPC os::fetch_frame_from_context(void* ucVoid, + intptr_t** ret_sp, + intptr_t** ret_fp) { + ShouldNotCallThis(); +} + +frame os::fetch_frame_from_context(void* ucVoid) { + ShouldNotCallThis(); +} + +extern "C" int +JVM_handle_linux_signal(int sig, + siginfo_t* info, + void* ucVoid, + int abort_if_unrecognized) { + ucontext_t* uc = (ucontext_t*) ucVoid; + + Thread* t = ThreadLocalStorage::get_thread_slow(); + + SignalHandlerMark shm(t); + + // Note: it's not uncommon that JNI code uses signal/sigset to + // install then restore certain signal handler (e.g. to temporarily + // block SIGPIPE, or have a SIGILL handler when detecting CPU + // type). When that happens, JVM_handle_linux_signal() might be + // invoked with junk info/ucVoid. To avoid unnecessary crash when + // libjsig is not preloaded, try handle signals that do not require + // siginfo/ucontext first. + + if (sig == SIGPIPE || sig == SIGXFSZ) { + // allow chained handler to go first + if (os::Linux::chained_handler(sig, info, ucVoid)) { + return true; + } else { + if (PrintMiscellaneous && (WizardMode || Verbose)) { + char buf[64]; + warning("Ignoring %s - see bugs 4229104 or 646499219", + os::exception_name(sig, buf, sizeof(buf))); + } + return true; + } + } + + JavaThread* thread = NULL; + VMThread* vmthread = NULL; + if (os::Linux::signal_handlers_are_installed) { + if (t != NULL ){ + if(t->is_Java_thread()) { + thread = (JavaThread*)t; + } + else if(t->is_VM_thread()){ + vmthread = (VMThread *)t; + } + } + } + + if (info != NULL && thread != NULL) { + // Handle ALL stack overflow variations here + if (sig == SIGSEGV) { + address addr = (address) info->si_addr; + + // check if fault address is within thread stack + if (addr < thread->stack_base() && + addr >= thread->stack_base() - thread->stack_size()) { + // stack overflow + if (thread->in_stack_yellow_zone(addr)) { + thread->disable_stack_yellow_zone(); + ShouldNotCallThis(); + } + else if (thread->in_stack_red_zone(addr)) { + thread->disable_stack_red_zone(); + ShouldNotCallThis(); + } + else { + // Accessing stack address below sp may cause SEGV if + // current thread has MAP_GROWSDOWN stack. This should + // only happen when current thread was created by user + // code with MAP_GROWSDOWN flag and then attached to VM. + // See notes in os_linux.cpp. + if (thread->osthread()->expanding_stack() == 0) { + thread->osthread()->set_expanding_stack(); + if (os::Linux::manually_expand_stack(thread, addr)) { + thread->osthread()->clear_expanding_stack(); + return true; + } + thread->osthread()->clear_expanding_stack(); + } + else { + fatal("recursive segv. expanding stack."); + } + } + } + } + + /*if (thread->thread_state() == _thread_in_Java) { + ShouldNotCallThis(); + } + else*/ if (thread->thread_state() == _thread_in_vm && + sig == SIGBUS && thread->doing_unsafe_access()) { + ShouldNotCallThis(); + } + + // jni_fast_GetField can trap at certain pc's if a GC + // kicks in and the heap gets shrunk before the field access. + /*if (sig == SIGSEGV || sig == SIGBUS) { + address addr = JNI_FastGetField::find_slowcase_pc(pc); + if (addr != (address)-1) { + stub = addr; + } + }*/ + + // Check to see if we caught the safepoint code in the process + // of write protecting the memory serialization page. It write + // enables the page immediately after protecting it so we can + // just return to retry the write. + if (sig == SIGSEGV && + os::is_memory_serialize_page(thread, (address) info->si_addr)) { + // Block current thread until permission is restored. + os::block_on_serialize_page_trap(); + return true; + } + } + + // signal-chaining + if (os::Linux::chained_handler(sig, info, ucVoid)) { + return true; + } + + if (!abort_if_unrecognized) { + // caller wants another chance, so give it to him + return false; + } + +#ifndef PRODUCT + if (sig == SIGSEGV) { + fatal("\n#" + "\n# /--------------------\\" + "\n# | segmentation fault |" + "\n# \\---\\ /--------------/" + "\n# /" + "\n# [-] |\\_/| " + "\n# (+)=C |o o|__ " + "\n# | | =-*-=__\\ " + "\n# OOO c_c_(___)"); + } +#endif // !PRODUCT + + const char *fmt = "caught unhandled signal %d"; + char buf[64]; + + sprintf(buf, fmt, sig); + fatal(buf); +} + +void os::Linux::init_thread_fpu_state(void) { + // Nothing to do +} + +int os::Linux::get_fpu_control_word() { + ShouldNotCallThis(); +} + +void os::Linux::set_fpu_control_word(int fpu) { + ShouldNotCallThis(); +} + +bool os::is_allocatable(size_t bytes) { + ShouldNotCallThis(); +} + +/////////////////////////////////////////////////////////////////////////////// +// thread stack + +size_t os::Linux::min_stack_allowed = 64 * K; + +bool os::Linux::supports_variable_stack_size() { + return true; +} + +size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +#ifdef _LP64 + size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); +#else + size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K); +#endif // _LP64 + return s; +} + +size_t os::Linux::default_guard_size(os::ThreadType thr_type) { + // Only enable glibc guard pages for non-Java threads + // (Java threads have HotSpot guard pages) + return (thr_type == java_thread ? 0 : page_size()); +} + +static void current_stack_region(address *bottom, size_t *size) { + pthread_attr_t attr; + int res = pthread_getattr_np(pthread_self(), &attr); + if (res != 0) { + if (res == ENOMEM) { + vm_exit_out_of_memory(0, "pthread_getattr_np"); + } + else { + fatal1("pthread_getattr_np failed with errno = %d", res); + } + } + + address stack_bottom; + size_t stack_bytes; + res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes); + if (res != 0) { + fatal1("pthread_attr_getstack failed with errno = %d", res); + } + address stack_top = stack_bottom + stack_bytes; + + // The block of memory returned by pthread_attr_getstack() includes + // guard pages where present. We need to trim these off. + size_t page_bytes = os::Linux::page_size(); + assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack"); + + size_t guard_bytes; + res = pthread_attr_getguardsize(&attr, &guard_bytes); + if (res != 0) { + fatal1("pthread_attr_getguardsize failed with errno = %d", res); + } + int guard_pages = align_size_up(guard_bytes, page_bytes) / page_bytes; + assert(guard_bytes == guard_pages * page_bytes, "unaligned guard"); + +#ifdef IA64 + // IA64 has two stacks sharing the same area of memory, a normal + // stack growing downwards and a register stack growing upwards. + // Guard pages, if present, are in the centre. This code splits + // the stack in two even without guard pages, though in theory + // there's nothing to stop us allocating more to the normal stack + // or more to the register stack if one or the other were found + // to grow faster. + int total_pages = align_size_down(stack_bytes, page_bytes) / page_bytes; + stack_bottom += (total_pages - guard_pages) / 2 * page_bytes; +#endif // IA64 + + stack_bottom += guard_bytes; + + pthread_attr_destroy(&attr); + + // The initial thread has a growable stack, and the size reported + // by pthread_attr_getstack is the maximum size it could possibly + // be given what currently mapped. This can be huge, so we cap it. + if (os::Linux::is_initial_thread()) { + stack_bytes = stack_top - stack_bottom; + + if (stack_bytes > JavaThread::stack_size_at_create()) + stack_bytes = JavaThread::stack_size_at_create(); + + stack_bottom = stack_top - stack_bytes; + } + + assert(os::current_stack_pointer() >= stack_bottom, "should do"); + assert(os::current_stack_pointer() < stack_top, "should do"); + + *bottom = stack_bottom; + *size = stack_top - stack_bottom; +} + +address os::current_stack_base() { + address bottom; + size_t size; + current_stack_region(&bottom, &size); + return bottom + size; +} + +size_t os::current_stack_size() { + // stack size includes normal stack and HotSpot guard pages + address bottom; + size_t size; + current_stack_region(&bottom, &size); + return size; +} + +///////////////////////////////////////////////////////////////////////////// +// helper functions for fatal error handler + +void os::print_context(outputStream* st, void* context) { + ShouldNotCallThis(); +} + +///////////////////////////////////////////////////////////////////////////// +// Stubs for things that would be in linux_zero.s if it existed. +// You probably want to disassemble these monkeys to check they're ok. + +extern "C" { + int SpinPause() { + } + + int SafeFetch32(int *adr, int errValue) { + int value = errValue; + value = *adr; + return value; + } + intptr_t SafeFetchN(intptr_t *adr, intptr_t errValue) { + intptr_t value = errValue; + value = *adr; + return value; + } + + void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { + if (from > to) { + jshort *end = from + count; + while (from < end) + *(to++) = *(from++); + } + else if (from < to) { + jshort *end = from; + from += count - 1; + to += count - 1; + while (from >= end) + *(to--) = *(from--); + } + } + void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) { + if (from > to) { + jint *end = from + count; + while (from < end) + *(to++) = *(from++); + } + else if (from < to) { + jint *end = from; + from += count - 1; + to += count - 1; + while (from >= end) + *(to--) = *(from--); + } + } + void _Copy_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { + if (from > to) { + jlong *end = from + count; + while (from < end) + os::atomic_copy64(from++, to++); + } + else if (from < to) { + jlong *end = from; + from += count - 1; + to += count - 1; + while (from >= end) + os::atomic_copy64(from--, to--); + } + } + + void _Copy_arrayof_conjoint_bytes(HeapWord* from, + HeapWord* to, + size_t count) { + ShouldNotCallThis(); + } + void _Copy_arrayof_conjoint_jshorts(HeapWord* from, + HeapWord* to, + size_t count) { + ShouldNotCallThis(); + } + void _Copy_arrayof_conjoint_jints(HeapWord* from, + HeapWord* to, + size_t count) { + ShouldNotCallThis(); + } + void _Copy_arrayof_conjoint_jlongs(HeapWord* from, + HeapWord* to, + size_t count) { + ShouldNotCallThis(); + } +}; + +///////////////////////////////////////////////////////////////////////////// +// Implementations of atomic operations not supported by processors. +// -- http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Atomic-Builtins.html + +#ifndef _LP64 +extern "C" { + long long unsigned int __sync_val_compare_and_swap_8( + volatile void *ptr, + long long unsigned int oldval, + long long unsigned int newval) { + ShouldNotCallThis(); + } +}; +#endif // !_LP64 diff --git a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.hpp new file mode 100644 index 00000000000..d226d5ca726 --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.hpp @@ -0,0 +1,45 @@ +/* + * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + + static void setup_fpu() {} + + static bool is_allocatable(size_t bytes); + + // Used to register dynamic code cache area with the OS + // Note: Currently only used in 64 bit Windows implementations + static bool register_code_area(char *low, char *high) { return true; } + + // Atomically copy 64 bits of data + static void atomic_copy64(volatile void *src, volatile void *dst) { +#if defined(PPC) && !defined(_LP64) + double tmp; + asm volatile ("lfd %0, 0(%1)\n" + "stfd %0, 0(%2)\n" + : "=f"(tmp) + : "b"(src), "b"(dst)); +#else + *(jlong *) dst = *(jlong *) src; +#endif // PPC && !_LP64 + } diff --git a/hotspot/src/os_cpu/linux_zero/vm/prefetch_linux_zero.inline.hpp b/hotspot/src/os_cpu/linux_zero/vm/prefetch_linux_zero.inline.hpp new file mode 100644 index 00000000000..0e649c16ac8 --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/prefetch_linux_zero.inline.hpp @@ -0,0 +1,30 @@ +/* + * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008 Red Hat, Inc. + * 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 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. + * + */ + +inline void Prefetch::read(void* loc, intx interval) { +} + +inline void Prefetch::write(void* loc, intx interval) { +} diff --git a/jaxws/src/share/classes/com/sun/xml/internal/xsom/XSAttGroupDecl.java b/hotspot/src/os_cpu/linux_zero/vm/threadLS_linux_zero.cpp similarity index 65% rename from jaxws/src/share/classes/com/sun/xml/internal/xsom/XSAttGroupDecl.java rename to hotspot/src/os_cpu/linux_zero/vm/threadLS_linux_zero.cpp index 436913fe4d1..efbc62c5700 100644 --- a/jaxws/src/share/classes/com/sun/xml/internal/xsom/XSAttGroupDecl.java +++ b/hotspot/src/os_cpu/linux_zero/vm/threadLS_linux_zero.cpp @@ -1,12 +1,11 @@ /* - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. * 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. + * 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 @@ -21,17 +20,20 @@ * 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. - */ - - -package com.sun.xml.internal.xsom; - -/** - * Attribute group declaration. * - * @author - * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) */ -public interface XSAttGroupDecl extends XSAttContainer { +#include "incls/_precompiled.incl" +#include "incls/_threadLS_linux_zero.cpp.incl" + +void ThreadLocalStorage::generate_code_for_get_thread() { + // nothing to do +} + +void ThreadLocalStorage::pd_init() { + // nothing to do +} + +void ThreadLocalStorage::pd_set_thread(Thread* thread) { + os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); } diff --git a/hotspot/src/os_cpu/linux_zero/vm/threadLS_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/threadLS_linux_zero.hpp new file mode 100644 index 00000000000..de285ef83cc --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/threadLS_linux_zero.hpp @@ -0,0 +1,30 @@ +/* + * Copyright 2003 Sun Microsystems, Inc. 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 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. + * + */ + +// Processor dependent parts of ThreadLocalStorage + + public: + static Thread* thread() { + return (Thread*) os::thread_local_storage_at(thread_index()); + } diff --git a/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.cpp b/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp new file mode 100644 index 00000000000..a1ca908d08a --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp @@ -0,0 +1,104 @@ +/* + * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007, 2008, 2009 Red Hat, Inc. + * 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 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. + * + */ + + private: + ZeroStack _zero_stack; + ZeroFrame* _top_zero_frame; + + void pd_initialize() { + _top_zero_frame = NULL; + } + + public: + ZeroStack *zero_stack() { + return &_zero_stack; + } + + public: + ZeroFrame *top_zero_frame() { + return _top_zero_frame; + } + void push_zero_frame(ZeroFrame *frame) { + *(ZeroFrame **) frame = _top_zero_frame; + _top_zero_frame = frame; + } + void pop_zero_frame() { + zero_stack()->set_sp((intptr_t *) _top_zero_frame + 1); + _top_zero_frame = *(ZeroFrame **) _top_zero_frame; + } + + public: + static ByteSize zero_stack_offset() { + return byte_offset_of(JavaThread, _zero_stack); + } + static ByteSize top_zero_frame_offset() { + return byte_offset_of(JavaThread, _top_zero_frame); + } + + public: + void record_base_of_stack_pointer() { + assert(top_zero_frame() == NULL, "junk on stack prior to Java call"); + } + void set_base_of_stack_pointer(intptr_t* base_sp) { + assert(base_sp == NULL, "should be"); + assert(top_zero_frame() == NULL, "junk on stack after Java call"); + } + + public: + void set_last_Java_frame() { + JavaFrameAnchor *jfa = frame_anchor(); + jfa->set_last_Java_sp((intptr_t *) top_zero_frame()); + } + void reset_last_Java_frame() { + JavaFrameAnchor *jfa = frame_anchor(); + jfa->set_last_Java_sp(NULL); + } + + private: + frame pd_last_frame() { + assert(has_last_Java_frame(), "must have last_Java_sp() when suspended"); + return frame(last_Java_sp(), zero_stack()->sp()); + } + + public: + // Check for pending suspend requests and pending asynchronous + // exceptions. There are separate accessors for these, but + // _suspend_flags is volatile so using them would be unsafe. + bool has_special_condition_for_native_trans() { + return _suspend_flags != 0; + } + + public: + bool pd_get_top_frame_for_signal_handler(frame* fr_addr, + void* ucontext, + bool isInJava) { + ShouldNotCallThis(); + } + + // These routines are only used on cpu architectures that + // have separate register stacks (Itanium). + static bool register_stack_overflow() { return false; } + static void enable_register_stack_guard() {} + static void disable_register_stack_guard() {} diff --git a/hotspot/src/os_cpu/linux_zero/vm/vmStructs_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/vmStructs_linux_zero.hpp new file mode 100644 index 00000000000..4c40bbf6de4 --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/vmStructs_linux_zero.hpp @@ -0,0 +1,45 @@ +/* + * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2007 Red Hat, Inc. + * 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 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. + * + */ + +// These are the OS and CPU-specific fields, types and integer +// constants required by the Serviceability Agent. This file is +// referenced by vmStructs.cpp. + +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \ + /* This must be the last entry, and must be present */ \ + last_entry() + + +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type, last_entry) \ + /* This must be the last entry, and must be present */ \ + last_entry() + +#define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \ + /* This must be the last entry, and must be present */ \ + last_entry() + +#define VM_LONG_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \ + /* This must be the last entry, and must be present */ \ + last_entry() diff --git a/hotspot/src/os_cpu/linux_zero/vm/vm_version_linux_zero.cpp b/hotspot/src/os_cpu/linux_zero/vm/vm_version_linux_zero.cpp new file mode 100644 index 00000000000..1fba6011651 --- /dev/null +++ b/hotspot/src/os_cpu/linux_zero/vm/vm_version_linux_zero.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Red Hat, Inc. + * 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 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. + * + */ + +// This file is intentionally empty diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 51e28171903..048fba8d4b0 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -903,19 +903,20 @@ class sun_dyn_AdapterMethodHandle: public sun_dyn_BoundMethodHandle { // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): enum { OP_RETYPE_ONLY = 0x0, // no argument changes; straight retype - OP_CHECK_CAST = 0x1, // ref-to-ref conversion; requires a Class argument - OP_PRIM_TO_PRIM = 0x2, // converts from one primitive to another - OP_REF_TO_PRIM = 0x3, // unboxes a wrapper to produce a primitive - OP_PRIM_TO_REF = 0x4, // boxes a primitive into a wrapper (NYI) - OP_SWAP_ARGS = 0x5, // swap arguments (vminfo is 2nd arg) - OP_ROT_ARGS = 0x6, // rotate arguments (vminfo is displaced arg) - OP_DUP_ARGS = 0x7, // duplicates one or more arguments (at TOS) - OP_DROP_ARGS = 0x8, // remove one or more argument slots - OP_COLLECT_ARGS = 0x9, // combine one or more arguments into a varargs (NYI) - OP_SPREAD_ARGS = 0xA, // expand in place a varargs array (of known size) - OP_FLYBY = 0xB, // operate first on reified argument list (NYI) - OP_RICOCHET = 0xC, // run an adapter chain on the return value (NYI) - CONV_OP_LIMIT = 0xD, // limit of CONV_OP enumeration + OP_RETYPE_RAW = 0x1, // straight retype, trusted (void->int, Object->T) + OP_CHECK_CAST = 0x2, // ref-to-ref conversion; requires a Class argument + OP_PRIM_TO_PRIM = 0x3, // converts from one primitive to another + OP_REF_TO_PRIM = 0x4, // unboxes a wrapper to produce a primitive + OP_PRIM_TO_REF = 0x5, // boxes a primitive into a wrapper (NYI) + OP_SWAP_ARGS = 0x6, // swap arguments (vminfo is 2nd arg) + OP_ROT_ARGS = 0x7, // rotate arguments (vminfo is displaced arg) + OP_DUP_ARGS = 0x8, // duplicates one or more arguments (at TOS) + OP_DROP_ARGS = 0x9, // remove one or more argument slots + OP_COLLECT_ARGS = 0xA, // combine one or more arguments into a varargs (NYI) + OP_SPREAD_ARGS = 0xB, // expand in place a varargs array (of known size) + OP_FLYBY = 0xC, // operate first on reified argument list (NYI) + OP_RICOCHET = 0xD, // run an adapter chain on the return value (NYI) + CONV_OP_LIMIT = 0xE, // limit of CONV_OP enumeration CONV_OP_MASK = 0xF00, // this nybble contains the conversion op field CONV_VMINFO_MASK = 0x0FF, // LSB is reserved for JVM use diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index a0e1432c315..5598c9fcfb3 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1963,7 +1963,7 @@ void SystemDictionary::initialize_preloaded_classes(TRAPS) { WKID meth_group_end = WK_KLASS_ENUM_NAME(WrongMethodTypeException_klass); initialize_wk_klasses_until(meth_group_start, scan, CHECK); if (EnableMethodHandles) { - initialize_wk_klasses_through(meth_group_start, scan, CHECK); + initialize_wk_klasses_through(meth_group_end, scan, CHECK); } if (_well_known_klasses[meth_group_start] == NULL) { // Skip the rest of the method handle classes, if MethodHandle is not loaded. diff --git a/hotspot/src/share/vm/code/debugInfoRec.cpp b/hotspot/src/share/vm/code/debugInfoRec.cpp index c1bbe751b9f..fa24eb7c4c8 100644 --- a/hotspot/src/share/vm/code/debugInfoRec.cpp +++ b/hotspot/src/share/vm/code/debugInfoRec.cpp @@ -356,8 +356,7 @@ void DebugInformationRecorder::end_scopes(int pc_offset, bool is_safepoint) { // search forward until it finds last. // In addition, it does not matter if the last PcDesc // is for a safepoint or not. - if (_prev_safepoint_pc < prev->pc_offset() && - prev->scope_decode_offset() == last->scope_decode_offset()) { + if (_prev_safepoint_pc < prev->pc_offset() && prev->is_same_info(last)) { assert(prev == last-1, "sane"); prev->set_pc_offset(pc_offset); _pcs_length -= 1; diff --git a/hotspot/src/share/vm/code/pcDesc.hpp b/hotspot/src/share/vm/code/pcDesc.hpp index 36f60d787f3..de9334b4cee 100644 --- a/hotspot/src/share/vm/code/pcDesc.hpp +++ b/hotspot/src/share/vm/code/pcDesc.hpp @@ -39,6 +39,7 @@ class PcDesc VALUE_OBJ_CLASS_SPEC { struct { unsigned int reexecute: 1; } bits; + bool operator ==(const PcDescFlags& other) { return word == other.word; } } _flags; public: @@ -64,6 +65,13 @@ class PcDesc VALUE_OBJ_CLASS_SPEC { bool should_reexecute() const { return _flags.bits.reexecute; } void set_should_reexecute(bool z) { _flags.bits.reexecute = z; } + // Does pd refer to the same information as pd? + bool is_same_info(const PcDesc* pd) { + return _scope_decode_offset == pd->_scope_decode_offset && + _obj_decode_offset == pd->_obj_decode_offset && + _flags == pd->_flags; + } + // Returns the real pc address real_pc(const nmethod* code) const; diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp index 8ec60012c04..34939de57c7 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp @@ -377,3 +377,11 @@ void ConcurrentG1Refine::clear_and_record_card_counts() { _g1h->g1_policy()->record_cc_clear_time(elapsed * 1000.0); #endif } + +void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const { + for (int i = 0; i < _n_threads; ++i) { + _threads[i]->print_on(st); + st->cr(); + } +} + diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp index a6ee5484a37..5cef3058ca4 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp @@ -179,4 +179,6 @@ class ConcurrentG1Refine: public CHeapObj { void clear_and_record_card_counts(); static size_t thread_num(); + + void print_worker_threads_on(outputStream* st) const; }; diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp index 1954c949f61..aaf2544fe9b 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp @@ -204,8 +204,12 @@ void ConcurrentG1RefineThread::stop() { if (G1TraceConcurrentRefinement) gclog_or_tty->print_cr("G1-Refine-stop"); } -void ConcurrentG1RefineThread::print() { - gclog_or_tty->print("\"Concurrent G1 Refinement Thread\" "); - Thread::print(); - gclog_or_tty->cr(); +void ConcurrentG1RefineThread::print() const { + print_on(tty); +} + +void ConcurrentG1RefineThread::print_on(outputStream* st) const { + st->print("\"G1 Concurrent Refinement Thread#%d\" ", _worker_id); + Thread::print_on(st); + st->cr(); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp index 05a3243a115..167fc176ef7 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp @@ -77,7 +77,8 @@ class ConcurrentG1RefineThread: public ConcurrentGCThread { int worker_id_offset, int worker_id); // Printing - void print(); + void print() const; + void print_on(outputStream* st) const; // Total virtual time so far. double vtime_accum() { return _vtime_accum; } diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index 08d5e76e788..af93ae7d231 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -237,7 +237,7 @@ void CMMarkStack::par_push_arr(oop* ptr_arr, int n) { _index = next_index; for (int i = 0; i < n; i++) { int ind = start + i; - guarantee(ind < _capacity, "By overflow test above."); + assert(ind < _capacity, "By overflow test above."); _base[ind] = ptr_arr[i]; } } @@ -310,12 +310,12 @@ MemRegion CMRegionStack::pop() { if (res == index) { MemRegion mr = _base[next_index]; if (mr.start() != NULL) { - tmp_guarantee_CM( mr.end() != NULL, "invariant" ); - tmp_guarantee_CM( mr.word_size() > 0, "invariant" ); + assert(mr.end() != NULL, "invariant"); + assert(mr.word_size() > 0, "invariant"); return mr; } else { // that entry was invalidated... let's skip it - tmp_guarantee_CM( mr.end() == NULL, "invariant" ); + assert(mr.end() == NULL, "invariant"); } } // Otherwise, we need to try again. @@ -328,10 +328,10 @@ bool CMRegionStack::invalidate_entries_into_cset() { for (int i = 0; i < _oops_do_bound; ++i) { MemRegion mr = _base[i]; if (mr.start() != NULL) { - tmp_guarantee_CM( mr.end() != NULL, "invariant"); - tmp_guarantee_CM( mr.word_size() > 0, "invariant" ); + assert(mr.end() != NULL, "invariant"); + assert(mr.word_size() > 0, "invariant"); HeapRegion* hr = g1h->heap_region_containing(mr.start()); - tmp_guarantee_CM( hr != NULL, "invariant" ); + assert(hr != NULL, "invariant"); if (hr->in_collection_set()) { // The region points into the collection set _base[i] = MemRegion(); @@ -339,7 +339,7 @@ bool CMRegionStack::invalidate_entries_into_cset() { } } else { // that entry was invalidated... let's skip it - tmp_guarantee_CM( mr.end() == NULL, "invariant" ); + assert(mr.end() == NULL, "invariant"); } } return result; @@ -542,8 +542,8 @@ ConcurrentMark::ConcurrentMark(ReservedSpace rs, gclog_or_tty->print_cr("CL Sleep Factor %1.4lf", cleanup_sleep_factor()); #endif - guarantee( parallel_marking_threads() > 0, "peace of mind" ); - _parallel_workers = new WorkGang("Parallel Marking Threads", + guarantee(parallel_marking_threads() > 0, "peace of mind"); + _parallel_workers = new WorkGang("G1 Parallel Marking Threads", (int) parallel_marking_threads(), false, true); if (_parallel_workers == NULL) vm_exit_during_initialization("Failed necessary allocation."); @@ -569,8 +569,7 @@ void ConcurrentMark::update_g1_committed(bool force) { return; MemRegion committed = _g1h->g1_committed(); - tmp_guarantee_CM( committed.start() == _heap_start, - "start shouldn't change" ); + assert(committed.start() == _heap_start, "start shouldn't change"); HeapWord* new_end = committed.end(); if (new_end > _heap_end) { // The heap has been expanded. @@ -592,9 +591,10 @@ void ConcurrentMark::reset() { _heap_start = committed.start(); _heap_end = committed.end(); - guarantee( _heap_start != NULL && - _heap_end != NULL && - _heap_start < _heap_end, "heap bounds should look ok" ); + // Separated the asserts so that we know which one fires. + assert(_heap_start != NULL, "heap bounds should look ok"); + assert(_heap_end != NULL, "heap bounds should look ok"); + assert(_heap_start < _heap_end, "heap bounds should look ok"); // reset all the marking data structures and any necessary flags clear_marking_state(); @@ -614,7 +614,7 @@ void ConcurrentMark::reset() { } void ConcurrentMark::set_phase(size_t active_tasks, bool concurrent) { - guarantee( active_tasks <= _max_task_num, "we should not have more" ); + assert(active_tasks <= _max_task_num, "we should not have more"); _active_tasks = active_tasks; // Need to update the three data structures below according to the @@ -634,8 +634,8 @@ void ConcurrentMark::set_phase(size_t active_tasks, bool concurrent) { // We currently assume that the concurrent flag has been set to // false before we start remark. At this point we should also be // in a STW phase. - guarantee( !concurrent_marking_in_progress(), "invariant" ); - guarantee( _finger == _heap_end, "only way to get here" ); + assert(!concurrent_marking_in_progress(), "invariant"); + assert(_finger == _heap_end, "only way to get here"); update_g1_committed(true); } } @@ -667,39 +667,6 @@ ConcurrentMark::~ConcurrentMark() { // Called at the first checkpoint. // -#define PRINT_REACHABLE_AT_INITIAL_MARK 0 -#if PRINT_REACHABLE_AT_INITIAL_MARK -static FILE* reachable_file = NULL; - -class PrintReachableClosure: public OopsInGenClosure { - CMBitMap* _bm; - int _level; -public: - PrintReachableClosure(CMBitMap* bm) : - _bm(bm), _level(0) { - guarantee(reachable_file != NULL, "pre-condition"); - } - void do_oop(oop* p) { - oop obj = *p; - HeapWord* obj_addr = (HeapWord*)obj; - if (obj == NULL) return; - fprintf(reachable_file, "%d: "PTR_FORMAT" -> "PTR_FORMAT" (%d)\n", - _level, p, (void*) obj, _bm->isMarked(obj_addr)); - if (!_bm->isMarked(obj_addr)) { - _bm->mark(obj_addr); - _level++; - obj->oop_iterate(this); - _level--; - } - } -}; -#endif // PRINT_REACHABLE_AT_INITIAL_MARK - -#define SEND_HEAP_DUMP_TO_FILE 0 -#if SEND_HEAP_DUMP_TO_FILE -static FILE* heap_dump_file = NULL; -#endif // SEND_HEAP_DUMP_TO_FILE - void ConcurrentMark::clearNextBitmap() { guarantee(!G1CollectedHeap::heap()->mark_in_progress(), "Precondition."); @@ -737,32 +704,9 @@ void ConcurrentMark::checkpointRootsInitialPre() { _has_aborted = false; - // Find all the reachable objects... -#if PRINT_REACHABLE_AT_INITIAL_MARK - guarantee(reachable_file == NULL, "Protocol"); - char fn_buf[100]; - sprintf(fn_buf, "/tmp/reachable.txt.%d", os::current_process_id()); - reachable_file = fopen(fn_buf, "w"); - // clear the mark bitmap (no grey objects to start with) - _nextMarkBitMap->clearAll(); - PrintReachableClosure prcl(_nextMarkBitMap); - g1h->process_strong_roots(true, // activate StrongRootsScope - false, // fake perm gen collection - SharedHeap::SO_AllClasses, - &prcl, // Regular roots - NULL, // do not visit active blobs - &prcl // Perm Gen Roots - ); - // The root iteration above "consumed" dirty cards in the perm gen. - // Therefore, as a shortcut, we dirty all such cards. - g1h->rem_set()->invalidate(g1h->perm_gen()->used_region(), false); - fclose(reachable_file); - reachable_file = NULL; - // clear the mark bitmap again. - _nextMarkBitMap->clearAll(); - COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); - COMPILER2_PRESENT(DerivedPointerTable::clear()); -#endif // PRINT_REACHABLE_AT_INITIAL_MARK + if (G1PrintReachableAtInitialMark) { + print_reachable(true, "before"); + } // Initialise marking structures. This has to be done in a STW phase. reset(); @@ -933,8 +877,8 @@ void ConcurrentMark::grayRoot(oop p) { // initial-mark that the committed space is expanded during the // pause without CM observing this change. So the assertions below // is a bit conservative; but better than nothing. - tmp_guarantee_CM( _g1h->g1_committed().contains(addr), - "address should be within the heap bounds" ); + assert(_g1h->g1_committed().contains(addr), + "address should be within the heap bounds"); if (!_nextMarkBitMap->isMarked(addr)) _nextMarkBitMap->parMark(addr); @@ -960,12 +904,15 @@ void ConcurrentMark::grayRegionIfNecessary(MemRegion mr) { if (mr.start() < finger) { // The finger is always heap region aligned and it is not possible // for mr to span heap regions. - tmp_guarantee_CM( mr.end() <= finger, "invariant" ); + assert(mr.end() <= finger, "invariant"); - tmp_guarantee_CM( mr.start() <= mr.end() && - _heap_start <= mr.start() && - mr.end() <= _heap_end, - "region boundaries should fall within the committed space" ); + // Separated the asserts so that we know which one fires. + assert(mr.start() <= mr.end(), + "region boundaries should fall within the committed space"); + assert(_heap_start <= mr.start(), + "region boundaries should fall within the committed space"); + assert(mr.end() <= _heap_end, + "region boundaries should fall within the committed space"); if (verbose_low()) gclog_or_tty->print_cr("[global] region ["PTR_FORMAT", "PTR_FORMAT") " "below the finger, pushing it", @@ -1014,14 +961,14 @@ private: public: void work(int worker_i) { - guarantee( Thread::current()->is_ConcurrentGC_thread(), - "this should only be done by a conc GC thread" ); + assert(Thread::current()->is_ConcurrentGC_thread(), + "this should only be done by a conc GC thread"); double start_vtime = os::elapsedVTime(); ConcurrentGCThread::stsJoin(); - guarantee( (size_t)worker_i < _cm->active_tasks(), "invariant" ); + assert((size_t) worker_i < _cm->active_tasks(), "invariant"); CMTask* the_task = _cm->task(worker_i); the_task->record_start_time(); if (!_cm->has_aborted()) { @@ -1059,7 +1006,7 @@ public: } while (!_cm->has_aborted() && the_task->has_aborted()); } the_task->record_end_time(); - guarantee( !the_task->has_aborted() || _cm->has_aborted(), "invariant" ); + guarantee(!the_task->has_aborted() || _cm->has_aborted(), "invariant"); ConcurrentGCThread::stsLeave(); @@ -1182,8 +1129,7 @@ class CalcLiveObjectsClosure: public HeapRegionClosure { void mark_card_num_range(intptr_t start_card_num, intptr_t last_card_num) { for (intptr_t i = start_card_num; i <= last_card_num; i++) { #if CARD_BM_TEST_MODE - guarantee(_card_bm->at(i - _bottom_card_num), - "Should already be set."); + guarantee(_card_bm->at(i - _bottom_card_num), "Should already be set."); #else _card_bm->par_at_put(i - _bottom_card_num, 1); #endif @@ -1328,7 +1274,7 @@ public: // In any case, we set the last card num. last_card_num = obj_last_card_num; - marked_bytes += obj_sz * HeapWordSize; + marked_bytes += (size_t)obj_sz * HeapWordSize; // Find the next marked object after this one. start = _bm->getNextMarkedWordAddress(start + 1, nextTop); _changed = true; @@ -1442,7 +1388,7 @@ public: } assert(calccl.complete(), "Shouldn't have yielded!"); - guarantee( (size_t)i < _n_workers, "invariant" ); + assert((size_t) i < _n_workers, "invariant"); _live_bytes[i] = calccl.tot_live(); _used_bytes[i] = calccl.tot_used(); } @@ -1774,14 +1720,14 @@ void ConcurrentMark::completeCleanup() { hd->rem_set()->clear(); HeapRegion* next_hd = hd->next_from_unclean_list(); (void)list->pop(); - guarantee(list->hd() == next_hd, "how not?"); + assert(list->hd() == next_hd, "how not?"); _g1h->put_region_on_unclean_list(hd); if (!hd->isHumongous()) { // Add this to the _free_regions count by 1. _g1h->finish_free_region_work(0, 0, 1, NULL); } hd = list->hd(); - guarantee(hd == next_hd, "how not?"); + assert(hd == next_hd, "how not?"); } } } @@ -1931,9 +1877,6 @@ void ConcurrentMark::checkpointRootsFinalWork() { g1h->set_par_threads(n_workers); g1h->workers()->run_task(&remarkTask); g1h->set_par_threads(0); - - SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); - guarantee( satb_mq_set.completed_buffers_num() == 0, "invariant" ); } else { G1CollectedHeap::StrongRootsScope srs(g1h); // this is remark, so we'll use up all available threads @@ -1945,10 +1888,9 @@ void ConcurrentMark::checkpointRootsFinalWork() { // active_workers will be fewer. The extra ones will just bail out // immediately. remarkTask.work(0); - - SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); - guarantee( satb_mq_set.completed_buffers_num() == 0, "invariant" ); } + SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); + guarantee(satb_mq_set.completed_buffers_num() == 0, "invariant"); print_stats(); @@ -1967,15 +1909,21 @@ void ConcurrentMark::checkpointRootsFinalWork() { #endif } +#ifndef PRODUCT + class ReachablePrinterOopClosure: public OopClosure { private: G1CollectedHeap* _g1h; CMBitMapRO* _bitmap; outputStream* _out; + bool _use_prev_marking; public: - ReachablePrinterOopClosure(CMBitMapRO* bitmap, outputStream* out) : - _bitmap(bitmap), _g1h(G1CollectedHeap::heap()), _out(out) { } + ReachablePrinterOopClosure(CMBitMapRO* bitmap, + outputStream* out, + bool use_prev_marking) : + _g1h(G1CollectedHeap::heap()), + _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } void do_oop(narrowOop* p) { do_oop_work(p); } void do_oop( oop* p) { do_oop_work(p); } @@ -1989,15 +1937,24 @@ public: str = "outside G1 reserved"; else { HeapRegion* hr = _g1h->heap_region_containing(obj); - guarantee( hr != NULL, "invariant" ); - if (hr->obj_allocated_since_prev_marking(obj)) { + guarantee(hr != NULL, "invariant"); + bool over_tams = false; + if (_use_prev_marking) { + over_tams = hr->obj_allocated_since_prev_marking(obj); + } else { + over_tams = hr->obj_allocated_since_next_marking(obj); + } + + if (over_tams) { str = "over TAMS"; - if (_bitmap->isMarked((HeapWord*) obj)) + if (_bitmap->isMarked((HeapWord*) obj)) { str2 = " AND MARKED"; - } else if (_bitmap->isMarked((HeapWord*) obj)) + } + } else if (_bitmap->isMarked((HeapWord*) obj)) { str = "marked"; - else + } else { str = "#### NOT MARKED ####"; + } } _out->print_cr(" "PTR_FORMAT" contains "PTR_FORMAT" %s%s", @@ -2007,16 +1964,19 @@ public: class ReachablePrinterClosure: public BitMapClosure { private: - CMBitMapRO* _bitmap; + CMBitMapRO* _bitmap; outputStream* _out; + bool _use_prev_marking; public: - ReachablePrinterClosure(CMBitMapRO* bitmap, outputStream* out) : - _bitmap(bitmap), _out(out) { } + ReachablePrinterClosure(CMBitMapRO* bitmap, + outputStream* out, + bool use_prev_marking) : + _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } bool do_bit(size_t offset) { HeapWord* addr = _bitmap->offsetToHeapWord(offset); - ReachablePrinterOopClosure oopCl(_bitmap, _out); + ReachablePrinterOopClosure oopCl(_bitmap, _out, _use_prev_marking); _out->print_cr(" obj "PTR_FORMAT", offset %10d (marked)", addr, offset); oop(addr)->oop_iterate(&oopCl); @@ -2028,76 +1988,111 @@ public: class ObjInRegionReachablePrinterClosure : public ObjectClosure { private: - CMBitMapRO* _bitmap; + CMBitMapRO* _bitmap; outputStream* _out; + bool _use_prev_marking; public: + ObjInRegionReachablePrinterClosure(CMBitMapRO* bitmap, + outputStream* out, + bool use_prev_marking) : + _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } + void do_object(oop o) { - ReachablePrinterOopClosure oopCl(_bitmap, _out); + ReachablePrinterOopClosure oopCl(_bitmap, _out, _use_prev_marking); _out->print_cr(" obj "PTR_FORMAT" (over TAMS)", (void*) o); o->oop_iterate(&oopCl); _out->print_cr(""); } - - ObjInRegionReachablePrinterClosure(CMBitMapRO* bitmap, outputStream* out) : - _bitmap(bitmap), _out(out) { } }; class RegionReachablePrinterClosure : public HeapRegionClosure { private: - CMBitMapRO* _bitmap; + CMBitMapRO* _bitmap; outputStream* _out; + bool _use_prev_marking; public: bool doHeapRegion(HeapRegion* hr) { HeapWord* b = hr->bottom(); HeapWord* e = hr->end(); HeapWord* t = hr->top(); - HeapWord* p = hr->prev_top_at_mark_start(); + HeapWord* p = NULL; + if (_use_prev_marking) { + p = hr->prev_top_at_mark_start(); + } else { + p = hr->next_top_at_mark_start(); + } _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" " - "PTAMS: "PTR_FORMAT, b, e, t, p); + "TAMS: "PTR_FORMAT, b, e, t, p); _out->print_cr(""); - ObjInRegionReachablePrinterClosure ocl(_bitmap, _out); + ObjInRegionReachablePrinterClosure ocl(_bitmap, _out, _use_prev_marking); hr->object_iterate_mem_careful(MemRegion(p, t), &ocl); return false; } - RegionReachablePrinterClosure(CMBitMapRO* bitmap, - outputStream* out) : - _bitmap(bitmap), _out(out) { } + RegionReachablePrinterClosure(CMBitMapRO* bitmap, + outputStream* out, + bool use_prev_marking) : + _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } }; -void ConcurrentMark::print_prev_bitmap_reachable() { - outputStream* out = gclog_or_tty; +void ConcurrentMark::print_reachable(bool use_prev_marking, const char* str) { + gclog_or_tty->print_cr("== Doing reachable object dump... "); -#if SEND_HEAP_DUMP_TO_FILE - guarantee(heap_dump_file == NULL, "Protocol"); - char fn_buf[100]; - sprintf(fn_buf, "/tmp/dump.txt.%d", os::current_process_id()); - heap_dump_file = fopen(fn_buf, "w"); - fileStream fstream(heap_dump_file); - out = &fstream; -#endif // SEND_HEAP_DUMP_TO_FILE + if (G1PrintReachableBaseFile == NULL) { + gclog_or_tty->print_cr(" #### error: no base file defined"); + return; + } - RegionReachablePrinterClosure rcl(_prevMarkBitMap, out); - out->print_cr("--- ITERATING OVER REGIONS WITH PTAMS < TOP"); + if (strlen(G1PrintReachableBaseFile) + 1 + strlen(str) > + (JVM_MAXPATHLEN - 1)) { + gclog_or_tty->print_cr(" #### error: file name too long"); + return; + } + + char file_name[JVM_MAXPATHLEN]; + sprintf(file_name, "%s.%s", G1PrintReachableBaseFile, str); + gclog_or_tty->print_cr(" dumping to file %s", file_name); + + fileStream fout(file_name); + if (!fout.is_open()) { + gclog_or_tty->print_cr(" #### error: could not open file"); + return; + } + + outputStream* out = &fout; + + CMBitMapRO* bitmap = NULL; + if (use_prev_marking) { + bitmap = _prevMarkBitMap; + } else { + bitmap = _nextMarkBitMap; + } + + out->print_cr("-- USING %s", (use_prev_marking) ? "PTAMS" : "NTAMS"); + out->cr(); + + RegionReachablePrinterClosure rcl(bitmap, out, use_prev_marking); + out->print_cr("--- ITERATING OVER REGIONS WITH TAMS < TOP"); + out->cr(); _g1h->heap_region_iterate(&rcl); - out->print_cr(""); + out->cr(); - ReachablePrinterClosure cl(_prevMarkBitMap, out); - out->print_cr("--- REACHABLE OBJECTS ON THE BITMAP"); - _prevMarkBitMap->iterate(&cl); - out->print_cr(""); + ReachablePrinterClosure cl(bitmap, out, use_prev_marking); + out->print_cr("--- ITERATING OVER MARKED OBJECTS ON THE BITMAP"); + out->cr(); + bitmap->iterate(&cl); + out->cr(); -#if SEND_HEAP_DUMP_TO_FILE - fclose(heap_dump_file); - heap_dump_file = NULL; -#endif // SEND_HEAP_DUMP_TO_FILE + gclog_or_tty->print_cr(" done"); } +#endif // PRODUCT + // This note is for drainAllSATBBuffers and the code in between. // In the future we could reuse a task to do this work during an // evacuation pause (since now tasks are not active and can be claimed @@ -2125,7 +2120,7 @@ void ConcurrentMark::deal_with_reference(oop obj) { HeapWord* objAddr = (HeapWord*) obj; assert(obj->is_oop_or_null(true /* ignore mark word */), "Error"); if (_g1h->is_in_g1_reserved(objAddr)) { - tmp_guarantee_CM( obj != NULL, "is_in_g1_reserved should ensure this" ); + assert(obj != NULL, "is_in_g1_reserved should ensure this"); HeapRegion* hr = _g1h->heap_region_containing(obj); if (_g1h->is_obj_ill(obj, hr)) { if (verbose_high()) @@ -2167,7 +2162,7 @@ void ConcurrentMark::drainAllSATBBuffers() { satb_mq_set.iterate_closure_all_threads(); satb_mq_set.set_closure(NULL); - guarantee( satb_mq_set.completed_buffers_num() == 0, "invariant" ); + assert(satb_mq_set.completed_buffers_num() == 0, "invariant"); } void ConcurrentMark::markPrev(oop p) { @@ -2200,7 +2195,7 @@ ConcurrentMark::claim_region(int task_num) { // _heap_end will not change underneath our feet; it only changes at // yield points. while (finger < _heap_end) { - tmp_guarantee_CM( _g1h->is_in_g1_reserved(finger), "invariant" ); + assert(_g1h->is_in_g1_reserved(finger), "invariant"); // is the gap between reading the finger and doing the CAS too long? @@ -2222,7 +2217,7 @@ ConcurrentMark::claim_region(int task_num) { // notice that _finger == end cannot be guaranteed here since, // someone else might have moved the finger even further - guarantee( _finger >= end, "the finger should have moved forward" ); + assert(_finger >= end, "the finger should have moved forward"); if (verbose_low()) gclog_or_tty->print_cr("[%d] we were successful with region = " @@ -2234,8 +2229,8 @@ ConcurrentMark::claim_region(int task_num) { "returning it ", task_num, curr_region); return curr_region; } else { - tmp_guarantee_CM( limit == bottom, - "the region limit should be at bottom" ); + assert(limit == bottom, + "the region limit should be at bottom"); if (verbose_low()) gclog_or_tty->print_cr("[%d] region "PTR_FORMAT" is empty, " "returning NULL", task_num, curr_region); @@ -2244,7 +2239,7 @@ ConcurrentMark::claim_region(int task_num) { return NULL; } } else { - guarantee( _finger > finger, "the finger should have moved forward" ); + assert(_finger > finger, "the finger should have moved forward"); if (verbose_low()) gclog_or_tty->print_cr("[%d] somebody else moved the finger, " "global finger = "PTR_FORMAT", " @@ -2282,7 +2277,7 @@ void ConcurrentMark::oops_do(OopClosure* cl) { if (_regionStack.invalidate_entries_into_cset()) { // otherwise, any gray objects copied during the evacuation pause // might not be visited. - guarantee( _should_gray_objects, "invariant" ); + assert(_should_gray_objects, "invariant"); } } @@ -2637,6 +2632,10 @@ void ConcurrentMark::print_summary_info() { cmThread()->vtime_count_accum()); } +void ConcurrentMark::print_worker_threads_on(outputStream* st) const { + _parallel_workers->print_worker_threads_on(st); +} + // Closures // XXX: there seems to be a lot of code duplication here; // should refactor and consolidate the shared code. @@ -2711,12 +2710,12 @@ public: bool do_bit(size_t offset) { HeapWord* addr = _nextMarkBitMap->offsetToHeapWord(offset); - tmp_guarantee_CM( _nextMarkBitMap->isMarked(addr), "invariant" ); - tmp_guarantee_CM( addr < _cm->finger(), "invariant" ); + assert(_nextMarkBitMap->isMarked(addr), "invariant"); + assert( addr < _cm->finger(), "invariant"); if (_scanning_heap_region) { statsOnly( _task->increase_objs_found_on_bitmap() ); - tmp_guarantee_CM( addr >= _task->finger(), "invariant" ); + assert(addr >= _task->finger(), "invariant"); // We move that task's local finger along. _task->move_finger_to(addr); } else { @@ -2761,8 +2760,9 @@ public: virtual void do_oop( oop* p) { do_oop_work(p); } template void do_oop_work(T* p) { - tmp_guarantee_CM( _g1h->is_in_g1_reserved((HeapWord*) p), "invariant" ); - tmp_guarantee_CM( !_g1h->heap_region_containing((HeapWord*) p)->is_on_free_list(), "invariant" ); + assert(_g1h->is_in_g1_reserved((HeapWord*) p), "invariant"); + assert(!_g1h->heap_region_containing((HeapWord*) p)->is_on_free_list(), + "invariant"); oop obj = oopDesc::load_decode_heap_oop(p); if (_cm->verbose_high()) @@ -2779,8 +2779,11 @@ public: }; void CMTask::setup_for_region(HeapRegion* hr) { - tmp_guarantee_CM( hr != NULL && !hr->continuesHumongous(), - "claim_region() should have filtered out continues humongous regions" ); + // Separated the asserts so that we know which one fires. + assert(hr != NULL, + "claim_region() should have filtered out continues humongous regions"); + assert(!hr->continuesHumongous(), + "claim_region() should have filtered out continues humongous regions"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] setting up for region "PTR_FORMAT, @@ -2808,9 +2811,9 @@ void CMTask::update_region_limit() { // as the region is not supposed to be empty in the first place) _finger = bottom; } else if (limit >= _region_limit) { - tmp_guarantee_CM( limit >= _finger, "peace of mind" ); + assert(limit >= _finger, "peace of mind"); } else { - tmp_guarantee_CM( limit < _region_limit, "only way to get here" ); + assert(limit < _region_limit, "only way to get here"); // This can happen under some pretty unusual circumstances. An // evacuation pause empties the region underneath our feet (NTAMS // at bottom). We then do some allocation in the region (NTAMS @@ -2828,7 +2831,7 @@ void CMTask::update_region_limit() { } void CMTask::giveup_current_region() { - tmp_guarantee_CM( _curr_region != NULL, "invariant" ); + assert(_curr_region != NULL, "invariant"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] giving up region "PTR_FORMAT, _task_id, _curr_region); @@ -2846,7 +2849,7 @@ void CMTask::clear_region_fields() { } void CMTask::reset(CMBitMap* nextMarkBitMap) { - guarantee( nextMarkBitMap != NULL, "invariant" ); + guarantee(nextMarkBitMap != NULL, "invariant"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] resetting", _task_id); @@ -2912,7 +2915,7 @@ void CMTask::deal_with_reference(oop obj) { HeapWord* objAddr = (HeapWord*) obj; assert(obj->is_oop_or_null(true /* ignore mark word */), "Error"); if (_g1h->is_in_g1_reserved(objAddr)) { - tmp_guarantee_CM( obj != NULL, "is_in_g1_reserved should ensure this" ); + assert(obj != NULL, "is_in_g1_reserved should ensure this"); HeapRegion* hr = _g1h->heap_region_containing(obj); if (_g1h->is_obj_ill(obj, hr)) { if (_cm->verbose_high()) @@ -2973,10 +2976,11 @@ void CMTask::deal_with_reference(oop obj) { void CMTask::push(oop obj) { HeapWord* objAddr = (HeapWord*) obj; - tmp_guarantee_CM( _g1h->is_in_g1_reserved(objAddr), "invariant" ); - tmp_guarantee_CM( !_g1h->heap_region_containing(objAddr)->is_on_free_list(), "invariant" ); - tmp_guarantee_CM( !_g1h->is_obj_ill(obj), "invariant" ); - tmp_guarantee_CM( _nextMarkBitMap->isMarked(objAddr), "invariant" ); + assert(_g1h->is_in_g1_reserved(objAddr), "invariant"); + assert(!_g1h->heap_region_containing(objAddr)->is_on_free_list(), + "invariant"); + assert(!_g1h->is_obj_ill(obj), "invariant"); + assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); if (_cm->verbose_high()) gclog_or_tty->print_cr("[%d] pushing "PTR_FORMAT, _task_id, (void*) obj); @@ -2995,7 +2999,7 @@ void CMTask::push(oop obj) { // stack, we should have definitely removed some entries from the // local queue. So, there must be space on it. bool success = _task_queue->push(obj); - tmp_guarantee_CM( success, "invariant" ); + assert(success, "invariant"); } statsOnly( int tmp_size = _task_queue->size(); @@ -3005,9 +3009,9 @@ void CMTask::push(oop obj) { } void CMTask::reached_limit() { - tmp_guarantee_CM( _words_scanned >= _words_scanned_limit || - _refs_reached >= _refs_reached_limit , - "shouldn't have been called otherwise" ); + assert(_words_scanned >= _words_scanned_limit || + _refs_reached >= _refs_reached_limit , + "shouldn't have been called otherwise"); regular_clock_call(); } @@ -3165,8 +3169,8 @@ void CMTask::get_entries_from_global_stack() { oop buffer[global_stack_transfer_size]; int n; _cm->mark_stack_pop(buffer, global_stack_transfer_size, &n); - tmp_guarantee_CM( n <= global_stack_transfer_size, - "we should not pop more than the given limit" ); + assert(n <= global_stack_transfer_size, + "we should not pop more than the given limit"); if (n > 0) { // yes, we did actually pop at least one entry @@ -3178,7 +3182,7 @@ void CMTask::get_entries_from_global_stack() { bool success = _task_queue->push(buffer[i]); // We only call this when the local queue is empty or under a // given target limit. So, we do not expect this push to fail. - tmp_guarantee_CM( success, "invariant" ); + assert(success, "invariant"); } statsOnly( int tmp_size = _task_queue->size(); @@ -3218,10 +3222,9 @@ void CMTask::drain_local_queue(bool partially) { gclog_or_tty->print_cr("[%d] popped "PTR_FORMAT, _task_id, (void*) obj); - tmp_guarantee_CM( _g1h->is_in_g1_reserved((HeapWord*) obj), - "invariant" ); - tmp_guarantee_CM( !_g1h->heap_region_containing(obj)->is_on_free_list(), - "invariant" ); + assert(_g1h->is_in_g1_reserved((HeapWord*) obj), "invariant" ); + assert(!_g1h->heap_region_containing(obj)->is_on_free_list(), + "invariant"); scan_object(obj); @@ -3243,7 +3246,7 @@ void CMTask::drain_global_stack(bool partially) { // We have a policy to drain the local queue before we attempt to // drain the global stack. - tmp_guarantee_CM( partially || _task_queue->size() == 0, "invariant" ); + assert(partially || _task_queue->size() == 0, "invariant"); // Decide what the target size is, depending whether we're going to // drain it partially (so that other tasks can steal if they run out @@ -3324,9 +3327,9 @@ void CMTask::drain_satb_buffers() { _draining_satb_buffers = false; - tmp_guarantee_CM( has_aborted() || - concurrent() || - satb_mq_set.completed_buffers_num() == 0, "invariant" ); + assert(has_aborted() || + concurrent() || + satb_mq_set.completed_buffers_num() == 0, "invariant"); if (ParallelGCThreads > 0) satb_mq_set.set_par_closure(_task_id, NULL); @@ -3342,8 +3345,8 @@ void CMTask::drain_region_stack(BitMapClosure* bc) { if (has_aborted()) return; - tmp_guarantee_CM( _region_finger == NULL, - "it should be NULL when we're not scanning a region" ); + assert(_region_finger == NULL, + "it should be NULL when we're not scanning a region"); if (!_cm->region_stack_empty()) { if (_cm->verbose_low()) @@ -3359,12 +3362,12 @@ void CMTask::drain_region_stack(BitMapClosure* bc) { gclog_or_tty->print_cr("[%d] we are scanning region " "["PTR_FORMAT", "PTR_FORMAT")", _task_id, mr.start(), mr.end()); - tmp_guarantee_CM( mr.end() <= _cm->finger(), - "otherwise the region shouldn't be on the stack" ); + assert(mr.end() <= _cm->finger(), + "otherwise the region shouldn't be on the stack"); assert(!mr.is_empty(), "Only non-empty regions live on the region stack"); if (_nextMarkBitMap->iterate(bc, mr)) { - tmp_guarantee_CM( !has_aborted(), - "cannot abort the task without aborting the bitmap iteration" ); + assert(!has_aborted(), + "cannot abort the task without aborting the bitmap iteration"); // We finished iterating over the region without aborting. regular_clock_call(); @@ -3376,14 +3379,14 @@ void CMTask::drain_region_stack(BitMapClosure* bc) { statsOnly(if (mr.start() != NULL) ++_region_stack_pops ); } } else { - guarantee( has_aborted(), "currently the only way to do so" ); + assert(has_aborted(), "currently the only way to do so"); // The only way to abort the bitmap iteration is to return // false from the do_bit() method. However, inside the // do_bit() method we move the _region_finger to point to the // object currently being looked at. So, if we bail out, we // have definitely set _region_finger to something non-null. - guarantee( _region_finger != NULL, "invariant" ); + assert(_region_finger != NULL, "invariant"); // The iteration was actually aborted. So now _region_finger // points to the address of the object we last scanned. If we @@ -3412,13 +3415,6 @@ void CMTask::drain_region_stack(BitMapClosure* bc) { _region_finger = NULL; } - // We only push regions on the region stack during evacuation - // pauses. So if we come out the above iteration because we region - // stack is empty, it will remain empty until the next yield - // point. So, the guarantee below is safe. - guarantee( has_aborted() || _cm->region_stack_empty(), - "only way to exit the loop" ); - if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] drained region stack, size = %d", _task_id, _cm->region_stack_size()); @@ -3576,21 +3572,21 @@ void CMTask::print_stats() { *****************************************************************************/ void CMTask::do_marking_step(double time_target_ms) { - guarantee( time_target_ms >= 1.0, "minimum granularity is 1ms" ); - guarantee( concurrent() == _cm->concurrent(), "they should be the same" ); + assert(time_target_ms >= 1.0, "minimum granularity is 1ms"); + assert(concurrent() == _cm->concurrent(), "they should be the same"); - guarantee( concurrent() || _cm->region_stack_empty(), - "the region stack should have been cleared before remark" ); - guarantee( _region_finger == NULL, - "this should be non-null only when a region is being scanned" ); + assert(concurrent() || _cm->region_stack_empty(), + "the region stack should have been cleared before remark"); + assert(_region_finger == NULL, + "this should be non-null only when a region is being scanned"); G1CollectorPolicy* g1_policy = _g1h->g1_policy(); - guarantee( _task_queues != NULL, "invariant" ); - guarantee( _task_queue != NULL, "invariant" ); - guarantee( _task_queues->queue(_task_id) == _task_queue, "invariant" ); + assert(_task_queues != NULL, "invariant"); + assert(_task_queue != NULL, "invariant"); + assert(_task_queues->queue(_task_id) == _task_queue, "invariant"); - guarantee( !_claimed, - "only one thread should claim this task at any one time" ); + assert(!_claimed, + "only one thread should claim this task at any one time"); // OK, this doesn't safeguard again all possible scenarios, as it is // possible for two threads to set the _claimed flag at the same @@ -3661,9 +3657,8 @@ void CMTask::do_marking_step(double time_target_ms) { do { if (!has_aborted() && _curr_region != NULL) { // This means that we're already holding on to a region. - tmp_guarantee_CM( _finger != NULL, - "if region is not NULL, then the finger " - "should not be NULL either" ); + assert(_finger != NULL, "if region is not NULL, then the finger " + "should not be NULL either"); // We might have restarted this task after an evacuation pause // which might have evacuated the region we're holding on to @@ -3695,13 +3690,13 @@ void CMTask::do_marking_step(double time_target_ms) { giveup_current_region(); regular_clock_call(); } else { - guarantee( has_aborted(), "currently the only way to do so" ); + assert(has_aborted(), "currently the only way to do so"); // The only way to abort the bitmap iteration is to return // false from the do_bit() method. However, inside the // do_bit() method we move the _finger to point to the // object currently being looked at. So, if we bail out, we // have definitely set _finger to something non-null. - guarantee( _finger != NULL, "invariant" ); + assert(_finger != NULL, "invariant"); // Region iteration was actually aborted. So now _finger // points to the address of the object we last scanned. If we @@ -3728,9 +3723,10 @@ void CMTask::do_marking_step(double time_target_ms) { while (!has_aborted() && _curr_region == NULL && !_cm->out_of_regions()) { // We are going to try to claim a new region. We should have // given up on the previous one. - tmp_guarantee_CM( _curr_region == NULL && - _finger == NULL && - _region_limit == NULL, "invariant" ); + // Separated the asserts so that we know which one fires. + assert(_curr_region == NULL, "invariant"); + assert(_finger == NULL, "invariant"); + assert(_region_limit == NULL, "invariant"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] trying to claim a new region", _task_id); HeapRegion* claimed_region = _cm->claim_region(_task_id); @@ -3744,7 +3740,7 @@ void CMTask::do_marking_step(double time_target_ms) { _task_id, claimed_region); setup_for_region(claimed_region); - tmp_guarantee_CM( _curr_region == claimed_region, "invariant" ); + assert(_curr_region == claimed_region, "invariant"); } // It is important to call the regular clock here. It might take // a while to claim a region if, for example, we hit a large @@ -3755,8 +3751,8 @@ void CMTask::do_marking_step(double time_target_ms) { } if (!has_aborted() && _curr_region == NULL) { - tmp_guarantee_CM( _cm->out_of_regions(), - "at this point we should be out of regions" ); + assert(_cm->out_of_regions(), + "at this point we should be out of regions"); } } while ( _curr_region != NULL && !has_aborted()); @@ -3765,8 +3761,8 @@ void CMTask::do_marking_step(double time_target_ms) { // tasks might be pushing objects to it concurrently. We also cannot // check if the region stack is empty because if a thread is aborting // it can push a partially done region back. - tmp_guarantee_CM( _cm->out_of_regions(), - "at this point we should be out of regions" ); + assert(_cm->out_of_regions(), + "at this point we should be out of regions"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] all regions claimed", _task_id); @@ -3790,8 +3786,8 @@ void CMTask::do_marking_step(double time_target_ms) { // tasks might be pushing objects to it concurrently. We also cannot // check if the region stack is empty because if a thread is aborting // it can push a partially done region back. - guarantee( _cm->out_of_regions() && - _task_queue->size() == 0, "only way to reach here" ); + assert(_cm->out_of_regions() && _task_queue->size() == 0, + "only way to reach here"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] starting to steal", _task_id); @@ -3807,8 +3803,8 @@ void CMTask::do_marking_step(double time_target_ms) { statsOnly( ++_steals ); - tmp_guarantee_CM( _nextMarkBitMap->isMarked((HeapWord*) obj), - "any stolen object should be marked" ); + assert(_nextMarkBitMap->isMarked((HeapWord*) obj), + "any stolen object should be marked"); scan_object(obj); // And since we're towards the end, let's totally drain the @@ -3828,8 +3824,9 @@ void CMTask::do_marking_step(double time_target_ms) { // tasks might be concurrently pushing objects on it. We also cannot // check if the region stack is empty because if a thread is aborting // it can push a partially done region back. - guarantee( _cm->out_of_regions() && - _task_queue->size() == 0, "only way to reach here" ); + // Separated the asserts so that we know which one fires. + assert(_cm->out_of_regions(), "only way to reach here"); + assert(_task_queue->size() == 0, "only way to reach here"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] starting termination protocol", _task_id); @@ -3849,7 +3846,7 @@ void CMTask::do_marking_step(double time_target_ms) { if (_task_id == 0) { // let's allow task 0 to do this if (concurrent()) { - guarantee( _cm->concurrent_marking_in_progress(), "invariant" ); + assert(_cm->concurrent_marking_in_progress(), "invariant"); // we need to set this to false before the next // safepoint. This way we ensure that the marking phase // doesn't observe any more heap expansions. @@ -3858,15 +3855,16 @@ void CMTask::do_marking_step(double time_target_ms) { } // We can now guarantee that the global stack is empty, since - // all other tasks have finished. - guarantee( _cm->out_of_regions() && - _cm->region_stack_empty() && - _cm->mark_stack_empty() && - _task_queue->size() == 0 && - !_cm->has_overflown() && - !_cm->mark_stack_overflow() && - !_cm->region_stack_overflow(), - "only way to reach here" ); + // all other tasks have finished. We separated the guarantees so + // that, if a condition is false, we can immediately find out + // which one. + guarantee(_cm->out_of_regions(), "only way to reach here"); + guarantee(_cm->region_stack_empty(), "only way to reach here"); + guarantee(_cm->mark_stack_empty(), "only way to reach here"); + guarantee(_task_queue->size() == 0, "only way to reach here"); + guarantee(!_cm->has_overflown(), "only way to reach here"); + guarantee(!_cm->mark_stack_overflow(), "only way to reach here"); + guarantee(!_cm->region_stack_overflow(), "only way to reach here"); if (_cm->verbose_low()) gclog_or_tty->print_cr("[%d] all tasks terminated", _task_id); @@ -3961,8 +3959,8 @@ CMTask::CMTask(int task_id, _task_queue(task_queue), _task_queues(task_queues), _oop_closure(NULL) { - guarantee( task_queue != NULL, "invariant" ); - guarantee( task_queues != NULL, "invariant" ); + guarantee(task_queue != NULL, "invariant"); + guarantee(task_queues != NULL, "invariant"); statsOnly( _clock_due_to_scanning = 0; _clock_due_to_marking = 0 ); diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp index 010108f9300..f6902c86330 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp @@ -295,12 +295,6 @@ do { \ } while (0) #endif // _MARKING_STATS_ -// Some extra guarantees that I like to also enable in optimised mode -// when debugging. If you want to enable them, comment out the assert -// macro and uncomment out the guaratee macro -// #define tmp_guarantee_CM(expr, str) guarantee(expr, str) -#define tmp_guarantee_CM(expr, str) assert(expr, str) - typedef enum { no_verbose = 0, // verbose turned off stats_verbose, // only prints stats at the end of marking @@ -485,15 +479,15 @@ protected: // Returns the task with the given id CMTask* task(int id) { - guarantee( 0 <= id && id < (int) _active_tasks, "task id not within " - "active bounds" ); + assert(0 <= id && id < (int) _active_tasks, + "task id not within active bounds"); return _tasks[id]; } // Returns the task queue with the given id CMTaskQueue* task_queue(int id) { - guarantee( 0 <= id && id < (int) _active_tasks, "task queue id not within " - "active bounds" ); + assert(0 <= id && id < (int) _active_tasks, + "task queue id not within active bounds"); return (CMTaskQueue*) _task_queues->queue(id); } @@ -618,10 +612,11 @@ public: // we do nothing. void markAndGrayObjectIfNecessary(oop p); - // This iterates over the bitmap of the previous marking and prints - // out all objects that are marked on the bitmap and indicates - // whether what they point to is also marked or not. - void print_prev_bitmap_reachable(); + // This iterates over the marking bitmap (either prev or next) and + // prints out all objects that are marked on the bitmap and indicates + // whether what they point to is also marked or not. It also iterates + // the objects over TAMS (either prev or next). + void print_reachable(bool use_prev_marking, const char* str); // Clear the next marking bitmap (will be called concurrently). void clearNextBitmap(); @@ -723,6 +718,8 @@ public: void print_summary_info(); + void print_worker_threads_on(outputStream* st) const; + // The following indicate whether a given verbose level has been // set. Notice that anything above stats is conditional to // _MARKING_VERBOSE_ having been set to 1 @@ -959,8 +956,7 @@ public: // It scans an object and visits its children. void scan_object(oop obj) { - tmp_guarantee_CM( _nextMarkBitMap->isMarked((HeapWord*) obj), - "invariant" ); + assert(_nextMarkBitMap->isMarked((HeapWord*) obj), "invariant"); if (_cm->verbose_high()) gclog_or_tty->print_cr("[%d] we're scanning object "PTR_FORMAT, @@ -999,14 +995,13 @@ public: // moves the local finger to a new location inline void move_finger_to(HeapWord* new_finger) { - tmp_guarantee_CM( new_finger >= _finger && new_finger < _region_limit, - "invariant" ); + assert(new_finger >= _finger && new_finger < _region_limit, "invariant"); _finger = new_finger; } // moves the region finger to a new location inline void move_region_finger_to(HeapWord* new_finger) { - tmp_guarantee_CM( new_finger < _cm->finger(), "invariant" ); + assert(new_finger < _cm->finger(), "invariant"); _region_finger = new_finger; } diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp index 445a342c862..b1a8b2a7b46 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp @@ -286,10 +286,14 @@ void ConcurrentMarkThread::stop() { } } -void ConcurrentMarkThread::print() { - gclog_or_tty->print("\"Concurrent Mark GC Thread\" "); - Thread::print(); - gclog_or_tty->cr(); +void ConcurrentMarkThread::print() const { + print_on(tty); +} + +void ConcurrentMarkThread::print_on(outputStream* st) const { + st->print("\"G1 Main Concurrent Mark GC Thread\" "); + Thread::print_on(st); + st->cr(); } void ConcurrentMarkThread::sleepBeforeNextCycle() { diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp index e439bdb44d1..77f8f35753f 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp @@ -57,7 +57,8 @@ class ConcurrentMarkThread: public ConcurrentGCThread { static SurrogateLockerThread* slt() { return _slt; } // Printing - void print(); + void print_on(outputStream* st) const; + void print() const; // Total virtual time so far. double vtime_accum(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.cpp index 3f508f823d6..fef8805f1b6 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.cpp @@ -157,10 +157,14 @@ void ConcurrentZFThread::stop() { } } -void ConcurrentZFThread::print() { - gclog_or_tty->print("\"Concurrent ZF Thread\" "); - Thread::print(); - gclog_or_tty->cr(); +void ConcurrentZFThread::print() const { + print_on(tty); +} + +void ConcurrentZFThread::print_on(outputStream* st) const { + st->print("\"G1 Concurrent Zero-Fill Thread\" "); + Thread::print_on(st); + st->cr(); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.hpp index d7f4cfa0c5f..75774942e85 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.hpp @@ -61,7 +61,8 @@ class ConcurrentZFThread: public ConcurrentGCThread { virtual void run(); // Printing - void print(); + void print_on(outputStream* st) const; + void print() const; // Waits until "r" has been zero-filled. Requires caller to hold the // ZF_mon. diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 62e987f2b1c..550b028ea60 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -2210,40 +2210,58 @@ private: bool _allow_dirty; bool _par; bool _use_prev_marking; + bool _failures; public: // use_prev_marking == true -> use "prev" marking information, // use_prev_marking == false -> use "next" marking information VerifyRegionClosure(bool allow_dirty, bool par, bool use_prev_marking) : _allow_dirty(allow_dirty), _par(par), - _use_prev_marking(use_prev_marking) {} + _use_prev_marking(use_prev_marking), + _failures(false) {} + + bool failures() { + return _failures; + } bool doHeapRegion(HeapRegion* r) { guarantee(_par || r->claim_value() == HeapRegion::InitialClaimValue, "Should be unclaimed at verify points."); if (!r->continuesHumongous()) { - VerifyObjsInRegionClosure not_dead_yet_cl(r, _use_prev_marking); - r->verify(_allow_dirty, _use_prev_marking); - r->object_iterate(¬_dead_yet_cl); - guarantee(r->max_live_bytes() >= not_dead_yet_cl.live_bytes(), - "More live objects than counted in last complete marking."); + bool failures = false; + r->verify(_allow_dirty, _use_prev_marking, &failures); + if (failures) { + _failures = true; + } else { + VerifyObjsInRegionClosure not_dead_yet_cl(r, _use_prev_marking); + r->object_iterate(¬_dead_yet_cl); + if (r->max_live_bytes() < not_dead_yet_cl.live_bytes()) { + gclog_or_tty->print_cr("["PTR_FORMAT","PTR_FORMAT"] " + "max_live_bytes "SIZE_FORMAT" " + "< calculated "SIZE_FORMAT, + r->bottom(), r->end(), + r->max_live_bytes(), + not_dead_yet_cl.live_bytes()); + _failures = true; + } + } } - return false; + return false; // stop the region iteration if we hit a failure } }; class VerifyRootsClosure: public OopsInGenClosure { private: G1CollectedHeap* _g1h; - bool _failures; bool _use_prev_marking; + bool _failures; public: // use_prev_marking == true -> use "prev" marking information, // use_prev_marking == false -> use "next" marking information VerifyRootsClosure(bool use_prev_marking) : _g1h(G1CollectedHeap::heap()), - _failures(false), - _use_prev_marking(use_prev_marking) { } + _use_prev_marking(use_prev_marking), + _failures(false) { } bool failures() { return _failures; } @@ -2253,7 +2271,7 @@ public: oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); if (_g1h->is_obj_dead_cond(obj, _use_prev_marking)) { gclog_or_tty->print_cr("Root location "PTR_FORMAT" " - "points to dead obj "PTR_FORMAT, p, (void*) obj); + "points to dead obj "PTR_FORMAT, p, (void*) obj); obj->print_on(gclog_or_tty); _failures = true; } @@ -2271,6 +2289,7 @@ private: G1CollectedHeap* _g1h; bool _allow_dirty; bool _use_prev_marking; + bool _failures; public: // use_prev_marking == true -> use "prev" marking information, @@ -2280,13 +2299,21 @@ public: AbstractGangTask("Parallel verify task"), _g1h(g1h), _allow_dirty(allow_dirty), - _use_prev_marking(use_prev_marking) { } + _use_prev_marking(use_prev_marking), + _failures(false) { } + + bool failures() { + return _failures; + } void work(int worker_i) { HandleMark hm; VerifyRegionClosure blk(_allow_dirty, true, _use_prev_marking); _g1h->heap_region_par_iterate_chunked(&blk, worker_i, HeapRegion::ParVerifyClaimValue); + if (blk.failures()) { + _failures = true; + } } }; @@ -2307,6 +2334,7 @@ void G1CollectedHeap::verify(bool allow_dirty, &rootsCl, &blobsCl, &rootsCl); + bool failures = rootsCl.failures(); rem_set()->invalidate(perm_gen()->used_region(), false); if (!silent) { gclog_or_tty->print("heapRegions "); } if (GCParallelVerificationEnabled && ParallelGCThreads > 1) { @@ -2318,6 +2346,9 @@ void G1CollectedHeap::verify(bool allow_dirty, set_par_threads(n_workers); workers()->run_task(&task); set_par_threads(0); + if (task.failures()) { + failures = true; + } assert(check_heap_region_claim_values(HeapRegion::ParVerifyClaimValue), "sanity check"); @@ -2329,10 +2360,24 @@ void G1CollectedHeap::verify(bool allow_dirty, } else { VerifyRegionClosure blk(allow_dirty, false, use_prev_marking); _hrs->iterate(&blk); + if (blk.failures()) { + failures = true; + } } if (!silent) gclog_or_tty->print("remset "); rem_set()->verify(); - guarantee(!rootsCl.failures(), "should not have had failures"); + + if (failures) { + gclog_or_tty->print_cr("Heap:"); + print_on(gclog_or_tty, true /* extended */); + gclog_or_tty->print_cr(""); + if (VerifyDuringGC && G1VerifyDuringGCPrintReachable) { + concurrent_mark()->print_reachable(use_prev_marking, + "failed-verification"); + } + gclog_or_tty->flush(); + } + guarantee(!failures, "there should not have been any failures"); } else { if (!silent) gclog_or_tty->print("(SKIPPING roots, heapRegions, remset) "); } @@ -2374,6 +2419,7 @@ void G1CollectedHeap::print_on(outputStream* st, bool extended) const { st->cr(); perm()->as_gen()->print_on(st); if (extended) { + st->cr(); print_on_extended(st); } } @@ -2383,27 +2429,18 @@ void G1CollectedHeap::print_on_extended(outputStream* st) const { _hrs->iterate(&blk); } -class PrintOnThreadsClosure : public ThreadClosure { - outputStream* _st; -public: - PrintOnThreadsClosure(outputStream* st) : _st(st) { } - virtual void do_thread(Thread *t) { - t->print_on(_st); - } -}; - void G1CollectedHeap::print_gc_threads_on(outputStream* st) const { if (ParallelGCThreads > 0) { - workers()->print_worker_threads(); + workers()->print_worker_threads_on(st); } - st->print("\"G1 concurrent mark GC Thread\" "); - _cmThread->print(); + + _cmThread->print_on(st); st->cr(); - st->print("\"G1 concurrent refinement GC Threads\" "); - PrintOnThreadsClosure p(st); - _cg1r->threads_do(&p); - st->cr(); - st->print("\"G1 zero-fill GC Thread\" "); + + _cm->print_worker_threads_on(st); + + _cg1r->print_worker_threads_on(st); + _czft->print_on(st); st->cr(); } @@ -3099,7 +3136,7 @@ void G1CollectedHeap::finalize_for_evac_failure() { _evac_failure_scan_stack->length() == 0, "Postcondition"); assert(!_drain_in_progress, "Postcondition"); - // Don't have to delete, since the scan stack is a resource object. + delete _evac_failure_scan_stack; _evac_failure_scan_stack = NULL; } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 4ce7bdcfee8..5e07828267f 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -992,11 +992,39 @@ public: // Can a compiler initialize a new object without store barriers? // This permission only extends from the creation of a new object - // via a TLAB up to the first subsequent safepoint. + // via a TLAB up to the first subsequent safepoint. If such permission + // is granted for this heap type, the compiler promises to call + // defer_store_barrier() below on any slow path allocation of + // a new object for which such initializing store barriers will + // have been elided. G1, like CMS, allows this, but should be + // ready to provide a compensating write barrier as necessary + // if that storage came out of a non-young region. The efficiency + // of this implementation depends crucially on being able to + // answer very efficiently in constant time whether a piece of + // storage in the heap comes from a young region or not. + // See ReduceInitialCardMarks. virtual bool can_elide_tlab_store_barriers() const { - // Since G1's TLAB's may, on occasion, come from non-young regions - // as well. (Is there a flag controlling that? XXX) - return false; + return true; + } + + bool is_in_young(oop obj) { + HeapRegion* hr = heap_region_containing(obj); + return hr != NULL && hr->is_young(); + } + + // We don't need barriers for initializing stores to objects + // in the young gen: for the SATB pre-barrier, there is no + // pre-value that needs to be remembered; for the remembered-set + // update logging post-barrier, we don't maintain remembered set + // information for young gen objects. Note that non-generational + // G1 does not have any "young" objects, should not elide + // the rs logging barrier and so should always answer false below. + // However, non-generational G1 (-XX:-G1Gen) appears to have + // bit-rotted so was not tested below. + virtual bool can_elide_initializing_store_barrier(oop new_obj) { + assert(G1Gen || !is_in_young(new_obj), + "Non-generational G1 should never return true below"); + return is_in_young(new_obj); } // Can a compiler elide a store barrier when it writes diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp index ecbddba4404..20e8fba5dea 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @@ -1516,7 +1516,8 @@ void G1CollectorPolicy::record_collection_pause_end(bool abandoned) { (end_time_sec - _recent_prev_end_times_for_all_gcs_sec->oldest()) * 1000.0; update_recent_gc_times(end_time_sec, elapsed_ms); _recent_avg_pause_time_ratio = _recent_gc_times_ms->sum()/interval_ms; - assert(recent_avg_pause_time_ratio() < 1.00, "All GC?"); + // using 1.01 to account for floating point inaccuracies + assert(recent_avg_pause_time_ratio() < 1.01, "All GC?"); } if (G1PolicyVerbose > 1) { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp index b56a0281313..c941c8755d6 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp @@ -55,8 +55,14 @@ develop(intx, G1MarkingVerboseLevel, 0, \ "Level (0-4) of verboseness of the marking code") \ \ - develop(bool, G1VerifyConcMarkPrintReachable, false, \ - "If conc mark verification fails, print reachable objects") \ + develop(bool, G1PrintReachableAtInitialMark, false, \ + "Reachable object dump at the initial mark pause") \ + \ + develop(bool, G1VerifyDuringGCPrintReachable, false, \ + "If conc mark verification fails, dump reachable objects") \ + \ + develop(ccstr, G1PrintReachableBaseFile, NULL, \ + "The base file name for the reachable object dumps") \ \ develop(bool, G1TraceMarkStackOverflow, false, \ "If true, extra debugging code for CM restart for ovflw.") \ diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp index 6cbdf87583b..8afaee40a85 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp @@ -722,12 +722,13 @@ void HeapRegion::print_on(outputStream* st) const { st->print(" F"); else st->print(" "); - st->print(" %d", _gc_time_stamp); + st->print(" %5d", _gc_time_stamp); G1OffsetTableContigSpace::print_on(st); } void HeapRegion::verify(bool allow_dirty) const { - verify(allow_dirty, /* use_prev_marking */ true); + bool dummy = false; + verify(allow_dirty, /* use_prev_marking */ true, /* failures */ &dummy); } #define OBJ_SAMPLE_INTERVAL 0 @@ -736,8 +737,11 @@ void HeapRegion::verify(bool allow_dirty) const { // This really ought to be commoned up into OffsetTableContigSpace somehow. // We would need a mechanism to make that code skip dead objects. -void HeapRegion::verify(bool allow_dirty, bool use_prev_marking) const { +void HeapRegion::verify(bool allow_dirty, + bool use_prev_marking, + bool* failures) const { G1CollectedHeap* g1 = G1CollectedHeap::heap(); + *failures = false; HeapWord* p = bottom(); HeapWord* prev_p = NULL; int objs = 0; @@ -746,8 +750,14 @@ void HeapRegion::verify(bool allow_dirty, bool use_prev_marking) const { while (p < top()) { size_t size = oop(p)->size(); if (blocks == BLOCK_SAMPLE_INTERVAL) { - guarantee(p == block_start_const(p + (size/2)), - "check offset computation"); + HeapWord* res = block_start_const(p + (size/2)); + if (p != res) { + gclog_or_tty->print_cr("offset computation 1 for "PTR_FORMAT" and " + SIZE_FORMAT" returned "PTR_FORMAT, + p, size, res); + *failures = true; + return; + } blocks = 0; } else { blocks++; @@ -755,11 +765,34 @@ void HeapRegion::verify(bool allow_dirty, bool use_prev_marking) const { if (objs == OBJ_SAMPLE_INTERVAL) { oop obj = oop(p); if (!g1->is_obj_dead_cond(obj, this, use_prev_marking)) { - obj->verify(); - vl_cl.set_containing_obj(obj); - obj->oop_iterate(&vl_cl); - if (G1MaxVerifyFailures >= 0 - && vl_cl.n_failures() >= G1MaxVerifyFailures) break; + if (obj->is_oop()) { + klassOop klass = obj->klass(); + if (!klass->is_perm()) { + gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " + "not in perm", klass, obj); + *failures = true; + return; + } else if (!klass->is_klass()) { + gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" " + "not a klass", klass, obj); + *failures = true; + return; + } else { + vl_cl.set_containing_obj(obj); + obj->oop_iterate(&vl_cl); + if (vl_cl.failures()) { + *failures = true; + } + if (G1MaxVerifyFailures >= 0 && + vl_cl.n_failures() >= G1MaxVerifyFailures) { + return; + } + } + } else { + gclog_or_tty->print_cr(PTR_FORMAT" no an oop", obj); + *failures = true; + return; + } } objs = 0; } else { @@ -771,21 +804,22 @@ void HeapRegion::verify(bool allow_dirty, bool use_prev_marking) const { HeapWord* rend = end(); HeapWord* rtop = top(); if (rtop < rend) { - guarantee(block_start_const(rtop + (rend - rtop) / 2) == rtop, - "check offset computation"); + HeapWord* res = block_start_const(rtop + (rend - rtop) / 2); + if (res != rtop) { + gclog_or_tty->print_cr("offset computation 2 for "PTR_FORMAT" and " + PTR_FORMAT" returned "PTR_FORMAT, + rtop, rend, res); + *failures = true; + return; + } } - if (vl_cl.failures()) { - gclog_or_tty->print_cr("Heap:"); - G1CollectedHeap::heap()->print_on(gclog_or_tty, true /* extended */); - gclog_or_tty->print_cr(""); + + if (p != top()) { + gclog_or_tty->print_cr("end of last object "PTR_FORMAT" " + "does not match top "PTR_FORMAT, p, top()); + *failures = true; + return; } - if (VerifyDuringGC && - G1VerifyConcMarkPrintReachable && - vl_cl.failures()) { - g1->concurrent_mark()->print_prev_bitmap_reachable(); - } - guarantee(!vl_cl.failures(), "region verification failed"); - guarantee(p == top(), "end of last object must match end of space"); } // G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp index 9a96a84da55..fd88a3798b4 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp @@ -569,13 +569,8 @@ class HeapRegion: public G1OffsetTableContigSpace { // ever evacuated into this region. If we evacuate, allocate, and // then evacuate we are in deep doodoo. void note_end_of_copying() { - assert(top() >= _next_top_at_mark_start, - "Increase only"); - // Survivor regions will be scanned on the start of concurrent - // marking. - if (!is_survivor()) { - _next_top_at_mark_start = top(); - } + assert(top() >= _next_top_at_mark_start, "Increase only"); + _next_top_at_mark_start = top(); } // Returns "false" iff no object in the region was allocated when the @@ -798,7 +793,7 @@ class HeapRegion: public G1OffsetTableContigSpace { // use_prev_marking == true. Currently, there is only one case where // this is called with use_prev_marking == false, which is to verify // the "next" marking information at the end of remark. - void verify(bool allow_dirty, bool use_prev_marking) const; + void verify(bool allow_dirty, bool use_prev_marking, bool *failures) const; // Override; it uses the "prev" marking information virtual void verify(bool allow_dirty) const; diff --git a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp index e57953b03e0..cef8297a367 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp @@ -135,7 +135,6 @@ RSHashTable::RSHashTable(size_t capacity) : _occupied_entries(0), _occupied_cards(0), _entries(NEW_C_HEAP_ARRAY(SparsePRTEntry, capacity)), _buckets(NEW_C_HEAP_ARRAY(int, capacity)), - _next_deleted(NULL), _deleted(false), _free_list(NullEntry), _free_region(0) { clear(); @@ -296,40 +295,6 @@ void RSHashTable::add_entry(SparsePRTEntry* e) { assert(e2->num_valid_cards() > 0, "Postcondition."); } -RSHashTable* RSHashTable::_head_deleted_list = NULL; - -void RSHashTable::add_to_deleted_list(RSHashTable* rsht) { - assert(!rsht->deleted(), "Should delete only once."); - rsht->set_deleted(true); - RSHashTable* hd = _head_deleted_list; - while (true) { - rsht->_next_deleted = hd; - RSHashTable* res = - (RSHashTable*) - Atomic::cmpxchg_ptr(rsht, &_head_deleted_list, hd); - if (res == hd) return; - else hd = res; - } -} - -RSHashTable* RSHashTable::get_from_deleted_list() { - RSHashTable* hd = _head_deleted_list; - while (hd != NULL) { - RSHashTable* next = hd->next_deleted(); - RSHashTable* res = - (RSHashTable*) - Atomic::cmpxchg_ptr(next, &_head_deleted_list, hd); - if (res == hd) { - hd->set_next_deleted(NULL); - hd->set_deleted(false); - return hd; - } else { - hd = res; - } - } - return NULL; -} - CardIdx_t /* RSHashTable:: */ RSHashTableIter::find_first_card_in_list() { CardIdx_t res; while (_bl_ind != RSHashTable::NullEntry) { @@ -442,15 +407,6 @@ void SparsePRT::cleanup_all() { sprt->cleanup(); sprt = get_from_expanded_list(); } - // Now delete all deleted RSHashTables. - RSHashTable* rsht = RSHashTable::get_from_deleted_list(); - while (rsht != NULL) { -#if SPARSE_PRT_VERBOSE - gclog_or_tty->print_cr("About to delete RSHT " PTR_FORMAT ".", rsht); -#endif - delete rsht; - rsht = RSHashTable::get_from_deleted_list(); - } } @@ -511,8 +467,10 @@ void SparsePRT::clear() { } void SparsePRT::cleanup() { - // Make sure that the current and next tables agree. (Another mechanism - // takes care of deleting now-unused tables.) + // Make sure that the current and next tables agree. + if (_cur != _next) { + delete _cur; + } _cur = _next; set_expanded(false); } @@ -535,7 +493,8 @@ void SparsePRT::expand() { _next->add_entry(e); } } - if (last != _cur) - RSHashTable::add_to_deleted_list(last); + if (last != _cur) { + delete last; + } add_to_expanded_list(this); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp index b67126ae80f..c5a39737c52 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.hpp @@ -102,13 +102,6 @@ class RSHashTable : public CHeapObj { int _free_region; int _free_list; - static RSHashTable* _head_deleted_list; - RSHashTable* _next_deleted; - RSHashTable* next_deleted() { return _next_deleted; } - void set_next_deleted(RSHashTable* rsht) { _next_deleted = rsht; } - bool _deleted; - void set_deleted(bool b) { _deleted = b; } - // Requires that the caller hold a lock preventing parallel modifying // operations, and that the the table be less than completely full. If // an entry for "region_ind" is already in the table, finds it and @@ -154,14 +147,10 @@ public: size_t occupied_entries() const { return _occupied_entries; } size_t occupied_cards() const { return _occupied_cards; } size_t mem_size() const; - bool deleted() { return _deleted; } SparsePRTEntry* entry(int i) const { return &_entries[i]; } void print(); - - static void add_to_deleted_list(RSHashTable* rsht); - static RSHashTable* get_from_deleted_list(); }; // ValueObj because will be embedded in HRRS iterator. diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 0835503d262..8396e7960b1 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -314,41 +314,6 @@ bool ParallelScavengeHeap::is_in_reserved(const void* p) const { return false; } -// Static method -bool ParallelScavengeHeap::is_in_young(oop* p) { - ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); - assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, - "Must be ParallelScavengeHeap"); - - PSYoungGen* young_gen = heap->young_gen(); - - if (young_gen->is_in_reserved(p)) { - return true; - } - - return false; -} - -// Static method -bool ParallelScavengeHeap::is_in_old_or_perm(oop* p) { - ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); - assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, - "Must be ParallelScavengeHeap"); - - PSOldGen* old_gen = heap->old_gen(); - PSPermGen* perm_gen = heap->perm_gen(); - - if (old_gen->is_in_reserved(p)) { - return true; - } - - if (perm_gen->is_in_reserved(p)) { - return true; - } - - return false; -} - // There are two levels of allocation policy here. // // When an allocation request fails, the requesting thread must invoke a VM @@ -764,6 +729,13 @@ void ParallelScavengeHeap::resize_all_tlabs() { CollectedHeap::resize_all_tlabs(); } +bool ParallelScavengeHeap::can_elide_initializing_store_barrier(oop new_obj) { + // We don't need barriers for stores to objects in the + // young gen and, a fortiori, for initializing stores to + // objects therein. + return is_in_young(new_obj); +} + // This method is used by System.gc() and JVMTI. void ParallelScavengeHeap::collect(GCCause::Cause cause) { assert(!Heap_lock->owned_by_self(), diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp index 5b19b7a5c0c..3bf7671b29a 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp @@ -129,8 +129,8 @@ class ParallelScavengeHeap : public CollectedHeap { return perm_gen()->is_in(p); } - static bool is_in_young(oop *p); // reserved part - static bool is_in_old_or_perm(oop *p); // reserved part + inline bool is_in_young(oop p); // reserved part + inline bool is_in_old_or_perm(oop p); // reserved part // Memory allocation. "gc_time_limit_was_exceeded" will // be set to true if the adaptive size policy determine that @@ -191,6 +191,10 @@ class ParallelScavengeHeap : public CollectedHeap { return true; } + // Return true if we don't we need a store barrier for + // initializing stores to an object at this address. + virtual bool can_elide_initializing_store_barrier(oop new_obj); + // Can a compiler elide a store barrier when it writes // a permanent oop into the heap? Applies when the compiler // is storing x to the heap, where x->is_perm() is true. diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp index bcc80ab630e..ccdbd043cb7 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp @@ -41,3 +41,11 @@ inline void ParallelScavengeHeap::invoke_full_gc(bool maximum_compaction) PSMarkSweep::invoke(maximum_compaction); } } + +inline bool ParallelScavengeHeap::is_in_young(oop p) { + return young_gen()->is_in_reserved(p); +} + +inline bool ParallelScavengeHeap::is_in_old_or_perm(oop p) { + return old_gen()->is_in_reserved(p) || perm_gen()->is_in_reserved(p); +} diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp index 7e2daebd4de..c775e6021b1 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp @@ -137,6 +137,89 @@ HeapWord* CollectedHeap::allocate_from_tlab_slow(Thread* thread, size_t size) { return obj; } +void CollectedHeap::flush_deferred_store_barrier(JavaThread* thread) { + MemRegion deferred = thread->deferred_card_mark(); + if (!deferred.is_empty()) { + { + // Verify that the storage points to a parsable object in heap + DEBUG_ONLY(oop old_obj = oop(deferred.start());) + assert(is_in(old_obj), "Not in allocated heap"); + assert(!can_elide_initializing_store_barrier(old_obj), + "Else should have been filtered in defer_store_barrier()"); + assert(!is_in_permanent(old_obj), "Sanity: not expected"); + assert(old_obj->is_oop(true), "Not an oop"); + assert(old_obj->is_parsable(), "Will not be concurrently parsable"); + assert(deferred.word_size() == (size_t)(old_obj->size()), + "Mismatch: multiple objects?"); + } + BarrierSet* bs = barrier_set(); + assert(bs->has_write_region_opt(), "No write_region() on BarrierSet"); + bs->write_region(deferred); + // "Clear" the deferred_card_mark field + thread->set_deferred_card_mark(MemRegion()); + } + assert(thread->deferred_card_mark().is_empty(), "invariant"); +} + +// Helper for ReduceInitialCardMarks. For performance, +// compiled code may elide card-marks for initializing stores +// to a newly allocated object along the fast-path. We +// compensate for such elided card-marks as follows: +// (a) Generational, non-concurrent collectors, such as +// GenCollectedHeap(ParNew,DefNew,Tenured) and +// ParallelScavengeHeap(ParallelGC, ParallelOldGC) +// need the card-mark if and only if the region is +// in the old gen, and do not care if the card-mark +// succeeds or precedes the initializing stores themselves, +// so long as the card-mark is completed before the next +// scavenge. For all these cases, we can do a card mark +// at the point at which we do a slow path allocation +// in the old gen. For uniformity, however, we end +// up using the same scheme (see below) for all three +// cases (deferring the card-mark appropriately). +// (b) GenCollectedHeap(ConcurrentMarkSweepGeneration) requires +// in addition that the card-mark for an old gen allocated +// object strictly follow any associated initializing stores. +// In these cases, the memRegion remembered below is +// used to card-mark the entire region either just before the next +// slow-path allocation by this thread or just before the next scavenge or +// CMS-associated safepoint, whichever of these events happens first. +// (The implicit assumption is that the object has been fully +// initialized by this point, a fact that we assert when doing the +// card-mark.) +// (c) G1CollectedHeap(G1) uses two kinds of write barriers. When a +// G1 concurrent marking is in progress an SATB (pre-write-)barrier is +// is used to remember the pre-value of any store. Initializing +// stores will not need this barrier, so we need not worry about +// compensating for the missing pre-barrier here. Turning now +// to the post-barrier, we note that G1 needs a RS update barrier +// which simply enqueues a (sequence of) dirty cards which may +// optionally be refined by the concurrent update threads. Note +// that this barrier need only be applied to a non-young write, +// but, like in CMS, because of the presence of concurrent refinement +// (much like CMS' precleaning), must strictly follow the oop-store. +// Thus, using the same protocol for maintaining the intended +// invariants turns out, serendepitously, to be the same for all +// three collectors/heap types above. +// +// For each future collector, this should be reexamined with +// that specific collector in mind. +oop CollectedHeap::defer_store_barrier(JavaThread* thread, oop new_obj) { + // If a previous card-mark was deferred, flush it now. + flush_deferred_store_barrier(thread); + if (can_elide_initializing_store_barrier(new_obj)) { + // The deferred_card_mark region should be empty + // following the flush above. + assert(thread->deferred_card_mark().is_empty(), "Error"); + } else { + // Remember info for the newly deferred store barrier + MemRegion deferred = MemRegion((HeapWord*)new_obj, new_obj->size()); + assert(!deferred.is_empty(), "Error"); + thread->set_deferred_card_mark(deferred); + } + return new_obj; +} + size_t CollectedHeap::filler_array_hdr_size() { return size_t(arrayOopDesc::header_size(T_INT)); } @@ -225,16 +308,6 @@ void CollectedHeap::fill_with_objects(HeapWord* start, size_t words) fill_with_object_impl(start, words); } -oop CollectedHeap::new_store_barrier(oop new_obj) { - // %%% This needs refactoring. (It was imported from the server compiler.) - guarantee(can_elide_tlab_store_barriers(), "store barrier elision not supported"); - BarrierSet* bs = this->barrier_set(); - assert(bs->has_write_region_opt(), "Barrier set does not have write_region"); - int new_size = new_obj->size(); - bs->write_region(MemRegion((HeapWord*)new_obj, new_size)); - return new_obj; -} - HeapWord* CollectedHeap::allocate_new_tlab(size_t size) { guarantee(false, "thread-local allocation buffers not supported"); return NULL; diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp index f39f1ebfa80..18148c8a30f 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp @@ -415,9 +415,14 @@ class CollectedHeap : public CHeapObj { guarantee(false, "thread-local allocation buffers not supported"); return 0; } + // Can a compiler initialize a new object without store barriers? // This permission only extends from the creation of a new object - // via a TLAB up to the first subsequent safepoint. + // via a TLAB up to the first subsequent safepoint. If such permission + // is granted for this heap type, the compiler promises to call + // defer_store_barrier() below on any slow path allocation of + // a new object for which such initializing store barriers will + // have been elided. virtual bool can_elide_tlab_store_barriers() const = 0; // If a compiler is eliding store barriers for TLAB-allocated objects, @@ -425,8 +430,19 @@ class CollectedHeap : public CHeapObj { // an object allocated anywhere. The compiler's runtime support // promises to call this function on such a slow-path-allocated // object before performing initializations that have elided - // store barriers. Returns new_obj, or maybe a safer copy thereof. - virtual oop new_store_barrier(oop new_obj); + // store barriers. Returns new_obj, or maybe a safer copy thereof. + virtual oop defer_store_barrier(JavaThread* thread, oop new_obj); + + // Answers whether an initializing store to a new object currently + // allocated at the given address doesn't need a (deferred) store + // barrier. Returns "true" if it doesn't need an initializing + // store barrier; answers "false" if it does. + virtual bool can_elide_initializing_store_barrier(oop new_obj) = 0; + + // If the CollectedHeap was asked to defer a store barrier above, + // this informs it to flush such a deferred store barrier to the + // remembered set. + virtual void flush_deferred_store_barrier(JavaThread* thread); // Can a compiler elide a store barrier when it writes // a permanent oop into the heap? Applies when the compiler diff --git a/hotspot/src/share/vm/includeDB_zero b/hotspot/src/share/vm/includeDB_zero new file mode 100644 index 00000000000..4d1d52cfdf5 --- /dev/null +++ b/hotspot/src/share/vm/includeDB_zero @@ -0,0 +1,55 @@ +// +// Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. +// Copyright 2009 Red Hat, Inc. +// 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 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. +// +// + +// NOTE: DO NOT CHANGE THIS COPYRIGHT TO NEW STYLE - IT WILL BREAK makeDeps! + +entryFrame_.hpp javaCalls.hpp +entryFrame_.hpp stack_.hpp + +fakeStubFrame_.hpp stack_.hpp + +frame.hpp stack_.hpp + +frame.inline.hpp fakeStubFrame_.hpp +frame.inline.hpp entryFrame_.hpp +frame.inline.hpp interpreterFrame_.hpp +frame.inline.hpp sharkFrame_.hpp + +frame_.cpp interpreterRuntime.hpp +frame_.cpp scopeDesc.hpp + +interpreter.hpp entry_.hpp + +interpreterFrame_.hpp bytecodeInterpreter.hpp +interpreterFrame_.hpp methodOop.hpp +interpreterFrame_.hpp stack_.hpp +interpreterFrame_.hpp thread.hpp + +sharkFrame_.hpp methodOop.hpp +sharkFrame_.hpp stack_.hpp + +stack_.hpp sizes.hpp + +thread.hpp stack_.hpp diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index e20ea9d1876..ac46f4ab5e1 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -3031,9 +3031,9 @@ BytecodeInterpreter::print() { tty->print_cr("&native_fresult: " INTPTR_FORMAT, (uintptr_t) &this->_native_fresult); tty->print_cr("native_lresult: " INTPTR_FORMAT, (uintptr_t) this->_native_lresult); #endif -#ifdef IA64 +#if defined(IA64) && !defined(ZERO) tty->print_cr("last_Java_fp: " INTPTR_FORMAT, (uintptr_t) this->_last_Java_fp); -#endif // IA64 +#endif // IA64 && !ZERO tty->print_cr("self_link: " INTPTR_FORMAT, (uintptr_t) this->_self_link); } diff --git a/hotspot/src/share/vm/interpreter/oopMapCache.cpp b/hotspot/src/share/vm/interpreter/oopMapCache.cpp index 3b45b5956ec..170a73f9ce9 100644 --- a/hotspot/src/share/vm/interpreter/oopMapCache.cpp +++ b/hotspot/src/share/vm/interpreter/oopMapCache.cpp @@ -281,7 +281,7 @@ class MaskFillerForNative: public NativeSignatureIterator { public: void pass_int() { /* ignore */ } void pass_long() { /* ignore */ } -#ifdef _LP64 +#if defined(_LP64) || defined(ZERO) void pass_float() { /* ignore */ } #endif void pass_double() { /* ignore */ } diff --git a/hotspot/src/share/vm/memory/compactingPermGenGen.cpp b/hotspot/src/share/vm/memory/compactingPermGenGen.cpp index e1de54e38e8..dbb0f016951 100644 --- a/hotspot/src/share/vm/memory/compactingPermGenGen.cpp +++ b/hotspot/src/share/vm/memory/compactingPermGenGen.cpp @@ -352,15 +352,19 @@ void CompactingPermGenGen::post_compact() { } +// Do not use in time-critical operations due to the possibility of paging +// in otherwise untouched or previously unread portions of the perm gen, +// for instance, the shared spaces. NOTE: Because CompactingPermGenGen +// derives from OneContigSpaceCardGeneration which is supposed to have a +// single space, and does not override its object_iterate() method, +// object iteration via that interface does not look at the objects in +// the shared spaces when using CDS. This should be fixed; see CR 6897798. void CompactingPermGenGen::space_iterate(SpaceClosure* blk, bool usedOnly) { OneContigSpaceCardGeneration::space_iterate(blk, usedOnly); if (spec()->enable_shared_spaces()) { -#ifdef PRODUCT // Making the rw_space walkable will page in the entire space, and - // is to be avoided. However, this is required for Verify options. - ShouldNotReachHere(); -#endif - + // is to be avoided in the case of time-critical operations. + // However, this is required for Verify and heap dump operations. blk->do_space(ro_space()); blk->do_space(rw_space()); } diff --git a/hotspot/src/share/vm/memory/compactingPermGenGen.hpp b/hotspot/src/share/vm/memory/compactingPermGenGen.hpp index 4f2788a32f8..8e21545ee88 100644 --- a/hotspot/src/share/vm/memory/compactingPermGenGen.hpp +++ b/hotspot/src/share/vm/memory/compactingPermGenGen.hpp @@ -29,6 +29,9 @@ class PermanentGenerationSpec; // This is the "generation" view of a CompactingPermGen. +// NOTE: the shared spaces used for CDS are here handled in +// a somewhat awkward and potentially buggy fashion, see CR 6801625. +// This infelicity should be fixed, see CR 6897789. class CompactingPermGenGen: public OneContigSpaceCardGeneration { friend class VMStructs; // Abstractly, this is a subtype that gets access to protected fields. @@ -47,7 +50,7 @@ private: OffsetTableContigSpace* _ro_space; OffsetTableContigSpace* _rw_space; - // With shared spaces there is a dicotomy in the use of the + // With shared spaces there is a dichotomy in the use of the // _virtual_space of the generation. There is a portion of the // _virtual_space that is used for the unshared part of the // permanent generation and a portion that is reserved for the shared part. diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.hpp b/hotspot/src/share/vm/memory/genCollectedHeap.hpp index 1a04fb0a31a..9004e0d842c 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp @@ -260,6 +260,20 @@ public: return true; } + // We don't need barriers for stores to objects in the + // young gen and, a fortiori, for initializing stores to + // objects therein. This applies to {DefNew,ParNew}+{Tenured,CMS} + // only and may need to be re-examined in case other + // kinds of collectors are implemented in the future. + virtual bool can_elide_initializing_store_barrier(oop new_obj) { + // We wanted to assert that:- + // assert(UseParNewGC || UseSerialGC || UseConcMarkSweepGC, + // "Check can_elide_initializing_store_barrier() for this collector"); + // but unfortunately the flag UseSerialGC need not necessarily always + // be set when DefNew+Tenured are being used. + return is_in_youngest((void*)new_obj); + } + // Can a compiler elide a store barrier when it writes // a permanent oop into the heap? Applies when the compiler // is storing x to the heap, where x->is_perm() is true. diff --git a/hotspot/src/share/vm/memory/generation.cpp b/hotspot/src/share/vm/memory/generation.cpp index 117ee18526c..e91b9972b54 100644 --- a/hotspot/src/share/vm/memory/generation.cpp +++ b/hotspot/src/share/vm/memory/generation.cpp @@ -606,6 +606,13 @@ void OneContigSpaceCardGeneration::shrink_by(size_t bytes) { void OneContigSpaceCardGeneration::prepare_for_verify() {} +// Override for a card-table generation with one contiguous +// space. NOTE: For reasons that are lost in the fog of history, +// this code is used when you iterate over perm gen objects, +// even when one uses CDS, where the perm gen has a couple of +// other spaces; this is because CompactingPermGenGen derives +// from OneContigSpaceCardGeneration. This should be cleaned up, +// see CR 6897789.. void OneContigSpaceCardGeneration::object_iterate(ObjectClosure* blk) { _the_space->object_iterate(blk); } diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 7e5b0ebf17d..aaa2bfe876e 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -1900,7 +1900,7 @@ void instanceKlass::release_C_heap_structures() { } } -char* instanceKlass::signature_name() const { +const char* instanceKlass::signature_name() const { const char* src = (const char*) (name()->as_C_string()); const int src_length = (int)strlen(src); char* dest = NEW_RESOURCE_ARRAY(char, src_length + 3); @@ -2259,6 +2259,10 @@ void instanceKlass::oop_print_on(oop obj, outputStream* st) { st->print(BULLET"fake entry for array: "); array_klass->print_value_on(st); st->cr(); + } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { + st->print(BULLET"signature: "); + java_dyn_MethodType::print_signature(obj, st); + st->cr(); } } @@ -2284,6 +2288,9 @@ void instanceKlass::oop_print_value_on(oop obj, outputStream* st) { const char* tname = type2name(java_lang_Class::primitive_type(obj)); st->print("%s", tname ? tname : "type?"); } + } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { + st->print(" = "); + java_dyn_MethodType::print_signature(obj, st); } else if (java_lang_boxing_object::is_instance(obj)) { st->print(" = "); java_lang_boxing_object::print(obj, st); diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index bb992170e02..9147892b1ea 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -722,7 +722,7 @@ class instanceKlass: public Klass { #endif // SERIALGC // Naming - char* signature_name() const; + const char* signature_name() const; // Iterators int oop_oop_iterate(oop obj, OopClosure* blk) { diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 63a342e5b67..a842709649e 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -496,11 +496,13 @@ const char* Klass::external_name() const { return result; } } + if (name() == NULL) return ""; return name()->as_klass_external_name(); } -char* Klass::signature_name() const { +const char* Klass::signature_name() const { + if (name() == NULL) return ""; return name()->as_C_string(); } diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp index 9ed07d2fb81..c4436d6554f 100644 --- a/hotspot/src/share/vm/oops/klass.hpp +++ b/hotspot/src/share/vm/oops/klass.hpp @@ -546,7 +546,7 @@ class Klass : public Klass_vtbl { // For arrays, this returns the name of the element with a leading '['. // For classes, this returns the name with a leading 'L' and a trailing ';' // and the package separators as '/'. - virtual char* signature_name() const; + virtual const char* signature_name() const; // garbage collection support virtual void oop_follow_contents(oop obj) = 0; diff --git a/hotspot/src/share/vm/oops/markOop.cpp b/hotspot/src/share/vm/oops/markOop.cpp index ac1a99c2cd7..0bec23f9034 100644 --- a/hotspot/src/share/vm/oops/markOop.cpp +++ b/hotspot/src/share/vm/oops/markOop.cpp @@ -31,8 +31,9 @@ void markOopDesc::print_on(outputStream* st) const { st->print("locked(0x%lx)->", value()); markOop(*(markOop*)value())->print_on(st); } else { - assert(is_unlocked(), "just checking"); + assert(is_unlocked() || has_bias_pattern(), "just checking"); st->print("mark("); + if (has_bias_pattern()) st->print("biased,"); st->print("hash %#lx,", hash()); st->print("age %d)", age()); } diff --git a/hotspot/src/share/vm/oops/methodOop.cpp b/hotspot/src/share/vm/oops/methodOop.cpp index e68c289510c..cd575e5c488 100644 --- a/hotspot/src/share/vm/oops/methodOop.cpp +++ b/hotspot/src/share/vm/oops/methodOop.cpp @@ -881,7 +881,7 @@ methodHandle methodOopDesc::make_invoke_method(KlassHandle holder, assert((oop)p == method_type(), "pointer chase is correct"); #endif - if (TraceMethodHandles) + if (TraceMethodHandles && (Verbose || WizardMode)) m->print_on(tty); return m; diff --git a/hotspot/src/share/vm/opto/callnode.cpp b/hotspot/src/share/vm/opto/callnode.cpp index ff4cdbbbb6e..5c69109b8fe 100644 --- a/hotspot/src/share/vm/opto/callnode.cpp +++ b/hotspot/src/share/vm/opto/callnode.cpp @@ -421,21 +421,23 @@ void JVMState::format(PhaseRegAlloc *regalloc, const Node *n, outputStream* st) iklass = cik->as_instance_klass(); } else if (cik->is_type_array_klass()) { cik->as_array_klass()->base_element_type()->print_name_on(st); - st->print("[%d]=", spobj->n_fields()); + st->print("[%d]", spobj->n_fields()); } else if (cik->is_obj_array_klass()) { - ciType* cie = cik->as_array_klass()->base_element_type(); - int ndim = 1; - while (cie->is_obj_array_klass()) { - ndim += 1; - cie = cie->as_array_klass()->base_element_type(); + ciKlass* cie = cik->as_obj_array_klass()->base_element_klass(); + if (cie->is_instance_klass()) { + cie->print_name_on(st); + } else if (cie->is_type_array_klass()) { + cie->as_array_klass()->base_element_type()->print_name_on(st); + } else { + ShouldNotReachHere(); } - cie->print_name_on(st); + st->print("[%d]", spobj->n_fields()); + int ndim = cik->as_array_klass()->dimension() - 1; while (ndim-- > 0) { st->print("[]"); } - st->print("[%d]=", spobj->n_fields()); } - st->print("{"); + st->print("={"); uint nf = spobj->n_fields(); if (nf > 0) { uint first_ind = spobj->first_index(); diff --git a/hotspot/src/share/vm/opto/cfgnode.cpp b/hotspot/src/share/vm/opto/cfgnode.cpp index 02c2ae01a21..b1da1c716d9 100644 --- a/hotspot/src/share/vm/opto/cfgnode.cpp +++ b/hotspot/src/share/vm/opto/cfgnode.cpp @@ -1531,6 +1531,8 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; // No change Node *top = phase->C->top(); + bool new_phi = (outcnt() == 0); // transforming new Phi + assert(!can_reshape || !new_phi, "for igvn new phi should be hooked"); // The are 2 situations when only one valid phi's input is left // (in addition to Region input). @@ -1550,6 +1552,12 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { } } + if (can_reshape && outcnt() == 0) { + // set_req() above may kill outputs if Phi is referenced + // only by itself on the dead (top) control path. + return top; + } + Node* uin = unique_input(phase); if (uin == top) { // Simplest case: no alive inputs. if (can_reshape) // IGVN transformation @@ -1684,8 +1692,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Equivalent code is in MemNode::Ideal_common Node *m = phase->transform(n); if (outcnt() == 0) { // Above transform() may kill us! - progress = phase->C->top(); - break; + return top; } // If transformed to a MergeMem, get the desired slice // Otherwise the returned node represents memory for every slice diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp index eb177c8f56c..86f5f273876 100644 --- a/hotspot/src/share/vm/opto/chaitin.cpp +++ b/hotspot/src/share/vm/opto/chaitin.cpp @@ -985,6 +985,8 @@ void PhaseChaitin::Simplify( ) { uint lo_score = _hi_degree; double score = lrgs(lo_score).score(); double area = lrgs(lo_score)._area; + double cost = lrgs(lo_score)._cost; + bool bound = lrgs(lo_score)._is_bound; // Find cheapest guy debug_only( int lo_no_simplify=0; ); @@ -1002,17 +1004,27 @@ void PhaseChaitin::Simplify( ) { debug_only( if( lrgs(i)._was_lo ) lo_no_simplify=i; ); double iscore = lrgs(i).score(); double iarea = lrgs(i)._area; + double icost = lrgs(i)._cost; + bool ibound = lrgs(i)._is_bound; // Compare cost/area of i vs cost/area of lo_score. Smaller cost/area // wins. Ties happen because all live ranges in question have spilled // a few times before and the spill-score adds a huge number which // washes out the low order bits. We are choosing the lesser of 2 // evils; in this case pick largest area to spill. + // Ties also happen when live ranges are defined and used only inside + // one block. In which case their area is 0 and score set to max. + // In such case choose bound live range over unbound to free registers + // or with smaller cost to spill. if( iscore < score || - (iscore == score && iarea > area && lrgs(lo_score)._was_spilled2) ) { + (iscore == score && iarea > area && lrgs(lo_score)._was_spilled2) || + (iscore == score && iarea == area && + ( (ibound && !bound) || ibound == bound && (icost < cost) )) ) { lo_score = i; score = iscore; area = iarea; + cost = icost; + bound = ibound; } } LRG *lo_lrg = &lrgs(lo_score); diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index b178119f3e5..b63aae489ff 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -3186,6 +3186,15 @@ void GraphKit::write_barrier_post(Node* oop_store, return; } + if (use_ReduceInitialCardMarks() + && obj == just_allocated_object(control())) { + // We can skip marks on a freshly-allocated object in Eden. + // Keep this code in sync with maybe_defer_card_mark() in runtime.cpp. + // That routine informs GC to take appropriate compensating steps + // so as to make this card-mark elision safe. + return; + } + if (!use_precise) { // All card marks for a (non-array) instance are in one place: adr = obj; diff --git a/hotspot/src/share/vm/opto/ifnode.cpp b/hotspot/src/share/vm/opto/ifnode.cpp index 277b2881469..51ca8fe28ad 100644 --- a/hotspot/src/share/vm/opto/ifnode.cpp +++ b/hotspot/src/share/vm/opto/ifnode.cpp @@ -240,13 +240,13 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { // as a single huge transform. igvn->register_new_node_with_optimizer( region_c ); igvn->register_new_node_with_optimizer( region_x ); - phi_x = phase->transform( phi_x ); // Prevent the untimely death of phi_x. Currently he has no uses. He is // about to get one. If this only use goes away, then phi_x will look dead. // However, he will be picking up some more uses down below. Node *hook = new (igvn->C, 4) Node(4); hook->init_req(0, phi_x); hook->init_req(1, phi_c); + phi_x = phase->transform( phi_x ); // Make the compare Node *cmp_c = phase->makecon(t); @@ -322,6 +322,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { phi_s = PhiNode::make_blank(region_s,phi); phi_s->init_req( 1, phi_c ); phi_s->init_req( 2, phi_x ); + hook->add_req(phi_s); phi_s = phase->transform(phi_s); } proj_path_data = phi_s; @@ -333,6 +334,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { phi_f = PhiNode::make_blank(region_f,phi); phi_f->init_req( 1, phi_c ); phi_f->init_req( 2, phi_x ); + hook->add_req(phi_f); phi_f = phase->transform(phi_f); } proj_path_data = phi_f; diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index dedf3492b64..1be04de6acf 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -4160,13 +4160,13 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) { result_mem ->set_req(_objArray_path, reset_memory()); } } - // We can dispense with card marks if we know the allocation - // comes out of eden (TLAB)... In fact, ReduceInitialCardMarks - // causes the non-eden paths to simulate a fresh allocation, - // insofar that no further card marks are required to initialize - // the object. - // Otherwise, there are no card marks to worry about. + // (We can dispense with card marks if we know the allocation + // comes out of eden (TLAB)... In fact, ReduceInitialCardMarks + // causes the non-eden paths to take compensating steps to + // simulate a fresh allocation, so that no further + // card marks are required in compiled code to initialize + // the object.) if (!stopped()) { copy_to_clone(obj, alloc_obj, obj_size, true, false); diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp index 4583f0da7b3..1cde5cc1a46 100644 --- a/hotspot/src/share/vm/opto/phaseX.cpp +++ b/hotspot/src/share/vm/opto/phaseX.cpp @@ -1502,7 +1502,7 @@ Node *PhaseCCP::transform_once( Node *n ) { //---------------------------------saturate------------------------------------ const Type* PhaseCCP::saturate(const Type* new_type, const Type* old_type, const Type* limit_type) const { - const Type* wide_type = new_type->widen(old_type); + const Type* wide_type = new_type->widen(old_type, limit_type); if (wide_type != new_type) { // did we widen? // If so, we may have widened beyond the limit type. Clip it back down. new_type = wide_type->filter(limit_type); diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index cbbbfacfcb5..2b3851961ee 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -143,18 +143,20 @@ const char* OptoRuntime::stub_name(address entry) { // We failed the fast-path allocation. Now we need to do a scavenge or GC // and try allocation again. -void OptoRuntime::do_eager_card_mark(JavaThread* thread) { +void OptoRuntime::maybe_defer_card_mark(JavaThread* thread) { // After any safepoint, just before going back to compiled code, - // we perform a card mark. This lets the compiled code omit - // card marks for initialization of new objects. - // Keep this code consistent with GraphKit::store_barrier. + // we inform the GC that we will be doing initializing writes to + // this object in the future without emitting card-marks, so + // GC may take any compensating steps. + // NOTE: Keep this code consistent with GraphKit::store_barrier. oop new_obj = thread->vm_result(); if (new_obj == NULL) return; assert(Universe::heap()->can_elide_tlab_store_barriers(), "compiler must check this first"); - new_obj = Universe::heap()->new_store_barrier(new_obj); + // GC may decide to give back a safer copy of new_obj. + new_obj = Universe::heap()->defer_store_barrier(thread, new_obj); thread->set_vm_result(new_obj); } @@ -197,8 +199,8 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(klassOopDesc* klass, JavaThrea JRT_BLOCK_END; if (GraphKit::use_ReduceInitialCardMarks()) { - // do them now so we don't have to do them on the fast path - do_eager_card_mark(thread); + // inform GC that we won't do card marks for initializing writes. + maybe_defer_card_mark(thread); } JRT_END @@ -236,8 +238,8 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(klassOopDesc* array_type, int len JRT_BLOCK_END; if (GraphKit::use_ReduceInitialCardMarks()) { - // do them now so we don't have to do them on the fast path - do_eager_card_mark(thread); + // inform GC that we won't do card marks for initializing writes. + maybe_defer_card_mark(thread); } JRT_END diff --git a/hotspot/src/share/vm/opto/runtime.hpp b/hotspot/src/share/vm/opto/runtime.hpp index 8a51b2facce..c3d8238ae1e 100644 --- a/hotspot/src/share/vm/opto/runtime.hpp +++ b/hotspot/src/share/vm/opto/runtime.hpp @@ -133,8 +133,8 @@ class OptoRuntime : public AllStatic { // Allocate storage for a objArray or typeArray static void new_array_C(klassOopDesc* array_klass, int len, JavaThread *thread); - // Post-allocation step for implementing ReduceInitialCardMarks: - static void do_eager_card_mark(JavaThread* thread); + // Post-slow-path-allocation step for implementing ReduceInitialCardMarks: + static void maybe_defer_card_mark(JavaThread* thread); // Allocate storage for a multi-dimensional arrays // Note: needs to be fixed for arbitrary number of dimensions diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp index c21c7c044cd..c22d1e8f6b0 100644 --- a/hotspot/src/share/vm/opto/type.cpp +++ b/hotspot/src/share/vm/opto/type.cpp @@ -1115,7 +1115,7 @@ const Type *TypeInt::xdual() const { //------------------------------widen------------------------------------------ // Only happens for optimistic top-down optimizations. -const Type *TypeInt::widen( const Type *old ) const { +const Type *TypeInt::widen( const Type *old, const Type* limit ) const { // Coming from TOP or such; no widening if( old->base() != Int ) return this; const TypeInt *ot = old->is_int(); @@ -1134,15 +1134,21 @@ const Type *TypeInt::widen( const Type *old ) const { // Now widen new guy. // Check for widening too far if (_widen == WidenMax) { - if (min_jint < _lo && _hi < max_jint) { + int max = max_jint; + int min = min_jint; + if (limit->isa_int()) { + max = limit->is_int()->_hi; + min = limit->is_int()->_lo; + } + if (min < _lo && _hi < max) { // If neither endpoint is extremal yet, push out the endpoint // which is closer to its respective limit. if (_lo >= 0 || // easy common case - (juint)(_lo - min_jint) >= (juint)(max_jint - _hi)) { + (juint)(_lo - min) >= (juint)(max - _hi)) { // Try to widen to an unsigned range type of 31 bits: - return make(_lo, max_jint, WidenMax); + return make(_lo, max, WidenMax); } else { - return make(min_jint, _hi, WidenMax); + return make(min, _hi, WidenMax); } } return TypeInt::INT; @@ -1357,7 +1363,7 @@ const Type *TypeLong::xdual() const { //------------------------------widen------------------------------------------ // Only happens for optimistic top-down optimizations. -const Type *TypeLong::widen( const Type *old ) const { +const Type *TypeLong::widen( const Type *old, const Type* limit ) const { // Coming from TOP or such; no widening if( old->base() != Long ) return this; const TypeLong *ot = old->is_long(); @@ -1376,18 +1382,24 @@ const Type *TypeLong::widen( const Type *old ) const { // Now widen new guy. // Check for widening too far if (_widen == WidenMax) { - if (min_jlong < _lo && _hi < max_jlong) { + jlong max = max_jlong; + jlong min = min_jlong; + if (limit->isa_long()) { + max = limit->is_long()->_hi; + min = limit->is_long()->_lo; + } + if (min < _lo && _hi < max) { // If neither endpoint is extremal yet, push out the endpoint // which is closer to its respective limit. if (_lo >= 0 || // easy common case - (julong)(_lo - min_jlong) >= (julong)(max_jlong - _hi)) { + (julong)(_lo - min) >= (julong)(max - _hi)) { // Try to widen to an unsigned range type of 32/63 bits: - if (_hi < max_juint) + if (max >= max_juint && _hi < max_juint) return make(_lo, max_juint, WidenMax); else - return make(_lo, max_jlong, WidenMax); + return make(_lo, max, WidenMax); } else { - return make(min_jlong, _hi, WidenMax); + return make(min, _hi, WidenMax); } } return TypeLong::LONG; diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp index 4fac900b98c..9b11f9ca595 100644 --- a/hotspot/src/share/vm/opto/type.hpp +++ b/hotspot/src/share/vm/opto/type.hpp @@ -168,7 +168,7 @@ public: // MEET operation; lower in lattice. const Type *meet( const Type *t ) const; // WIDEN: 'widens' for Ints and other range types - virtual const Type *widen( const Type *old ) const { return this; } + virtual const Type *widen( const Type *old, const Type* limit ) const { return this; } // NARROW: complement for widen, used by pessimistic phases virtual const Type *narrow( const Type *old ) const { return this; } @@ -409,7 +409,7 @@ public: virtual const Type *xmeet( const Type *t ) const; virtual const Type *xdual() const; // Compute dual right now. - virtual const Type *widen( const Type *t ) const; + virtual const Type *widen( const Type *t, const Type* limit_type ) const; virtual const Type *narrow( const Type *t ) const; // Do not kill _widen bits. virtual const Type *filter( const Type *kills ) const; @@ -465,7 +465,7 @@ public: virtual const Type *xmeet( const Type *t ) const; virtual const Type *xdual() const; // Compute dual right now. - virtual const Type *widen( const Type *t ) const; + virtual const Type *widen( const Type *t, const Type* limit_type ) const; virtual const Type *narrow( const Type *t ) const; // Do not kill _widen bits. virtual const Type *filter( const Type *kills ) const; diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 2bba3e0af03..20484da07a9 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -2116,7 +2116,7 @@ JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, js DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); if (a->is_within_bounds(index)) { - jobject ret = JNIHandles::make_local(env, a->obj_at(index)); + ret = JNIHandles::make_local(env, a->obj_at(index)); return ret; } else { char buf[jintAsStringSize]; @@ -2150,14 +2150,14 @@ JNI_END #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result) \ \ - DT_RETURN_MARK_DECL_FOR(Result, New##Result##Array, Return);\ + DT_RETURN_MARK_DECL(New##Result##Array, Return);\ \ JNI_ENTRY(Return, \ jni_New##Result##Array(JNIEnv *env, jsize len)) \ JNIWrapper("New" XSTR(Result) "Array"); \ DTRACE_PROBE2(hotspot_jni, New##Result##Array__entry, env, len);\ Return ret = NULL;\ - DT_RETURN_MARK_FOR(Result, New##Result##Array, Return, (const Return&)ret);\ + DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ \ oop obj= oopFactory::Allocator(len, CHECK_0); \ ret = (Return) JNIHandles::make_local(env, obj); \ diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index f194644715e..b5910f21d37 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -33,8 +33,7 @@ bool MethodHandles::_enabled = false; // set true after successful native linkag MethodHandleEntry* MethodHandles::_entries[MethodHandles::_EK_LIMIT] = {NULL}; const char* MethodHandles::_entry_names[_EK_LIMIT+1] = { - "check_mtype", - "wrong_method_type", // what happens when there is a type mismatch + "raise_exception", "invokestatic", // how a MH emulates invokestatic "invokespecial", // ditto for the other invokes... "invokevirtual", @@ -48,6 +47,7 @@ const char* MethodHandles::_entry_names[_EK_LIMIT+1] = { // starting at _adapter_mh_first: "adapter_retype_only", // these are for AMH... + "adapter_retype_raw", "adapter_check_cast", "adapter_prim_to_prim", "adapter_ref_to_prim", @@ -82,6 +82,8 @@ const char* MethodHandles::_entry_names[_EK_LIMIT+1] = { NULL }; +jobject MethodHandles::_raise_exception_method; + #ifdef ASSERT bool MethodHandles::spot_check_entry_names() { assert(!strcmp(entry_name(_invokestatic_mh), "invokestatic"), ""); @@ -157,7 +159,8 @@ methodOop MethodHandles::decode_DirectMethodHandle(oop mh, klassOop& receiver_li } methodOop MethodHandles::decode_BoundMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result) { - assert(mh->klass() == SystemDictionary::BoundMethodHandle_klass(), ""); + assert(sun_dyn_BoundMethodHandle::is_instance(mh), ""); + assert(mh->klass() != SystemDictionary::AdapterMethodHandle_klass(), ""); for (oop bmh = mh;;) { // Bound MHs can be stacked to bind several arguments. oop target = java_dyn_MethodHandle::vmtarget(bmh); @@ -174,10 +177,9 @@ methodOop MethodHandles::decode_BoundMethodHandle(oop mh, klassOop& receiver_lim } else { // Optimized case: binding a receiver to a non-dispatched DMH // short-circuits directly to the methodOop. + // (It might be another argument besides a receiver also.) assert(target->is_method(), "must be a simple method"); methodOop m = (methodOop) target; - DEBUG_ONLY(int argslot = sun_dyn_BoundMethodHandle::vmargslot(bmh)); - assert(argslot == m->size_of_parameters() - 1, "must be initial argument (receiver)"); decode_flags_result |= MethodHandles::_dmf_binds_method; return m; } @@ -214,6 +216,9 @@ methodOop MethodHandles::decode_MethodHandle(oop mh, klassOop& receiver_limit_re return decode_BoundMethodHandle(mh, receiver_limit_result, decode_flags_result); } else if (mhk == SystemDictionary::AdapterMethodHandle_klass()) { return decode_AdapterMethodHandle(mh, receiver_limit_result, decode_flags_result); + } else if (sun_dyn_BoundMethodHandle::is_subclass(mhk)) { + // could be a JavaMethodHandle (but not an adapter MH) + return decode_BoundMethodHandle(mh, receiver_limit_result, decode_flags_result); } else { assert(false, "cannot parse this MH"); return NULL; // random MH? @@ -366,7 +371,13 @@ methodOop MethodHandles::decode_MemberName(oop mname, klassOop& receiver_limit_r oop vmtarget = sun_dyn_MemberName::vmtarget(mname); int vmindex = sun_dyn_MemberName::vmindex(mname); if (vmindex == VM_INDEX_UNINITIALIZED) return NULL; // not resolved - return decode_vmtarget(vmtarget, vmindex, NULL, receiver_limit_result, decode_flags_result); + methodOop m = decode_vmtarget(vmtarget, vmindex, NULL, receiver_limit_result, decode_flags_result); + oop clazz = sun_dyn_MemberName::clazz(mname); + if (clazz != NULL && java_lang_Class::is_instance(clazz)) { + klassOop klass = java_lang_Class::as_klassOop(clazz); + if (klass != NULL) receiver_limit_result = klass; + } + return m; } // An unresolved member name is a mere symbolic reference. @@ -789,6 +800,30 @@ oop MethodHandles::encode_target(Handle mh, int format, TRAPS) { THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), msg); } +static const char* always_null_names[] = { + "java/lang/Void", + "java/lang/Null", + //"java/lang/Nothing", + "sun/dyn/empty/Empty", + NULL +}; + +static bool is_always_null_type(klassOop klass) { + if (!Klass::cast(klass)->oop_is_instance()) return false; + instanceKlass* ik = instanceKlass::cast(klass); + // Must be on the boot class path: + if (ik->class_loader() != NULL) return false; + // Check the name. + symbolOop name = ik->name(); + for (int i = 0; ; i++) { + const char* test_name = always_null_names[i]; + if (test_name == NULL) break; + if (name->equals(test_name, (int) strlen(test_name))) + return true; + } + return false; +} + bool MethodHandles::class_cast_needed(klassOop src, klassOop dst) { if (src == dst || dst == SystemDictionary::object_klass()) return false; // quickest checks @@ -805,6 +840,12 @@ bool MethodHandles::class_cast_needed(klassOop src, klassOop dst) { //srck = Klass::cast(SystemDictionary::object_klass()); return true; } + if (is_always_null_type(src)) { + // some source types are known to be never instantiated; + // they represent references which are always null + // such null references never fail to convert safely + return false; + } return !srck->is_subclass_of(dstk->as_klassOop()); } @@ -814,9 +855,15 @@ static oop object_java_mirror() { bool MethodHandles::same_basic_type_for_arguments(BasicType src, BasicType dst, + bool raw, bool for_return) { - // return values can always be forgotten: - if (for_return && dst == T_VOID) return true; + if (for_return) { + // return values can always be forgotten: + if (dst == T_VOID) return true; + if (src == T_VOID) return raw && (dst == T_INT); + // We allow caller to receive a garbage int, which is harmless. + // This trick is pulled by trusted code (see VerifyType.canPassRaw). + } assert(src != T_VOID && dst != T_VOID, "should not be here"); if (src == dst) return true; if (type2size[src] != type2size[dst]) return false; @@ -929,8 +976,8 @@ void MethodHandles::verify_method_type(methodHandle m, const char* err = NULL; int first_ptype_pos = m_needs_receiver ? 1 : 0; - if (has_bound_recv && err == NULL) { - first_ptype_pos -= 1; + if (has_bound_recv) { + first_ptype_pos -= 1; // ptypes do not include the bound argument; start earlier in them if (m_needs_receiver && bound_recv_type.is_null()) { err = "bound receiver is not an object"; goto die; } } @@ -939,10 +986,10 @@ void MethodHandles::verify_method_type(methodHandle m, objArrayOop ptypes = java_dyn_MethodType::ptypes(mtype()); if (ptypes->length() < first_ptype_pos) { err = "receiver argument is missing"; goto die; } - if (first_ptype_pos == -1) + if (has_bound_recv) err = check_method_receiver(m(), bound_recv_type->as_klassOop()); else - err = check_method_receiver(m(), java_lang_Class::as_klassOop(ptypes->obj_at(0))); + err = check_method_receiver(m(), java_lang_Class::as_klassOop(ptypes->obj_at(first_ptype_pos-1))); if (err != NULL) goto die; } @@ -983,7 +1030,8 @@ const char* MethodHandles::check_method_type_change(oop src_mtype, int src_beg, int insert_argnum, oop insert_type, int change_argnum, oop change_type, int delete_argnum, - oop dst_mtype, int dst_beg, int dst_end) { + oop dst_mtype, int dst_beg, int dst_end, + bool raw) { objArrayOop src_ptypes = java_dyn_MethodType::ptypes(src_mtype); objArrayOop dst_ptypes = java_dyn_MethodType::ptypes(dst_mtype); @@ -1042,7 +1090,7 @@ const char* MethodHandles::check_method_type_change(oop src_mtype, int src_beg, if (src_type != dst_type) { if (src_type == NULL) return "not enough arguments"; if (dst_type == NULL) return "too many arguments"; - err = check_argument_type_change(src_type, dst_type, dst_idx); + err = check_argument_type_change(src_type, dst_type, dst_idx, raw); if (err != NULL) return err; } } @@ -1051,7 +1099,7 @@ const char* MethodHandles::check_method_type_change(oop src_mtype, int src_beg, oop src_rtype = java_dyn_MethodType::rtype(src_mtype); oop dst_rtype = java_dyn_MethodType::rtype(dst_mtype); if (src_rtype != dst_rtype) { - err = check_return_type_change(dst_rtype, src_rtype); // note reversal! + err = check_return_type_change(dst_rtype, src_rtype, raw); // note reversal! if (err != NULL) return err; } @@ -1061,38 +1109,45 @@ const char* MethodHandles::check_method_type_change(oop src_mtype, int src_beg, const char* MethodHandles::check_argument_type_change(BasicType src_type, - klassOop src_klass, - BasicType dst_type, - klassOop dst_klass, - int argnum) { + klassOop src_klass, + BasicType dst_type, + klassOop dst_klass, + int argnum, + bool raw) { const char* err = NULL; + bool for_return = (argnum < 0); // just in case: if (src_type == T_ARRAY) src_type = T_OBJECT; if (dst_type == T_ARRAY) dst_type = T_OBJECT; // Produce some nice messages if VerifyMethodHandles is turned on: - if (!same_basic_type_for_arguments(src_type, dst_type, (argnum < 0))) { + if (!same_basic_type_for_arguments(src_type, dst_type, raw, for_return)) { if (src_type == T_OBJECT) { + if (raw && dst_type == T_INT && is_always_null_type(src_klass)) + return NULL; // OK to convert a null pointer to a garbage int err = ((argnum >= 0) ? "type mismatch: passing a %s for method argument #%d, which expects primitive %s" : "type mismatch: returning a %s, but caller expects primitive %s"); } else if (dst_type == T_OBJECT) { - err = ((argnum < 0) + err = ((argnum >= 0) ? "type mismatch: passing a primitive %s for method argument #%d, which expects %s" : "type mismatch: returning a primitive %s, but caller expects %s"); } else { - err = ((argnum < 0) + err = ((argnum >= 0) ? "type mismatch: passing a %s for method argument #%d, which expects %s" : "type mismatch: returning a %s, but caller expects %s"); } - } else if (src_type == T_OBJECT && class_cast_needed(src_klass, dst_klass)) { + } else if (src_type == T_OBJECT && dst_type == T_OBJECT && + class_cast_needed(src_klass, dst_klass)) { if (!class_cast_needed(dst_klass, src_klass)) { - err = ((argnum < 0) + if (raw) + return NULL; // reverse cast is OK; the MH target is trusted to enforce it + err = ((argnum >= 0) ? "cast required: passing a %s for method argument #%d, which expects %s" : "cast required: returning a %s, but caller expects %s"); } else { - err = ((argnum < 0) + err = ((argnum >= 0) ? "reference mismatch: passing a %s for method argument #%d, which expects %s" : "reference mismatch: returning a %s, but caller expects %s"); } @@ -1429,10 +1484,10 @@ void MethodHandles::verify_BoundMethodHandle(Handle mh, Handle target, int argnu assert(this_pushes == slots_pushed, "BMH pushes one or two stack slots"); assert(slots_pushed <= MethodHandlePushLimit, ""); } else { - int prev_pushes = decode_MethodHandle_stack_pushes(target()); - assert(this_pushes == slots_pushed + prev_pushes, "BMH stack motion must be correct"); + int target_pushes = decode_MethodHandle_stack_pushes(target()); + assert(this_pushes == slots_pushed + target_pushes, "BMH stack motion must be correct"); // do not blow the stack; use a Java-based adapter if this limit is exceeded - if (slots_pushed + prev_pushes > MethodHandlePushLimit) + if (slots_pushed + target_pushes > MethodHandlePushLimit) err = "too many bound parameters"; } } @@ -1588,6 +1643,11 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) { if (err == NULL) { // Check that the src/dest types are supplied if needed. switch (ek) { + case _adapter_check_cast: + if (src != T_OBJECT || dest != T_OBJECT) { + err = "adapter requires object src/dest conversion subfields"; + } + break; case _adapter_prim_to_prim: if (!is_java_primitive(src) || !is_java_primitive(dest) || src == dest) { err = "adapter requires primitive src/dest conversion subfields"; break; @@ -1616,9 +1676,9 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) { err = "adapter requires src/dest conversion subfields for swap"; break; } int swap_size = type2size[src]; - oop src_mtype = sun_dyn_AdapterMethodHandle::type(target()); - oop dest_mtype = sun_dyn_AdapterMethodHandle::type(mh()); - int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(src_mtype); + oop src_mtype = sun_dyn_AdapterMethodHandle::type(mh()); + oop dest_mtype = sun_dyn_AdapterMethodHandle::type(target()); + int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(target()); int src_slot = argslot; int dest_slot = vminfo; bool rotate_up = (src_slot > dest_slot); // upward rotation @@ -1729,22 +1789,22 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) { // Make sure this adapter does not push too deeply. int slots_pushed = stack_move / stack_move_unit(); int this_vmslots = java_dyn_MethodHandle::vmslots(mh()); - int prev_vmslots = java_dyn_MethodHandle::vmslots(target()); - if (slots_pushed != (this_vmslots - prev_vmslots)) { + int target_vmslots = java_dyn_MethodHandle::vmslots(target()); + if (slots_pushed != (target_vmslots - this_vmslots)) { err = "stack_move inconsistent with previous and current MethodType vmslots"; } else if (slots_pushed > 0) { // verify stack_move against MethodHandlePushLimit - int prev_pushes = decode_MethodHandle_stack_pushes(target()); + int target_pushes = decode_MethodHandle_stack_pushes(target()); // do not blow the stack; use a Java-based adapter if this limit is exceeded - if (slots_pushed + prev_pushes > MethodHandlePushLimit) { + if (slots_pushed + target_pushes > MethodHandlePushLimit) { err = "adapter pushes too many parameters"; } } // While we're at it, check that the stack motion decoder works: - DEBUG_ONLY(int prev_pushes = decode_MethodHandle_stack_pushes(target())); + DEBUG_ONLY(int target_pushes = decode_MethodHandle_stack_pushes(target())); DEBUG_ONLY(int this_pushes = decode_MethodHandle_stack_pushes(mh())); - assert(this_pushes == slots_pushed + prev_pushes, "AMH stack motion must be correct"); + assert(this_pushes == slots_pushed + target_pushes, "AMH stack motion must be correct"); } if (err == NULL && vminfo != 0) { @@ -1761,7 +1821,11 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) { if (err == NULL) { switch (ek) { case _adapter_retype_only: - err = check_method_type_passthrough(src_mtype(), dst_mtype()); + err = check_method_type_passthrough(src_mtype(), dst_mtype(), false); + break; + + case _adapter_retype_raw: + err = check_method_type_passthrough(src_mtype(), dst_mtype(), true); break; case _adapter_check_cast: @@ -1821,6 +1885,7 @@ void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnu // Now it's time to finish the case analysis and pick a MethodHandleEntry. switch (ek_orig) { case _adapter_retype_only: + case _adapter_retype_raw: case _adapter_check_cast: case _adapter_dup_args: case _adapter_drop_args: @@ -1888,8 +1953,7 @@ void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnu case _adapter_rot_args: { int swap_slots = type2size[src]; - oop mtype = sun_dyn_AdapterMethodHandle::type(mh()); - int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(mtype); + int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(mh()); int src_slot = argslot; int dest_slot = vminfo; int rotate = (ek_orig == _adapter_swap_args) ? 0 : (src_slot > dest_slot) ? 1 : -1; @@ -2133,7 +2197,7 @@ JVM_ENTRY(jint, MHI_getConstant(JNIEnv *env, jobject igcls, jint which)) { guarantee(MethodHandlePushLimit >= 2 && MethodHandlePushLimit <= 0xFF, "MethodHandlePushLimit parameter must be in valid range"); return MethodHandlePushLimit; - case MethodHandles::GC_JVM_STACK_MOVE_LIMIT: + case MethodHandles::GC_JVM_STACK_MOVE_UNIT: // return number of words per slot, signed according to stack direction return MethodHandles::stack_move_unit(); } @@ -2144,7 +2208,7 @@ JVM_END #ifndef PRODUCT #define EACH_NAMED_CON(template) \ template(MethodHandles,GC_JVM_PUSH_LIMIT) \ - template(MethodHandles,GC_JVM_STACK_MOVE_LIMIT) \ + template(MethodHandles,GC_JVM_STACK_MOVE_UNIT) \ template(MethodHandles,ETF_HANDLE_OR_METHOD_NAME) \ template(MethodHandles,ETF_DIRECT_HANDLE) \ template(MethodHandles,ETF_METHOD_NAME) \ @@ -2157,6 +2221,7 @@ JVM_END template(sun_dyn_MemberName,MN_SEARCH_INTERFACES) \ template(sun_dyn_MemberName,VM_INDEX_UNINITIALIZED) \ template(sun_dyn_AdapterMethodHandle,OP_RETYPE_ONLY) \ + template(sun_dyn_AdapterMethodHandle,OP_RETYPE_RAW) \ template(sun_dyn_AdapterMethodHandle,OP_CHECK_CAST) \ template(sun_dyn_AdapterMethodHandle,OP_PRIM_TO_PRIM) \ template(sun_dyn_AdapterMethodHandle,OP_REF_TO_PRIM) \ @@ -2345,10 +2410,12 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) // note: this explicit warning-producing stuff will be replaced by auto-detection of the JSR 292 classes if (!EnableMethodHandles) { - warning("JSR 292 method handles are disabled in this JVM. Use -XX:+EnableMethodHandles to enable."); + warning("JSR 292 method handles are disabled in this JVM. Use -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles to enable."); return; // bind nothing } + bool enable_MH = true; + { ThreadToNativeFromVM ttnfv(thread); @@ -2356,14 +2423,33 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) if (env->ExceptionOccurred()) { MethodHandles::set_enabled(false); warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); + enable_MH = false; env->ExceptionClear(); - } else { - MethodHandles::set_enabled(true); } } + if (enable_MH) { + KlassHandle MHI_klass = SystemDictionaryHandles::MethodHandleImpl_klass(); + if (MHI_klass.not_null()) { + symbolHandle raiseException_name = oopFactory::new_symbol_handle("raiseException", CHECK); + symbolHandle raiseException_sig = oopFactory::new_symbol_handle("(ILjava/lang/Object;Ljava/lang/Object;)V", CHECK); + methodOop raiseException_method = instanceKlass::cast(MHI_klass->as_klassOop()) + ->find_method(raiseException_name(), raiseException_sig()); + if (raiseException_method != NULL && raiseException_method->is_static()) { + MethodHandles::set_raise_exception_method(raiseException_method); + } else { + warning("JSR 292 method handle code is mismatched to this JVM. Disabling support."); + enable_MH = false; + } + } + } + + if (enable_MH) { + MethodHandles::set_enabled(true); + } + if (!EnableInvokeDynamic) { - warning("JSR 292 invokedynamic is disabled in this JVM. Use -XX:+EnableInvokeDynamic to enable."); + warning("JSR 292 invokedynamic is disabled in this JVM. Use -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic to enable."); return; // bind nothing } diff --git a/hotspot/src/share/vm/prims/methodHandles.hpp b/hotspot/src/share/vm/prims/methodHandles.hpp index 5f660e743e4..fea29650b5c 100644 --- a/hotspot/src/share/vm/prims/methodHandles.hpp +++ b/hotspot/src/share/vm/prims/methodHandles.hpp @@ -32,8 +32,7 @@ class MethodHandles: AllStatic { // See also javaClasses for layouts java_dyn_Method{Handle,Type,Type::Form}. public: enum EntryKind { - _check_mtype, // how a caller calls a MH - _wrong_method_type, // what happens when there is a type mismatch + _raise_exception, // stub for error generation from other stubs _invokestatic_mh, // how a MH emulates invokestatic _invokespecial_mh, // ditto for the other invokes... _invokevirtual_mh, @@ -47,6 +46,7 @@ class MethodHandles: AllStatic { _adapter_mh_first, // adapter sequence goes here... _adapter_retype_only = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY, + _adapter_retype_raw = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW, _adapter_check_cast = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_CHECK_CAST, _adapter_prim_to_prim = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM, _adapter_ref_to_prim = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM, @@ -113,6 +113,8 @@ class MethodHandles: AllStatic { static bool _enabled; static MethodHandleEntry* _entries[_EK_LIMIT]; static const char* _entry_names[_EK_LIMIT+1]; + static jobject _raise_exception_method; + static bool ek_valid(EntryKind ek) { return (uint)ek < (uint)_EK_LIMIT; } static bool conv_op_valid(int op) { return (uint)op < (uint)CONV_OP_LIMIT; } @@ -131,6 +133,16 @@ class MethodHandles: AllStatic { _entries[ek] = me; } + static methodOop raise_exception_method() { + oop rem = JNIHandles::resolve(_raise_exception_method); + assert(rem == NULL || rem->is_method(), ""); + return (methodOop) rem; + } + static void set_raise_exception_method(methodOop rem) { + assert(_raise_exception_method == NULL, ""); + _raise_exception_method = JNIHandles::make_global(Handle(rem)); + } + static jint adapter_conversion(int conv_op, BasicType src, BasicType dest, int stack_move = 0, int vminfo = 0) { assert(conv_op_valid(conv_op), "oob"); @@ -243,7 +255,7 @@ class MethodHandles: AllStatic { enum { // format of query to getConstant: GC_JVM_PUSH_LIMIT = 0, - GC_JVM_STACK_MOVE_LIMIT = 1, + GC_JVM_STACK_MOVE_UNIT = 1, // format of result from getTarget / encode_target: ETF_HANDLE_OR_METHOD_NAME = 0, // all available data (immediate MH or method) @@ -261,7 +273,8 @@ class MethodHandles: AllStatic { int insert_argnum, oop insert_type, int change_argnum, oop change_type, int delete_argnum, - oop dst_mtype, int dst_beg, int dst_end); + oop dst_mtype, int dst_beg, int dst_end, + bool raw = false); static const char* check_method_type_insertion(oop src_mtype, int insert_argnum, oop insert_type, oop dst_mtype) { @@ -278,29 +291,29 @@ class MethodHandles: AllStatic { change_argnum, change_type, -1, dst_mtype, 0, -1); } - static const char* check_method_type_passthrough(oop src_mtype, oop dst_mtype) { + static const char* check_method_type_passthrough(oop src_mtype, oop dst_mtype, bool raw) { oop no_ref = NULL; return check_method_type_change(src_mtype, 0, -1, -1, no_ref, -1, no_ref, -1, - dst_mtype, 0, -1); + dst_mtype, 0, -1, raw); } // These checkers operate on pairs of argument or return types: static const char* check_argument_type_change(BasicType src_type, klassOop src_klass, BasicType dst_type, klassOop dst_klass, - int argnum); + int argnum, bool raw = false); static const char* check_argument_type_change(oop src_type, oop dst_type, - int argnum) { + int argnum, bool raw = false) { klassOop src_klass = NULL, dst_klass = NULL; BasicType src_bt = java_lang_Class::as_BasicType(src_type, &src_klass); BasicType dst_bt = java_lang_Class::as_BasicType(dst_type, &dst_klass); return check_argument_type_change(src_bt, src_klass, - dst_bt, dst_klass, argnum); + dst_bt, dst_klass, argnum, raw); } - static const char* check_return_type_change(oop src_type, oop dst_type) { - return check_argument_type_change(src_type, dst_type, -1); + static const char* check_return_type_change(oop src_type, oop dst_type, bool raw = false) { + return check_argument_type_change(src_type, dst_type, -1, raw); } static const char* check_return_type_change(BasicType src_type, klassOop src_klass, @@ -357,9 +370,10 @@ class MethodHandles: AllStatic { TRAPS); static bool same_basic_type_for_arguments(BasicType src, BasicType dst, + bool raw = false, bool for_return = false); - static bool same_basic_type_for_returns(BasicType src, BasicType dst) { - return same_basic_type_for_arguments(src, dst, true); + static bool same_basic_type_for_returns(BasicType src, BasicType dst, bool raw = false) { + return same_basic_type_for_arguments(src, dst, raw, true); } enum { // arg_mask values diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index b9e208f06b3..ccd568f3a6d 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1229,6 +1229,7 @@ void Arguments::set_ergonomics_flags() { } } +#ifndef ZERO #ifdef _LP64 // Check that UseCompressedOops can be set with the max heap size allocated // by ergonomics. @@ -1254,6 +1255,7 @@ void Arguments::set_ergonomics_flags() { // Also checks that certain machines are slower with compressed oops // in vm_version initialization code. #endif // _LP64 +#endif // !ZERO } void Arguments::set_parallel_gc_flags() { diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index f48cafe8208..df9cb2b778a 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -47,7 +47,6 @@ define_pd_global(intx, Tier4BackEdgeThreshold, 0); define_pd_global(intx, OnStackReplacePercentage, 0); define_pd_global(bool, ResizeTLAB, false); define_pd_global(intx, FreqInlineSize, 0); -define_pd_global(intx, InlineSmallCode, 0); define_pd_global(intx, NewSizeThreadIncrease, 4*K); define_pd_global(intx, NewRatio, 4); define_pd_global(intx, InlineClassNatives, true); diff --git a/hotspot/src/share/vm/runtime/jniHandles.hpp b/hotspot/src/share/vm/runtime/jniHandles.hpp index 99c4245028e..0cd24950caf 100644 --- a/hotspot/src/share/vm/runtime/jniHandles.hpp +++ b/hotspot/src/share/vm/runtime/jniHandles.hpp @@ -99,6 +99,8 @@ class JNIHandles : AllStatic { class JNIHandleBlock : public CHeapObj { friend class VMStructs; + friend class CppInterpreter; + private: enum SomeConstants { block_size_in_oops = 32 // Number of handles per handle block @@ -126,9 +128,11 @@ class JNIHandleBlock : public CHeapObj { // Fill block with bad_handle values void zap(); + protected: // No more handles in the both the current and following blocks void clear() { _top = 0; } + private: // Free list computation void rebuild_free_list(); diff --git a/hotspot/src/share/vm/runtime/mutex.hpp b/hotspot/src/share/vm/runtime/mutex.hpp index f0b9e8bd79d..dba1f23f5b4 100644 --- a/hotspot/src/share/vm/runtime/mutex.hpp +++ b/hotspot/src/share/vm/runtime/mutex.hpp @@ -61,18 +61,10 @@ union SplitWord { // full-word with separately addressable LSB } ; // Endian-ness ... index of least-significant byte in SplitWord.Bytes[] -#ifdef AMD64 // little +#ifdef VM_LITTLE_ENDIAN #define _LSBINDEX 0 #else -#if IA32 // little - #define _LSBINDEX 0 -#else -#ifdef SPARC // big #define _LSBINDEX (sizeof(intptr_t)-1) -#else - #error "unknown architecture" -#endif -#endif #endif class ParkEvent ; diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index bbe60732c45..04a5240d734 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -81,6 +81,14 @@ void SafepointSynchronize::begin() { jlong safepoint_limit_time; timeout_error_printed = false; + // PrintSafepointStatisticsTimeout can be specified separately. When + // specified, PrintSafepointStatistics will be set to true in + // deferred_initialize_stat method. The initialization has to be done + // early enough to avoid any races. See bug 6880029 for details. + if (PrintSafepointStatistics || PrintSafepointStatisticsTimeout > 0) { + deferred_initialize_stat(); + } + // Begin the process of bringing the system to a safepoint. // Java threads can be in several different states and are // stopped by different mechanisms: @@ -169,8 +177,7 @@ void SafepointSynchronize::begin() { } } - if ( (PrintSafepointStatistics || (PrintSafepointStatisticsTimeout > 0)) - && iterations == 0) { + if (PrintSafepointStatistics && iterations == 0) { begin_statistics(nof_threads, still_running); } @@ -1026,8 +1033,7 @@ void SafepointSynchronize::deferred_initialize_stat() { } void SafepointSynchronize::begin_statistics(int nof_threads, int nof_running) { - deferred_initialize_stat(); - + assert(init_done, "safepoint statistics array hasn't been initialized"); SafepointStats *spstat = &_safepoint_stats[_cur_stat_index]; VM_Operation *op = VMThread::vm_operation(); diff --git a/hotspot/src/share/vm/runtime/signature.hpp b/hotspot/src/share/vm/runtime/signature.hpp index 9b506d32902..9d67b0334ec 100644 --- a/hotspot/src/share/vm/runtime/signature.hpp +++ b/hotspot/src/share/vm/runtime/signature.hpp @@ -275,11 +275,14 @@ class NativeSignatureIterator: public SignatureIterator { void do_bool () { pass_int(); _jni_offset++; _offset++; } void do_char () { pass_int(); _jni_offset++; _offset++; } -#ifdef _LP64 +#if defined(_LP64) || defined(ZERO) void do_float () { pass_float(); _jni_offset++; _offset++; } - void do_double() { pass_double(); _jni_offset++; _offset += 2; } #else void do_float () { pass_int(); _jni_offset++; _offset++; } +#endif +#ifdef _LP64 + void do_double() { pass_double(); _jni_offset++; _offset += 2; } +#else void do_double() { pass_double(); _jni_offset += 2; _offset += 2; } #endif void do_byte () { pass_int(); _jni_offset++; _offset++; } @@ -303,8 +306,10 @@ class NativeSignatureIterator: public SignatureIterator { virtual void pass_int() = 0; virtual void pass_long() = 0; virtual void pass_object() = 0; -#ifdef _LP64 +#if defined(_LP64) || defined(ZERO) virtual void pass_float() = 0; +#endif +#ifdef _LP64 virtual void pass_double() = 0; #else virtual void pass_double() { pass_long(); } // may be same as long diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 05588d5fcae..38e3ac438b3 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -1213,6 +1213,7 @@ JavaThread::JavaThread(bool is_attaching) : { initialize(); _is_attaching = is_attaching; + assert(_deferred_card_mark.is_empty(), "Default MemRegion ctor"); } bool JavaThread::reguard_stack(address cur_sp) { @@ -2318,6 +2319,10 @@ void JavaThread::gc_prologue() { void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { + // Flush deferred store-barriers, if any, associated with + // initializing stores done by this JavaThread in the current epoch. + Universe::heap()->flush_deferred_store_barrier(this); + // The ThreadProfiler oops_do is done from FlatProfiler::oops_do // since there may be more than one thread using each ThreadProfiler. diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 1def1aeec66..cb4d6168a82 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -684,8 +684,13 @@ class JavaThread: public Thread { methodOop _callee_target; // Oop results of VM runtime calls - oop _vm_result; // Used to pass back an oop result into Java code, GC-preserved - oop _vm_result_2; // Used to pass back an oop result into Java code, GC-preserved + oop _vm_result; // Used to pass back an oop result into Java code, GC-preserved + oop _vm_result_2; // Used to pass back an oop result into Java code, GC-preserved + + // See ReduceInitialCardMarks: this holds the precise space interval of + // the most recent slow path allocation for which compiled code has + // elided card-marks for performance along the fast-path. + MemRegion _deferred_card_mark; MonitorChunk* _monitor_chunks; // Contains the off stack monitors // allocated during deoptimization @@ -1082,6 +1087,9 @@ class JavaThread: public Thread { oop vm_result_2() const { return _vm_result_2; } void set_vm_result_2 (oop x) { _vm_result_2 = x; } + MemRegion deferred_card_mark() const { return _deferred_card_mark; } + void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; } + // Exception handling for compiled methods oop exception_oop() const { return _exception_oop; } int exception_stack_size() const { return _exception_stack_size; } diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index f90c8a46b08..bbff61b478b 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -594,6 +594,7 @@ static inline uint64_t cast_uint64_t(size_t x) \ nonstatic_field(PcDesc, _pc_offset, int) \ nonstatic_field(PcDesc, _scope_decode_offset, int) \ + nonstatic_field(PcDesc, _obj_decode_offset, int) \ nonstatic_field(PcDesc, _flags, PcDesc::PcDescFlags) \ \ /***************************************************/ \ diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp index b05e41ffc6b..39c08fc7fa1 100644 --- a/hotspot/src/share/vm/runtime/vm_version.cpp +++ b/hotspot/src/share/vm/runtime/vm_version.cpp @@ -93,9 +93,13 @@ void Abstract_VM_Version::initialize() { #else // KERNEL #ifdef TIERED #define VMTYPE "Server" -#else - #define VMTYPE COMPILER1_PRESENT("Client") \ - COMPILER2_PRESENT("Server") +#else // TIERED +#ifdef ZERO + #define VMTYPE "Zero" +#else // ZERO + #define VMTYPE COMPILER1_PRESENT("Client") \ + COMPILER2_PRESENT("Server") +#endif // ZERO #endif // TIERED #endif // KERNEL @@ -142,10 +146,14 @@ const char* Abstract_VM_Version::vm_release() { WINDOWS_ONLY("windows") \ SOLARIS_ONLY("solaris") +#ifdef ZERO +#define CPU ZERO_LIBARCH +#else #define CPU IA32_ONLY("x86") \ IA64_ONLY("ia64") \ AMD64_ONLY("amd64") \ SPARC_ONLY("sparc") +#endif // ZERO const char *Abstract_VM_Version::vm_platform_string() { return OS "-" CPU; diff --git a/hotspot/src/share/vm/services/heapDumper.cpp b/hotspot/src/share/vm/services/heapDumper.cpp index 49e343025ab..5bc0d2ffeff 100644 --- a/hotspot/src/share/vm/services/heapDumper.cpp +++ b/hotspot/src/share/vm/services/heapDumper.cpp @@ -1913,8 +1913,9 @@ void HeapDumper::dump_heap() { if (use_default_filename) { char fn[32]; sprintf(fn, "java_pid%d", os::current_process_id()); - assert(strlen(base_path) + strlen(fn) < sizeof(base_path), "HeapDumpPath too long"); + assert(strlen(base_path) + strlen(fn) + strlen(".hprof") < sizeof(base_path), "HeapDumpPath too long"); strcat(base_path, fn); + strcat(base_path, ".hprof"); } assert(strlen(base_path) < sizeof(my_path), "Buffer too small"); strcpy(my_path, base_path); @@ -1927,8 +1928,6 @@ void HeapDumper::dump_heap() { strcat(my_path, fn); } dump_file_seq++; // increment seq number for next time we dump - assert(strlen(".hprof") + strlen(my_path) < sizeof(my_path), "HeapDumpPath too long"); - strcat(my_path, ".hprof"); HeapDumper dumper(false /* no GC before heap dump */, true /* send to tty */); diff --git a/hotspot/src/share/vm/utilities/exceptions.cpp b/hotspot/src/share/vm/utilities/exceptions.cpp index 91c3cd733d3..6c9a0722d37 100644 --- a/hotspot/src/share/vm/utilities/exceptions.cpp +++ b/hotspot/src/share/vm/utilities/exceptions.cpp @@ -103,15 +103,18 @@ void Exceptions::_throw_oop(Thread* thread, const char* file, int line, oop exce _throw(thread, file, line, h_exception); } -void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception) { +void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) { assert(h_exception() != NULL, "exception should not be NULL"); // tracing (do this up front - so it works during boot strapping) if (TraceExceptions) { ttyLocker ttyl; ResourceMark rm; - tty->print_cr("Exception <%s> (" INTPTR_FORMAT " ) \nthrown [%s, line %d]\nfor thread " INTPTR_FORMAT, - h_exception->print_value_string(), (address)h_exception(), file, line, thread); + tty->print_cr("Exception <%s>%s%s (" INTPTR_FORMAT " ) \n" + "thrown [%s, line %d]\nfor thread " INTPTR_FORMAT, + h_exception->print_value_string(), + message ? ": " : "", message ? message : "", + (address)h_exception(), file, line, thread); } // for AbortVMOnException flag NOT_PRODUCT(Exceptions::debug_check_abort(h_exception)); @@ -135,7 +138,7 @@ void Exceptions::_throw_msg(Thread* thread, const char* file, int line, symbolHa // Create and throw exception Handle h_cause(thread, NULL); Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); - _throw(thread, file, line, h_exception); + _throw(thread, file, line, h_exception, message); } // Throw an exception with a message and a cause @@ -144,7 +147,7 @@ void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, sy if (special_exception(thread, file, line, h_name, message)) return; // Create and throw exception and init cause Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); - _throw(thread, file, line, h_exception); + _throw(thread, file, line, h_exception, message); } // This version creates handles and calls the other version diff --git a/hotspot/src/share/vm/utilities/exceptions.hpp b/hotspot/src/share/vm/utilities/exceptions.hpp index ca01f455c75..8425e64eca2 100644 --- a/hotspot/src/share/vm/utilities/exceptions.hpp +++ b/hotspot/src/share/vm/utilities/exceptions.hpp @@ -103,7 +103,7 @@ class Exceptions { } ExceptionMsgToUtf8Mode; // Throw exceptions: w/o message, w/ message & with formatted message. static void _throw_oop(Thread* thread, const char* file, int line, oop exception); - static void _throw(Thread* thread, const char* file, int line, Handle exception); + static void _throw(Thread* thread, const char* file, int line, Handle exception, const char* msg = NULL); static void _throw_msg(Thread* thread, const char* file, int line, symbolHandle name, const char* message, Handle loader, Handle protection_domain); diff --git a/hotspot/src/share/vm/utilities/taskqueue.hpp b/hotspot/src/share/vm/utilities/taskqueue.hpp index 34ca1668c7f..19bdb3245c4 100644 --- a/hotspot/src/share/vm/utilities/taskqueue.hpp +++ b/hotspot/src/share/vm/utilities/taskqueue.hpp @@ -207,7 +207,7 @@ bool GenericTaskQueue::push_slow(E t, uint dirty_n_elems) { // Actually means 0, so do the push. uint localBot = _bottom; _elems[localBot] = t; - _bottom = increment_index(localBot); + OrderAccess::release_store(&_bottom, increment_index(localBot)); return true; } return false; @@ -465,19 +465,7 @@ public: #endif }; -#define SIMPLE_STACK 0 - template inline bool GenericTaskQueue::push(E t) { -#if SIMPLE_STACK - uint localBot = _bottom; - if (_bottom < max_elems()) { - _elems[localBot] = t; - _bottom = localBot + 1; - return true; - } else { - return false; - } -#else uint localBot = _bottom; assert((localBot >= 0) && (localBot < N), "_bottom out of range."); idx_t top = _age.top(); @@ -485,23 +473,14 @@ template inline bool GenericTaskQueue::push(E t) { assert((dirty_n_elems >= 0) && (dirty_n_elems < N), "n_elems out of range."); if (dirty_n_elems < max_elems()) { _elems[localBot] = t; - _bottom = increment_index(localBot); + OrderAccess::release_store(&_bottom, increment_index(localBot)); return true; } else { return push_slow(t, dirty_n_elems); } -#endif } template inline bool GenericTaskQueue::pop_local(E& t) { -#if SIMPLE_STACK - uint localBot = _bottom; - assert(localBot > 0, "precondition."); - localBot--; - t = _elems[localBot]; - _bottom = localBot; - return true; -#else uint localBot = _bottom; // This value cannot be N-1. That can only occur as a result of // the assignment to bottom in this method. If it does, this method @@ -529,7 +508,6 @@ template inline bool GenericTaskQueue::pop_local(E& t) { // path. return pop_local_slow(localBot, _age.get()); } -#endif } typedef oop Task; diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp index f3f3edc12fc..2a2ddf83ab1 100644 --- a/hotspot/src/share/vm/utilities/vmError.cpp +++ b/hotspot/src/share/vm/utilities/vmError.cpp @@ -458,6 +458,40 @@ void VMError::report(outputStream* st) { if (_verbose && _thread && _thread->is_Java_thread()) { JavaThread* jt = (JavaThread*)_thread; +#ifdef ZERO + if (jt->zero_stack()->sp() && jt->top_zero_frame()) { + // StackFrameStream uses the frame anchor, which may not have + // been set up. This can be done at any time in Zero, however, + // so if it hasn't been set up then we just set it up now and + // clear it again when we're done. + bool has_last_Java_frame = jt->has_last_Java_frame(); + if (!has_last_Java_frame) + jt->set_last_Java_frame(); + st->print("Java frames:"); + + // If the top frame is a Shark frame and the frame anchor isn't + // set up then it's possible that the information in the frame + // is garbage: it could be from a previous decache, or it could + // simply have never been written. So we print a warning... + StackFrameStream sfs(jt); + if (!has_last_Java_frame && !sfs.is_done()) { + if (sfs.current()->zeroframe()->is_shark_frame()) { + st->print(" (TOP FRAME MAY BE JUNK)"); + } + } + st->cr(); + + // Print the frames + for(int i = 0; !sfs.is_done(); sfs.next(), i++) { + sfs.current()->zero_print_on_error(i, st, buf, sizeof(buf)); + st->cr(); + } + + // Reset the frame anchor if necessary + if (!has_last_Java_frame) + jt->reset_last_Java_frame(); + } +#else if (jt->has_last_Java_frame()) { st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { @@ -465,6 +499,7 @@ void VMError::report(outputStream* st) { st->cr(); } } +#endif // ZERO } STEP(140, "(printing VM operation)" ) diff --git a/hotspot/test/compiler/6879902/Test6879902.java b/hotspot/test/compiler/6879902/Test6879902.java new file mode 100644 index 00000000000..29c681f61be --- /dev/null +++ b/hotspot/test/compiler/6879902/Test6879902.java @@ -0,0 +1,49 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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 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. + */ + +/** + * @test + * @bug 6879902 + * @summary CTW failure jdk6_18/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp:845 + * + * @run main Test6879902 + */ + +import java.util.Arrays; + +public class Test6879902 { + public static void main(String[] args) { + Object[] oa = new Object[250]; + for (int i = 0; i < 250; i++) { + oa[i] = Integer.valueOf(i); + } + Object[] oa2 = createArray(oa[0], oa[1], oa[2], oa[3], oa[4], oa[5], oa[6], oa[7], oa[8], oa[9], oa[10], oa[11], oa[12], oa[13], oa[14], oa[15], oa[16], oa[17], oa[18], oa[19], oa[20], oa[21], oa[22], oa[23], oa[24], oa[25], oa[26], oa[27], oa[28], oa[29], oa[30], oa[31], oa[32], oa[33], oa[34], oa[35], oa[36], oa[37], oa[38], oa[39], oa[40], oa[41], oa[42], oa[43], oa[44], oa[45], oa[46], oa[47], oa[48], oa[49], oa[50], oa[51], oa[52], oa[53], oa[54], oa[55], oa[56], oa[57], oa[58], oa[59], oa[60], oa[61], oa[62], oa[63], oa[64], oa[65], oa[66], oa[67], oa[68], oa[69], oa[70], oa[71], oa[72], oa[73], oa[74], oa[75], oa[76], oa[77], oa[78], oa[79], oa[80], oa[81], oa[82], oa[83], oa[84], oa[85], oa[86], oa[87], oa[88], oa[89], oa[90], oa[91], oa[92], oa[93], oa[94], oa[95], oa[96], oa[97], oa[98], oa[99], oa[100], oa[101], oa[102], oa[103], oa[104], oa[105], oa[106], oa[107], oa[108], oa[109], oa[110], oa[111], oa[112], oa[113], oa[114], oa[115], oa[116], oa[117], oa[118], oa[119], oa[120], oa[121], oa[122], oa[123], oa[124], oa[125], oa[126], oa[127], oa[128], oa[129], oa[130], oa[131], oa[132], oa[133], oa[134], oa[135], oa[136], oa[137], oa[138], oa[139], oa[140], oa[141], oa[142], oa[143], oa[144], oa[145], oa[146], oa[147], oa[148], oa[149], oa[150], oa[151], oa[152], oa[153], oa[154], oa[155], oa[156], oa[157], oa[158], oa[159], oa[160], oa[161], oa[162], oa[163], oa[164], oa[165], oa[166], oa[167], oa[168], oa[169], oa[170], oa[171], oa[172], oa[173], oa[174], oa[175], oa[176], oa[177], oa[178], oa[179], oa[180], oa[181], oa[182], oa[183], oa[184], oa[185], oa[186], oa[187], oa[188], oa[189], oa[190], oa[191], oa[192], oa[193], oa[194], oa[195], oa[196], oa[197], oa[198], oa[199], oa[200], oa[201], oa[202], oa[203], oa[204], oa[205], oa[206], oa[207], oa[208], oa[209], oa[210], oa[211], oa[212], oa[213], oa[214], oa[215], oa[216], oa[217], oa[218], oa[219], oa[220], oa[221], oa[222], oa[223], oa[224], oa[225], oa[226], oa[227], oa[228], oa[229], oa[230], oa[231], oa[232], oa[233], oa[234], oa[235], oa[236], oa[237], oa[238], oa[239], oa[240], oa[241], oa[242], oa[243], oa[244], oa[245], oa[246], oa[247], oa[248], oa[249]); + if (!Arrays.equals(oa, oa2)) + throw new InternalError("arrays not equal"); + } + + public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20, Object arg21, Object arg22, Object arg23, Object arg24, Object arg25, Object arg26, Object arg27, Object arg28, Object arg29, Object arg30, Object arg31, Object arg32, Object arg33, Object arg34, Object arg35, Object arg36, Object arg37, Object arg38, Object arg39, Object arg40, Object arg41, Object arg42, Object arg43, Object arg44, Object arg45, Object arg46, Object arg47, Object arg48, Object arg49, Object arg50, Object arg51, Object arg52, Object arg53, Object arg54, Object arg55, Object arg56, Object arg57, Object arg58, Object arg59, Object arg60, Object arg61, Object arg62, Object arg63, Object arg64, Object arg65, Object arg66, Object arg67, Object arg68, Object arg69, Object arg70, Object arg71, Object arg72, Object arg73, Object arg74, Object arg75, Object arg76, Object arg77, Object arg78, Object arg79, Object arg80, Object arg81, Object arg82, Object arg83, Object arg84, Object arg85, Object arg86, Object arg87, Object arg88, Object arg89, Object arg90, Object arg91, Object arg92, Object arg93, Object arg94, Object arg95, Object arg96, Object arg97, Object arg98, Object arg99, Object arg100, Object arg101, Object arg102, Object arg103, Object arg104, Object arg105, Object arg106, Object arg107, Object arg108, Object arg109, Object arg110, Object arg111, Object arg112, Object arg113, Object arg114, Object arg115, Object arg116, Object arg117, Object arg118, Object arg119, Object arg120, Object arg121, Object arg122, Object arg123, Object arg124, Object arg125, Object arg126, Object arg127, Object arg128, Object arg129, Object arg130, Object arg131, Object arg132, Object arg133, Object arg134, Object arg135, Object arg136, Object arg137, Object arg138, Object arg139, Object arg140, Object arg141, Object arg142, Object arg143, Object arg144, Object arg145, Object arg146, Object arg147, Object arg148, Object arg149, Object arg150, Object arg151, Object arg152, Object arg153, Object arg154, Object arg155, Object arg156, Object arg157, Object arg158, Object arg159, Object arg160, Object arg161, Object arg162, Object arg163, Object arg164, Object arg165, Object arg166, Object arg167, Object arg168, Object arg169, Object arg170, Object arg171, Object arg172, Object arg173, Object arg174, Object arg175, Object arg176, Object arg177, Object arg178, Object arg179, Object arg180, Object arg181, Object arg182, Object arg183, Object arg184, Object arg185, Object arg186, Object arg187, Object arg188, Object arg189, Object arg190, Object arg191, Object arg192, Object arg193, Object arg194, Object arg195, Object arg196, Object arg197, Object arg198, Object arg199, Object arg200, Object arg201, Object arg202, Object arg203, Object arg204, Object arg205, Object arg206, Object arg207, Object arg208, Object arg209, Object arg210, Object arg211, Object arg212, Object arg213, Object arg214, Object arg215, Object arg216, Object arg217, Object arg218, Object arg219, Object arg220, Object arg221, Object arg222, Object arg223, Object arg224, Object arg225, Object arg226, Object arg227, Object arg228, Object arg229, Object arg230, Object arg231, Object arg232, Object arg233, Object arg234, Object arg235, Object arg236, Object arg237, Object arg238, Object arg239, Object arg240, Object arg241, Object arg242, Object arg243, Object arg244, Object arg245, Object arg246, Object arg247, Object arg248, Object arg249) { + return new Object[]{ + arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25, arg26, arg27, arg28, arg29, arg30, arg31, arg32, arg33, arg34, arg35, arg36, arg37, arg38, arg39, arg40, arg41, arg42, arg43, arg44, arg45, arg46, arg47, arg48, arg49, arg50, arg51, arg52, arg53, arg54, arg55, arg56, arg57, arg58, arg59, arg60, arg61, arg62, arg63, arg64, arg65, arg66, arg67, arg68, arg69, arg70, arg71, arg72, arg73, arg74, arg75, arg76, arg77, arg78, arg79, arg80, arg81, arg82, arg83, arg84, arg85, arg86, arg87, arg88, arg89, arg90, arg91, arg92, arg93, arg94, arg95, arg96, arg97, arg98, arg99, arg100, arg101, arg102, arg103, arg104, arg105, arg106, arg107, arg108, arg109, arg110, arg111, arg112, arg113, arg114, arg115, arg116, arg117, arg118, arg119, arg120, arg121, arg122, arg123, arg124, arg125, arg126, arg127, arg128, arg129, arg130, arg131, arg132, arg133, arg134, arg135, arg136, arg137, arg138, arg139, arg140, arg141, arg142, arg143, arg144, arg145, arg146, arg147, arg148, arg149, arg150, arg151, arg152, arg153, arg154, arg155, arg156, arg157, arg158, arg159, arg160, arg161, arg162, arg163, arg164, arg165, arg166, arg167, arg168, arg169, arg170, arg171, arg172, arg173, arg174, arg175, arg176, arg177, arg178, arg179, arg180, arg181, arg182, arg183, arg184, arg185, arg186, arg187, arg188, arg189, arg190, arg191, arg192, arg193, arg194, arg195, arg196, arg197, arg198, arg199, arg200, arg201, arg202, arg203, arg204, arg205, arg206, arg207, arg208, arg209, arg210, arg211, arg212, arg213, arg214, arg215, arg216, arg217, arg218, arg219, arg220, arg221, arg222, arg223, arg224, arg225, arg226, arg227, arg228, arg229, arg230, arg231, arg232, arg233, arg234, arg235, arg236, arg237, arg238, arg239, arg240, arg241, arg242, arg243, arg244, arg245, arg246, arg247, arg248, arg249}; + } +} diff --git a/hotspot/test/compiler/6880034/Test6880034.java b/hotspot/test/compiler/6880034/Test6880034.java new file mode 100644 index 00000000000..bc69282ee02 --- /dev/null +++ b/hotspot/test/compiler/6880034/Test6880034.java @@ -0,0 +1,163 @@ +/* + * Copyright 2009 SAP AG. 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 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. + */ + +/** + * @test + * @bug 6880034 + * @summary SIGBUS during deoptimisation at a safepoint on 64bit-SPARC + * + * @run main/othervm -Xcomp -Xbatch -XX:CompileCommand=compileonly,Test6880034,deopt_compiledframe_at_safepoint -XX:+PrintCompilation Test6880034 + */ + + + +// This test provokes a deoptimisation at a safepoint. +// +// It achieves this by compiling the method 'deopt_compiledframe_at_safepoint' +// before its first usage at a point in time when a call to the virtual method +// A::doSomething() from within 'deopt_compiledframe_at_safepoint' can be +// optimised to a static call because class A has no descendants. +// +// Later, when deopt_compiledframe_at_safepoint() is running, class B which +// extends A and overrides the virtual method "doSomething()", is loaded +// asynchronously in another thread. This makes the compiled code of +// 'deopt_compiledframe_at_safepoint' invalid and triggers a deoptimisation of +// the frame where 'deopt_compiledframe_at_safepoint' is running in a +// loop. +// +// The deoptimisation leads to a SIGBUS on 64-bit server VMs on SPARC and to +// an incorrect result on 32-bit server VMs on SPARC due to a regression +// introduced by the change: "6420645: Create a vm that uses compressed oops +// for up to 32gb heapsizes" +// (http://hg.openjdk.java.net/jdk7/jdk7/hotspot/rev/ba764ed4b6f2). Further +// investigation showed that change 6420645 is not really the root cause of +// this error but only reveals a problem with the float register encodings in +// sparc.ad which was hidden until now. +// +// Notice that for this test to fail in jtreg it is crucial that +// deopt_compiledframe_at_safepoint() runs in the main thread. Otherwise a +// crash in deopt_compiledframe_at_safepoint() will not be detected as a test +// failure by jtreg. +// +// Author: Volker H. Simonis + +class A { + public int doSomething() { + return 0; + } +} + +class B extends A { + public B() {} + // override 'A::doSomething()' + public int doSomething() { + return 1; + } +} + +class G { + public static volatile A a = new A(); + + // Change 'a' to point to a 'B' object + public static void setAtoB() { + try { + a = (A) ClassLoader. + getSystemClassLoader(). + loadClass("B"). + getConstructor(new Class[] {}). + newInstance(new Object[] {}); + } + catch (Exception e) { + System.out.println(e); + } + } +} + +public class Test6880034 { + + public static volatile boolean is_in_loop = false; + public static volatile boolean stop_while_loop = false; + + public static double deopt_compiledframe_at_safepoint() { + // This will be an optimised static call to A::doSomething() until we load "B" + int i = G.a.doSomething(); + + // Need more than 16 'double' locals in this frame + double local1 = 1; + double local2 = 2; + double local3 = 3; + double local4 = 4; + double local5 = 5; + double local6 = 6; + double local7 = 7; + double local8 = 8; + + long k = 0; + // Once we load "B", this method will be made 'not entrant' and deoptimised + // at the safepoint which is at the end of this loop. + while (!stop_while_loop) { + if (k == 1) local1 += i; + if (k == 2) local2 += i; + if (k == 3) local3 += i; + if (k == 4) local4 += i; + if (k == 5) local5 += i; + if (k == 6) local6 += i; + if (k == 7) local7 += i; + if (k == 8) local8 += i; + + // Tell the world that we're now running wild in the loop + if (k++ == 20000) is_in_loop = true; + } + + return + local1 + local2 + local3 + local4 + + local5 + local6 + local7 + local8 + i; + } + + public static void main(String[] args) { + + // Just to resolve G before we compile deopt_compiledframe_at_safepoint() + G g = new G(); + + // Asynchronous thread which will eventually invalidate the code for + // deopt_compiledframe_at_safepoint() and therefore triggering a + // deoptimisation of that method. + new Thread() { + public void run() { + while (!is_in_loop) { + // Wait until the loop is running + } + // Load class 'B' asynchronously.. + G.setAtoB(); + // ..and stop the loop + stop_while_loop = true; + } + }.start(); + + // Run the loop in deopt_compiledframe_at_safepoint() + double retVal = deopt_compiledframe_at_safepoint(); + + System.out.println(retVal == 36 ? "OK" : "ERROR : " + retVal); + if (retVal != 36) throw new RuntimeException(); + } +} diff --git a/jdk/test/javax/management/namespace/WombatMBean.java b/hotspot/test/compiler/6885584/Test6885584.java similarity index 55% rename from jdk/test/javax/management/namespace/WombatMBean.java rename to hotspot/test/compiler/6885584/Test6885584.java index 73f4875317e..0dd9f43fd30 100644 --- a/jdk/test/javax/management/namespace/WombatMBean.java +++ b/hotspot/test/compiler/6885584/Test6885584.java @@ -1,6 +1,5 @@ - /* - * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2009 Sun Microsystems, Inc. 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 @@ -20,40 +19,40 @@ * 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. + * */ -import java.util.Set; -import javax.management.ObjectName; - /** - * Interface WombatMBean - * Wombat Description - * @author dfuchs + * @test + * @bug 6885584 + * @summary A particular class structure causes large allocation spike for jit + * + * @run main/othervm -Xbatch Test6885584 */ -public interface WombatMBean -{ - /** - * This Wombat's mood on a [-100,+100] scale. - * -100 means that this wombat is very angry. - * @return The wombat's mood. - */ - public int getMood(); - /** - * Get A simple caption to describe a wombat - */ - public String getCaption(); - /** - * Set A simple caption to describe a wombat - */ - public void setCaption(String value); - /** - * List matching MBeans in the same server. - * @param pattern an ObjectName pattern or null. - * @return A list of matching MBeans. - */ - public Set listMatching(ObjectName pattern); +public class Test6885584 { + static private int i1; + static private int i2; + static private int i3; + + static int limit = Integer.MAX_VALUE - 8; + + public static void main(String args[]) { + // Run long enough to trigger an OSR + for(int j = 200000; j != 0; j--) { + } + + // This must reference a field + i1 = i2; + + // The resource leak is roughly proportional to this initial value + for(int k = Integer.MAX_VALUE - 1; k != 0; k--) { + // Make sure the body does some work + if(i2 > i3)i1 = k; + if (k <= limit) break; + } + } } diff --git a/hotspot/test/compiler/6891750/Test6891750.java b/hotspot/test/compiler/6891750/Test6891750.java new file mode 100644 index 00000000000..cb98f7249d1 --- /dev/null +++ b/hotspot/test/compiler/6891750/Test6891750.java @@ -0,0 +1,108 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. 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 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. + * + */ + +/** + * @test + * @bug 6891750 + * @summary deopt blob kills values in O5 + * + * @run main Test6891750 + */ + +abstract class Base6891750 extends Thread { + abstract public long m(); +} +class Other6891750 extends Base6891750 { + public long m() { + return 0; + } +} + +public class Test6891750 extends Base6891750 { + Base6891750 d; + volatile long value = 9; + + static int limit = 400000; + + Test6891750() { + d = this; + + } + public long m() { + return value; + } + + public long test(boolean doit) { + if (doit) { + long total0 = 0; + long total1 = 0; + long total2 = 0; + long total3 = 0; + long total4 = 0; + long total5 = 0; + long total6 = 0; + long total7 = 0; + long total8 = 0; + long total9 = 0; + for (int i = 0; i < limit; i++) { + total0 += d.m(); + total1 += d.m(); + total2 += d.m(); + total3 += d.m(); + total4 += d.m(); + total5 += d.m(); + total6 += d.m(); + total7 += d.m(); + total8 += d.m(); + total9 += d.m(); + } + return total0 + total1 + total2 + total3 + total4 + total5 + total6 + total7 + total8 + total9; + } + return 0; + } + + public void run() { + long result = test(true); + for (int i = 0; i < 300; i++) { + long result2 = test(true); + if (result != result2) { + throw new InternalError(result + " != " + result2); + } + } + } + + public static void main(String[] args) throws Exception { + Test6891750 Test6891750 = new Test6891750(); + // warm it up + for (int i = 0; i < 200000; i++) { + Test6891750.test(false); + } + // set in off running + Test6891750.start(); + Thread.sleep(2000); + + // Load a class to invalidate CHA + new Other6891750(); + } +} diff --git a/hotspot/test/gc/6845368/bigobj.java b/hotspot/test/gc/6845368/bigobj.java index 087bdc9236b..5185326bb4a 100644 --- a/hotspot/test/gc/6845368/bigobj.java +++ b/hotspot/test/gc/6845368/bigobj.java @@ -3,7 +3,7 @@ @bug 6845368 @summary ensure gc updates references > 64K bytes from the start of the obj @author John Coomes - @run main/othervm -Xmx64m bigobj + @run main/othervm/timeout=720 -Xmx64m bigobj */ // Allocate an object with a block of reference fields that starts more diff --git a/jaxp/.hgignore b/jaxp/.hgignore index 05a4793cff1..655f5df9053 100644 --- a/jaxp/.hgignore +++ b/jaxp/.hgignore @@ -1,5 +1,6 @@ ^build/ ^dist/ ^drop/ +^drop_included/ ^webrev/ ^nbproject/private/ diff --git a/jaxp/.hgtags b/jaxp/.hgtags index f9500dfdb66..e3f8d778afd 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -48,3 +48,5 @@ c83f0106b78a85c7e614d27a328675460b2081cf jdk7-b70 ff94d8ce0daded647bb326630e643d010357afce jdk7-b71 37c805b6156fd492c12301688b54a6bcca39e729 jdk7-b72 feb05980f9f2964e6bc2b3a8532f9b3054c2289b jdk7-b73 +ea7b88c676dd8b269bc858a4a17c14dc96c8aed1 jdk7-b74 +555fb78ee4cebed082ca7ddabff46d2e5b4c9026 jdk7-b75 diff --git a/jaxp/build-defs.xml b/jaxp/build-defs.xml index a20d94791db..9e137e59110 100644 --- a/jaxp/build-defs.xml +++ b/jaxp/build-defs.xml @@ -68,32 +68,14 @@ - + - - - - - - - - - - - - - - - - - - - - + + @@ -102,24 +84,19 @@ + depends="init, -use-drop"> - - - - - - + - + diff --git a/jaxp/build-drop-template.xml b/jaxp/build-drop-template.xml index 1fe858cef23..528b8a98d6e 100644 --- a/jaxp/build-drop-template.xml +++ b/jaxp/build-drop-template.xml @@ -34,7 +34,7 @@ + value="${drop.expanded.dir}/bundles/${@DROP@.bundle.name}"/> @@ -43,10 +43,13 @@ - - - - + + + + + + + @@ -72,7 +75,6 @@ - @@ -106,6 +108,16 @@ + + + + + + Checksum on file ${@DROP@.bundle.copy} is + ${@DROP@.bundle.md5.checksum.is}, not ${@DROP@.bundle.md5.checksum} + diff --git a/jaxp/build.properties b/jaxp/build.properties index 880b11c8a55..9e5f63306c9 100644 --- a/jaxp/build.properties +++ b/jaxp/build.properties @@ -25,7 +25,7 @@ # Base locations where bundles are located slashjava=/java -devtools=${slashjava}/devtools +drops.dir=${slashjava}/devtools/share/jdk7-drops # This is the JDK used to build and run the bootstrap version of javac. # The bootstrap javac is used to compile both boostrap versions of the @@ -64,16 +64,15 @@ dist.lib.dir=${dist.dir}/lib dist.classes.jar=${dist.lib.dir}/classes.jar dist.src.zip=${dist.lib.dir}/src.zip -# Where all drop sources live -drop.dir=./drop +# Where all drop sources get placed when downloaded and unzipped +drop.expanded.dir=${output.dir}/drop + +# Location if the sources were included already +drop.included.dir=./drop_included # Where patches to drop bundle sources live patches.dir=patches -# Original source area -orig.dir=src -orig.src.dir=${orig.dir}/share/classes - # Sanity information sanity.info= Sanity Settings:${line.separator}\ ant.home=${ant.home}${line.separator}\ @@ -98,6 +97,7 @@ sanity.info= Sanity Settings:${line.separator}\ build.dir=${build.dir}${line.separator}\ dist.dir=${dist.dir}${line.separator}\ drop.dir=${drop.dir}${line.separator}\ + drops.dir=${drops.dir}${line.separator}\ ${line.separator} #------------------------------------------------------------ diff --git a/jaxp/build.xml b/jaxp/build.xml index 5e26e78068c..28831d69a0b 100644 --- a/jaxp/build.xml +++ b/jaxp/build.xml @@ -49,6 +49,13 @@ + + + + + @@ -131,6 +138,16 @@ description="Populate all source file directories"> + + + + + + + + @@ -142,7 +159,7 @@ - + diff --git a/jaxp/jaxp.properties b/jaxp/jaxp.properties index de30baa92d4..64689b73ab8 100644 --- a/jaxp/jaxp.properties +++ b/jaxp/jaxp.properties @@ -23,12 +23,12 @@ # have any questions. # -drops.master.copy.base=${devtools}/share/jdk7-drops -drops.master.url.base=http://kenai.com/projects/jdk7-drops/downloads/download +drops.master.copy.base=${drops.dir} +drops.master.url.base=https://jaxp.dev.java.net/files/documents/913/144160 -jaxp_src.bundle.name=jdk7-jaxp-2009_09_28.zip +jaxp_src.bundle.name=jdk7-jaxp-m5.zip +jaxp_src.bundle.md5.checksum=8b58ce7919cda8e32a9afc5cb4b58bb1 jaxp_src.master.bundle.dir=${drops.master.copy.base} -#jaxp_src.bundle.url.base=https://jaxp.dev.java.net/files/documents/913/142147 jaxp_src.master.bundle.url.base=${drops.master.url.base} jaxp_tests.bundle.name=jdk7-jaxp-tests-2009_08_28.zip diff --git a/jaxp/make/Makefile b/jaxp/make/Makefile index 74bd74b10fd..071a434a358 100644 --- a/jaxp/make/Makefile +++ b/jaxp/make/Makefile @@ -86,15 +86,22 @@ else endif endif -# Where is /java/devtools in case we need it -ifdef ALT_JDK_DEVTOOLS_DIR - _DEVTOOLS = $(ALT_JDK_DEVTOOLS_DIR) +# Do we have the drops already downloaded? +# Check ALT_DROPS_DIR for a full path first, +# before trying to use the devtools path, +# either via ALT_JDK_DEVTOOLS_DIR or /java/devtools. +ifdef ALT_DROPS_DIR + DROPS_DIR = $(ALT_DROPS_DIR) else - _DEVTOOLS = $(_SLASHJAVA)/devtools + ifdef ALT_JDK_DEVTOOLS_DIR + DROPS_DIR = $(ALT_JDK_DEVTOOLS_DIR)/share/jdk7-drops + else + DROPS_DIR = $(_SLASHJAVA)/devtools/share/jdk7-drops + endif endif -# Add in path to devtools -ANT_OPTIONS += -Ddevtools=$(_DEVTOOLS) +# Add in path to drops already downloaded +ANT_OPTIONS += -Ddrops.dir=$(DROPS_DIR) ifdef ALT_OUTPUTDIR OUTPUTDIR = $(ALT_OUTPUTDIR) @@ -130,7 +137,7 @@ endif default: all # All ant targets of interest -ANT_TARGETS = all source build dist clobber clean sanity +ANT_TARGETS = all source drop_included build dist clobber clean sanity # Create a make target for each $(ANT_TARGETS): diff --git a/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/Scanner.java b/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/Scanner.java deleted file mode 100644 index 7de11ea280f..00000000000 --- a/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/Scanner.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2003-2005 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * 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 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. - */ - -package com.sun.java_cup.internal.runtime; - -/** - * Defines the Scanner interface, which CUP uses in the default - * implementation of lr_parser.scan(). Integration - * of scanners implementing Scanner is facilitated. - * - * @author David MacMahon - */ - -/* ************************************************* - Interface Scanner - - Declares the next_token() method that should be - implemented by scanners. This method is typically - called by lr_parser.scan(). - ***************************************************/ -public interface Scanner { - public Symbol next_token() throws java.lang.Exception; -} diff --git a/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/Symbol.java b/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/Symbol.java deleted file mode 100644 index f1f274c02da..00000000000 --- a/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/Symbol.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2003-2005 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * 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 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. - */ - -package com.sun.java_cup.internal.runtime; - -/** - * Defines the Symbol class, which is used to represent all terminals - * and nonterminals while parsing. The lexer should pass CUP Symbols - * and CUP returns a Symbol. - * - * @author Frank Flannery - */ - -/* **************************************************************** - Class Symbol - what the parser expects to receive from the lexer. - the token is identified as follows: - sym: the symbol type - parse_state: the parse state. - value: is the lexical value of type Object - left : is the left position in the original input file - right: is the right position in the original input file -******************************************************************/ - -public class Symbol { - -/******************************* - Constructor for l,r values - *******************************/ - - public Symbol(int id, int l, int r, Object o) { - this(id); - left = l; - right = r; - value = o; - } - -/******************************* - Constructor for no l,r values -********************************/ - - public Symbol(int id, Object o) { - this(id); - left = -1; - right = -1; - value = o; - } - -/***************************** - Constructor for no value - ***************************/ - - public Symbol(int sym_num, int l, int r) { - sym = sym_num; - left = l; - right = r; - value = null; - } - -/*********************************** - Constructor for no value or l,r -***********************************/ - - public Symbol(int sym_num) { - this(sym_num, -1); - left = -1; - right = -1; - value = null; - } - -/*********************************** - Constructor to give a start state -***********************************/ - public Symbol(int sym_num, int state) - { - sym = sym_num; - parse_state = state; - } - -/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The symbol number of the terminal or non terminal being represented */ - public int sym; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The parse state to be recorded on the parse stack with this symbol. - * This field is for the convenience of the parser and shouldn't be - * modified except by the parser. - */ - public int parse_state; - /** This allows us to catch some errors caused by scanners recycling - * symbols. For the use of the parser only. [CSA, 23-Jul-1999] */ - boolean used_by_parser = false; - -/******************************* - The data passed to parser - *******************************/ - - public int left, right; - public Object value; - - /***************************** - Printing this token out. (Override for pretty-print). - ****************************/ - public String toString() { return "#"+sym; } -} diff --git a/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java b/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java deleted file mode 100644 index ffb99f8ef26..00000000000 --- a/jaxp/src/share/classes/com/sun/java_cup/internal/runtime/lr_parser.java +++ /dev/null @@ -1,1251 +0,0 @@ -/* - * Copyright 2003-2005 Sun Microsystems, Inc. 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. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * 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 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. - */ - - -package com.sun.java_cup.internal.runtime; - -import java.util.Stack; - -/** This class implements a skeleton table driven LR parser. In general, - * LR parsers are a form of bottom up shift-reduce parsers. Shift-reduce - * parsers act by shifting input onto a parse stack until the Symbols - * matching the right hand side of a production appear on the top of the - * stack. Once this occurs, a reduce is performed. This involves removing - * the Symbols corresponding to the right hand side of the production - * (the so called "handle") and replacing them with the non-terminal from - * the left hand side of the production.

    - * - * To control the decision of whether to shift or reduce at any given point, - * the parser uses a state machine (the "viable prefix recognition machine" - * built by the parser generator). The current state of the machine is placed - * on top of the parse stack (stored as part of a Symbol object representing - * a terminal or non terminal). The parse action table is consulted - * (using the current state and the current lookahead Symbol as indexes) to - * determine whether to shift or to reduce. When the parser shifts, it - * changes to a new state by pushing a new Symbol (containing a new state) - * onto the stack. When the parser reduces, it pops the handle (right hand - * side of a production) off the stack. This leaves the parser in the state - * it was in before any of those Symbols were matched. Next the reduce-goto - * table is consulted (using the new state and current lookahead Symbol as - * indexes) to determine a new state to go to. The parser then shifts to - * this goto state by pushing the left hand side Symbol of the production - * (also containing the new state) onto the stack.

    - * - * This class actually provides four LR parsers. The methods parse() and - * debug_parse() provide two versions of the main parser (the only difference - * being that debug_parse() emits debugging trace messages as it parses). - * In addition to these main parsers, the error recovery mechanism uses two - * more. One of these is used to simulate "parsing ahead" in the input - * without carrying out actions (to verify that a potential error recovery - * has worked), and the other is used to parse through buffered "parse ahead" - * input in order to execute all actions and re-synchronize the actual parser - * configuration.

    - * - * This is an abstract class which is normally filled out by a subclass - * generated by the JavaCup parser generator. In addition to supplying - * the actual parse tables, generated code also supplies methods which - * invoke various pieces of user supplied code, provide access to certain - * special Symbols (e.g., EOF and error), etc. Specifically, the following - * abstract methods are normally supplied by generated code: - *

    - *
    short[][] production_table() - *
    Provides a reference to the production table (indicating the index of - * the left hand side non terminal and the length of the right hand side - * for each production in the grammar). - *
    short[][] action_table() - *
    Provides a reference to the parse action table. - *
    short[][] reduce_table() - *
    Provides a reference to the reduce-goto table. - *
    int start_state() - *
    Indicates the index of the start state. - *
    int start_production() - *
    Indicates the index of the starting production. - *
    int EOF_sym() - *
    Indicates the index of the EOF Symbol. - *
    int error_sym() - *
    Indicates the index of the error Symbol. - *
    Symbol do_action() - *
    Executes a piece of user supplied action code. This always comes at - * the point of a reduce in the parse, so this code also allocates and - * fills in the left hand side non terminal Symbol object that is to be - * pushed onto the stack for the reduce. - *
    void init_actions() - *
    Code to initialize a special object that encapsulates user supplied - * actions (this object is used by do_action() to actually carry out the - * actions). - *
    - * - * In addition to these routines that must be supplied by the - * generated subclass there are also a series of routines that may - * be supplied. These include: - *
    - *
    Symbol scan() - *
    Used to get the next input Symbol from the scanner. - *
    Scanner getScanner() - *
    Used to provide a scanner for the default implementation of - * scan(). - *
    int error_sync_size() - *
    This determines how many Symbols past the point of an error - * must be parsed without error in order to consider a recovery to - * be valid. This defaults to 3. Values less than 2 are not - * recommended. - *
    void report_error(String message, Object info) - *
    This method is called to report an error. The default implementation - * simply prints a message to System.err and where the error occurred. - * This method is often replaced in order to provide a more sophisticated - * error reporting mechanism. - *
    void report_fatal_error(String message, Object info) - *
    This method is called when a fatal error that cannot be recovered from - * is encountered. In the default implementation, it calls - * report_error() to emit a message, then throws an exception. - *
    void syntax_error(Symbol cur_token) - *
    This method is called as soon as syntax error is detected (but - * before recovery is attempted). In the default implementation it - * invokes: report_error("Syntax error", null); - *
    void unrecovered_syntax_error(Symbol cur_token) - *
    This method is called if syntax error recovery fails. In the default - * implementation it invokes:
    - * report_fatal_error("Couldn't repair and continue parse", null); - *
    - * - * @see com.sun.java_cup.internal.runtime.Symbol - * @see com.sun.java_cup.internal.runtime.Symbol - * @see com.sun.java_cup.internal.runtime.virtual_parse_stack - * @author Frank Flannery - */ - -public abstract class lr_parser { - - /*-----------------------------------------------------------*/ - /*--- Constructor(s) ----------------------------------------*/ - /*-----------------------------------------------------------*/ - - /** Simple constructor. */ - public lr_parser() - { - /* nothing to do here */ - } - - /** Constructor that sets the default scanner. [CSA/davidm] */ - public lr_parser(Scanner s) { - this(); /* in case default constructor someday does something */ - setScanner(s); - } - - /*-----------------------------------------------------------*/ - /*--- (Access to) Static (Class) Variables ------------------*/ - /*-----------------------------------------------------------*/ - - /** The default number of Symbols after an error we much match to consider - * it recovered from. - */ - protected final static int _error_sync_size = 3; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The number of Symbols after an error we much match to consider it - * recovered from. - */ - protected int error_sync_size() {return _error_sync_size; } - - /*-----------------------------------------------------------*/ - /*--- (Access to) Instance Variables ------------------------*/ - /*-----------------------------------------------------------*/ - - /** Table of production information (supplied by generated subclass). - * This table contains one entry per production and is indexed by - * the negative-encoded values (reduce actions) in the action_table. - * Each entry has two parts, the index of the non-terminal on the - * left hand side of the production, and the number of Symbols - * on the right hand side. - */ - public abstract short[][] production_table(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The action table (supplied by generated subclass). This table is - * indexed by state and terminal number indicating what action is to - * be taken when the parser is in the given state (i.e., the given state - * is on top of the stack) and the given terminal is next on the input. - * States are indexed using the first dimension, however, the entries for - * a given state are compacted and stored in adjacent index, value pairs - * which are searched for rather than accessed directly (see get_action()). - * The actions stored in the table will be either shifts, reduces, or - * errors. Shifts are encoded as positive values (one greater than the - * state shifted to). Reduces are encoded as negative values (one less - * than the production reduced by). Error entries are denoted by zero. - * - * @see com.sun.java_cup.internal.runtime.lr_parser#get_action - */ - public abstract short[][] action_table(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The reduce-goto table (supplied by generated subclass). This - * table is indexed by state and non-terminal number and contains - * state numbers. States are indexed using the first dimension, however, - * the entries for a given state are compacted and stored in adjacent - * index, value pairs which are searched for rather than accessed - * directly (see get_reduce()). When a reduce occurs, the handle - * (corresponding to the RHS of the matched production) is popped off - * the stack. The new top of stack indicates a state. This table is - * then indexed by that state and the LHS of the reducing production to - * indicate where to "shift" to. - * - * @see com.sun.java_cup.internal.runtime.lr_parser#get_reduce - */ - public abstract short[][] reduce_table(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The index of the start state (supplied by generated subclass). */ - public abstract int start_state(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The index of the start production (supplied by generated subclass). */ - public abstract int start_production(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The index of the end of file terminal Symbol (supplied by generated - * subclass). - */ - public abstract int EOF_sym(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The index of the special error Symbol (supplied by generated subclass). */ - public abstract int error_sym(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Internal flag to indicate when parser should quit. */ - protected boolean _done_parsing = false; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** This method is called to indicate that the parser should quit. This is - * normally called by an accept action, but can be used to cancel parsing - * early in other circumstances if desired. - */ - public void done_parsing() - { - _done_parsing = true; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - /* Global parse state shared by parse(), error recovery, and - * debugging routines */ - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Indication of the index for top of stack (for use by actions). */ - protected int tos; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The current lookahead Symbol. */ - protected Symbol cur_token; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** The parse stack itself. */ - protected Stack stack = new Stack(); - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Direct reference to the production table. */ - protected short[][] production_tab; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Direct reference to the action table. */ - protected short[][] action_tab; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Direct reference to the reduce-goto table. */ - protected short[][] reduce_tab; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** This is the scanner object used by the default implementation - * of scan() to get Symbols. To avoid name conflicts with existing - * code, this field is private. [CSA/davidm] */ - private Scanner _scanner; - - /** - * Simple accessor method to set the default scanner. - */ - public void setScanner(Scanner s) { _scanner = s; } - - /** - * Simple accessor method to get the default scanner. - */ - public Scanner getScanner() { return _scanner; } - - /*-----------------------------------------------------------*/ - /*--- General Methods ---------------------------------------*/ - /*-----------------------------------------------------------*/ - - /** Perform a bit of user supplied action code (supplied by generated - * subclass). Actions are indexed by an internal action number assigned - * at parser generation time. - * - * @param act_num the internal index of the action to be performed. - * @param parser the parser object we are acting for. - * @param stack the parse stack of that object. - * @param top the index of the top element of the parse stack. - */ - public abstract Symbol do_action( - int act_num, - lr_parser parser, - Stack stack, - int top) - throws java.lang.Exception; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** User code for initialization inside the parser. Typically this - * initializes the scanner. This is called before the parser requests - * the first Symbol. Here this is just a placeholder for subclasses that - * might need this and we perform no action. This method is normally - * overridden by the generated code using this contents of the "init with" - * clause as its body. - */ - public void user_init() throws java.lang.Exception { } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Initialize the action object. This is called before the parser does - * any parse actions. This is filled in by generated code to create - * an object that encapsulates all action code. - */ - protected abstract void init_actions() throws java.lang.Exception; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Get the next Symbol from the input (supplied by generated subclass). - * Once end of file has been reached, all subsequent calls to scan - * should return an EOF Symbol (which is Symbol number 0). By default - * this method returns getScanner().next_token(); this implementation - * can be overriden by the generated parser using the code declared in - * the "scan with" clause. Do not recycle objects; every call to - * scan() should return a fresh object. - */ - public Symbol scan() throws java.lang.Exception { - return getScanner().next_token(); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Report a fatal error. This method takes a message string and an - * additional object (to be used by specializations implemented in - * subclasses). Here in the base class a very simple implementation - * is provided which reports the error then throws an exception. - * - * @param message an error message. - * @param info an extra object reserved for use by specialized subclasses. - */ - public void report_fatal_error( - String message, - Object info) - throws java.lang.Exception - { - /* stop parsing (not really necessary since we throw an exception, but) */ - done_parsing(); - - /* use the normal error message reporting to put out the message */ - report_error(message, info); - - /* throw an exception */ - throw new Exception("Can't recover from previous error(s)"); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Report a non fatal error (or warning). This method takes a message - * string and an additional object (to be used by specializations - * implemented in subclasses). Here in the base class a very simple - * implementation is provided which simply prints the message to - * System.err. - * - * @param message an error message. - * @param info an extra object reserved for use by specialized subclasses. - */ - public void report_error(String message, Object info) - { - System.err.print(message); - if (info instanceof Symbol) - if (((Symbol)info).left != -1) - System.err.println(" at character " + ((Symbol)info).left + - " of input"); - else System.err.println(""); - else System.err.println(""); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** This method is called when a syntax error has been detected and recovery - * is about to be invoked. Here in the base class we just emit a - * "Syntax error" error message. - * - * @param cur_token the current lookahead Symbol. - */ - public void syntax_error(Symbol cur_token) - { - report_error("Syntax error", cur_token); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** This method is called if it is determined that syntax error recovery - * has been unsuccessful. Here in the base class we report a fatal error. - * - * @param cur_token the current lookahead Symbol. - */ - public void unrecovered_syntax_error(Symbol cur_token) - throws java.lang.Exception - { - report_fatal_error("Couldn't repair and continue parse", cur_token); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Fetch an action from the action table. The table is broken up into - * rows, one per state (rows are indexed directly by state number). - * Within each row, a list of index, value pairs are given (as sequential - * entries in the table), and the list is terminated by a default entry - * (denoted with a Symbol index of -1). To find the proper entry in a row - * we do a linear or binary search (depending on the size of the row). - * - * @param state the state index of the action being accessed. - * @param sym the Symbol index of the action being accessed. - */ - protected final short get_action(int state, int sym) - { - short tag; - int first, last, probe; - short[] row = action_tab[state]; - - /* linear search if we are < 10 entries */ - if (row.length < 20) - for (probe = 0; probe < row.length; probe++) - { - /* is this entry labeled with our Symbol or the default? */ - tag = row[probe++]; - if (tag == sym || tag == -1) - { - /* return the next entry */ - return row[probe]; - } - } - /* otherwise binary search */ - else - { - first = 0; - last = (row.length-1)/2 - 1; /* leave out trailing default entry */ - while (first <= last) - { - probe = (first+last)/2; - if (sym == row[probe*2]) - return row[probe*2+1]; - else if (sym > row[probe*2]) - first = probe+1; - else - last = probe-1; - } - - /* not found, use the default at the end */ - return row[row.length-1]; - } - - /* shouldn't happened, but if we run off the end we return the - default (error == 0) */ - return 0; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Fetch a state from the reduce-goto table. The table is broken up into - * rows, one per state (rows are indexed directly by state number). - * Within each row, a list of index, value pairs are given (as sequential - * entries in the table), and the list is terminated by a default entry - * (denoted with a Symbol index of -1). To find the proper entry in a row - * we do a linear search. - * - * @param state the state index of the entry being accessed. - * @param sym the Symbol index of the entry being accessed. - */ - protected final short get_reduce(int state, int sym) - { - short tag; - short[] row = reduce_tab[state]; - - /* if we have a null row we go with the default */ - if (row == null) - return -1; - - for (int probe = 0; probe < row.length; probe++) - { - /* is this entry labeled with our Symbol or the default? */ - tag = row[probe++]; - if (tag == sym || tag == -1) - { - /* return the next entry */ - return row[probe]; - } - } - /* if we run off the end we return the default (error == -1) */ - return -1; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** This method provides the main parsing routine. It returns only when - * done_parsing() has been called (typically because the parser has - * accepted, or a fatal error has been reported). See the header - * documentation for the class regarding how shift/reduce parsers operate - * and how the various tables are used. - */ - public Symbol parse() throws java.lang.Exception - { - /* the current action code */ - int act; - - /* the Symbol/stack element returned by a reduce */ - Symbol lhs_sym = null; - - /* information about production being reduced with */ - short handle_size, lhs_sym_num; - - /* set up direct reference to tables to drive the parser */ - - production_tab = production_table(); - action_tab = action_table(); - reduce_tab = reduce_table(); - - /* initialize the action encapsulation object */ - init_actions(); - - /* do user initialization */ - user_init(); - - /* get the first token */ - cur_token = scan(); - - /* push dummy Symbol with start state to get us underway */ - stack.removeAllElements(); - stack.push(new Symbol(0, start_state())); - tos = 0; - - /* continue until we are told to stop */ - for (_done_parsing = false; !_done_parsing; ) - { - /* Check current token for freshness. */ - if (cur_token.used_by_parser) - throw new Error("Symbol recycling detected (fix your scanner)."); - - /* current state is always on the top of the stack */ - - /* look up action out of the current state with the current input */ - act = get_action(((Symbol)stack.peek()).parse_state, cur_token.sym); - - /* decode the action -- > 0 encodes shift */ - if (act > 0) - { - /* shift to the encoded state by pushing it on the stack */ - cur_token.parse_state = act-1; - cur_token.used_by_parser = true; - stack.push(cur_token); - tos++; - - /* advance to the next Symbol */ - cur_token = scan(); - } - /* if its less than zero, then it encodes a reduce action */ - else if (act < 0) - { - /* perform the action for the reduce */ - lhs_sym = do_action((-act)-1, this, stack, tos); - - /* look up information about the production */ - lhs_sym_num = production_tab[(-act)-1][0]; - handle_size = production_tab[(-act)-1][1]; - - /* pop the handle off the stack */ - for (int i = 0; i < handle_size; i++) - { - stack.pop(); - tos--; - } - - /* look up the state to go to from the one popped back to */ - act = get_reduce(((Symbol)stack.peek()).parse_state, lhs_sym_num); - - /* shift to that state */ - lhs_sym.parse_state = act; - lhs_sym.used_by_parser = true; - stack.push(lhs_sym); - tos++; - } - /* finally if the entry is zero, we have an error */ - else if (act == 0) - { - /* call user syntax error reporting routine */ - syntax_error(cur_token); - - /* try to error recover */ - if (!error_recovery(false)) - { - /* if that fails give up with a fatal syntax error */ - unrecovered_syntax_error(cur_token); - - /* just in case that wasn't fatal enough, end parse */ - done_parsing(); - } else { - lhs_sym = (Symbol)stack.peek(); - } - } - } - return lhs_sym; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Write a debugging message to System.err for the debugging version - * of the parser. - * - * @param mess the text of the debugging message. - */ - public void debug_message(String mess) - { - System.err.println(mess); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Dump the parse stack for debugging purposes. */ - public void dump_stack() - { - if (stack == null) - { - debug_message("# Stack dump requested, but stack is null"); - return; - } - - debug_message("============ Parse Stack Dump ============"); - - /* dump the stack */ - for (int i=0; i"); - if ((i%3)==2 || (i==(stack.size()-1))) { - debug_message(sb.toString()); - sb = new StringBuffer(" "); - } - } - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Perform a parse with debugging output. This does exactly the - * same things as parse(), except that it calls debug_shift() and - * debug_reduce() when shift and reduce moves are taken by the parser - * and produces various other debugging messages. - */ - public Symbol debug_parse() - throws java.lang.Exception - { - /* the current action code */ - int act; - - /* the Symbol/stack element returned by a reduce */ - Symbol lhs_sym = null; - - /* information about production being reduced with */ - short handle_size, lhs_sym_num; - - /* set up direct reference to tables to drive the parser */ - production_tab = production_table(); - action_tab = action_table(); - reduce_tab = reduce_table(); - - debug_message("# Initializing parser"); - - /* initialize the action encapsulation object */ - init_actions(); - - /* do user initialization */ - user_init(); - - /* the current Symbol */ - cur_token = scan(); - - debug_message("# Current Symbol is #" + cur_token.sym); - - /* push dummy Symbol with start state to get us underway */ - stack.removeAllElements(); - stack.push(new Symbol(0, start_state())); - tos = 0; - - /* continue until we are told to stop */ - for (_done_parsing = false; !_done_parsing; ) - { - /* Check current token for freshness. */ - if (cur_token.used_by_parser) - throw new Error("Symbol recycling detected (fix your scanner)."); - - /* current state is always on the top of the stack */ - //debug_stack(); - - /* look up action out of the current state with the current input */ - act = get_action(((Symbol)stack.peek()).parse_state, cur_token.sym); - - /* decode the action -- > 0 encodes shift */ - if (act > 0) - { - /* shift to the encoded state by pushing it on the stack */ - cur_token.parse_state = act-1; - cur_token.used_by_parser = true; - debug_shift(cur_token); - stack.push(cur_token); - tos++; - - /* advance to the next Symbol */ - cur_token = scan(); - debug_message("# Current token is " + cur_token); - } - /* if its less than zero, then it encodes a reduce action */ - else if (act < 0) - { - /* perform the action for the reduce */ - lhs_sym = do_action((-act)-1, this, stack, tos); - - /* look up information about the production */ - lhs_sym_num = production_tab[(-act)-1][0]; - handle_size = production_tab[(-act)-1][1]; - - debug_reduce((-act)-1, lhs_sym_num, handle_size); - - /* pop the handle off the stack */ - for (int i = 0; i < handle_size; i++) - { - stack.pop(); - tos--; - } - - /* look up the state to go to from the one popped back to */ - act = get_reduce(((Symbol)stack.peek()).parse_state, lhs_sym_num); - debug_message("# Reduce rule: top state " + - ((Symbol)stack.peek()).parse_state + - ", lhs sym " + lhs_sym_num + " -> state " + act); - - /* shift to that state */ - lhs_sym.parse_state = act; - lhs_sym.used_by_parser = true; - stack.push(lhs_sym); - tos++; - - debug_message("# Goto state #" + act); - } - /* finally if the entry is zero, we have an error */ - else if (act == 0) - { - /* call user syntax error reporting routine */ - syntax_error(cur_token); - - /* try to error recover */ - if (!error_recovery(true)) - { - /* if that fails give up with a fatal syntax error */ - unrecovered_syntax_error(cur_token); - - /* just in case that wasn't fatal enough, end parse */ - done_parsing(); - } else { - lhs_sym = (Symbol)stack.peek(); - } - } - } - return lhs_sym; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - /* Error recovery code */ - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Attempt to recover from a syntax error. This returns false if recovery - * fails, true if it succeeds. Recovery happens in 4 steps. First we - * pop the parse stack down to a point at which we have a shift out - * of the top-most state on the error Symbol. This represents the - * initial error recovery configuration. If no such configuration is - * found, then we fail. Next a small number of "lookahead" or "parse - * ahead" Symbols are read into a buffer. The size of this buffer is - * determined by error_sync_size() and determines how many Symbols beyond - * the error must be matched to consider the recovery a success. Next, - * we begin to discard Symbols in attempt to get past the point of error - * to a point where we can continue parsing. After each Symbol, we attempt - * to "parse ahead" though the buffered lookahead Symbols. The "parse ahead" - * process simulates that actual parse, but does not modify the real - * parser's configuration, nor execute any actions. If we can parse all - * the stored Symbols without error, then the recovery is considered a - * success. Once a successful recovery point is determined, we do an - * actual parse over the stored input -- modifying the real parse - * configuration and executing all actions. Finally, we return the the - * normal parser to continue with the overall parse. - * - * @param debug should we produce debugging messages as we parse. - */ - protected boolean error_recovery(boolean debug) - throws java.lang.Exception - { - if (debug) debug_message("# Attempting error recovery"); - - /* first pop the stack back into a state that can shift on error and - do that shift (if that fails, we fail) */ - if (!find_recovery_config(debug)) - { - if (debug) debug_message("# Error recovery fails"); - return false; - } - - /* read ahead to create lookahead we can parse multiple times */ - read_lookahead(); - - /* repeatedly try to parse forward until we make it the required dist */ - for (;;) - { - /* try to parse forward, if it makes it, bail out of loop */ - if (debug) debug_message("# Trying to parse ahead"); - if (try_parse_ahead(debug)) - { - break; - } - - /* if we are now at EOF, we have failed */ - if (lookahead[0].sym == EOF_sym()) - { - if (debug) debug_message("# Error recovery fails at EOF"); - return false; - } - - /* otherwise, we consume another Symbol and try again */ - if (debug) - debug_message("# Consuming Symbol #" + cur_err_token().sym); - restart_lookahead(); - } - - /* we have consumed to a point where we can parse forward */ - if (debug) debug_message("# Parse-ahead ok, going back to normal parse"); - - /* do the real parse (including actions) across the lookahead */ - parse_lookahead(debug); - - /* we have success */ - return true; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Determine if we can shift under the special error Symbol out of the - * state currently on the top of the (real) parse stack. - */ - protected boolean shift_under_error() - { - /* is there a shift under error Symbol */ - return get_action(((Symbol)stack.peek()).parse_state, error_sym()) > 0; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Put the (real) parse stack into error recovery configuration by - * popping the stack down to a state that can shift on the special - * error Symbol, then doing the shift. If no suitable state exists on - * the stack we return false - * - * @param debug should we produce debugging messages as we parse. - */ - protected boolean find_recovery_config(boolean debug) - { - Symbol error_token; - int act; - - if (debug) debug_message("# Finding recovery state on stack"); - - /* Remember the right-position of the top symbol on the stack */ - int right_pos = ((Symbol)stack.peek()).right; - int left_pos = ((Symbol)stack.peek()).left; - - /* pop down until we can shift under error Symbol */ - while (!shift_under_error()) - { - /* pop the stack */ - if (debug) - debug_message("# Pop stack by one, state was # " + - ((Symbol)stack.peek()).parse_state); - left_pos = ((Symbol)stack.pop()).left; - tos--; - - /* if we have hit bottom, we fail */ - if (stack.empty()) - { - if (debug) debug_message("# No recovery state found on stack"); - return false; - } - } - - /* state on top of the stack can shift under error, find the shift */ - act = get_action(((Symbol)stack.peek()).parse_state, error_sym()); - if (debug) - { - debug_message("# Recover state found (#" + - ((Symbol)stack.peek()).parse_state + ")"); - debug_message("# Shifting on error to state #" + (act-1)); - } - - /* build and shift a special error Symbol */ - error_token = new Symbol(error_sym(), left_pos, right_pos); - error_token.parse_state = act-1; - error_token.used_by_parser = true; - stack.push(error_token); - tos++; - - return true; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Lookahead Symbols used for attempting error recovery "parse aheads". */ - protected Symbol lookahead[]; - - /** Position in lookahead input buffer used for "parse ahead". */ - protected int lookahead_pos; - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Read from input to establish our buffer of "parse ahead" lookahead - * Symbols. - */ - protected void read_lookahead() throws java.lang.Exception - { - /* create the lookahead array */ - lookahead = new Symbol[error_sync_size()]; - - /* fill in the array */ - for (int i = 0; i < error_sync_size(); i++) - { - lookahead[i] = cur_token; - cur_token = scan(); - } - - /* start at the beginning */ - lookahead_pos = 0; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Return the current lookahead in our error "parse ahead" buffer. */ - protected Symbol cur_err_token() { return lookahead[lookahead_pos]; } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Advance to next "parse ahead" input Symbol. Return true if we have - * input to advance to, false otherwise. - */ - protected boolean advance_lookahead() - { - /* advance the input location */ - lookahead_pos++; - - /* return true if we didn't go off the end */ - return lookahead_pos < error_sync_size(); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Reset the parse ahead input to one Symbol past where we started error - * recovery (this consumes one new Symbol from the real input). - */ - protected void restart_lookahead() throws java.lang.Exception - { - /* move all the existing input over */ - for (int i = 1; i < error_sync_size(); i++) - lookahead[i-1] = lookahead[i]; - - /* read a new Symbol into the last spot */ - cur_token = scan(); - lookahead[error_sync_size()-1] = cur_token; - - /* reset our internal position marker */ - lookahead_pos = 0; - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Do a simulated parse forward (a "parse ahead") from the current - * stack configuration using stored lookahead input and a virtual parse - * stack. Return true if we make it all the way through the stored - * lookahead input without error. This basically simulates the action of - * parse() using only our saved "parse ahead" input, and not executing any - * actions. - * - * @param debug should we produce debugging messages as we parse. - */ - protected boolean try_parse_ahead(boolean debug) - throws java.lang.Exception - { - int act; - short lhs, rhs_size; - - /* create a virtual stack from the real parse stack */ - virtual_parse_stack vstack = new virtual_parse_stack(stack); - - /* parse until we fail or get past the lookahead input */ - for (;;) - { - /* look up the action from the current state (on top of stack) */ - act = get_action(vstack.top(), cur_err_token().sym); - - /* if its an error, we fail */ - if (act == 0) return false; - - /* > 0 encodes a shift */ - if (act > 0) - { - /* push the new state on the stack */ - vstack.push(act-1); - - if (debug) debug_message("# Parse-ahead shifts Symbol #" + - cur_err_token().sym + " into state #" + (act-1)); - - /* advance simulated input, if we run off the end, we are done */ - if (!advance_lookahead()) return true; - } - /* < 0 encodes a reduce */ - else - { - /* if this is a reduce with the start production we are done */ - if ((-act)-1 == start_production()) - { - if (debug) debug_message("# Parse-ahead accepts"); - return true; - } - - /* get the lhs Symbol and the rhs size */ - lhs = production_tab[(-act)-1][0]; - rhs_size = production_tab[(-act)-1][1]; - - /* pop handle off the stack */ - for (int i = 0; i < rhs_size; i++) - vstack.pop(); - - if (debug) - debug_message("# Parse-ahead reduces: handle size = " + - rhs_size + " lhs = #" + lhs + " from state #" + vstack.top()); - - /* look up goto and push it onto the stack */ - vstack.push(get_reduce(vstack.top(), lhs)); - if (debug) - debug_message("# Goto state #" + vstack.top()); - } - } - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Parse forward using stored lookahead Symbols. In this case we have - * already verified that parsing will make it through the stored lookahead - * Symbols and we are now getting back to the point at which we can hand - * control back to the normal parser. Consequently, this version of the - * parser performs all actions and modifies the real parse configuration. - * This returns once we have consumed all the stored input or we accept. - * - * @param debug should we produce debugging messages as we parse. - */ - protected void parse_lookahead(boolean debug) - throws java.lang.Exception - { - /* the current action code */ - int act; - - /* the Symbol/stack element returned by a reduce */ - Symbol lhs_sym = null; - - /* information about production being reduced with */ - short handle_size, lhs_sym_num; - - /* restart the saved input at the beginning */ - lookahead_pos = 0; - - if (debug) - { - debug_message("# Reparsing saved input with actions"); - debug_message("# Current Symbol is #" + cur_err_token().sym); - debug_message("# Current state is #" + - ((Symbol)stack.peek()).parse_state); - } - - /* continue until we accept or have read all lookahead input */ - while(!_done_parsing) - { - /* current state is always on the top of the stack */ - - /* look up action out of the current state with the current input */ - act = - get_action(((Symbol)stack.peek()).parse_state, cur_err_token().sym); - - /* decode the action -- > 0 encodes shift */ - if (act > 0) - { - /* shift to the encoded state by pushing it on the stack */ - cur_err_token().parse_state = act-1; - cur_err_token().used_by_parser = true; - if (debug) debug_shift(cur_err_token()); - stack.push(cur_err_token()); - tos++; - - /* advance to the next Symbol, if there is none, we are done */ - if (!advance_lookahead()) - { - if (debug) debug_message("# Completed reparse"); - - /* scan next Symbol so we can continue parse */ - // BUGFIX by Chris Harris : - // correct a one-off error by commenting out - // this next line. - /*cur_token = scan();*/ - - /* go back to normal parser */ - return; - } - - if (debug) - debug_message("# Current Symbol is #" + cur_err_token().sym); - } - /* if its less than zero, then it encodes a reduce action */ - else if (act < 0) - { - /* perform the action for the reduce */ - lhs_sym = do_action((-act)-1, this, stack, tos); - - /* look up information about the production */ - lhs_sym_num = production_tab[(-act)-1][0]; - handle_size = production_tab[(-act)-1][1]; - - if (debug) debug_reduce((-act)-1, lhs_sym_num, handle_size); - - /* pop the handle off the stack */ - for (int i = 0; i < handle_size; i++) - { - stack.pop(); - tos--; - } - - /* look up the state to go to from the one popped back to */ - act = get_reduce(((Symbol)stack.peek()).parse_state, lhs_sym_num); - - /* shift to that state */ - lhs_sym.parse_state = act; - lhs_sym.used_by_parser = true; - stack.push(lhs_sym); - tos++; - - if (debug) debug_message("# Goto state #" + act); - - } - /* finally if the entry is zero, we have an error - (shouldn't happen here, but...)*/ - else if (act == 0) - { - report_fatal_error("Syntax error", lhs_sym); - return; - } - } - - - } - - /*-----------------------------------------------------------*/ - - /** Utility function: unpacks parse tables from strings */ - protected static short[][] unpackFromStrings(String[] sa) - { - // Concatanate initialization strings. - StringBuffer sb = new StringBuffer(sa[0]); - for (int i=1; i= real_stack.size()) return; - - /* get a copy of the first Symbol we have not transfered */ - stack_sym = (Symbol)real_stack.elementAt(real_stack.size()-1-real_next); - - /* record the transfer */ - real_next++; - - /* put the state number from the Symbol onto the virtual stack */ - vstack.push(new Integer(stack_sym.parse_state)); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Indicate whether the stack is empty. */ - public boolean empty() - { - /* if vstack is empty then we were unable to transfer onto it and - the whole thing is empty. */ - return vstack.empty(); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Return value on the top of the stack (without popping it). */ - public int top() throws java.lang.Exception - { - if (vstack.empty()) - throw new Exception( - "Internal parser error: top() called on empty virtual stack"); - - return ((Integer)vstack.peek()).intValue(); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Pop the stack. */ - public void pop() throws java.lang.Exception - { - if (vstack.empty()) - throw new Exception( - "Internal parser error: pop from empty virtual stack"); - - /* pop it */ - vstack.pop(); - - /* if we are now empty transfer an element (if there is one) */ - if (vstack.empty()) - get_from_real(); - } - - /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ - - /** Push a state number onto the stack. */ - public void push(int state_num) - { - vstack.push(new Integer(state_num)); - } - - /*-----------------------------------------------------------*/ - -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/Constants.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/Constants.java deleted file mode 100644 index ac4ae3e3e37..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/Constants.java +++ /dev/null @@ -1,788 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -/** - * Constants for the project, mostly defined in the JVM specification. - * - * @author M. Dahm - */ -public interface Constants { - /** Major and minor version of the code. - */ - public final static short MAJOR_1_1 = 45; - public final static short MINOR_1_1 = 3; - public final static short MAJOR_1_2 = 46; - public final static short MINOR_1_2 = 0; - public final static short MAJOR_1_3 = 47; - public final static short MINOR_1_3 = 0; - public final static short MAJOR = MAJOR_1_1; // Defaults - public final static short MINOR = MINOR_1_1; - - /** Maximum value for an unsigned short. - */ - public final static int MAX_SHORT = 65535; // 2^16 - 1 - - /** Maximum value for an unsigned byte. - */ - public final static int MAX_BYTE = 255; // 2^8 - 1 - - /** Access flags for classes, fields and methods. - */ - public final static short ACC_PUBLIC = 0x0001; - public final static short ACC_PRIVATE = 0x0002; - public final static short ACC_PROTECTED = 0x0004; - public final static short ACC_STATIC = 0x0008; - - public final static short ACC_FINAL = 0x0010; - public final static short ACC_SYNCHRONIZED = 0x0020; - public final static short ACC_VOLATILE = 0x0040; - public final static short ACC_TRANSIENT = 0x0080; - - public final static short ACC_NATIVE = 0x0100; - public final static short ACC_INTERFACE = 0x0200; - public final static short ACC_ABSTRACT = 0x0400; - public final static short ACC_STRICT = 0x0800; - - // Applies to classes compiled by new compilers only - public final static short ACC_SUPER = 0x0020; - - public final static short MAX_ACC_FLAG = ACC_STRICT; - - public final static String[] ACCESS_NAMES = { - "public", "private", "protected", "static", "final", "synchronized", - "volatile", "transient", "native", "interface", "abstract", "strictfp" - }; - - /** Tags in constant pool to denote type of constant. - */ - public final static byte CONSTANT_Utf8 = 1; - public final static byte CONSTANT_Integer = 3; - public final static byte CONSTANT_Float = 4; - public final static byte CONSTANT_Long = 5; - public final static byte CONSTANT_Double = 6; - public final static byte CONSTANT_Class = 7; - public final static byte CONSTANT_Fieldref = 9; - public final static byte CONSTANT_String = 8; - public final static byte CONSTANT_Methodref = 10; - public final static byte CONSTANT_InterfaceMethodref = 11; - public final static byte CONSTANT_NameAndType = 12; - - public final static String[] CONSTANT_NAMES = { - "", "CONSTANT_Utf8", "", "CONSTANT_Integer", - "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double", - "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref", - "CONSTANT_Methodref", "CONSTANT_InterfaceMethodref", - "CONSTANT_NameAndType" }; - - /** The name of the static initializer, also called "class - * initialization method" or "interface initialization - * method". This is "<clinit>". - */ - public final static String STATIC_INITIALIZER_NAME = ""; - - /** The name of every constructor method in a class, also called - * "instance initialization method". This is "<init>". - */ - public final static String CONSTRUCTOR_NAME = ""; - - /** The names of the interfaces implemented by arrays */ - public final static String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"}; - - /** - * Limitations of the Java Virtual Machine. - * See The Java Virtual Machine Specification, Second Edition, page 152, chapter 4.10. - */ - public static final int MAX_CP_ENTRIES = 65535; - public static final int MAX_CODE_SIZE = 65536; //bytes - - /** Java VM opcodes. - */ - public static final short NOP = 0; - public static final short ACONST_NULL = 1; - public static final short ICONST_M1 = 2; - public static final short ICONST_0 = 3; - public static final short ICONST_1 = 4; - public static final short ICONST_2 = 5; - public static final short ICONST_3 = 6; - public static final short ICONST_4 = 7; - public static final short ICONST_5 = 8; - public static final short LCONST_0 = 9; - public static final short LCONST_1 = 10; - public static final short FCONST_0 = 11; - public static final short FCONST_1 = 12; - public static final short FCONST_2 = 13; - public static final short DCONST_0 = 14; - public static final short DCONST_1 = 15; - public static final short BIPUSH = 16; - public static final short SIPUSH = 17; - public static final short LDC = 18; - public static final short LDC_W = 19; - public static final short LDC2_W = 20; - public static final short ILOAD = 21; - public static final short LLOAD = 22; - public static final short FLOAD = 23; - public static final short DLOAD = 24; - public static final short ALOAD = 25; - public static final short ILOAD_0 = 26; - public static final short ILOAD_1 = 27; - public static final short ILOAD_2 = 28; - public static final short ILOAD_3 = 29; - public static final short LLOAD_0 = 30; - public static final short LLOAD_1 = 31; - public static final short LLOAD_2 = 32; - public static final short LLOAD_3 = 33; - public static final short FLOAD_0 = 34; - public static final short FLOAD_1 = 35; - public static final short FLOAD_2 = 36; - public static final short FLOAD_3 = 37; - public static final short DLOAD_0 = 38; - public static final short DLOAD_1 = 39; - public static final short DLOAD_2 = 40; - public static final short DLOAD_3 = 41; - public static final short ALOAD_0 = 42; - public static final short ALOAD_1 = 43; - public static final short ALOAD_2 = 44; - public static final short ALOAD_3 = 45; - public static final short IALOAD = 46; - public static final short LALOAD = 47; - public static final short FALOAD = 48; - public static final short DALOAD = 49; - public static final short AALOAD = 50; - public static final short BALOAD = 51; - public static final short CALOAD = 52; - public static final short SALOAD = 53; - public static final short ISTORE = 54; - public static final short LSTORE = 55; - public static final short FSTORE = 56; - public static final short DSTORE = 57; - public static final short ASTORE = 58; - public static final short ISTORE_0 = 59; - public static final short ISTORE_1 = 60; - public static final short ISTORE_2 = 61; - public static final short ISTORE_3 = 62; - public static final short LSTORE_0 = 63; - public static final short LSTORE_1 = 64; - public static final short LSTORE_2 = 65; - public static final short LSTORE_3 = 66; - public static final short FSTORE_0 = 67; - public static final short FSTORE_1 = 68; - public static final short FSTORE_2 = 69; - public static final short FSTORE_3 = 70; - public static final short DSTORE_0 = 71; - public static final short DSTORE_1 = 72; - public static final short DSTORE_2 = 73; - public static final short DSTORE_3 = 74; - public static final short ASTORE_0 = 75; - public static final short ASTORE_1 = 76; - public static final short ASTORE_2 = 77; - public static final short ASTORE_3 = 78; - public static final short IASTORE = 79; - public static final short LASTORE = 80; - public static final short FASTORE = 81; - public static final short DASTORE = 82; - public static final short AASTORE = 83; - public static final short BASTORE = 84; - public static final short CASTORE = 85; - public static final short SASTORE = 86; - public static final short POP = 87; - public static final short POP2 = 88; - public static final short DUP = 89; - public static final short DUP_X1 = 90; - public static final short DUP_X2 = 91; - public static final short DUP2 = 92; - public static final short DUP2_X1 = 93; - public static final short DUP2_X2 = 94; - public static final short SWAP = 95; - public static final short IADD = 96; - public static final short LADD = 97; - public static final short FADD = 98; - public static final short DADD = 99; - public static final short ISUB = 100; - public static final short LSUB = 101; - public static final short FSUB = 102; - public static final short DSUB = 103; - public static final short IMUL = 104; - public static final short LMUL = 105; - public static final short FMUL = 106; - public static final short DMUL = 107; - public static final short IDIV = 108; - public static final short LDIV = 109; - public static final short FDIV = 110; - public static final short DDIV = 111; - public static final short IREM = 112; - public static final short LREM = 113; - public static final short FREM = 114; - public static final short DREM = 115; - public static final short INEG = 116; - public static final short LNEG = 117; - public static final short FNEG = 118; - public static final short DNEG = 119; - public static final short ISHL = 120; - public static final short LSHL = 121; - public static final short ISHR = 122; - public static final short LSHR = 123; - public static final short IUSHR = 124; - public static final short LUSHR = 125; - public static final short IAND = 126; - public static final short LAND = 127; - public static final short IOR = 128; - public static final short LOR = 129; - public static final short IXOR = 130; - public static final short LXOR = 131; - public static final short IINC = 132; - public static final short I2L = 133; - public static final short I2F = 134; - public static final short I2D = 135; - public static final short L2I = 136; - public static final short L2F = 137; - public static final short L2D = 138; - public static final short F2I = 139; - public static final short F2L = 140; - public static final short F2D = 141; - public static final short D2I = 142; - public static final short D2L = 143; - public static final short D2F = 144; - public static final short I2B = 145; - public static final short INT2BYTE = 145; // Old notion - public static final short I2C = 146; - public static final short INT2CHAR = 146; // Old notion - public static final short I2S = 147; - public static final short INT2SHORT = 147; // Old notion - public static final short LCMP = 148; - public static final short FCMPL = 149; - public static final short FCMPG = 150; - public static final short DCMPL = 151; - public static final short DCMPG = 152; - public static final short IFEQ = 153; - public static final short IFNE = 154; - public static final short IFLT = 155; - public static final short IFGE = 156; - public static final short IFGT = 157; - public static final short IFLE = 158; - public static final short IF_ICMPEQ = 159; - public static final short IF_ICMPNE = 160; - public static final short IF_ICMPLT = 161; - public static final short IF_ICMPGE = 162; - public static final short IF_ICMPGT = 163; - public static final short IF_ICMPLE = 164; - public static final short IF_ACMPEQ = 165; - public static final short IF_ACMPNE = 166; - public static final short GOTO = 167; - public static final short JSR = 168; - public static final short RET = 169; - public static final short TABLESWITCH = 170; - public static final short LOOKUPSWITCH = 171; - public static final short IRETURN = 172; - public static final short LRETURN = 173; - public static final short FRETURN = 174; - public static final short DRETURN = 175; - public static final short ARETURN = 176; - public static final short RETURN = 177; - public static final short GETSTATIC = 178; - public static final short PUTSTATIC = 179; - public static final short GETFIELD = 180; - public static final short PUTFIELD = 181; - public static final short INVOKEVIRTUAL = 182; - public static final short INVOKESPECIAL = 183; - public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0 - public static final short INVOKESTATIC = 184; - public static final short INVOKEINTERFACE = 185; - public static final short NEW = 187; - public static final short NEWARRAY = 188; - public static final short ANEWARRAY = 189; - public static final short ARRAYLENGTH = 190; - public static final short ATHROW = 191; - public static final short CHECKCAST = 192; - public static final short INSTANCEOF = 193; - public static final short MONITORENTER = 194; - public static final short MONITOREXIT = 195; - public static final short WIDE = 196; - public static final short MULTIANEWARRAY = 197; - public static final short IFNULL = 198; - public static final short IFNONNULL = 199; - public static final short GOTO_W = 200; - public static final short JSR_W = 201; - - /** - * Non-legal opcodes, may be used by JVM internally. - */ - public static final short BREAKPOINT = 202; - public static final short LDC_QUICK = 203; - public static final short LDC_W_QUICK = 204; - public static final short LDC2_W_QUICK = 205; - public static final short GETFIELD_QUICK = 206; - public static final short PUTFIELD_QUICK = 207; - public static final short GETFIELD2_QUICK = 208; - public static final short PUTFIELD2_QUICK = 209; - public static final short GETSTATIC_QUICK = 210; - public static final short PUTSTATIC_QUICK = 211; - public static final short GETSTATIC2_QUICK = 212; - public static final short PUTSTATIC2_QUICK = 213; - public static final short INVOKEVIRTUAL_QUICK = 214; - public static final short INVOKENONVIRTUAL_QUICK = 215; - public static final short INVOKESUPER_QUICK = 216; - public static final short INVOKESTATIC_QUICK = 217; - public static final short INVOKEINTERFACE_QUICK = 218; - public static final short INVOKEVIRTUALOBJECT_QUICK = 219; - public static final short NEW_QUICK = 221; - public static final short ANEWARRAY_QUICK = 222; - public static final short MULTIANEWARRAY_QUICK = 223; - public static final short CHECKCAST_QUICK = 224; - public static final short INSTANCEOF_QUICK = 225; - public static final short INVOKEVIRTUAL_QUICK_W = 226; - public static final short GETFIELD_QUICK_W = 227; - public static final short PUTFIELD_QUICK_W = 228; - public static final short IMPDEP1 = 254; - public static final short IMPDEP2 = 255; - - /** - * For internal purposes only. - */ - public static final short PUSH = 4711; - public static final short SWITCH = 4712; - - /** - * Illegal codes - */ - public static final short UNDEFINED = -1; - public static final short UNPREDICTABLE = -2; - public static final short RESERVED = -3; - public static final String ILLEGAL_OPCODE = ""; - public static final String ILLEGAL_TYPE = ""; - - public static final byte T_BOOLEAN = 4; - public static final byte T_CHAR = 5; - public static final byte T_FLOAT = 6; - public static final byte T_DOUBLE = 7; - public static final byte T_BYTE = 8; - public static final byte T_SHORT = 9; - public static final byte T_INT = 10; - public static final byte T_LONG = 11; - - public static final byte T_VOID = 12; // Non-standard - public static final byte T_ARRAY = 13; - public static final byte T_OBJECT = 14; - public static final byte T_REFERENCE = 14; // Deprecated - public static final byte T_UNKNOWN = 15; - public static final byte T_ADDRESS = 16; - - /** The primitive type names corresponding to the T_XX constants, - * e.g., TYPE_NAMES[T_INT] = "int" - */ - public static final String[] TYPE_NAMES = { - ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, - "boolean", "char", "float", "double", "byte", "short", "int", "long", - "void", "array", "object", "unknown" // Non-standard - }; - - /** The primitive class names corresponding to the T_XX constants, - * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer" - */ - public static final String[] CLASS_TYPE_NAMES = { - ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, - "java.lang.Boolean", "java.lang.Character", "java.lang.Float", - "java.lang.Double", "java.lang.Byte", "java.lang.Short", - "java.lang.Integer", "java.lang.Long", "java.lang.Void", - ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE - }; - - /** The signature characters corresponding to primitive types, - * e.g., SHORT_TYPE_NAMES[T_INT] = "I" - */ - public static final String[] SHORT_TYPE_NAMES = { - ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, - "Z", "C", "F", "D", "B", "S", "I", "J", - "V", ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE - }; - - /** - * Number of byte code operands, i.e., number of bytes after the tag byte - * itself. - */ - public static final short[] NO_OF_OPERANDS = { - 0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/, - 0/*iconst_1*/, 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/, - 0/*iconst_5*/, 0/*lconst_0*/, 0/*lconst_1*/, 0/*fconst_0*/, - 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/, 0/*dconst_1*/, - 1/*bipush*/, 2/*sipush*/, 1/*ldc*/, 2/*ldc_w*/, 2/*ldc2_w*/, - 1/*iload*/, 1/*lload*/, 1/*fload*/, 1/*dload*/, 1/*aload*/, - 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/, 0/*iload_3*/, - 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/, - 0/*fload_0*/, 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/, - 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/, 0/*dload_3*/, - 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/, - 0/*iaload*/, 0/*laload*/, 0/*faload*/, 0/*daload*/, - 0/*aaload*/, 0/*baload*/, 0/*caload*/, 0/*saload*/, - 1/*istore*/, 1/*lstore*/, 1/*fstore*/, 1/*dstore*/, - 1/*astore*/, 0/*istore_0*/, 0/*istore_1*/, 0/*istore_2*/, - 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/, 0/*lstore_2*/, - 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/, - 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, - 0/*dstore_3*/, 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, - 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/, 0/*fastore*/, - 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, - 0/*sastore*/, 0/*pop*/, 0/*pop2*/, 0/*dup*/, 0/*dup_x1*/, - 0/*dup_x2*/, 0/*dup2*/, 0/*dup2_x1*/, 0/*dup2_x2*/, 0/*swap*/, - 0/*iadd*/, 0/*ladd*/, 0/*fadd*/, 0/*dadd*/, 0/*isub*/, - 0/*lsub*/, 0/*fsub*/, 0/*dsub*/, 0/*imul*/, 0/*lmul*/, - 0/*fmul*/, 0/*dmul*/, 0/*idiv*/, 0/*ldiv*/, 0/*fdiv*/, - 0/*ddiv*/, 0/*irem*/, 0/*lrem*/, 0/*frem*/, 0/*drem*/, - 0/*ineg*/, 0/*lneg*/, 0/*fneg*/, 0/*dneg*/, 0/*ishl*/, - 0/*lshl*/, 0/*ishr*/, 0/*lshr*/, 0/*iushr*/, 0/*lushr*/, - 0/*iand*/, 0/*land*/, 0/*ior*/, 0/*lor*/, 0/*ixor*/, 0/*lxor*/, - 2/*iinc*/, 0/*i2l*/, 0/*i2f*/, 0/*i2d*/, 0/*l2i*/, 0/*l2f*/, - 0/*l2d*/, 0/*f2i*/, 0/*f2l*/, 0/*f2d*/, 0/*d2i*/, 0/*d2l*/, - 0/*d2f*/, 0/*i2b*/, 0/*i2c*/, 0/*i2s*/, 0/*lcmp*/, 0/*fcmpl*/, - 0/*fcmpg*/, 0/*dcmpl*/, 0/*dcmpg*/, 2/*ifeq*/, 2/*ifne*/, - 2/*iflt*/, 2/*ifge*/, 2/*ifgt*/, 2/*ifle*/, 2/*if_icmpeq*/, - 2/*if_icmpne*/, 2/*if_icmplt*/, 2/*if_icmpge*/, 2/*if_icmpgt*/, - 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/, 2/*goto*/, - 2/*jsr*/, 1/*ret*/, UNPREDICTABLE/*tableswitch*/, UNPREDICTABLE/*lookupswitch*/, - 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/, - 0/*dreturn*/, 0/*areturn*/, 0/*return*/, - 2/*getstatic*/, 2/*putstatic*/, 2/*getfield*/, - 2/*putfield*/, 2/*invokevirtual*/, 2/*invokespecial*/, 2/*invokestatic*/, - 4/*invokeinterface*/, UNDEFINED, 2/*new*/, - 1/*newarray*/, 2/*anewarray*/, - 0/*arraylength*/, 0/*athrow*/, 2/*checkcast*/, - 2/*instanceof*/, 0/*monitorenter*/, - 0/*monitorexit*/, UNPREDICTABLE/*wide*/, 3/*multianewarray*/, - 2/*ifnull*/, 2/*ifnonnull*/, 4/*goto_w*/, - 4/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, RESERVED/*impdep1*/, RESERVED/*impdep2*/ - }; - - /** - * How the byte code operands are to be interpreted. - */ - public static final short[][] TYPE_OF_OPERANDS = { - {}/*nop*/, {}/*aconst_null*/, {}/*iconst_m1*/, {}/*iconst_0*/, - {}/*iconst_1*/, {}/*iconst_2*/, {}/*iconst_3*/, {}/*iconst_4*/, - {}/*iconst_5*/, {}/*lconst_0*/, {}/*lconst_1*/, {}/*fconst_0*/, - {}/*fconst_1*/, {}/*fconst_2*/, {}/*dconst_0*/, {}/*dconst_1*/, - {T_BYTE}/*bipush*/, {T_SHORT}/*sipush*/, {T_BYTE}/*ldc*/, - {T_SHORT}/*ldc_w*/, {T_SHORT}/*ldc2_w*/, - {T_BYTE}/*iload*/, {T_BYTE}/*lload*/, {T_BYTE}/*fload*/, - {T_BYTE}/*dload*/, {T_BYTE}/*aload*/, {}/*iload_0*/, - {}/*iload_1*/, {}/*iload_2*/, {}/*iload_3*/, {}/*lload_0*/, - {}/*lload_1*/, {}/*lload_2*/, {}/*lload_3*/, {}/*fload_0*/, - {}/*fload_1*/, {}/*fload_2*/, {}/*fload_3*/, {}/*dload_0*/, - {}/*dload_1*/, {}/*dload_2*/, {}/*dload_3*/, {}/*aload_0*/, - {}/*aload_1*/, {}/*aload_2*/, {}/*aload_3*/, {}/*iaload*/, - {}/*laload*/, {}/*faload*/, {}/*daload*/, {}/*aaload*/, - {}/*baload*/, {}/*caload*/, {}/*saload*/, {T_BYTE}/*istore*/, - {T_BYTE}/*lstore*/, {T_BYTE}/*fstore*/, {T_BYTE}/*dstore*/, - {T_BYTE}/*astore*/, {}/*istore_0*/, {}/*istore_1*/, - {}/*istore_2*/, {}/*istore_3*/, {}/*lstore_0*/, {}/*lstore_1*/, - {}/*lstore_2*/, {}/*lstore_3*/, {}/*fstore_0*/, {}/*fstore_1*/, - {}/*fstore_2*/, {}/*fstore_3*/, {}/*dstore_0*/, {}/*dstore_1*/, - {}/*dstore_2*/, {}/*dstore_3*/, {}/*astore_0*/, {}/*astore_1*/, - {}/*astore_2*/, {}/*astore_3*/, {}/*iastore*/, {}/*lastore*/, - {}/*fastore*/, {}/*dastore*/, {}/*aastore*/, {}/*bastore*/, - {}/*castore*/, {}/*sastore*/, {}/*pop*/, {}/*pop2*/, {}/*dup*/, - {}/*dup_x1*/, {}/*dup_x2*/, {}/*dup2*/, {}/*dup2_x1*/, - {}/*dup2_x2*/, {}/*swap*/, {}/*iadd*/, {}/*ladd*/, {}/*fadd*/, - {}/*dadd*/, {}/*isub*/, {}/*lsub*/, {}/*fsub*/, {}/*dsub*/, - {}/*imul*/, {}/*lmul*/, {}/*fmul*/, {}/*dmul*/, {}/*idiv*/, - {}/*ldiv*/, {}/*fdiv*/, {}/*ddiv*/, {}/*irem*/, {}/*lrem*/, - {}/*frem*/, {}/*drem*/, {}/*ineg*/, {}/*lneg*/, {}/*fneg*/, - {}/*dneg*/, {}/*ishl*/, {}/*lshl*/, {}/*ishr*/, {}/*lshr*/, - {}/*iushr*/, {}/*lushr*/, {}/*iand*/, {}/*land*/, {}/*ior*/, - {}/*lor*/, {}/*ixor*/, {}/*lxor*/, {T_BYTE, T_BYTE}/*iinc*/, - {}/*i2l*/, {}/*i2f*/, {}/*i2d*/, {}/*l2i*/, {}/*l2f*/, {}/*l2d*/, - {}/*f2i*/, {}/*f2l*/, {}/*f2d*/, {}/*d2i*/, {}/*d2l*/, {}/*d2f*/, - {}/*i2b*/, {}/*i2c*/,{}/*i2s*/, {}/*lcmp*/, {}/*fcmpl*/, - {}/*fcmpg*/, {}/*dcmpl*/, {}/*dcmpg*/, {T_SHORT}/*ifeq*/, - {T_SHORT}/*ifne*/, {T_SHORT}/*iflt*/, {T_SHORT}/*ifge*/, - {T_SHORT}/*ifgt*/, {T_SHORT}/*ifle*/, {T_SHORT}/*if_icmpeq*/, - {T_SHORT}/*if_icmpne*/, {T_SHORT}/*if_icmplt*/, - {T_SHORT}/*if_icmpge*/, {T_SHORT}/*if_icmpgt*/, - {T_SHORT}/*if_icmple*/, {T_SHORT}/*if_acmpeq*/, - {T_SHORT}/*if_acmpne*/, {T_SHORT}/*goto*/, {T_SHORT}/*jsr*/, - {T_BYTE}/*ret*/, {}/*tableswitch*/, {}/*lookupswitch*/, - {}/*ireturn*/, {}/*lreturn*/, {}/*freturn*/, {}/*dreturn*/, - {}/*areturn*/, {}/*return*/, {T_SHORT}/*getstatic*/, - {T_SHORT}/*putstatic*/, {T_SHORT}/*getfield*/, - {T_SHORT}/*putfield*/, {T_SHORT}/*invokevirtual*/, - {T_SHORT}/*invokespecial*/, {T_SHORT}/*invokestatic*/, - {T_SHORT, T_BYTE, T_BYTE}/*invokeinterface*/, {}, - {T_SHORT}/*new*/, {T_BYTE}/*newarray*/, - {T_SHORT}/*anewarray*/, {}/*arraylength*/, {}/*athrow*/, - {T_SHORT}/*checkcast*/, {T_SHORT}/*instanceof*/, - {}/*monitorenter*/, {}/*monitorexit*/, {T_BYTE}/*wide*/, - {T_SHORT, T_BYTE}/*multianewarray*/, {T_SHORT}/*ifnull*/, - {T_SHORT}/*ifnonnull*/, {T_INT}/*goto_w*/, {T_INT}/*jsr_w*/, - {}/*breakpoint*/, {}, {}, {}, {}, {}, {}, {}, - {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, - {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, - {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, - {}/*impdep1*/, {}/*impdep2*/ - }; - - /** - * Names of opcodes. - */ - public static final String[] OPCODE_NAMES = { - "nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1", - "iconst_2", "iconst_3", "iconst_4", "iconst_5", "lconst_0", - "lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0", - "dconst_1", "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload", - "lload", "fload", "dload", "aload", "iload_0", "iload_1", "iload_2", - "iload_3", "lload_0", "lload_1", "lload_2", "lload_3", "fload_0", - "fload_1", "fload_2", "fload_3", "dload_0", "dload_1", "dload_2", - "dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload", - "laload", "faload", "daload", "aaload", "baload", "caload", "saload", - "istore", "lstore", "fstore", "dstore", "astore", "istore_0", - "istore_1", "istore_2", "istore_3", "lstore_0", "lstore_1", - "lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2", - "fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3", - "astore_0", "astore_1", "astore_2", "astore_3", "iastore", "lastore", - "fastore", "dastore", "aastore", "bastore", "castore", "sastore", - "pop", "pop2", "dup", "dup_x1", "dup_x2", "dup2", "dup2_x1", - "dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub", - "fsub", "dsub", "imul", "lmul", "fmul", "dmul", "idiv", "ldiv", - "fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg", - "fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr", - "iand", "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f", - "i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", "d2f", - "i2b", "i2c", "i2s", "lcmp", "fcmpl", "fcmpg", - "dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle", - "if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge", "if_icmpgt", - "if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret", - "tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn", - "dreturn", "areturn", "return", "getstatic", "putstatic", "getfield", - "putfield", "invokevirtual", "invokespecial", "invokestatic", - "invokeinterface", ILLEGAL_OPCODE, "new", "newarray", "anewarray", - "arraylength", "athrow", "checkcast", "instanceof", "monitorenter", - "monitorexit", "wide", "multianewarray", "ifnull", "ifnonnull", - "goto_w", "jsr_w", "breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, - ILLEGAL_OPCODE, "impdep1", "impdep2" - }; - - /** - * Number of words consumed on operand stack by instructions. - */ - public static final int[] CONSUME_STACK = { - 0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/, 0/*iconst_1*/, - 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/, 0/*iconst_5*/, 0/*lconst_0*/, - 0/*lconst_1*/, 0/*fconst_0*/, 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/, - 0/*dconst_1*/, 0/*bipush*/, 0/*sipush*/, 0/*ldc*/, 0/*ldc_w*/, 0/*ldc2_w*/, 0/*iload*/, - 0/*lload*/, 0/*fload*/, 0/*dload*/, 0/*aload*/, 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/, - 0/*iload_3*/, 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/, 0/*fload_0*/, - 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/, 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/, - 0/*dload_3*/, 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/, 2/*iaload*/, - 2/*laload*/, 2/*faload*/, 2/*daload*/, 2/*aaload*/, 2/*baload*/, 2/*caload*/, 2/*saload*/, - 1/*istore*/, 2/*lstore*/, 1/*fstore*/, 2/*dstore*/, 1/*astore*/, 1/*istore_0*/, - 1/*istore_1*/, 1/*istore_2*/, 1/*istore_3*/, 2/*lstore_0*/, 2/*lstore_1*/, - 2/*lstore_2*/, 2/*lstore_3*/, 1/*fstore_0*/, 1/*fstore_1*/, 1/*fstore_2*/, - 1/*fstore_3*/, 2/*dstore_0*/, 2/*dstore_1*/, 2/*dstore_2*/, 2/*dstore_3*/, - 1/*astore_0*/, 1/*astore_1*/, 1/*astore_2*/, 1/*astore_3*/, 3/*iastore*/, 4/*lastore*/, - 3/*fastore*/, 4/*dastore*/, 3/*aastore*/, 3/*bastore*/, 3/*castore*/, 3/*sastore*/, - 1/*pop*/, 2/*pop2*/, 1/*dup*/, 2/*dup_x1*/, 3/*dup_x2*/, 2/*dup2*/, 3/*dup2_x1*/, - 4/*dup2_x2*/, 2/*swap*/, 2/*iadd*/, 4/*ladd*/, 2/*fadd*/, 4/*dadd*/, 2/*isub*/, 4/*lsub*/, - 2/*fsub*/, 4/*dsub*/, 2/*imul*/, 4/*lmul*/, 2/*fmul*/, 4/*dmul*/, 2/*idiv*/, 4/*ldiv*/, - 2/*fdiv*/, 4/*ddiv*/, 2/*irem*/, 4/*lrem*/, 2/*frem*/, 4/*drem*/, 1/*ineg*/, 2/*lneg*/, - 1/*fneg*/, 2/*dneg*/, 2/*ishl*/, 3/*lshl*/, 2/*ishr*/, 3/*lshr*/, 2/*iushr*/, 3/*lushr*/, - 2/*iand*/, 4/*land*/, 2/*ior*/, 4/*lor*/, 2/*ixor*/, 4/*lxor*/, 0/*iinc*/, - 1/*i2l*/, 1/*i2f*/, 1/*i2d*/, 2/*l2i*/, 2/*l2f*/, 2/*l2d*/, 1/*f2i*/, 1/*f2l*/, - 1/*f2d*/, 2/*d2i*/, 2/*d2l*/, 2/*d2f*/, 1/*i2b*/, 1/*i2c*/, 1/*i2s*/, - 4/*lcmp*/, 2/*fcmpl*/, 2/*fcmpg*/, 4/*dcmpl*/, 4/*dcmpg*/, 1/*ifeq*/, 1/*ifne*/, - 1/*iflt*/, 1/*ifge*/, 1/*ifgt*/, 1/*ifle*/, 2/*if_icmpeq*/, 2/*if_icmpne*/, 2/*if_icmplt*/, - 2 /*if_icmpge*/, 2/*if_icmpgt*/, 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/, - 0/*goto*/, 0/*jsr*/, 0/*ret*/, 1/*tableswitch*/, 1/*lookupswitch*/, 1/*ireturn*/, - 2/*lreturn*/, 1/*freturn*/, 2/*dreturn*/, 1/*areturn*/, 0/*return*/, 0/*getstatic*/, - UNPREDICTABLE/*putstatic*/, 1/*getfield*/, UNPREDICTABLE/*putfield*/, - UNPREDICTABLE/*invokevirtual*/, UNPREDICTABLE/*invokespecial*/, - UNPREDICTABLE/*invokestatic*/, - UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 0/*new*/, 1/*newarray*/, 1/*anewarray*/, - 1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 1/*monitorenter*/, - 1/*monitorexit*/, 0/*wide*/, UNPREDICTABLE/*multianewarray*/, 1/*ifnull*/, 1/*ifnonnull*/, - 0/*goto_w*/, 0/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/ - }; - - /** - * Number of words produced onto operand stack by instructions. - */ - public static final int[] PRODUCE_STACK = { - 0/*nop*/, 1/*aconst_null*/, 1/*iconst_m1*/, 1/*iconst_0*/, 1/*iconst_1*/, - 1/*iconst_2*/, 1/*iconst_3*/, 1/*iconst_4*/, 1/*iconst_5*/, 2/*lconst_0*/, - 2/*lconst_1*/, 1/*fconst_0*/, 1/*fconst_1*/, 1/*fconst_2*/, 2/*dconst_0*/, - 2/*dconst_1*/, 1/*bipush*/, 1/*sipush*/, 1/*ldc*/, 1/*ldc_w*/, 2/*ldc2_w*/, 1/*iload*/, - 2/*lload*/, 1/*fload*/, 2/*dload*/, 1/*aload*/, 1/*iload_0*/, 1/*iload_1*/, 1/*iload_2*/, - 1/*iload_3*/, 2/*lload_0*/, 2/*lload_1*/, 2/*lload_2*/, 2/*lload_3*/, 1/*fload_0*/, - 1/*fload_1*/, 1/*fload_2*/, 1/*fload_3*/, 2/*dload_0*/, 2/*dload_1*/, 2/*dload_2*/, - 2/*dload_3*/, 1/*aload_0*/, 1/*aload_1*/, 1/*aload_2*/, 1/*aload_3*/, 1/*iaload*/, - 2/*laload*/, 1/*faload*/, 2/*daload*/, 1/*aaload*/, 1/*baload*/, 1/*caload*/, 1/*saload*/, - 0/*istore*/, 0/*lstore*/, 0/*fstore*/, 0/*dstore*/, 0/*astore*/, 0/*istore_0*/, - 0/*istore_1*/, 0/*istore_2*/, 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/, - 0/*lstore_2*/, 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/, - 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, 0/*dstore_3*/, - 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/, - 0/*fastore*/, 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, 0/*sastore*/, - 0/*pop*/, 0/*pop2*/, 2/*dup*/, 3/*dup_x1*/, 4/*dup_x2*/, 4/*dup2*/, 5/*dup2_x1*/, - 6/*dup2_x2*/, 2/*swap*/, 1/*iadd*/, 2/*ladd*/, 1/*fadd*/, 2/*dadd*/, 1/*isub*/, 2/*lsub*/, - 1/*fsub*/, 2/*dsub*/, 1/*imul*/, 2/*lmul*/, 1/*fmul*/, 2/*dmul*/, 1/*idiv*/, 2/*ldiv*/, - 1/*fdiv*/, 2/*ddiv*/, 1/*irem*/, 2/*lrem*/, 1/*frem*/, 2/*drem*/, 1/*ineg*/, 2/*lneg*/, - 1/*fneg*/, 2/*dneg*/, 1/*ishl*/, 2/*lshl*/, 1/*ishr*/, 2/*lshr*/, 1/*iushr*/, 2/*lushr*/, - 1/*iand*/, 2/*land*/, 1/*ior*/, 2/*lor*/, 1/*ixor*/, 2/*lxor*/, - 0/*iinc*/, 2/*i2l*/, 1/*i2f*/, 2/*i2d*/, 1/*l2i*/, 1/*l2f*/, 2/*l2d*/, 1/*f2i*/, - 2/*f2l*/, 2/*f2d*/, 1/*d2i*/, 2/*d2l*/, 1/*d2f*/, - 1/*i2b*/, 1/*i2c*/, 1/*i2s*/, 1/*lcmp*/, 1/*fcmpl*/, 1/*fcmpg*/, - 1/*dcmpl*/, 1/*dcmpg*/, 0/*ifeq*/, 0/*ifne*/, 0/*iflt*/, 0/*ifge*/, 0/*ifgt*/, 0/*ifle*/, - 0/*if_icmpeq*/, 0/*if_icmpne*/, 0/*if_icmplt*/, 0/*if_icmpge*/, 0/*if_icmpgt*/, - 0/*if_icmple*/, 0/*if_acmpeq*/, 0/*if_acmpne*/, 0/*goto*/, 1/*jsr*/, 0/*ret*/, - 0/*tableswitch*/, 0/*lookupswitch*/, 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/, - 0/*dreturn*/, 0/*areturn*/, 0/*return*/, UNPREDICTABLE/*getstatic*/, 0/*putstatic*/, - UNPREDICTABLE/*getfield*/, 0/*putfield*/, UNPREDICTABLE/*invokevirtual*/, - UNPREDICTABLE/*invokespecial*/, UNPREDICTABLE/*invokestatic*/, - UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 1/*new*/, 1/*newarray*/, 1/*anewarray*/, - 1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 0/*monitorenter*/, - 0/*monitorexit*/, 0/*wide*/, 1/*multianewarray*/, 0/*ifnull*/, 0/*ifnonnull*/, - 0/*goto_w*/, 1/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, - UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/ - }; - - /** Attributes and their corresponding names. - */ - public static final byte ATTR_UNKNOWN = -1; - public static final byte ATTR_SOURCE_FILE = 0; - public static final byte ATTR_CONSTANT_VALUE = 1; - public static final byte ATTR_CODE = 2; - public static final byte ATTR_EXCEPTIONS = 3; - public static final byte ATTR_LINE_NUMBER_TABLE = 4; - public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5; - public static final byte ATTR_INNER_CLASSES = 6; - public static final byte ATTR_SYNTHETIC = 7; - public static final byte ATTR_DEPRECATED = 8; - public static final byte ATTR_PMG = 9; - public static final byte ATTR_SIGNATURE = 10; - public static final byte ATTR_STACK_MAP = 11; - - public static final short KNOWN_ATTRIBUTES = 12; - - public static final String[] ATTRIBUTE_NAMES = { - "SourceFile", "ConstantValue", "Code", "Exceptions", - "LineNumberTable", "LocalVariableTable", - "InnerClasses", "Synthetic", "Deprecated", - "PMGClass", "Signature", "StackMap" - }; - - /** Constants used in the StackMap attribute. - */ - public static final byte ITEM_Bogus = 0; - public static final byte ITEM_Integer = 1; - public static final byte ITEM_Float = 2; - public static final byte ITEM_Double = 3; - public static final byte ITEM_Long = 4; - public static final byte ITEM_Null = 5; - public static final byte ITEM_InitObject = 6; - public static final byte ITEM_Object = 7; - public static final byte ITEM_NewObject = 8; - - public static final String[] ITEM_NAMES = { - "Bogus", "Integer", "Float", "Double", "Long", - "Null", "InitObject", "Object", "NewObject" - }; -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/ExceptionConstants.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/ExceptionConstants.java deleted file mode 100644 index 8fd320424f1..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/ExceptionConstants.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -/** - * Exception constants. - * - * @author E. Haase - */ -public interface ExceptionConstants { - /** The mother of all exceptions - */ - public static final Class THROWABLE = Throwable.class; - - /** Super class of any run-time exception - */ - public static final Class RUNTIME_EXCEPTION = RuntimeException.class; - - /** Super class of any linking exception (aka Linkage Error) - */ - public static final Class LINKING_EXCEPTION = LinkageError.class; - - /** Linking Exceptions - */ - public static final Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class; - public static final Class CLASS_FORMAT_ERROR = ClassFormatError.class; - public static final Class EXCEPTION_IN_INITIALIZER_ERROR = ExceptionInInitializerError.class; - public static final Class INCOMPATIBLE_CLASS_CHANGE_ERROR = IncompatibleClassChangeError.class; - public static final Class ABSTRACT_METHOD_ERROR = AbstractMethodError.class; - public static final Class ILLEGAL_ACCESS_ERROR = IllegalAccessError.class; - public static final Class INSTANTIATION_ERROR = InstantiationError.class; - public static final Class NO_SUCH_FIELD_ERROR = NoSuchFieldError.class; - public static final Class NO_SUCH_METHOD_ERROR = NoSuchMethodError.class; - public static final Class NO_CLASS_DEF_FOUND_ERROR = NoClassDefFoundError.class; - public static final Class UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class; - public static final Class VERIFY_ERROR = VerifyError.class; - - /* UnsupportedClassVersionError is new in JDK 1.2 */ - //public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class; - - /** Run-Time Exceptions - */ - public static final Class NULL_POINTER_EXCEPTION = NullPointerException.class; - public static final Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class; - public static final Class ARITHMETIC_EXCEPTION = ArithmeticException.class; - public static final Class NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class; - public static final Class CLASS_CAST_EXCEPTION = ClassCastException.class; - public static final Class ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class; - - /** Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual - * Machine Specification - */ - public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = { - NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR, - EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR - }; // Chapter 5.1 - - public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = { - NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR - }; // Chapter 5.2 - - public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below) - public static final Class[] EXCS_STRING_RESOLUTION = new Class[0]; - // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.) - - public static final Class[] EXCS_ARRAY_EXCEPTION = { - NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION - }; - -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/Repository.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/Repository.java deleted file mode 100644 index ca7c65add3b..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/Repository.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.classfile.JavaClass; -import com.sun.org.apache.bcel.internal.util.*; -import java.io.*; - -/** - * The repository maintains informations about class interdependencies, e.g., - * whether a class is a sub-class of another. Delegates actual class loading - * to SyntheticRepository with current class path by default. - * - * @see com.sun.org.apache.bcel.internal.util.Repository - * @see com.sun.org.apache.bcel.internal.util.SyntheticRepository - * - * @author M. Dahm - */ -public abstract class Repository { - private static com.sun.org.apache.bcel.internal.util.Repository _repository = - SyntheticRepository.getInstance(); - - /** @return currently used repository instance - */ - public static com.sun.org.apache.bcel.internal.util.Repository getRepository() { - return _repository; - } - - /** Set repository instance to be used for class loading - */ - public static void setRepository(com.sun.org.apache.bcel.internal.util.Repository rep) { - _repository = rep; - } - - /** Lookup class somewhere found on your CLASSPATH, or whereever the - * repository instance looks for it. - * - * @return class object for given fully qualified class name, or null - * if the class could not be found or parsed correctly - */ - public static JavaClass lookupClass(String class_name) { - try { - JavaClass clazz = _repository.findClass(class_name); - - if(clazz == null) { - return _repository.loadClass(class_name); - } else { - return clazz; - } - } catch(ClassNotFoundException ex) { return null; } - } - - /** - * Try to find class source via getResourceAsStream(). - * @see Class - * @return JavaClass object for given runtime class - */ - public static JavaClass lookupClass(Class clazz) { - try { - return _repository.loadClass(clazz); - } catch(ClassNotFoundException ex) { return null; } - } - - /** @return class file object for given Java class. - */ - public static ClassPath.ClassFile lookupClassFile(String class_name) { - try { - return ClassPath.SYSTEM_CLASS_PATH.getClassFile(class_name); - } catch(IOException e) { return null; } - } - - /** Clear the repository. - */ - public static void clearCache() { - _repository.clear(); - } - - /** - * Add clazz to repository if there isn't an equally named class already in there. - * - * @return old entry in repository - */ - public static JavaClass addClass(JavaClass clazz) { - JavaClass old = _repository.findClass(clazz.getClassName()); - _repository.storeClass(clazz); - return old; - } - - /** - * Remove class with given (fully qualified) name from repository. - */ - public static void removeClass(String clazz) { - _repository.removeClass(_repository.findClass(clazz)); - } - - /** - * Remove given class from repository. - */ - public static void removeClass(JavaClass clazz) { - _repository.removeClass(clazz); - } - - /** - * @return list of super classes of clazz in ascending order, i.e., - * Object is always the last element - */ - public static JavaClass[] getSuperClasses(JavaClass clazz) { - return clazz.getSuperClasses(); - } - - /** - * @return list of super classes of clazz in ascending order, i.e., - * Object is always the last element. return "null", if class - * cannot be found. - */ - public static JavaClass[] getSuperClasses(String class_name) { - JavaClass jc = lookupClass(class_name); - return (jc == null? null : getSuperClasses(jc)); - } - - /** - * @return all interfaces implemented by class and its super - * classes and the interfaces that those interfaces extend, and so on. - * (Some people call this a transitive hull). - */ - public static JavaClass[] getInterfaces(JavaClass clazz) { - return clazz.getAllInterfaces(); - } - - /** - * @return all interfaces implemented by class and its super - * classes and the interfaces that extend those interfaces, and so on - */ - public static JavaClass[] getInterfaces(String class_name) { - return getInterfaces(lookupClass(class_name)); - } - - /** - * Equivalent to runtime "instanceof" operator. - * @return true, if clazz is an instance of super_class - */ - public static boolean instanceOf(JavaClass clazz, JavaClass super_class) { - return clazz.instanceOf(super_class); - } - - /** - * @return true, if clazz is an instance of super_class - */ - public static boolean instanceOf(String clazz, String super_class) { - return instanceOf(lookupClass(clazz), lookupClass(super_class)); - } - - /** - * @return true, if clazz is an instance of super_class - */ - public static boolean instanceOf(JavaClass clazz, String super_class) { - return instanceOf(clazz, lookupClass(super_class)); - } - - /** - * @return true, if clazz is an instance of super_class - */ - public static boolean instanceOf(String clazz, JavaClass super_class) { - return instanceOf(lookupClass(clazz), super_class); - } - - /** - * @return true, if clazz is an implementation of interface inter - */ - public static boolean implementationOf(JavaClass clazz, JavaClass inter) { - return clazz.implementationOf(inter); - } - - /** - * @return true, if clazz is an implementation of interface inter - */ - public static boolean implementationOf(String clazz, String inter) { - return implementationOf(lookupClass(clazz), lookupClass(inter)); - } - - /** - * @return true, if clazz is an implementation of interface inter - */ - public static boolean implementationOf(JavaClass clazz, String inter) { - return implementationOf(clazz, lookupClass(inter)); - } - - /** - * @return true, if clazz is an implementation of interface inter - */ - public static boolean implementationOf(String clazz, JavaClass inter) { - return implementationOf(lookupClass(clazz), inter); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java deleted file mode 100644 index ad50a97b501..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; - -/** - * Super class for all objects that have modifiers like private, final, ... - * I.e. classes, fields, and methods. - * - * @author M. Dahm - */ -public abstract class AccessFlags implements java.io.Serializable { - protected int access_flags; - - public AccessFlags() {} - - /** - * @param a inital access flags - */ - public AccessFlags(int a) { - access_flags = a; - } - - /** - * @return Access flags of the object aka. "modifiers". - */ - public final int getAccessFlags() { return access_flags; } - - /** - * @return Access flags of the object aka. "modifiers". - */ - public final int getModifiers() { return access_flags; } - - /** Set access flags aka "modifiers". - * @param access_flags Access flags of the object. - */ - public final void setAccessFlags(int access_flags) { - this.access_flags = access_flags; - } - - /** Set access flags aka "modifiers". - * @param access_flags Access flags of the object. - */ - public final void setModifiers(int access_flags) { - setAccessFlags(access_flags); - } - - private final void setFlag(int flag, boolean set) { - if((access_flags & flag) != 0) { // Flag is set already - if(!set) // Delete flag ? - access_flags ^= flag; - } else { // Flag not set - if(set) // Set flag ? - access_flags |= flag; - } - } - - public final void isPublic(boolean flag) { setFlag(Constants.ACC_PUBLIC, flag); } - public final boolean isPublic() { - return (access_flags & Constants.ACC_PUBLIC) != 0; - } - - public final void isPrivate(boolean flag) { setFlag(Constants.ACC_PRIVATE, flag); } - public final boolean isPrivate() { - return (access_flags & Constants.ACC_PRIVATE) != 0; - } - - public final void isProtected(boolean flag) { setFlag(Constants.ACC_PROTECTED, flag); } - public final boolean isProtected() { - return (access_flags & Constants.ACC_PROTECTED) != 0; - } - - public final void isStatic(boolean flag) { setFlag(Constants.ACC_STATIC, flag); } - public final boolean isStatic() { - return (access_flags & Constants.ACC_STATIC) != 0; - } - - public final void isFinal(boolean flag) { setFlag(Constants.ACC_FINAL, flag); } - public final boolean isFinal() { - return (access_flags & Constants.ACC_FINAL) != 0; - } - - public final void isSynchronized(boolean flag) { setFlag(Constants.ACC_SYNCHRONIZED, flag); } - public final boolean isSynchronized() { - return (access_flags & Constants.ACC_SYNCHRONIZED) != 0; - } - - public final void isVolatile(boolean flag) { setFlag(Constants.ACC_VOLATILE, flag); } - public final boolean isVolatile() { - return (access_flags & Constants.ACC_VOLATILE) != 0; - } - - public final void isTransient(boolean flag) { setFlag(Constants.ACC_TRANSIENT, flag); } - public final boolean isTransient() { - return (access_flags & Constants.ACC_TRANSIENT) != 0; - } - - public final void isNative(boolean flag) { setFlag(Constants.ACC_NATIVE, flag); } - public final boolean isNative() { - return (access_flags & Constants.ACC_NATIVE) != 0; - } - - public final void isInterface(boolean flag) { setFlag(Constants.ACC_INTERFACE, flag); } - public final boolean isInterface() { - return (access_flags & Constants.ACC_INTERFACE) != 0; - } - - public final void isAbstract(boolean flag) { setFlag(Constants.ACC_ABSTRACT, flag); } - public final boolean isAbstract() { - return (access_flags & Constants.ACC_ABSTRACT) != 0; - } - - public final void isStrictfp(boolean flag) { setFlag(Constants.ACC_STRICT, flag); } - public final boolean isStrictfp() { - return (access_flags & Constants.ACC_STRICT) != 0; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java deleted file mode 100644 index a391d4d639a..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Attribute.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; -import java.util.HashMap; - -/** - * Abstract super class for Attribute objects. Currently the - * ConstantValue, SourceFile, Code, - * Exceptiontable, LineNumberTable, - * LocalVariableTable, InnerClasses and - * Synthetic attributes are supported. The - * Unknown attribute stands for non-standard-attributes. - * - * @author M. Dahm - * @see ConstantValue - * @see SourceFile - * @see Code - * @see Unknown - * @see ExceptionTable - * @see LineNumberTable - * @see LocalVariableTable - * @see InnerClasses - * @see Synthetic - * @see Deprecated - * @see Signature -*/ -public abstract class Attribute implements Cloneable, Node, Serializable { - protected int name_index; // Points to attribute name in constant pool - protected int length; // Content length of attribute field - protected byte tag; // Tag to distiguish subclasses - protected ConstantPool constant_pool; - - protected Attribute(byte tag, int name_index, int length, - ConstantPool constant_pool) { - this.tag = tag; - this.name_index = name_index; - this.length = length; - this.constant_pool = constant_pool; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public abstract void accept(Visitor v); - - /** - * Dump attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public void dump(DataOutputStream file) throws IOException - { - file.writeShort(name_index); - file.writeInt(length); - } - - private static HashMap readers = new HashMap(); - - /** Add an Attribute reader capable of parsing (user-defined) attributes - * named "name". You should not add readers for the standard attributes - * such as "LineNumberTable", because those are handled internally. - * - * @param name the name of the attribute as stored in the class file - * @param r the reader object - */ - public static void addAttributeReader(String name, AttributeReader r) { - readers.put(name, r); - } - - /** Remove attribute reader - * - * @param name the name of the attribute as stored in the class file - */ - public static void removeAttributeReader(String name) { - readers.remove(name); - } - - /* Class method reads one attribute from the input data stream. - * This method must not be accessible from the outside. It is - * called by the Field and Method constructor methods. - * - * @see Field - * @see Method - * @param file Input stream - * @param constant_pool Array of constants - * @return Attribute - * @throws IOException - * @throws ClassFormatException - */ - public static final Attribute readAttribute(DataInputStream file, - ConstantPool constant_pool) - throws IOException, ClassFormatException - { - ConstantUtf8 c; - String name; - int name_index; - int length; - byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute - - // Get class name from constant pool via `name_index' indirection - name_index = (int)file.readUnsignedShort(); - c = (ConstantUtf8)constant_pool.getConstant(name_index, - Constants.CONSTANT_Utf8); - name = c.getBytes(); - - // Length of data in bytes - length = file.readInt(); - - // Compare strings to find known attribute - for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { - if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { - tag = i; // found! - break; - } - } - - // Call proper constructor, depending on `tag' - switch(tag) { - case Constants.ATTR_UNKNOWN: - AttributeReader r = (AttributeReader)readers.get(name); - - if(r != null) - return r.createAttribute(name_index, length, file, constant_pool); - else - return new Unknown(name_index, length, file, constant_pool); - - case Constants.ATTR_CONSTANT_VALUE: - return new ConstantValue(name_index, length, file, constant_pool); - - case Constants.ATTR_SOURCE_FILE: - return new SourceFile(name_index, length, file, constant_pool); - - case Constants.ATTR_CODE: - return new Code(name_index, length, file, constant_pool); - - case Constants.ATTR_EXCEPTIONS: - return new ExceptionTable(name_index, length, file, constant_pool); - - case Constants.ATTR_LINE_NUMBER_TABLE: - return new LineNumberTable(name_index, length, file, constant_pool); - - case Constants.ATTR_LOCAL_VARIABLE_TABLE: - return new LocalVariableTable(name_index, length, file, constant_pool); - - case Constants.ATTR_INNER_CLASSES: - return new InnerClasses(name_index, length, file, constant_pool); - - case Constants.ATTR_SYNTHETIC: - return new Synthetic(name_index, length, file, constant_pool); - - case Constants.ATTR_DEPRECATED: - return new Deprecated(name_index, length, file, constant_pool); - - case Constants.ATTR_PMG: - return new PMGClass(name_index, length, file, constant_pool); - - case Constants.ATTR_SIGNATURE: - return new Signature(name_index, length, file, constant_pool); - - case Constants.ATTR_STACK_MAP: - return new StackMap(name_index, length, file, constant_pool); - - default: // Never reached - throw new IllegalStateException("Ooops! default case reached."); - } - } - - /** - * @return Length of attribute field in bytes. - */ - public final int getLength() { return length; } - - /** - * @param Attribute length in bytes. - */ - public final void setLength(int length) { - this.length = length; - } - - /** - * @param name_index of attribute. - */ - public final void setNameIndex(int name_index) { - this.name_index = name_index; - } - - /** - * @return Name index in constant pool of attribute name. - */ - public final int getNameIndex() { return name_index; } - - /** - * @return Tag of attribute, i.e., its type. Value may not be altered, thus - * there is no setTag() method. - */ - public final byte getTag() { return tag; } - - /** - * @return Constant pool used by this object. - * @see ConstantPool - */ - public final ConstantPool getConstantPool() { return constant_pool; } - - /** - * @param constant_pool Constant pool to be used for this object. - * @see ConstantPool - */ - public final void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } - - /** - * Use copy() if you want to have a deep copy(), i.e., with all references - * copied correctly. - * - * @return shallow copy of this attribute - */ - public Object clone() { - Object o = null; - - try { - o = super.clone(); - } catch(CloneNotSupportedException e) { - e.printStackTrace(); // Never occurs - } - - return o; - } - - /** - * @return deep copy of this attribute - */ - public abstract Attribute copy(ConstantPool constant_pool); - - /** - * @return attribute name. - */ - public String toString() { - return Constants.ATTRIBUTE_NAMES[tag]; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java deleted file mode 100644 index d1f395180aa..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/AttributeReader.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -/** - * Unknown (non-standard) attributes may be read via user-defined factory - * objects that can be registered with the Attribute.addAttributeReader - * method. These factory objects should implement this interface. - - * @see Attribute - * @author M. Dahm - */ -public interface AttributeReader { - /** - When this attribute reader is added via the static method - Attribute.addAttributeReader, an attribute name is associated with it. - As the class file parser parses attributes, it will call various - AttributeReaders based on the name of the attributes it is - constructing. - - @param name_index An index into the constant pool, indexing a - ConstantUtf8 that represents the name of the attribute. - - @param length The length of the data contained in the attribute. This - is written into the constant pool and should agree with what the - factory expects the length to be. - - @param file This is the data input stream that the factory needs to read - its data from. - - @param constant_pool This is the constant pool associated with the - Attribute that we are constructing. - - @return The user-defined AttributeReader should take this data and use - it to construct an attribute. In the case of errors, a null can be - returned which will cause the parsing of the class file to fail. - - @see Attribute#addAttributeReader( String, AttributeReader ) - */ - public Attribute createAttribute(int name_index, - int length, - java.io.DataInputStream file, - ConstantPool constant_pool); -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java deleted file mode 100644 index 203faf3c101..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassFormatException.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -/** - * Thrown when the BCEL attempts to read a class file and determines - * that the file is malformed or otherwise cannot be interpreted as a - * class file. - * - * @author M. Dahm - */ -public class ClassFormatException extends RuntimeException { - public ClassFormatException() { super(); } - public ClassFormatException(String s) { super(s); } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java deleted file mode 100644 index d8f32fc5a43..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ClassParser.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; -import java.util.zip.*; - -/** - * Wrapper class that parses a given Java .class file. The method parse returns a - * JavaClass object on success. When an I/O error or an - * inconsistency occurs an appropiate exception is propagated back to - * the caller. - * - * The structure and the names comply, except for a few conveniences, - * exactly with the - * JVM specification 1.0. See this paper for - * further details about the structure of a bytecode file. - * - * @author M. Dahm - */ -public final class ClassParser { - private DataInputStream file; - private ZipFile zip; - private String file_name; - private int class_name_index, superclass_name_index; - private int major, minor; // Compiler version - private int access_flags; // Access rights of parsed class - private int[] interfaces; // Names of implemented interfaces - private ConstantPool constant_pool; // collection of constants - private Field[] fields; // class fields, i.e., its variables - private Method[] methods; // methods defined in the class - private Attribute[] attributes; // attributes defined in the class - private boolean is_zip; // Loaded from zip file - - private static final int BUFSIZE = 8192; - - /** - * Parse class from the given stream. - * - * @param file Input stream - * @param file_name File name - */ - public ClassParser(InputStream file, String file_name) { - this.file_name = file_name; - - String clazz = file.getClass().getName(); // Not a very clean solution ... - is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar."); - - if(file instanceof DataInputStream) // Is already a data stream - this.file = (DataInputStream)file; - else - this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE)); - } - - /** Parse class from given .class file. - * - * @param file_name file name - * @throws IOException - */ - public ClassParser(String file_name) throws IOException - { - is_zip = false; - this.file_name = file_name; - file = new DataInputStream(new BufferedInputStream - (new FileInputStream(file_name), BUFSIZE)); - } - - /** Parse class from given .class file in a ZIP-archive - * - * @param file_name file name - * @throws IOException - */ - public ClassParser(String zip_file, String file_name) throws IOException - { - is_zip = true; - zip = new ZipFile(zip_file); - ZipEntry entry = zip.getEntry(file_name); - - this.file_name = file_name; - - file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry), - BUFSIZE)); - } - - /** - * Parse the given Java class file and return an object that represents - * the contained data, i.e., constants, methods, fields and commands. - * A ClassFormatException is raised, if the file is not a valid - * .class file. (This does not include verification of the byte code as it - * is performed by the java interpreter). - * - * @return Class object representing the parsed class file - * @throws IOException - * @throws ClassFormatException - */ - public JavaClass parse() throws IOException, ClassFormatException - { - /****************** Read headers ********************************/ - // Check magic tag of class file - readID(); - - // Get compiler version - readVersion(); - - /****************** Read constant pool and related **************/ - // Read constant pool entries - readConstantPool(); - - // Get class information - readClassInfo(); - - // Get interface information, i.e., implemented interfaces - readInterfaces(); - - /****************** Read class fields and methods ***************/ - // Read class fields, i.e., the variables of the class - readFields(); - - // Read class methods, i.e., the functions in the class - readMethods(); - - // Read class attributes - readAttributes(); - - // Check for unknown variables - //Unknown[] u = Unknown.getUnknownAttributes(); - //for(int i=0; i < u.length; i++) - // System.err.println("WARNING: " + u[i]); - - // Everything should have been read now - // if(file.available() > 0) { - // int bytes = file.available(); - // byte[] buf = new byte[bytes]; - // file.read(buf); - - // if(!(is_zip && (buf.length == 1))) { - // System.err.println("WARNING: Trailing garbage at end of " + file_name); - // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf)); - // } - // } - - // Read everything of interest, so close the file - file.close(); - if(zip != null) - zip.close(); - - // Return the information we have gathered in a new object - return new JavaClass(class_name_index, superclass_name_index, - file_name, major, minor, access_flags, - constant_pool, interfaces, fields, - methods, attributes, is_zip? JavaClass.ZIP : JavaClass.FILE); - } - - /** - * Read information about the attributes of the class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readAttributes() throws IOException, ClassFormatException - { - int attributes_count; - - attributes_count = file.readUnsignedShort(); - attributes = new Attribute[attributes_count]; - - for(int i=0; i < attributes_count; i++) - attributes[i] = Attribute.readAttribute(file, constant_pool); - } - - /** - * Read information about the class and its super class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readClassInfo() throws IOException, ClassFormatException - { - access_flags = file.readUnsignedShort(); - - /* Interfaces are implicitely abstract, the flag should be set - * according to the JVM specification. - */ - if((access_flags & Constants.ACC_INTERFACE) != 0) - access_flags |= Constants.ACC_ABSTRACT; - - if(((access_flags & Constants.ACC_ABSTRACT) != 0) && - ((access_flags & Constants.ACC_FINAL) != 0 )) - throw new ClassFormatException("Class can't be both final and abstract"); - - class_name_index = file.readUnsignedShort(); - superclass_name_index = file.readUnsignedShort(); - } - /** - * Read constant pool entries. - * @throws IOException - * @throws ClassFormatException - */ - private final void readConstantPool() throws IOException, ClassFormatException - { - constant_pool = new ConstantPool(file); - } - - /** - * Read information about the fields of the class, i.e., its variables. - * @throws IOException - * @throws ClassFormatException - */ - private final void readFields() throws IOException, ClassFormatException - { - int fields_count; - - fields_count = file.readUnsignedShort(); - fields = new Field[fields_count]; - - for(int i=0; i < fields_count; i++) - fields[i] = new Field(file, constant_pool); - } - - /******************** Private utility methods **********************/ - - /** - * Check whether the header of the file is ok. - * Of course, this has to be the first action on successive file reads. - * @throws IOException - * @throws ClassFormatException - */ - private final void readID() throws IOException, ClassFormatException - { - int magic = 0xCAFEBABE; - - if(file.readInt() != magic) - throw new ClassFormatException(file_name + " is not a Java .class file"); - } - /** - * Read information about the interfaces implemented by this class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readInterfaces() throws IOException, ClassFormatException - { - int interfaces_count; - - interfaces_count = file.readUnsignedShort(); - interfaces = new int[interfaces_count]; - - for(int i=0; i < interfaces_count; i++) - interfaces[i] = file.readUnsignedShort(); - } - /** - * Read information about the methods of the class. - * @throws IOException - * @throws ClassFormatException - */ - private final void readMethods() throws IOException, ClassFormatException - { - int methods_count; - - methods_count = file.readUnsignedShort(); - methods = new Method[methods_count]; - - for(int i=0; i < methods_count; i++) - methods[i] = new Method(file, constant_pool); - } - /** - * Read major and minor version of compiler which created the file. - * @throws IOException - * @throws ClassFormatException - */ - private final void readVersion() throws IOException, ClassFormatException - { - minor = file.readUnsignedShort(); - major = file.readUnsignedShort(); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java deleted file mode 100644 index f7ace6f5480..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Code.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a chunk of Java byte code contained in a - * method. It is instantiated by the - * Attribute.readAttribute() method. A Code - * attribute contains informations about operand stack, local - * variables, byte code and the exceptions handled within this - * method. - * - * This attribute has attributes itself, namely LineNumberTable which - * is used for debugging purposes and LocalVariableTable which - * contains information about the local variables. - * - * @author M. Dahm - * @see Attribute - * @see CodeException - * @see LineNumberTable - * @see LocalVariableTable - */ -public final class Code extends Attribute { - private int max_stack; // Maximum size of stack used by this method - private int max_locals; // Number of local variables - private int code_length; // Length of code in bytes - private byte[] code; // Actual byte code - - private int exception_table_length; - private CodeException[] exception_table; // Table of handled exceptions - private int attributes_count; // Attributes of code: LineNumber - private Attribute[] attributes; // or LocalVariable - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use copy() for a physical copy. - */ - public Code(Code c) { - this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(), - c.getCode(), c.getExceptionTable(), c.getAttributes(), - c.getConstantPool()); - } - - /** - * @param name_index Index pointing to the name Code - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - */ - Code(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - // Initialize with some default values which will be overwritten later - this(name_index, length, - file.readUnsignedShort(), file.readUnsignedShort(), - (byte[])null, (CodeException[])null, (Attribute[])null, - constant_pool); - - code_length = file.readInt(); - code = new byte[code_length]; // Read byte code - file.readFully(code); - - /* Read exception table that contains all regions where an exception - * handler is active, i.e., a try { ... } catch() block. - */ - exception_table_length = file.readUnsignedShort(); - exception_table = new CodeException[exception_table_length]; - - for(int i=0; i < exception_table_length; i++) - exception_table[i] = new CodeException(file); - - /* Read all attributes, currently `LineNumberTable' and - * `LocalVariableTable' - */ - attributes_count = file.readUnsignedShort(); - attributes = new Attribute[attributes_count]; - for(int i=0; i < attributes_count; i++) - attributes[i] = Attribute.readAttribute(file, constant_pool); - - /* Adjust length, because of setAttributes in this(), s.b. length - * is incorrect, because it didn't take the internal attributes - * into account yet! Very subtle bug, fixed in 3.1.1. - */ - this.length = length; - } - - /** - * @param name_index Index pointing to the name Code - * @param length Content length in bytes - * @param max_stack Maximum size of stack - * @param max_locals Number of local variables - * @param code Actual byte code - * @param exception_table Table of handled exceptions - * @param attributes Attributes of code: LineNumber or LocalVariable - * @param constant_pool Array of constants - */ - public Code(int name_index, int length, - int max_stack, int max_locals, - byte[] code, - CodeException[] exception_table, - Attribute[] attributes, - ConstantPool constant_pool) - { - super(Constants.ATTR_CODE, name_index, length, constant_pool); - - this.max_stack = max_stack; - this.max_locals = max_locals; - - setCode(code); - setExceptionTable(exception_table); - setAttributes(attributes); // Overwrites length! - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitCode(this); - } - - /** - * Dump code attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - - file.writeShort(max_stack); - file.writeShort(max_locals); - file.writeInt(code_length); - file.write(code, 0, code_length); - - file.writeShort(exception_table_length); - for(int i=0; i < exception_table_length; i++) - exception_table[i].dump(file); - - file.writeShort(attributes_count); - for(int i=0; i < attributes_count; i++) - attributes[i].dump(file); - } - - /** - * @return Collection of code attributes. - * @see Attribute - */ - public final Attribute[] getAttributes() { return attributes; } - - /** - * @return LineNumberTable of Code, if it has one - */ - public LineNumberTable getLineNumberTable() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof LineNumberTable) - return (LineNumberTable)attributes[i]; - - return null; - } - - /** - * @return LocalVariableTable of Code, if it has one - */ - public LocalVariableTable getLocalVariableTable() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof LocalVariableTable) - return (LocalVariableTable)attributes[i]; - - return null; - } - - /** - * @return Actual byte code of the method. - */ - public final byte[] getCode() { return code; } - - /** - * @return Table of handled exceptions. - * @see CodeException - */ - public final CodeException[] getExceptionTable() { return exception_table; } - - /** - * @return Number of local variables. - */ - public final int getMaxLocals() { return max_locals; } - - /** - * @return Maximum size of stack used by this method. - */ - - public final int getMaxStack() { return max_stack; } - - /** - * @return the internal length of this code attribute (minus the first 6 bytes) - * and excluding all its attributes - */ - private final int getInternalLength() { - return 2 /*max_stack*/ + 2 /*max_locals*/ + 4 /*code length*/ - + code_length /*byte-code*/ - + 2 /*exception-table length*/ - + 8 * exception_table_length /* exception table */ - + 2 /* attributes count */; - } - - /** - * @return the full size of this code attribute, minus its first 6 bytes, - * including the size of all its contained attributes - */ - private final int calculateLength() { - int len = 0; - - for(int i=0; i < attributes_count; i++) - len += attributes[i].length + 6 /*attribute header size*/; - - return len + getInternalLength(); - } - - /** - * @param attributes. - */ - public final void setAttributes(Attribute[] attributes) { - this.attributes = attributes; - attributes_count = (attributes == null)? 0 : attributes.length; - length = calculateLength(); // Adjust length - } - - /** - * @param code byte code - */ - public final void setCode(byte[] code) { - this.code = code; - code_length = (code == null)? 0 : code.length; - } - - /** - * @param exception_table exception table - */ - public final void setExceptionTable(CodeException[] exception_table) { - this.exception_table = exception_table; - exception_table_length = (exception_table == null)? 0 : - exception_table.length; - } - - /** - * @param max_locals maximum number of local variables - */ - public final void setMaxLocals(int max_locals) { - this.max_locals = max_locals; - } - - /** - * @param max_stack maximum stack size - */ - public final void setMaxStack(int max_stack) { - this.max_stack = max_stack; - } - - /** - * @return String representation of code chunk. - */ - public final String toString(boolean verbose) { - StringBuffer buf; - - buf = new StringBuffer("Code(max_stack = " + max_stack + - ", max_locals = " + max_locals + - ", code_length = " + code_length + ")\n" + - Utility.codeToString(code, constant_pool, 0, -1, verbose)); - - if(exception_table_length > 0) { - buf.append("\nException handler(s) = \n" + "From\tTo\tHandler\tType\n"); - - for(int i=0; i < exception_table_length; i++) - buf.append(exception_table[i].toString(constant_pool, verbose) + "\n"); - } - - if(attributes_count > 0) { - buf.append("\nAttribute(s) = \n"); - - for(int i=0; i < attributes_count; i++) - buf.append(attributes[i].toString() + "\n"); - } - - return buf.toString(); - } - - /** - * @return String representation of code chunk. - */ - public final String toString() { - return toString(true); - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - Code c = (Code)clone(); - c.code = (byte[])code.clone(); - c.constant_pool = constant_pool; - - c.exception_table = new CodeException[exception_table_length]; - for(int i=0; i < exception_table_length; i++) - c.exception_table[i] = exception_table[i].copy(); - - c.attributes = new Attribute[attributes_count]; - for(int i=0; i < attributes_count; i++) - c.attributes[i] = attributes[i].copy(constant_pool); - - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java deleted file mode 100644 index 4cf1725a9d6..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/CodeException.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents an entry in the exception table of the Code - * attribute and is used only there. It contains a range in which a - * particular exception handler is active. - * - * @author M. Dahm - * @see Code - */ -public final class CodeException - implements Cloneable, Constants, Node, Serializable -{ - private int start_pc; // Range in the code the exception handler is - private int end_pc; // active. start_pc is inclusive, end_pc exclusive - private int handler_pc; /* Starting address of exception handler, i.e., - * an offset from start of code. - */ - private int catch_type; /* If this is zero the handler catches any - * exception, otherwise it points to the - * exception class which is to be caught. - */ - /** - * Initialize from another object. - */ - public CodeException(CodeException c) { - this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType()); - } - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - */ - CodeException(DataInputStream file) throws IOException - { - this(file.readUnsignedShort(), file.readUnsignedShort(), - file.readUnsignedShort(), file.readUnsignedShort()); - } - - /** - * @param start_pc Range in the code the exception handler is active, - * start_pc is inclusive while - * @param end_pc is exclusive - * @param handler_pc Starting address of exception handler, i.e., - * an offset from start of code. - * @param catch_type If zero the handler catches any - * exception, otherwise it points to the exception class which is - * to be caught. - */ - public CodeException(int start_pc, int end_pc, int handler_pc, - int catch_type) - { - this.start_pc = start_pc; - this.end_pc = end_pc; - this.handler_pc = handler_pc; - this.catch_type = catch_type; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitCodeException(this); - } - /** - * Dump code exception to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeShort(start_pc); - file.writeShort(end_pc); - file.writeShort(handler_pc); - file.writeShort(catch_type); - } - - /** - * @return 0, if the handler catches any exception, otherwise it points to - * the exception class which is to be caught. - */ - public final int getCatchType() { return catch_type; } - - /** - * @return Exclusive end index of the region where the handler is active. - */ - public final int getEndPC() { return end_pc; } - - /** - * @return Starting address of exception handler, relative to the code. - */ - public final int getHandlerPC() { return handler_pc; } - - /** - * @return Inclusive start index of the region where the handler is active. - */ - public final int getStartPC() { return start_pc; } - - /** - * @param catch_type. - */ - public final void setCatchType(int catch_type) { - this.catch_type = catch_type; - } - - /** - * @param end_pc end of handled block - */ - public final void setEndPC(int end_pc) { - this.end_pc = end_pc; - } - - /** - * @param handler_pc where the actual code is - */ - public final void setHandlerPC(int handler_pc) { - this.handler_pc = handler_pc; - } - - /** - * @param start_pc start of handled block - */ - public final void setStartPC(int start_pc) { - this.start_pc = start_pc; - } - - /** - * @return String representation. - */ - public final String toString() { - return "CodeException(start_pc = " + start_pc + - ", end_pc = " + end_pc + - ", handler_pc = " + handler_pc + ", catch_type = " + catch_type + ")"; - } - - /** - * @return String representation. - */ - public final String toString(ConstantPool cp, boolean verbose) { - String str; - - if(catch_type == 0) - str = "(0)"; - else - str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false) + - (verbose? "(" + catch_type + ")" : ""); - - return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; - } - - public final String toString(ConstantPool cp) { - return toString(cp, true); - } - - /** - * @return deep copy of this object - */ - public CodeException copy() { - try { - return (CodeException)clone(); - } catch(CloneNotSupportedException e) {} - - return null; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java deleted file mode 100644 index 931b8e27c79..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Constant.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * Abstract superclass for classes to represent the different constant types - * in the constant pool of a class file. The classes keep closely to - * the JVM specification. - * - * @author M. Dahm - */ -public abstract class Constant implements Cloneable, Node, Serializable { - /* In fact this tag is redundant since we can distinguish different - * `Constant' objects by their type, i.e., via `instanceof'. In some - * places we will use the tag for switch()es anyway. - * - * First, we want match the specification as closely as possible. Second we - * need the tag as an index to select the corresponding class name from the - * `CONSTANT_NAMES' array. - */ - protected byte tag; - - Constant(byte tag) { this.tag = tag; } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public abstract void accept(Visitor v); - - public abstract void dump(DataOutputStream file) throws IOException; - - /** - * @return Tag of constant, i.e., its type. No setTag() method to avoid - * confusion. - */ - public final byte getTag() { return tag; } - - /** - * @return String representation. - */ - public String toString() { - return Constants.CONSTANT_NAMES[tag] + "[" + tag + "]"; - } - - /** - * @return deep copy of this constant - */ - public Constant copy() { - try { - return (Constant)super.clone(); - } catch(CloneNotSupportedException e) {} - - return null; - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - /** - * Read one constant from the given file, the type depends on a tag byte. - * - * @param file Input stream - * @return Constant object - */ - static final Constant readConstant(DataInputStream file) - throws IOException, ClassFormatException - { - byte b = file.readByte(); // Read tag byte - - switch(b) { - case Constants.CONSTANT_Class: return new ConstantClass(file); - case Constants.CONSTANT_Fieldref: return new ConstantFieldref(file); - case Constants.CONSTANT_Methodref: return new ConstantMethodref(file); - case Constants.CONSTANT_InterfaceMethodref: return new - ConstantInterfaceMethodref(file); - case Constants.CONSTANT_String: return new ConstantString(file); - case Constants.CONSTANT_Integer: return new ConstantInteger(file); - case Constants.CONSTANT_Float: return new ConstantFloat(file); - case Constants.CONSTANT_Long: return new ConstantLong(file); - case Constants.CONSTANT_Double: return new ConstantDouble(file); - case Constants.CONSTANT_NameAndType: return new ConstantNameAndType(file); - case Constants.CONSTANT_Utf8: return new ConstantUtf8(file); - default: - throw new ClassFormatException("Invalid byte tag in constant pool: " + b); - } - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java deleted file mode 100644 index b12d752c2cb..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantCP.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ -import java.io.*; -import com.sun.org.apache.bcel.internal.Constants; - -/** - * Abstract super class for Fieldref and Methodref constants. - * - * @author M. Dahm - * @see ConstantFieldref - * @see ConstantMethodref - * @see ConstantInterfaceMethodref - */ -public abstract class ConstantCP extends Constant { - /** References to the constants containing the class and the field signature - */ - protected int class_index, name_and_type_index; - - /** - * Initialize from another object. - */ - public ConstantCP(ConstantCP c) { - this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex()); - } - - /** - * Initialize instance from file data. - * - * @param tag Constant type tag - * @param file Input stream - * @throws IOException - */ - ConstantCP(byte tag, DataInputStream file) throws IOException - { - this(tag, file.readUnsignedShort(), file.readUnsignedShort()); - } - - /** - * @param class_index Reference to the class containing the field - * @param name_and_type_index and the field signature - */ - protected ConstantCP(byte tag, int class_index, - int name_and_type_index) { - super(tag); - this.class_index = class_index; - this.name_and_type_index = name_and_type_index; - } - - /** - * Dump constant field reference to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeShort(class_index); - file.writeShort(name_and_type_index); - } - - /** - * @return Reference (index) to class this field or method belongs to. - */ - public final int getClassIndex() { return class_index; } - - /** - * @return Reference (index) to signature of the field. - */ - public final int getNameAndTypeIndex() { return name_and_type_index; } - - /** - * @param class_index points to Constant_class - */ - public final void setClassIndex(int class_index) { - this.class_index = class_index; - } - - /** - * @return Class this field belongs to. - */ - public String getClass(ConstantPool cp) { - return cp.constantToString(class_index, Constants.CONSTANT_Class); - } - - /** - * @param name_and_type_index points to Constant_NameAndType - */ - public final void setNameAndTypeIndex(int name_and_type_index) { - this.name_and_type_index = name_and_type_index; - } - - /** - * @return String representation. - */ - public final String toString() { - return super.toString() + "(class_index = " + class_index + - ", name_and_type_index = " + name_and_type_index + ")"; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java deleted file mode 100644 index e047ca88db5..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantClass.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a (external) class. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantClass extends Constant implements ConstantObject { - private int name_index; // Identical to ConstantString except for the name - - /** - * Initialize from another object. - */ - public ConstantClass(ConstantClass c) { - this(c.getNameIndex()); - } - - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantClass(DataInputStream file) throws IOException - { - this(file.readUnsignedShort()); - } - - /** - * @param name_index Name index in constant pool. Should refer to a - * ConstantUtf8. - */ - public ConstantClass(int name_index) { - super(Constants.CONSTANT_Class); - this.name_index = name_index; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantClass(this); - } - - /** - * Dump constant class to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeShort(name_index); - } - - /** - * @return Name index in constant pool of class name. - */ - public final int getNameIndex() { return name_index; } - - /** - * @param name_index. - */ - public final void setNameIndex(int name_index) { - this.name_index = name_index; - } - - - /** @return String object - */ - public Object getConstantValue(ConstantPool cp) { - Constant c = cp.getConstant(name_index, Constants.CONSTANT_Utf8); - return ((ConstantUtf8)c).getBytes(); - } - - /** @return dereferenced string - */ - public String getBytes(ConstantPool cp) { - return (String)getConstantValue(cp); - } - - /** - * @return String representation. - */ - public final String toString() { - return super.toString() + "(name_index = " + name_index + ")"; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java deleted file mode 100644 index 74e7ef8129d..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a Double object. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantDouble extends Constant implements ConstantObject { - private double bytes; - - /** - * @param bytes Data - */ - public ConstantDouble(double bytes) { - super(Constants.CONSTANT_Double); - this.bytes = bytes; - } - - /** - * Initialize from another object. - */ - public ConstantDouble(ConstantDouble c) { - this(c.getBytes()); - } - - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantDouble(DataInputStream file) throws IOException - { - this(file.readDouble()); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantDouble(this); - } - /** - * Dump constant double to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeDouble(bytes); - } - /** - * @return data, i.e., 8 bytes. - */ - public final double getBytes() { return bytes; } - /** - * @param bytes. - */ - public final void setBytes(double bytes) { - this.bytes = bytes; - } - /** - * @return String representation. - */ - public final String toString() - { - return super.toString() + "(bytes = " + bytes + ")"; - } - - /** @return Double object - */ - public Object getConstantValue(ConstantPool cp) { - return new Double(bytes); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java deleted file mode 100644 index 5d76e11fdd9..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFieldref.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a constant pool reference to a field. - * - * @author M. Dahm - */ -public final class ConstantFieldref extends ConstantCP { - /** - * Initialize from another object. - */ - public ConstantFieldref(ConstantFieldref c) { - super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex()); - } - - /** - * Initialize instance from file data. - * - * @param file input stream - * @throws IOException - */ - ConstantFieldref(DataInputStream file) throws IOException - { - super(Constants.CONSTANT_Fieldref, file); - } - - /** - * @param class_index Reference to the class containing the Field - * @param name_and_type_index and the Field signature - */ - public ConstantFieldref(int class_index, - int name_and_type_index) { - super(Constants.CONSTANT_Fieldref, class_index, name_and_type_index); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of Fields, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantFieldref(this); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java deleted file mode 100644 index e18eb14f973..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a float object. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantFloat extends Constant implements ConstantObject { - private float bytes; - - /** - * @param bytes Data - */ - public ConstantFloat(float bytes) - { - super(Constants.CONSTANT_Float); - this.bytes = bytes; - } - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public ConstantFloat(ConstantFloat c) { - this(c.getBytes()); - } - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantFloat(DataInputStream file) throws IOException - { - this(file.readFloat()); - } - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantFloat(this); - } - /** - * Dump constant float to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeFloat(bytes); - } - /** - * @return data, i.e., 4 bytes. - */ - public final float getBytes() { return bytes; } - /** - * @param bytes. - */ - public final void setBytes(float bytes) { - this.bytes = bytes; - } - - /** - * @return String representation. - */ - public final String toString() { - return super.toString() + "(bytes = " + bytes + ")"; - } - - /** @return Float object - */ - public Object getConstantValue(ConstantPool cp) { - return new Float(bytes); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java deleted file mode 100644 index a1e811e9b5e..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInteger.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ - -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to an int object. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantInteger extends Constant implements ConstantObject { - private int bytes; - - /** - * @param bytes Data - */ - public ConstantInteger(int bytes) - { - super(Constants.CONSTANT_Integer); - this.bytes = bytes; - } - - /** - * Initialize from another object. - */ - public ConstantInteger(ConstantInteger c) { - this(c.getBytes()); - } - - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantInteger(DataInputStream file) throws IOException - { - this(file.readInt()); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantInteger(this); - } - - /** - * Dump constant integer to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeInt(bytes); - } - - /** - * @return data, i.e., 4 bytes. - */ - public final int getBytes() { return bytes; } - - /** - * @param bytes. - */ - public final void setBytes(int bytes) { - this.bytes = bytes; - } - - /** - * @return String representation. - */ - public final String toString() { - return super.toString() + "(bytes = " + bytes + ")"; - } - - /** @return Integer object - */ - public Object getConstantValue(ConstantPool cp) { - return new Integer(bytes); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java deleted file mode 100644 index 46b742651b8..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantInterfaceMethodref.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a constant pool reference to an interface method. - * - * @author M. Dahm - */ -public final class ConstantInterfaceMethodref extends ConstantCP { - /** - * Initialize from another object. - */ - public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) { - super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex()); - } - - /** - * Initialize instance from file data. - * - * @param file input stream - * @throws IOException - */ - ConstantInterfaceMethodref(DataInputStream file) throws IOException - { - super(Constants.CONSTANT_InterfaceMethodref, file); - } - - /** - * @param class_index Reference to the class containing the method - * @param name_and_type_index and the method signature - */ - public ConstantInterfaceMethodref(int class_index, - int name_and_type_index) { - super(Constants.CONSTANT_InterfaceMethodref, class_index, name_and_type_index); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantInterfaceMethodref(this); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java deleted file mode 100644 index e29a7c9c1a3..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantLong.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a long object. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantLong extends Constant implements ConstantObject { - private long bytes; - - /** - * @param bytes Data - */ - public ConstantLong(long bytes) - { - super(Constants.CONSTANT_Long); - this.bytes = bytes; - } - /** - * Initialize from another object. - */ - public ConstantLong(ConstantLong c) { - this(c.getBytes()); - } - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantLong(DataInputStream file) throws IOException - { - this(file.readLong()); - } - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantLong(this); - } - /** - * Dump constant long to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeLong(bytes); - } - /** - * @return data, i.e., 8 bytes. - */ - public final long getBytes() { return bytes; } - /** - * @param bytes. - */ - public final void setBytes(long bytes) { - this.bytes = bytes; - } - /** - * @return String representation. - */ - public final String toString() { - return super.toString() + "(bytes = " + bytes + ")"; - } - - /** @return Long object - */ - public Object getConstantValue(ConstantPool cp) { - return new Long(bytes); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java deleted file mode 100644 index 044c99be955..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantMethodref.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a constant pool reference to a method. - * - * @author M. Dahm - */ -public final class ConstantMethodref extends ConstantCP { - /** - * Initialize from another object. - */ - public ConstantMethodref(ConstantMethodref c) { - super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex()); - } - - /** - * Initialize instance from file data. - * - * @param file input stream - * @throws IOException - */ - ConstantMethodref(DataInputStream file) throws IOException - { - super(Constants.CONSTANT_Methodref, file); - } - - /** - * @param class_index Reference to the class containing the method - * @param name_and_type_index and the method signature - */ - public ConstantMethodref(int class_index, - int name_and_type_index) { - super(Constants.CONSTANT_Methodref, class_index, name_and_type_index); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantMethodref(this); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java deleted file mode 100644 index 19ad468d7f3..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantNameAndType.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to the name and signature - * of a field or method. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantNameAndType extends Constant { - private int name_index; // Name of field/method - private int signature_index; // and its signature. - - /** - * Initialize from another object. - */ - public ConstantNameAndType(ConstantNameAndType c) { - this(c.getNameIndex(), c.getSignatureIndex()); - } - - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantNameAndType(DataInputStream file) throws IOException - { - this((int)file.readUnsignedShort(), (int)file.readUnsignedShort()); - } - - /** - * @param name_index Name of field/method - * @param signature_index and its signature - */ - public ConstantNameAndType(int name_index, - int signature_index) - { - super(Constants.CONSTANT_NameAndType); - this.name_index = name_index; - this.signature_index = signature_index; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantNameAndType(this); - } - - /** - * Dump name and signature index to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeShort(name_index); - file.writeShort(signature_index); - } - - /** - * @return Name index in constant pool of field/method name. - */ - public final int getNameIndex() { return name_index; } - - /** @return name - */ - public final String getName(ConstantPool cp) { - return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8); - } - - /** - * @return Index in constant pool of field/method signature. - */ - public final int getSignatureIndex() { return signature_index; } - - /** @return signature - */ - public final String getSignature(ConstantPool cp) { - return cp.constantToString(getSignatureIndex(), Constants.CONSTANT_Utf8); - } - - /** - * @param name_index. - */ - public final void setNameIndex(int name_index) { - this.name_index = name_index; - } - - /** - * @param signature_index. - */ - public final void setSignatureIndex(int signature_index) { - this.signature_index = signature_index; - } - - /** - * @return String representation - */ - public final String toString() { - return super.toString() + "(name_index = " + name_index + - ", signature_index = " + signature_index + ")"; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java deleted file mode 100644 index 61440e54a5c..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantObject.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -/** - * This interface denotes those constants that have a "natural" value, - * such as ConstantLong, ConstantString, etc.. - * - * @author M. Dahm - * @see Constant - */ -public interface ConstantObject { - /** @return object representing the constant, e.g., Long for ConstantLong - */ - public abstract Object getConstantValue(ConstantPool cp); -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java deleted file mode 100644 index 091e70cbfbf..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantPool.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents the constant pool, i.e., a table of constants, of - * a parsed classfile. It may contain null references, due to the JVM - * specification that skips an entry after an 8-byte constant (double, - * long) entry. Those interested in generating constant pools - * programatically should see - * ConstantPoolGen. - - * @see Constant - * @see com.sun.org.apache.bcel.internal.generic.ConstantPoolGen - * @author M. Dahm - */ -public class ConstantPool implements Cloneable, Node, Serializable { - private int constant_pool_count; - private Constant[] constant_pool; - - /** - * @param constant_pool Array of constants - */ - public ConstantPool(Constant[] constant_pool) - { - setConstantPool(constant_pool); - } - - /** - * Read constants from given file stream. - * - * @param file Input stream - * @throws IOException - * @throws ClassFormatException - */ - ConstantPool(DataInputStream file) throws IOException, ClassFormatException - { - byte tag; - - constant_pool_count = file.readUnsignedShort(); - constant_pool = new Constant[constant_pool_count]; - - /* constant_pool[0] is unused by the compiler and may be used freely - * by the implementation. - */ - for(int i=1; i < constant_pool_count; i++) { - constant_pool[i] = Constant.readConstant(file); - - /* Quote from the JVM specification: - * "All eight byte constants take up two spots in the constant pool. - * If this is the n'th byte in the constant pool, then the next item - * will be numbered n+2" - * - * Thus we have to increment the index counter. - */ - tag = constant_pool[i].getTag(); - if((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) - i++; - } - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantPool(this); - } - - /** - * Resolve constant to a string representation. - * - * @param constant Constant to be printed - * @return String representation - */ - public String constantToString(Constant c) - throws ClassFormatException - { - String str; - int i; - byte tag = c.getTag(); - - switch(tag) { - case Constants.CONSTANT_Class: - i = ((ConstantClass)c).getNameIndex(); - c = getConstant(i, Constants.CONSTANT_Utf8); - str = Utility.compactClassName(((ConstantUtf8)c).getBytes(), false); - break; - - case Constants.CONSTANT_String: - i = ((ConstantString)c).getStringIndex(); - c = getConstant(i, Constants.CONSTANT_Utf8); - str = "\"" + escape(((ConstantUtf8)c).getBytes()) + "\""; - break; - - case Constants.CONSTANT_Utf8: str = ((ConstantUtf8)c).getBytes(); break; - case Constants.CONSTANT_Double: str = "" + ((ConstantDouble)c).getBytes(); break; - case Constants.CONSTANT_Float: str = "" + ((ConstantFloat)c).getBytes(); break; - case Constants.CONSTANT_Long: str = "" + ((ConstantLong)c).getBytes(); break; - case Constants.CONSTANT_Integer: str = "" + ((ConstantInteger)c).getBytes(); break; - - case Constants.CONSTANT_NameAndType: - str = (constantToString(((ConstantNameAndType)c).getNameIndex(), - Constants.CONSTANT_Utf8) + " " + - constantToString(((ConstantNameAndType)c).getSignatureIndex(), - Constants.CONSTANT_Utf8)); - break; - - case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref: - case Constants.CONSTANT_Fieldref: - str = (constantToString(((ConstantCP)c).getClassIndex(), - Constants.CONSTANT_Class) + "." + - constantToString(((ConstantCP)c).getNameAndTypeIndex(), - Constants.CONSTANT_NameAndType)); - break; - - default: // Never reached - throw new RuntimeException("Unknown constant type " + tag); - } - - return str; - } - - private static final String escape(String str) { - int len = str.length(); - StringBuffer buf = new StringBuffer(len + 5); - char[] ch = str.toCharArray(); - - for(int i=0; i < len; i++) { - switch(ch[i]) { - case '\n' : buf.append("\\n"); break; - case '\r' : buf.append("\\r"); break; - case '\t' : buf.append("\\t"); break; - case '\b' : buf.append("\\b"); break; - case '"' : buf.append("\\\""); break; - default: buf.append(ch[i]); - } - } - - return buf.toString(); - } - - - /** - * Retrieve constant at `index' from constant pool and resolve it to - * a string representation. - * - * @param index of constant in constant pool - * @param tag expected type - * @return String representation - */ - public String constantToString(int index, byte tag) - throws ClassFormatException - { - Constant c = getConstant(index, tag); - return constantToString(c); - } - - /** - * Dump constant pool to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public void dump(DataOutputStream file) throws IOException - { - file.writeShort(constant_pool_count); - - for(int i=1; i < constant_pool_count; i++) - if(constant_pool[i] != null) - constant_pool[i].dump(file); - } - - /** - * Get constant from constant pool. - * - * @param index Index in constant pool - * @return Constant value - * @see Constant - */ - public Constant getConstant(int index) { - if (index >= constant_pool.length || index < 0) - throw new ClassFormatException("Invalid constant pool reference: " + - index + ". Constant pool size is: " + - constant_pool.length); - return constant_pool[index]; - } - - /** - * Get constant from constant pool and check whether it has the - * expected type. - * - * @param index Index in constant pool - * @param tag Tag of expected constant, i.e., its type - * @return Constant value - * @see Constant - * @throws ClassFormatException - */ - public Constant getConstant(int index, byte tag) - throws ClassFormatException - { - Constant c; - - c = getConstant(index); - - if(c == null) - throw new ClassFormatException("Constant pool at index " + index + " is null."); - - if(c.getTag() == tag) - return c; - else - throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag] + - "' at index " + index + " and got " + c); - } - - /** - * @return Array of constants. - * @see Constant - */ - public Constant[] getConstantPool() { return constant_pool; } - /** - * Get string from constant pool and bypass the indirection of - * `ConstantClass' and `ConstantString' objects. I.e. these classes have - * an index field that points to another entry of the constant pool of - * type `ConstantUtf8' which contains the real data. - * - * @param index Index in constant pool - * @param tag Tag of expected constant, either ConstantClass or ConstantString - * @return Contents of string reference - * @see ConstantClass - * @see ConstantString - * @throws ClassFormatException - */ - public String getConstantString(int index, byte tag) - throws ClassFormatException - { - Constant c; - int i; - - c = getConstant(index, tag); - - /* This switch() is not that elegant, since the two classes have the - * same contents, they just differ in the name of the index - * field variable. - * But we want to stick to the JVM naming conventions closely though - * we could have solved these more elegantly by using the same - * variable name or by subclassing. - */ - switch(tag) { - case Constants.CONSTANT_Class: i = ((ConstantClass)c).getNameIndex(); break; - case Constants.CONSTANT_String: i = ((ConstantString)c).getStringIndex(); break; - default: - throw new RuntimeException("getConstantString called with illegal tag " + tag); - } - - // Finally get the string from the constant pool - c = getConstant(i, Constants.CONSTANT_Utf8); - return ((ConstantUtf8)c).getBytes(); - } - /** - * @return Length of constant pool. - */ - public int getLength() - { - return constant_pool_count; - } - - /** - * @param constant Constant to set - */ - public void setConstant(int index, Constant constant) { - constant_pool[index] = constant; - } - - /** - * @param constant_pool - */ - public void setConstantPool(Constant[] constant_pool) { - this.constant_pool = constant_pool; - constant_pool_count = (constant_pool == null)? 0 : constant_pool.length; - } - /** - * @return String representation. - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - - for(int i=1; i < constant_pool_count; i++) - buf.append(i + ")" + constant_pool[i] + "\n"); - - return buf.toString(); - } - - /** - * @return deep copy of this constant pool - */ - public ConstantPool copy() { - ConstantPool c = null; - - try { - c = (ConstantPool)clone(); - } catch(CloneNotSupportedException e) {} - - c.constant_pool = new Constant[constant_pool_count]; - - for(int i=1; i < constant_pool_count; i++) { - if(constant_pool[i] != null) - c.constant_pool[i] = constant_pool[i].copy(); - } - - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java deleted file mode 100644 index 40ea5299f43..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantString.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a String object. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantString extends Constant implements ConstantObject { - private int string_index; // Identical to ConstantClass except for this name - - /** - * Initialize from another object. - */ - public ConstantString(ConstantString c) { - this(c.getStringIndex()); - } - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantString(DataInputStream file) throws IOException - { - this((int)file.readUnsignedShort()); - } - /** - * @param string_index Index of Constant_Utf8 in constant pool - */ - public ConstantString(int string_index) - { - super(Constants.CONSTANT_String); - this.string_index = string_index; - } - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantString(this); - } - /** - * Dump constant field reference to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeShort(string_index); - } - /** - * @return Index in constant pool of the string (ConstantUtf8). - */ - public final int getStringIndex() { return string_index; } - /** - * @param string_index. - */ - public final void setStringIndex(int string_index) { - this.string_index = string_index; - } - /** - * @return String representation. - */ - public final String toString() - { - return super.toString() + "(string_index = " + string_index + ")"; - } - - /** @return String object - */ - public Object getConstantValue(ConstantPool cp) { - Constant c = cp.getConstant(string_index, Constants.CONSTANT_Utf8); - return ((ConstantUtf8)c).getBytes(); - } - - /** @return dereferenced string - */ - public String getBytes(ConstantPool cp) { - return (String)getConstantValue(cp); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java deleted file mode 100644 index 32e9555e1b1..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantUtf8.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from the abstract - * Constant class - * and represents a reference to a Utf8 encoded string. - * - * @author M. Dahm - * @see Constant - */ -public final class ConstantUtf8 extends Constant { - private String bytes; - - /** - * Initialize from another object. - */ - public ConstantUtf8(ConstantUtf8 c) { - this(c.getBytes()); - } - - /** - * Initialize instance from file data. - * - * @param file Input stream - * @throws IOException - */ - ConstantUtf8(DataInputStream file) throws IOException - { - super(Constants.CONSTANT_Utf8); - - bytes = file.readUTF(); - } - - /** - * @param bytes Data - */ - public ConstantUtf8(String bytes) - { - super(Constants.CONSTANT_Utf8); - - if(bytes == null) - throw new IllegalArgumentException("bytes must not be null!"); - - this.bytes = bytes; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantUtf8(this); - } - - /** - * Dump String in Utf8 format to file stream. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(tag); - file.writeUTF(bytes); - } - - /** - * @return Data converted to string. - */ - public final String getBytes() { return bytes; } - - /** - * @param bytes. - */ - public final void setBytes(String bytes) { - this.bytes = bytes; - } - - /** - * @return String representation - */ - public final String toString() - { - return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")"; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java deleted file mode 100644 index e16d47b2fbd..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantValue.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from Attribute and represents a constant - * value, i.e., a default value for initializing a class field. - * This class is instantiated by the Attribute.readAttribute() method. - * - * @author M. Dahm - * @see Attribute - */ -public final class ConstantValue extends Attribute { - private int constantvalue_index; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public ConstantValue(ConstantValue c) { - this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), - c.getConstantPool()); - } - - /** - * Construct object from file stream. - * @param name_index Name index in constant pool - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throw IOException - */ - ConstantValue(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (int)file.readUnsignedShort(), constant_pool); - } - - /** - * @param name_index Name index in constant pool - * @param length Content length in bytes - * @param constantvalue_index Index in constant pool - * @param constant_pool Array of constants - */ - public ConstantValue(int name_index, int length, - int constantvalue_index, - ConstantPool constant_pool) - { - super(Constants.ATTR_CONSTANT_VALUE, name_index, length, constant_pool); - this.constantvalue_index = constantvalue_index; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitConstantValue(this); - } - /** - * Dump constant value attribute to file stream on binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(constantvalue_index); - } - /** - * @return Index in constant pool of constant value. - */ - public final int getConstantValueIndex() { return constantvalue_index; } - - /** - * @param constantvalue_index. - */ - public final void setConstantValueIndex(int constantvalue_index) { - this.constantvalue_index = constantvalue_index; - } - - /** - * @return String representation of constant value. - */ - public final String toString() { - Constant c = constant_pool.getConstant(constantvalue_index); - - String buf; - int i; - - // Print constant to string depending on its type - switch(c.getTag()) { - case Constants.CONSTANT_Long: buf = "" + ((ConstantLong)c).getBytes(); break; - case Constants.CONSTANT_Float: buf = "" + ((ConstantFloat)c).getBytes(); break; - case Constants.CONSTANT_Double: buf = "" + ((ConstantDouble)c).getBytes(); break; - case Constants.CONSTANT_Integer: buf = "" + ((ConstantInteger)c).getBytes(); break; - case Constants.CONSTANT_String: - i = ((ConstantString)c).getStringIndex(); - c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8); - buf = "\"" + Utility.convertString(((ConstantUtf8)c).getBytes()) + "\""; - break; - - default: - throw new IllegalStateException("Type of ConstValue invalid: " + c); - } - - return buf; - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - ConstantValue c = (ConstantValue)clone(); - c.constant_pool = constant_pool; - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java deleted file mode 100644 index 096f77f3b7a..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Deprecated.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from Attribute and denotes that this is a - * deprecated method. - * It is instantiated from the Attribute.readAttribute() method. - * - * @author M. Dahm - * @see Attribute - */ -public final class Deprecated extends Attribute { - private byte[] bytes; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public Deprecated(Deprecated c) { - this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); - } - - /** - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param bytes Attribute contents - * @param constant_pool Array of constants - */ - public Deprecated(int name_index, int length, byte[] bytes, - ConstantPool constant_pool) - { - super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool); - this.bytes = bytes; - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - Deprecated(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (byte [])null, constant_pool); - - if(length > 0) { - bytes = new byte[length]; - file.readFully(bytes); - System.err.println("Deprecated attribute with length > 0"); - } - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitDeprecated(this); - } - - /** - * Dump source file attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - - if(length > 0) - file.write(bytes, 0, length); - } - - /** - * @return data bytes. - */ - public final byte[] getBytes() { return bytes; } - - /** - * @param bytes. - */ - public final void setBytes(byte[] bytes) { - this.bytes = bytes; - } - - /** - * @return attribute name - */ - public final String toString() { - return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED]; - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - Deprecated c = (Deprecated)clone(); - - if(bytes != null) - c.bytes = (byte[])bytes.clone(); - - c.constant_pool = constant_pool; - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java deleted file mode 100644 index c25cce0555b..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/DescendingVisitor.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ -import java.util.Stack; - -/** - * Traverses a JavaClass with another Visitor object 'piggy-backed' - * that is applied to all components of a JavaClass object. I.e. this - * class supplies the traversal strategy, other classes can make use - * of it. - * - * @author M. Dahm - */ -public class DescendingVisitor implements Visitor { - private JavaClass clazz; - private Visitor visitor; - private Stack stack = new Stack(); - - /** @return container of current entitity, i.e., predecessor during traversal - */ - public Object predecessor() { - return predecessor(0); - } - - /** - * @param level nesting level, i.e., 0 returns the direct predecessor - * @return container of current entitity, i.e., predecessor during traversal - */ - public Object predecessor(int level) { - int size = stack.size(); - - if((size < 2) || (level < 0)) - return null; - else - return stack.elementAt(size - (level + 2)); // size - 1 == current - } - - /** @return current object - */ - public Object current() { - return stack.peek(); - } - - /** - * @param clazz Class to traverse - * @param visitor visitor object to apply to all components - */ - public DescendingVisitor(JavaClass clazz, Visitor visitor) { - this.clazz = clazz; - this.visitor = visitor; - } - - /** - * Start traversal. - */ - public void visit() { clazz.accept(this); } - - public void visitJavaClass(JavaClass clazz) { - stack.push(clazz); - clazz.accept(visitor); - - Field[] fields = clazz.getFields(); - for(int i=0; i < fields.length; i++) - fields[i].accept(this); - - Method[] methods = clazz.getMethods(); - for(int i=0; i < methods.length; i++) - methods[i].accept(this); - - Attribute[] attributes = clazz.getAttributes(); - for(int i=0; i < attributes.length; i++) - attributes[i].accept(this); - - clazz.getConstantPool().accept(this); - stack.pop(); - } - - public void visitField(Field field) { - stack.push(field); - field.accept(visitor); - - Attribute[] attributes = field.getAttributes(); - for(int i=0; i < attributes.length; i++) - attributes[i].accept(this); - stack.pop(); - } - - public void visitConstantValue(ConstantValue cv) { - stack.push(cv); - cv.accept(visitor); - stack.pop(); - } - - public void visitMethod(Method method) { - stack.push(method); - method.accept(visitor); - - Attribute[] attributes = method.getAttributes(); - for(int i=0; i < attributes.length; i++) - attributes[i].accept(this); - - stack.pop(); - } - - public void visitExceptionTable(ExceptionTable table) { - stack.push(table); - table.accept(visitor); - stack.pop(); - } - - public void visitCode(Code code) { - stack.push(code); - code.accept(visitor); - - CodeException[] table = code.getExceptionTable(); - for(int i=0; i < table.length; i++) - table[i].accept(this); - - Attribute[] attributes = code.getAttributes(); - for(int i=0; i < attributes.length; i++) - attributes[i].accept(this); - stack.pop(); - } - - public void visitCodeException(CodeException ce) { - stack.push(ce); - ce.accept(visitor); - stack.pop(); - } - - public void visitLineNumberTable(LineNumberTable table) { - stack.push(table); - table.accept(visitor); - - LineNumber[] numbers = table.getLineNumberTable(); - for(int i=0; i < numbers.length; i++) - numbers[i].accept(this); - stack.pop(); - } - - public void visitLineNumber(LineNumber number) { - stack.push(number); - number.accept(visitor); - stack.pop(); - } - - public void visitLocalVariableTable(LocalVariableTable table) { - stack.push(table); - table.accept(visitor); - - LocalVariable[] vars = table.getLocalVariableTable(); - for(int i=0; i < vars.length; i++) - vars[i].accept(this); - stack.pop(); - } - - public void visitStackMap(StackMap table) { - stack.push(table); - table.accept(visitor); - - StackMapEntry[] vars = table.getStackMap(); - - for(int i=0; i < vars.length; i++) - vars[i].accept(this); - stack.pop(); - } - - public void visitStackMapEntry(StackMapEntry var) { - stack.push(var); - var.accept(visitor); - stack.pop(); - } - - public void visitLocalVariable(LocalVariable var) { - stack.push(var); - var.accept(visitor); - stack.pop(); - } - - public void visitConstantPool(ConstantPool cp) { - stack.push(cp); - cp.accept(visitor); - - Constant[] constants = cp.getConstantPool(); - for(int i=1; i < constants.length; i++) { - if(constants[i] != null) - constants[i].accept(this); - } - - stack.pop(); - } - - public void visitConstantClass(ConstantClass constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantDouble(ConstantDouble constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantFieldref(ConstantFieldref constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantFloat(ConstantFloat constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantInteger(ConstantInteger constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantLong(ConstantLong constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantMethodref(ConstantMethodref constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantNameAndType(ConstantNameAndType constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantString(ConstantString constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitConstantUtf8(ConstantUtf8 constant) { - stack.push(constant); - constant.accept(visitor); - stack.pop(); - } - - public void visitInnerClasses(InnerClasses ic) { - stack.push(ic); - ic.accept(visitor); - - InnerClass[] ics = ic.getInnerClasses(); - for(int i=0; i < ics.length; i++) - ics[i].accept(this); - stack.pop(); - } - - public void visitInnerClass(InnerClass inner) { - stack.push(inner); - inner.accept(visitor); - stack.pop(); - } - - public void visitDeprecated(Deprecated attribute) { - stack.push(attribute); - attribute.accept(visitor); - stack.pop(); - } - - public void visitSignature(Signature attribute) { - stack.push(attribute); - attribute.accept(visitor); - stack.pop(); - } - - public void visitSourceFile(SourceFile attribute) { - stack.push(attribute); - attribute.accept(visitor); - stack.pop(); - } - - public void visitSynthetic(Synthetic attribute) { - stack.push(attribute); - attribute.accept(visitor); - stack.pop(); - } - - public void visitUnknown(Unknown attribute) { - stack.push(attribute); - attribute.accept(visitor); - stack.pop(); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java deleted file mode 100644 index 88fe11e6a8a..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/EmptyVisitor.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.classfile.*; -import com.sun.org.apache.bcel.internal.*; - -/** - * Visitor with empty method bodies, can be extended and used in conjunction with the - * DescendingVisitor class, e.g. - * - * By courtesy of David Spencer. - * - * @see DescendingVisitor - * - */ -public class EmptyVisitor implements Visitor { - protected EmptyVisitor() { } - - public void visitCode(Code obj) {} - public void visitCodeException(CodeException obj) {} - public void visitConstantClass(ConstantClass obj) {} - public void visitConstantDouble(ConstantDouble obj) {} - public void visitConstantFieldref(ConstantFieldref obj) {} - public void visitConstantFloat(ConstantFloat obj) {} - public void visitConstantInteger(ConstantInteger obj) {} - public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj) {} - public void visitConstantLong(ConstantLong obj) {} - public void visitConstantMethodref(ConstantMethodref obj) {} - public void visitConstantNameAndType(ConstantNameAndType obj) {} - public void visitConstantPool(ConstantPool obj) {} - public void visitConstantString(ConstantString obj) {} - public void visitConstantUtf8(ConstantUtf8 obj) {} - public void visitConstantValue(ConstantValue obj) {} - public void visitDeprecated(Deprecated obj) {} - public void visitExceptionTable(ExceptionTable obj) {} - public void visitField(Field obj) {} - public void visitInnerClass(InnerClass obj) {} - public void visitInnerClasses(InnerClasses obj) {} - public void visitJavaClass(JavaClass obj) {} - public void visitLineNumber(LineNumber obj) {} - public void visitLineNumberTable(LineNumberTable obj) {} - public void visitLocalVariable(LocalVariable obj) {} - public void visitLocalVariableTable(LocalVariableTable obj) {} - public void visitMethod(Method obj) {} - public void visitSignature(Signature obj) {} - public void visitSourceFile(SourceFile obj) {} - public void visitSynthetic(Synthetic obj) {} - public void visitUnknown(Unknown obj) {} - public void visitStackMap(StackMap obj) {} - public void visitStackMapEntry(StackMapEntry obj) {} -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java deleted file mode 100644 index 0a9e1dcf155..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/ExceptionTable.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents the table of exceptions that are thrown by a - * method. This attribute may be used once per method. The name of - * this class is ExceptionTable for historical reasons; The - * Java Virtual Machine Specification, Second Edition defines this - * attribute using the name Exceptions (which is inconsistent - * with the other classes). - * - * @author M. Dahm - * @see Code - */ -public final class ExceptionTable extends Attribute { - private int number_of_exceptions; // Table of indices into - private int[] exception_index_table; // constant pool - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use copy() for a physical copy. - */ - public ExceptionTable(ExceptionTable c) { - this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), - c.getConstantPool()); - } - - /** - * @param name_index Index in constant pool - * @param length Content length in bytes - * @param exception_index_table Table of indices in constant pool - * @param constant_pool Array of constants - */ - public ExceptionTable(int name_index, int length, - int[] exception_index_table, - ConstantPool constant_pool) - { - super(Constants.ATTR_EXCEPTIONS, name_index, length, constant_pool); - setExceptionIndexTable(exception_index_table); - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - ExceptionTable(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (int[])null, constant_pool); - - number_of_exceptions = file.readUnsignedShort(); - exception_index_table = new int[number_of_exceptions]; - - for(int i=0; i < number_of_exceptions; i++) - exception_index_table[i] = file.readUnsignedShort(); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitExceptionTable(this); - } - - /** - * Dump exceptions attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(number_of_exceptions); - for(int i=0; i < number_of_exceptions; i++) - file.writeShort(exception_index_table[i]); - } - - /** - * @return Array of indices into constant pool of thrown exceptions. - */ - public final int[] getExceptionIndexTable() {return exception_index_table;} - /** - * @return Length of exception table. - */ - public final int getNumberOfExceptions() { return number_of_exceptions; } - - /** - * @return class names of thrown exceptions - */ - public final String[] getExceptionNames() { - String[] names = new String[number_of_exceptions]; - for(int i=0; i < number_of_exceptions; i++) - names[i] = constant_pool.getConstantString(exception_index_table[i], - Constants.CONSTANT_Class). - replace('/', '.'); - return names; - } - - /** - * @param exception_index_table. - * Also redefines number_of_exceptions according to table length. - */ - public final void setExceptionIndexTable(int[] exception_index_table) { - this.exception_index_table = exception_index_table; - number_of_exceptions = (exception_index_table == null)? 0 : - exception_index_table.length; - } - /** - * @return String representation, i.e., a list of thrown exceptions. - */ - public final String toString() { - StringBuffer buf = new StringBuffer(""); - String str; - - for(int i=0; i < number_of_exceptions; i++) { - str = constant_pool.getConstantString(exception_index_table[i], - Constants.CONSTANT_Class); - buf.append(Utility.compactClassName(str, false)); - - if(i < number_of_exceptions - 1) - buf.append(", "); - } - - return buf.toString(); - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - ExceptionTable c = (ExceptionTable)clone(); - c.exception_index_table = (int[])exception_index_table.clone(); - c.constant_pool = constant_pool; - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Field.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Field.java deleted file mode 100644 index 6bc42ee48be..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Field.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ -import com.sun.org.apache.bcel.internal.Constants; -import com.sun.org.apache.bcel.internal.generic.Type; -import java.io.*; - -/** - * This class represents the field info structure, i.e., the representation - * for a variable in the class. See JVM specification for details. - * - * @author M. Dahm - */ -public final class Field extends FieldOrMethod { - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public Field(Field c) { - super(c); - } - - /** - * Construct object from file stream. - * @param file Input stream - */ - Field(DataInputStream file, ConstantPool constant_pool) - throws IOException, ClassFormatException - { - super(file, constant_pool); - } - - /** - * @param access_flags Access rights of field - * @param name_index Points to field name in constant pool - * @param signature_index Points to encoded signature - * @param attributes Collection of attributes - * @param constant_pool Array of constants - */ - public Field(int access_flags, int name_index, int signature_index, - Attribute[] attributes, ConstantPool constant_pool) - { - super(access_flags, name_index, signature_index, attributes, constant_pool); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitField(this); - } - - /** - * @return constant value associated with this field (may be null) - */ - public final ConstantValue getConstantValue() { - for(int i=0; i < attributes_count; i++) - if(attributes[i].getTag() == Constants.ATTR_CONSTANT_VALUE) - return (ConstantValue)attributes[i]; - - return null; - } - - /** - * Return string representation close to declaration format, - * `public static final short MAX = 100', e.g.. - * - * @return String representation of field, including the signature. - */ - public final String toString() { - String name, signature, access; // Short cuts to constant pool - - // Get names from constant pool - access = Utility.accessToString(access_flags); - access = access.equals("")? "" : (access + " "); - signature = Utility.signatureToString(getSignature()); - name = getName(); - - StringBuffer buf = new StringBuffer(access + signature + " " + name); - ConstantValue cv = getConstantValue(); - - if(cv != null) - buf.append(" = " + cv); - - for(int i=0; i < attributes_count; i++) { - Attribute a = attributes[i]; - - if(!(a instanceof ConstantValue)) - buf.append(" [" + a.toString() + "]"); - } - - return buf.toString(); - } - - /** - * @return deep copy of this field - */ - public final Field copy(ConstantPool constant_pool) { - return (Field)copy_(constant_pool); - } - - /** - * @return type of field - */ - public Type getType() { - return Type.getReturnType(getSignature()); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java deleted file mode 100644 index 86b7da20be7..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/FieldOrMethod.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * Abstract super class for fields and methods. - * - * @author M. Dahm - */ -public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node { - protected int name_index; // Points to field name in constant pool - protected int signature_index; // Points to encoded signature - protected int attributes_count;// No. of attributes - protected Attribute[] attributes; // Collection of attributes - protected ConstantPool constant_pool; - - FieldOrMethod() {} - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - protected FieldOrMethod(FieldOrMethod c) { - this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), - c.getAttributes(), c.getConstantPool()); - } - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - * @throws ClassFormatException - */ - protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool) - throws IOException, ClassFormatException - { - this(file.readUnsignedShort(), file.readUnsignedShort(), - file.readUnsignedShort(), null, constant_pool); - - attributes_count = file.readUnsignedShort(); - attributes = new Attribute[attributes_count]; - for(int i=0; i < attributes_count; i++) - attributes[i] = Attribute.readAttribute(file, constant_pool); - } - - /** - * @param access_flags Access rights of method - * @param name_index Points to field name in constant pool - * @param signature_index Points to encoded signature - * @param attributes Collection of attributes - * @param constant_pool Array of constants - */ - protected FieldOrMethod(int access_flags, int name_index, int signature_index, - Attribute[] attributes, ConstantPool constant_pool) - { - this.access_flags = access_flags; - this.name_index = name_index; - this.signature_index = signature_index; - this.constant_pool = constant_pool; - - setAttributes(attributes); - } - - /** - * Dump object to file stream on binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeShort(access_flags); - file.writeShort(name_index); - file.writeShort(signature_index); - file.writeShort(attributes_count); - - for(int i=0; i < attributes_count; i++) - attributes[i].dump(file); - } - - /** - * @return Collection of object attributes. - */ - public final Attribute[] getAttributes() { return attributes; } - - /** - * @param attributes Collection of object attributes. - */ - public final void setAttributes(Attribute[] attributes) { - this.attributes = attributes; - attributes_count = (attributes == null)? 0 : attributes.length; - } - - /** - * @return Constant pool used by this object. - */ - public final ConstantPool getConstantPool() { return constant_pool; } - - /** - * @param constant_pool Constant pool to be used for this object. - */ - public final void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } - - /** - * @return Index in constant pool of object's name. - */ - public final int getNameIndex() { return name_index; } - - /** - * @param name_index Index in constant pool of object's name. - */ - public final void setNameIndex(int name_index) { - this.name_index = name_index; - } - - /** - * @return Index in constant pool of field signature. - */ - public final int getSignatureIndex() { return signature_index; } - - /** - * @param signature_index Index in constant pool of field signature. - */ - public final void setSignatureIndex(int signature_index) { - this.signature_index = signature_index; - } - - /** - * @return Name of object, i.e., method name or field name - */ - public final String getName() { - ConstantUtf8 c; - c = (ConstantUtf8)constant_pool.getConstant(name_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * @return String representation of object's type signature (java style) - */ - public final String getSignature() { - ConstantUtf8 c; - c = (ConstantUtf8)constant_pool.getConstant(signature_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * @return deep copy of this field - */ - protected FieldOrMethod copy_(ConstantPool constant_pool) { - FieldOrMethod c = null; - - try { - c = (FieldOrMethod)clone(); - } catch(CloneNotSupportedException e) {} - - c.constant_pool = constant_pool; - c.attributes = new Attribute[attributes_count]; - - for(int i=0; i < attributes_count; i++) - c.attributes[i] = attributes[i].copy(constant_pool); - - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java deleted file mode 100644 index 8693fa6a1f0..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClass.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a inner class attribute, i.e., the class - * indices of the inner and outer classes, the name and the attributes - * of the inner class. - * - * @author M. Dahm - * @see InnerClasses - */ -public final class InnerClass implements Cloneable, Node { - private int inner_class_index; - private int outer_class_index; - private int inner_name_index; - private int inner_access_flags; - - /** - * Initialize from another object. - */ - public InnerClass(InnerClass c) { - this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), - c.getInnerAccessFlags()); - } - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - */ - InnerClass(DataInputStream file) throws IOException - { - this(file.readUnsignedShort(), file.readUnsignedShort(), - file.readUnsignedShort(), file.readUnsignedShort()); - } - - /** - * @param inner_class_index Class index in constant pool of inner class - * @param outer_class_index Class index in constant pool of outer class - * @param inner_name_index Name index in constant pool of inner class - * @param inner_access_flags Access flags of inner class - */ - public InnerClass(int inner_class_index, int outer_class_index, - int inner_name_index, int inner_access_flags) - { - this.inner_class_index = inner_class_index; - this.outer_class_index = outer_class_index; - this.inner_name_index = inner_name_index; - this.inner_access_flags = inner_access_flags; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitInnerClass(this); - } - /** - * Dump inner class attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeShort(inner_class_index); - file.writeShort(outer_class_index); - file.writeShort(inner_name_index); - file.writeShort(inner_access_flags); - } - /** - * @return access flags of inner class. - */ - public final int getInnerAccessFlags() { return inner_access_flags; } - /** - * @return class index of inner class. - */ - public final int getInnerClassIndex() { return inner_class_index; } - /** - * @return name index of inner class. - */ - public final int getInnerNameIndex() { return inner_name_index; } - /** - * @return class index of outer class. - */ - public final int getOuterClassIndex() { return outer_class_index; } - /** - * @param inner_access_flags. - */ - public final void setInnerAccessFlags(int inner_access_flags) { - this.inner_access_flags = inner_access_flags; - } - /** - * @param inner_class_index. - */ - public final void setInnerClassIndex(int inner_class_index) { - this.inner_class_index = inner_class_index; - } - /** - * @param inner_name_index. - */ - public final void setInnerNameIndex(int inner_name_index) { - this.inner_name_index = inner_name_index; - } - /** - * @param outer_class_index. - */ - public final void setOuterClassIndex(int outer_class_index) { - this.outer_class_index = outer_class_index; - } - /** - * @return String representation. - */ - public final String toString() { - return "InnerClass(" + inner_class_index + ", " + outer_class_index + - ", " + inner_name_index + ", " + inner_access_flags + ")"; - } - - /** - * @return Resolved string representation - */ - public final String toString(ConstantPool constant_pool) { - String inner_class_name, outer_class_name, inner_name, access; - - inner_class_name = constant_pool.getConstantString(inner_class_index, - Constants.CONSTANT_Class); - inner_class_name = Utility.compactClassName(inner_class_name); - - if (outer_class_index != 0) { - outer_class_name = constant_pool.getConstantString(outer_class_index, - Constants.CONSTANT_Class); - outer_class_name = Utility.compactClassName(outer_class_name); - } - else - outer_class_name = ""; - - if(inner_name_index != 0) - inner_name = ((ConstantUtf8)constant_pool. - getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes(); - else - inner_name = ""; - - access = Utility.accessToString(inner_access_flags, true); - access = access.equals("")? "" : (access + " "); - - return "InnerClass:" + access + inner_class_name + - "(\"" + outer_class_name + "\", \"" + inner_name + "\")"; - } - - /** - * @return deep copy of this object - */ - public InnerClass copy() { - try { - return (InnerClass)clone(); - } catch(CloneNotSupportedException e) {} - - return null; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java deleted file mode 100644 index da320361327..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/InnerClasses.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from Attribute and denotes that this class - * is an Inner class of another. - * to the source file of this class. - * It is instantiated from the Attribute.readAttribute() method. - * - * @author M. Dahm - * @see Attribute - */ -public final class InnerClasses extends Attribute { - private InnerClass[] inner_classes; - private int number_of_classes; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public InnerClasses(InnerClasses c) { - this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), - c.getConstantPool()); - } - - /** - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param inner_classes array of inner classes attributes - * @param constant_pool Array of constants - * @param sourcefile_index Index in constant pool to CONSTANT_Utf8 - */ - public InnerClasses(int name_index, int length, - InnerClass[] inner_classes, - ConstantPool constant_pool) - { - super(Constants.ATTR_INNER_CLASSES, name_index, length, constant_pool); - setInnerClasses(inner_classes); - } - - /** - * Construct object from file stream. - * - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - InnerClasses(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (InnerClass[])null, constant_pool); - - number_of_classes = file.readUnsignedShort(); - inner_classes = new InnerClass[number_of_classes]; - - for(int i=0; i < number_of_classes; i++) - inner_classes[i] = new InnerClass(file); - } - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitInnerClasses(this); - } - /** - * Dump source file attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(number_of_classes); - - for(int i=0; i < number_of_classes; i++) - inner_classes[i].dump(file); - } - - /** - * @return array of inner class "records" - */ - public final InnerClass[] getInnerClasses() { return inner_classes; } - - /** - * @param inner_classes. - */ - public final void setInnerClasses(InnerClass[] inner_classes) { - this.inner_classes = inner_classes; - number_of_classes = (inner_classes == null)? 0 : inner_classes.length; - } - - /** - * @return String representation. - */ - public final String toString() { - StringBuffer buf = new StringBuffer(); - - for(int i=0; i < number_of_classes; i++) - buf.append(inner_classes[i].toString(constant_pool) + "\n"); - - return buf.toString(); - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - InnerClasses c = (InnerClasses)clone(); - - c.inner_classes = new InnerClass[number_of_classes]; - for(int i=0; i < number_of_classes; i++) - c.inner_classes[i] = inner_classes[i].copy(); - - c.constant_pool = constant_pool; - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java deleted file mode 100644 index 1c0d54ebb75..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/JavaClass.java +++ /dev/null @@ -1,824 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import com.sun.org.apache.bcel.internal.util.SyntheticRepository; -import com.sun.org.apache.bcel.internal.util.ClassVector; -import com.sun.org.apache.bcel.internal.util.ClassQueue; -import com.sun.org.apache.bcel.internal.generic.Type; - -import java.io.*; -import java.util.StringTokenizer; - -/** - * Represents a Java class, i.e., the data structures, constant pool, - * fields, methods and commands contained in a Java .class file. - * See JVM - * specification for details. - - * The intent of this class is to represent a parsed or otherwise existing - * class file. Those interested in programatically generating classes - * should see the ClassGen class. - - * @see com.sun.org.apache.bcel.internal.generic.ClassGen - * @author M. Dahm - */ -public class JavaClass extends AccessFlags implements Cloneable, Node { - private String file_name; - private String package_name; - private String source_file_name = ""; - private int class_name_index; - private int superclass_name_index; - private String class_name; - private String superclass_name; - private int major, minor; // Compiler version - private ConstantPool constant_pool; // Constant pool - private int[] interfaces; // implemented interfaces - private String[] interface_names; - private Field[] fields; // Fields, i.e., variables of class - private Method[] methods; // methods defined in the class - private Attribute[] attributes; // attributes defined in the class - private byte source = HEAP; // Generated in memory - - public static final byte HEAP = 1; - public static final byte FILE = 2; - public static final byte ZIP = 3; - - static boolean debug = false; // Debugging on/off - static char sep = '/'; // directory separator - - /** - * In cases where we go ahead and create something, - * use the default SyntheticRepository, because we - * don't know any better. - */ - private transient com.sun.org.apache.bcel.internal.util.Repository repository = - SyntheticRepository.getInstance(); - - /** - * Constructor gets all contents as arguments. - * - * @param class_name_index Index into constant pool referencing a - * ConstantClass that represents this class. - * @param superclass_name_index Index into constant pool referencing a - * ConstantClass that represents this class's superclass. - * @param file_name File name - * @param major Major compiler version - * @param minor Minor compiler version - * @param access_flags Access rights defined by bit flags - * @param constant_pool Array of constants - * @param interfaces Implemented interfaces - * @param fields Class fields - * @param methods Class methods - * @param attributes Class attributes - * @param source Read from file or generated in memory? - */ - public JavaClass(int class_name_index, - int superclass_name_index, - String file_name, - int major, - int minor, - int access_flags, - ConstantPool constant_pool, - int[] interfaces, - Field[] fields, - Method[] methods, - Attribute[] attributes, - byte source) - { - if(interfaces == null) // Allowed for backward compatibility - interfaces = new int[0]; - if(attributes == null) - this.attributes = new Attribute[0]; - if(fields == null) - fields = new Field[0]; - if(methods == null) - methods = new Method[0]; - - this.class_name_index = class_name_index; - this.superclass_name_index = superclass_name_index; - this.file_name = file_name; - this.major = major; - this.minor = minor; - this.access_flags = access_flags; - this.constant_pool = constant_pool; - this.interfaces = interfaces; - this.fields = fields; - this.methods = methods; - this.attributes = attributes; - this.source = source; - - // Get source file name if available - for(int i=0; i < attributes.length; i++) { - if(attributes[i] instanceof SourceFile) { - source_file_name = ((SourceFile)attributes[i]).getSourceFileName(); - break; - } - } - - /* According to the specification the following entries must be of type - * `ConstantClass' but we check that anyway via the - * `ConstPool.getConstant' method. - */ - class_name = constant_pool.getConstantString(class_name_index, - Constants.CONSTANT_Class); - class_name = Utility.compactClassName(class_name, false); - - int index = class_name.lastIndexOf('.'); - if(index < 0) - package_name = ""; - else - package_name = class_name.substring(0, index); - - if(superclass_name_index > 0) { // May be zero -> class is java.lang.Object - superclass_name = constant_pool.getConstantString(superclass_name_index, - Constants.CONSTANT_Class); - superclass_name = Utility.compactClassName(superclass_name, false); - } - else - superclass_name = "java.lang.Object"; - - interface_names = new String[interfaces.length]; - for(int i=0; i < interfaces.length; i++) { - String str = constant_pool.getConstantString(interfaces[i], Constants.CONSTANT_Class); - interface_names[i] = Utility.compactClassName(str, false); - } - } - - /** - * Constructor gets all contents as arguments. - * - * @param class_name_index Class name - * @param superclass_name_index Superclass name - * @param file_name File name - * @param major Major compiler version - * @param minor Minor compiler version - * @param access_flags Access rights defined by bit flags - * @param constant_pool Array of constants - * @param interfaces Implemented interfaces - * @param fields Class fields - * @param methods Class methods - * @param attributes Class attributes - */ - public JavaClass(int class_name_index, - int superclass_name_index, - String file_name, - int major, - int minor, - int access_flags, - ConstantPool constant_pool, - int[] interfaces, - Field[] fields, - Method[] methods, - Attribute[] attributes) { - this(class_name_index, superclass_name_index, file_name, major, minor, access_flags, - constant_pool, interfaces, fields, methods, attributes, HEAP); - } - - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitJavaClass(this); - } - - /* Print debug information depending on `JavaClass.debug' - */ - static final void Debug(String str) { - if(debug) - System.out.println(str); - } - - /** - * Dump class to a file. - * - * @param file Output file - * @throws IOException - */ - public void dump(File file) throws IOException - { - String parent = file.getParent(); - - if(parent != null) { - File dir = new File(parent); - - if(dir != null) - dir.mkdirs(); - } - - dump(new DataOutputStream(new FileOutputStream(file))); - } - - /** - * Dump class to a file named file_name. - * - * @param file_name Output file name - * @exception IOException - */ - public void dump(String file_name) throws IOException - { - dump(new File(file_name)); - } - - /** - * @return class in binary format - */ - public byte[] getBytes() { - ByteArrayOutputStream s = new ByteArrayOutputStream(); - DataOutputStream ds = new DataOutputStream(s); - - try { - dump(ds); - } catch(IOException e) { - e.printStackTrace(); - } finally { - try { ds.close(); } catch(IOException e2) { e2.printStackTrace(); } - } - - return s.toByteArray(); - } - - /** - * Dump Java class to output stream in binary format. - * - * @param file Output stream - * @exception IOException - */ - public void dump(OutputStream file) throws IOException { - dump(new DataOutputStream(file)); - } - - /** - * Dump Java class to output stream in binary format. - * - * @param file Output stream - * @exception IOException - */ - public void dump(DataOutputStream file) throws IOException - { - file.writeInt(0xcafebabe); - file.writeShort(minor); - file.writeShort(major); - - constant_pool.dump(file); - - file.writeShort(access_flags); - file.writeShort(class_name_index); - file.writeShort(superclass_name_index); - - file.writeShort(interfaces.length); - for(int i=0; i < interfaces.length; i++) - file.writeShort(interfaces[i]); - - file.writeShort(fields.length); - for(int i=0; i < fields.length; i++) - fields[i].dump(file); - - file.writeShort(methods.length); - for(int i=0; i < methods.length; i++) - methods[i].dump(file); - - if(attributes != null) { - file.writeShort(attributes.length); - for(int i=0; i < attributes.length; i++) - attributes[i].dump(file); - } - else - file.writeShort(0); - - file.close(); - } - - /** - * @return Attributes of the class. - */ - public Attribute[] getAttributes() { return attributes; } - - /** - * @return Class name. - */ - public String getClassName() { return class_name; } - - /** - * @return Package name. - */ - public String getPackageName() { return package_name; } - - /** - * @return Class name index. - */ - public int getClassNameIndex() { return class_name_index; } - - /** - * @return Constant pool. - */ - public ConstantPool getConstantPool() { return constant_pool; } - - /** - * @return Fields, i.e., variables of the class. Like the JVM spec - * mandates for the classfile format, these fields are those specific to - * this class, and not those of the superclass or superinterfaces. - */ - public Field[] getFields() { return fields; } - - /** - * @return File name of class, aka SourceFile attribute value - */ - public String getFileName() { return file_name; } - - /** - * @return Names of implemented interfaces. - */ - public String[] getInterfaceNames() { return interface_names; } - - /** - * @return Indices in constant pool of implemented interfaces. - */ - public int[] getInterfaceIndices() { return interfaces; } - - /** - * @return Major number of class file version. - */ - public int getMajor() { return major; } - - /** - * @return Methods of the class. - */ - public Method[] getMethods() { return methods; } - - /** - * @return A com.sun.org.apache.bcel.internal.classfile.Method corresponding to - * java.lang.reflect.Method if any - */ - public Method getMethod(java.lang.reflect.Method m) { - for(int i = 0; i < methods.length; i++) { - Method method = methods[i]; - - if(m.getName().equals(method.getName()) && - (m.getModifiers() == method.getModifiers()) && - Type.getSignature(m).equals(method.getSignature())) { - return method; - } - } - - return null; - } - - /** - * @return Minor number of class file version. - */ - public int getMinor() { return minor; } - - /** - * @return sbsolute path to file where this class was read from - */ - public String getSourceFileName() { return source_file_name; } - - /** - * @return Superclass name. - */ - public String getSuperclassName() { return superclass_name; } - - /** - * @return Class name index. - */ - public int getSuperclassNameIndex() { return superclass_name_index; } - - static { - // Debugging ... on/off - String debug = null, sep = null; - - try { - debug = System.getProperty("JavaClass.debug"); - // Get path separator either / or \ usually - sep = System.getProperty("file.separator"); - } - catch (SecurityException e) { - // falls through - } - - if(debug != null) - JavaClass.debug = new Boolean(debug).booleanValue(); - - if(sep != null) - try { - JavaClass.sep = sep.charAt(0); - } catch(StringIndexOutOfBoundsException e) {} // Never reached - } - - /** - * @param attributes . - */ - public void setAttributes(Attribute[] attributes) { - this.attributes = attributes; - } - - /** - * @param class_name . - */ - public void setClassName(String class_name) { - this.class_name = class_name; - } - - /** - * @param class_name_index . - */ - public void setClassNameIndex(int class_name_index) { - this.class_name_index = class_name_index; - } - - /** - * @param constant_pool . - */ - public void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } - - /** - * @param fields . - */ - public void setFields(Field[] fields) { - this.fields = fields; - } - - /** - * Set File name of class, aka SourceFile attribute value - */ - public void setFileName(String file_name) { - this.file_name = file_name; - } - - /** - * @param interface_names . - */ - public void setInterfaceNames(String[] interface_names) { - this.interface_names = interface_names; - } - - /** - * @param interfaces . - */ - public void setInterfaces(int[] interfaces) { - this.interfaces = interfaces; - } - - /** - * @param major . - */ - public void setMajor(int major) { - this.major = major; - } - - /** - * @param methods . - */ - public void setMethods(Method[] methods) { - this.methods = methods; - } - - /** - * @param minor . - */ - public void setMinor(int minor) { - this.minor = minor; - } - - /** - * Set absolute path to file this class was read from. - */ - public void setSourceFileName(String source_file_name) { - this.source_file_name = source_file_name; - } - - /** - * @param superclass_name . - */ - public void setSuperclassName(String superclass_name) { - this.superclass_name = superclass_name; - } - - /** - * @param superclass_name_index . - */ - public void setSuperclassNameIndex(int superclass_name_index) { - this.superclass_name_index = superclass_name_index; - } - - /** - * @return String representing class contents. - */ - public String toString() { - String access = Utility.accessToString(access_flags, true); - access = access.equals("")? "" : (access + " "); - - StringBuffer buf = new StringBuffer(access + - Utility.classOrInterface(access_flags) + - " " + - class_name + " extends " + - Utility.compactClassName(superclass_name, - false) + '\n'); - int size = interfaces.length; - - if(size > 0) { - buf.append("implements\t\t"); - - for(int i=0; i < size; i++) { - buf.append(interface_names[i]); - if(i < size - 1) - buf.append(", "); - } - - buf.append('\n'); - } - - buf.append("filename\t\t" + file_name + '\n'); - buf.append("compiled from\t\t" + source_file_name + '\n'); - buf.append("compiler version\t" + major + "." + minor + '\n'); - buf.append("access flags\t\t" + access_flags + '\n'); - buf.append("constant pool\t\t" + constant_pool.getLength() + " entries\n"); - buf.append("ACC_SUPER flag\t\t" + isSuper() + "\n"); - - if(attributes.length > 0) { - buf.append("\nAttribute(s):\n"); - for(int i=0; i < attributes.length; i++) - buf.append(indent(attributes[i])); - } - - if(fields.length > 0) { - buf.append("\n" + fields.length + " fields:\n"); - for(int i=0; i < fields.length; i++) - buf.append("\t" + fields[i] + '\n'); - } - - if(methods.length > 0) { - buf.append("\n" + methods.length + " methods:\n"); - for(int i=0; i < methods.length; i++) - buf.append("\t" + methods[i] + '\n'); - } - - return buf.toString(); - } - - private static final String indent(Object obj) { - StringTokenizer tok = new StringTokenizer(obj.toString(), "\n"); - StringBuffer buf = new StringBuffer(); - - while(tok.hasMoreTokens()) - buf.append("\t" + tok.nextToken() + "\n"); - - return buf.toString(); - } - - /** - * @return deep copy of this class - */ - public JavaClass copy() { - JavaClass c = null; - - try { - c = (JavaClass)clone(); - } catch(CloneNotSupportedException e) {} - - c.constant_pool = constant_pool.copy(); - c.interfaces = (int[])interfaces.clone(); - c.interface_names = (String[])interface_names.clone(); - - c.fields = new Field[fields.length]; - for(int i=0; i < fields.length; i++) - c.fields[i] = fields[i].copy(c.constant_pool); - - c.methods = new Method[methods.length]; - for(int i=0; i < methods.length; i++) - c.methods[i] = methods[i].copy(c.constant_pool); - - c.attributes = new Attribute[attributes.length]; - for(int i=0; i < attributes.length; i++) - c.attributes[i] = attributes[i].copy(c.constant_pool); - - return c; - } - - public final boolean isSuper() { - return (access_flags & Constants.ACC_SUPER) != 0; - } - - public final boolean isClass() { - return (access_flags & Constants.ACC_INTERFACE) == 0; - } - - /** @return returns either HEAP (generated), FILE, or ZIP - */ - public final byte getSource() { - return source; - } - - /********************* New repository functionality *********************/ - - /** - * Gets the ClassRepository which holds its definition. By default - * this is the same as SyntheticRepository.getInstance(); - */ - public com.sun.org.apache.bcel.internal.util.Repository getRepository() { - return repository; - } - - /** - * Sets the ClassRepository which loaded the JavaClass. - * Should be called immediately after parsing is done. - */ - public void setRepository(com.sun.org.apache.bcel.internal.util.Repository repository) { - this.repository = repository; - } - - /** Equivalent to runtime "instanceof" operator. - * - * @return true if this JavaClass is derived from teh super class - */ - public final boolean instanceOf(JavaClass super_class) { - if(this.equals(super_class)) - return true; - - JavaClass[] super_classes = getSuperClasses(); - - for(int i=0; i < super_classes.length; i++) { - if(super_classes[i].equals(super_class)) { - return true; - } - } - - if(super_class.isInterface()) { - return implementationOf(super_class); - } - - return false; - } - - /** - * @return true, if clazz is an implementation of interface inter - */ - public boolean implementationOf(JavaClass inter) { - if(!inter.isInterface()) { - throw new IllegalArgumentException(inter.getClassName() + " is no interface"); - } - - if(this.equals(inter)) { - return true; - } - - JavaClass[] super_interfaces = getAllInterfaces(); - - for(int i=0; i < super_interfaces.length; i++) { - if(super_interfaces[i].equals(inter)) { - return true; - } - } - - return false; - } - - /** - * @return the superclass for this JavaClass object, or null if this - * is java.lang.Object - */ - public JavaClass getSuperClass() { - if("java.lang.Object".equals(getClassName())) { - return null; - } - - try { - return repository.loadClass(getSuperclassName()); - } catch(ClassNotFoundException e) { - System.err.println(e); - return null; - } - } - - /** - * @return list of super classes of this class in ascending order, i.e., - * java.lang.Object is always the last element - */ - public JavaClass[] getSuperClasses() { - JavaClass clazz = this; - ClassVector vec = new ClassVector(); - - for(clazz = clazz.getSuperClass(); clazz != null; - clazz = clazz.getSuperClass()) - { - vec.addElement(clazz); - } - - return vec.toArray(); - } - - /** - * Get interfaces directly implemented by this JavaClass. - */ - public JavaClass[] getInterfaces() { - String[] interfaces = getInterfaceNames(); - JavaClass[] classes = new JavaClass[interfaces.length]; - - try { - for(int i = 0; i < interfaces.length; i++) { - classes[i] = repository.loadClass(interfaces[i]); - } - } catch(ClassNotFoundException e) { - System.err.println(e); - return null; - } - - return classes; - } - - /** - * Get all interfaces implemented by this JavaClass (transitively). - */ - public JavaClass[] getAllInterfaces() { - ClassQueue queue = new ClassQueue(); - ClassVector vec = new ClassVector(); - - queue.enqueue(this); - - while(!queue.empty()) { - JavaClass clazz = queue.dequeue(); - - JavaClass souper = clazz.getSuperClass(); - JavaClass[] interfaces = clazz.getInterfaces(); - - if(clazz.isInterface()) { - vec.addElement(clazz); - } else { - if(souper != null) { - queue.enqueue(souper); - } - } - - for(int i = 0; i < interfaces.length; i++) { - queue.enqueue(interfaces[i]); - } - } - - return vec.toArray(); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java deleted file mode 100644 index ec8b4728036..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumber.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a (PC offset, line number) pair, i.e., a line number in - * the source that corresponds to a relative address in the byte code. This - * is used for debugging purposes. - * - * @author M. Dahm - * @see LineNumberTable - */ -public final class LineNumber implements Cloneable, Node, Serializable { - private int start_pc; // Program Counter (PC) corresponds to line - private int line_number; // number in source file - - /** - * Initialize from another object. - */ - public LineNumber(LineNumber c) { - this(c.getStartPC(), c.getLineNumber()); - } - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - */ - LineNumber(DataInputStream file) throws IOException - { - this(file.readUnsignedShort(), file.readUnsignedShort()); - } - - /** - * @param start_pc Program Counter (PC) corresponds to - * @param line_number line number in source file - */ - public LineNumber(int start_pc, int line_number) - { - this.start_pc = start_pc; - this.line_number = line_number; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitLineNumber(this); - } - - /** - * Dump line number/pc pair to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeShort(start_pc); - file.writeShort(line_number); - - } - /** - * @return Corresponding source line - */ - public final int getLineNumber() { return line_number; } - - /** - * @return PC in code - */ - public final int getStartPC() { return start_pc; } - - /** - * @param line_number. - */ - public final void setLineNumber(int line_number) { - this.line_number = line_number; - } - - /** - * @param start_pc. - */ - public final void setStartPC(int start_pc) { - this.start_pc = start_pc; - } - - /** - * @return String representation - */ - public final String toString() { - return "LineNumber(" + start_pc + ", " + line_number + ")"; - } - - /** - * @return deep copy of this object - */ - public LineNumber copy() { - try { - return (LineNumber)clone(); - } catch(CloneNotSupportedException e) {} - - return null; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java deleted file mode 100644 index 1fa9bfeaf3e..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LineNumberTable.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a table of line numbers for debugging - * purposes. This attribute is used by the Code attribute. It - * contains pairs of PCs and line numbers. - * - * @author M. Dahm - * @see Code - * @see LineNumber - */ -public final class LineNumberTable extends Attribute { - private int line_number_table_length; - private LineNumber[] line_number_table; // Table of line/numbers pairs - - /* - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use copy() for a physical copy. - */ - public LineNumberTable(LineNumberTable c) { - this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), - c.getConstantPool()); - } - - /* - * @param name_index Index of name - * @param length Content length in bytes - * @param line_number_table Table of line/numbers pairs - * @param constant_pool Array of constants - */ - public LineNumberTable(int name_index, int length, - LineNumber[] line_number_table, - ConstantPool constant_pool) - { - super(Constants.ATTR_LINE_NUMBER_TABLE, name_index, length, constant_pool); - setLineNumberTable(line_number_table); - } - - /** - * Construct object from file stream. - * @param name_index Index of name - * @param length Content length in bytes - * @param file Input stream - * @throws IOException - * @param constant_pool Array of constants - */ - LineNumberTable(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (LineNumber[])null, constant_pool); - line_number_table_length = (file.readUnsignedShort()); - line_number_table = new LineNumber[line_number_table_length]; - - for(int i=0; i < line_number_table_length; i++) - line_number_table[i] = new LineNumber(file); - } - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitLineNumberTable(this); - } - /** - * Dump line number table attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(line_number_table_length); - for(int i=0; i < line_number_table_length; i++) - line_number_table[i].dump(file); - } - - /** - * @return Array of (pc offset, line number) pairs. - */ - public final LineNumber[] getLineNumberTable() { return line_number_table; } - - /** - * @param line_number_table. - */ - public final void setLineNumberTable(LineNumber[] line_number_table) { - this.line_number_table = line_number_table; - - line_number_table_length = (line_number_table == null)? 0 : - line_number_table.length; - } - - /** - * @return String representation. - */ - public final String toString() { - StringBuffer buf = new StringBuffer(); - StringBuffer line = new StringBuffer(); - - for(int i=0; i < line_number_table_length; i++) { - line.append(line_number_table[i].toString()); - - if(i < line_number_table_length - 1) - line.append(", "); - - if(line.length() > 72) { - line.append('\n'); - buf.append(line); - line.setLength(0); - } - } - - buf.append(line); - - return buf.toString(); - } - - /** - * Map byte code positions to source code lines. - * - * @param pos byte code offset - * @return corresponding line in source code - */ - public int getSourceLine(int pos) { - int l = 0, r = line_number_table_length-1; - - if(r < 0) // array is empty - return -1; - - int min_index = -1, min=-1; - - /* Do a binary search since the array is ordered. - */ - do { - int i = (l + r) / 2; - int j = line_number_table[i].getStartPC(); - - if(j == pos) - return line_number_table[i].getLineNumber(); - else if(pos < j) // else constrain search area - r = i - 1; - else // pos > j - l = i + 1; - - /* If exact match can't be found (which is the most common case) - * return the line number that corresponds to the greatest index less - * than pos. - */ - if(j < pos && j > min) { - min = j; - min_index = i; - } - } while(l <= r); - - /* It's possible that we did not find any valid entry for the bytecode - * offset we were looking for. - */ - if (min_index < 0) - return -1; - - return line_number_table[min_index].getLineNumber(); - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - LineNumberTable c = (LineNumberTable)clone(); - - c.line_number_table = new LineNumber[line_number_table_length]; - for(int i=0; i < line_number_table_length; i++) - c.line_number_table[i] = line_number_table[i].copy(); - - c.constant_pool = constant_pool; - return c; - } - - public final int getTableLength() { return line_number_table_length; } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java deleted file mode 100644 index a80bc3bb6c4..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariable.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a local variable within a method. It contains its - * scope, name, signature and index on the method's frame. - * - * @author M. Dahm - * @see LocalVariableTable - */ -public final class LocalVariable - implements Constants, Cloneable, Node, Serializable -{ - private int start_pc; // Range in which the variable is valid - private int length; - private int name_index; // Index in constant pool of variable name - private int signature_index; // Index of variable signature - private int index; /* Variable is `index'th local variable on - * this method's frame. - */ - - private ConstantPool constant_pool; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use copy() for a physical copy. - */ - public LocalVariable(LocalVariable c) { - this(c.getStartPC(), c.getLength(), c.getNameIndex(), - c.getSignatureIndex(), c.getIndex(), c.getConstantPool()); - } - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - */ - LocalVariable(DataInputStream file, ConstantPool constant_pool) - throws IOException - { - this(file.readUnsignedShort(), file.readUnsignedShort(), - file.readUnsignedShort(), file.readUnsignedShort(), - file.readUnsignedShort(), constant_pool); - } - - /** - * @param start_pc Range in which the variable - * @param length ... is valid - * @param name_index Index in constant pool of variable name - * @param signature_index Index of variable's signature - * @param index Variable is `index'th local variable on the method's frame - * @param constant_pool Array of constants - */ - public LocalVariable(int start_pc, int length, int name_index, - int signature_index, int index, - ConstantPool constant_pool) - { - this.start_pc = start_pc; - this.length = length; - this.name_index = name_index; - this.signature_index = signature_index; - this.index = index; - this.constant_pool = constant_pool; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitLocalVariable(this); - } - - /** - * Dump local variable to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeShort(start_pc); - file.writeShort(length); - file.writeShort(name_index); - file.writeShort(signature_index); - file.writeShort(index); - } - - /** - * @return Constant pool used by this object. - */ - public final ConstantPool getConstantPool() { return constant_pool; } - - /** - * @return Variable is valid within getStartPC() .. getStartPC()+getLength() - */ - public final int getLength() { return length; } - - /** - * @return Variable name. - */ - public final String getName() { - ConstantUtf8 c; - - c = (ConstantUtf8)constant_pool.getConstant(name_index, CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * @return Index in constant pool of variable name. - */ - public final int getNameIndex() { return name_index; } - - /** - * @return Signature. - */ - public final String getSignature() { - ConstantUtf8 c; - c = (ConstantUtf8)constant_pool.getConstant(signature_index, - CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * @return Index in constant pool of variable signature. - */ - public final int getSignatureIndex() { return signature_index; } - - /** - * @return index of register where variable is stored - */ - public final int getIndex() { return index; } - - /** - * @return Start of range where he variable is valid - */ - public final int getStartPC() { return start_pc; } - - /** - * @param constant_pool Constant pool to be used for this object. - */ - public final void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } - - /** - * @param length. - */ - public final void setLength(int length) { - this.length = length; - } - - /** - * @param name_index. - */ - public final void setNameIndex(int name_index) { - this.name_index = name_index; - } - - /** - * @param signature_index. - */ - public final void setSignatureIndex(int signature_index) { - this.signature_index = signature_index; - } - - /** - * @param index. - */ - public final void setIndex(int index) { this.index = index; } - - /** - * @param start_pc Specify range where the local variable is valid. - */ - public final void setStartPC(int start_pc) { - this.start_pc = start_pc; - } - - /** - * @return string representation. - */ - public final String toString() { - String name = getName(), signature = Utility.signatureToString(getSignature()); - - return "LocalVariable(start_pc = " + start_pc + ", length = " + length + - ", index = " + index + ":" + signature + " " + name + ")"; - } - - /** - * @return deep copy of this object - */ - public LocalVariable copy() { - try { - return (LocalVariable)clone(); - } catch(CloneNotSupportedException e) {} - - return null; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java deleted file mode 100644 index db0631f5b89..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/LocalVariableTable.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents colection of local variables in a - * method. This attribute is contained in the Code attribute. - * - * @author M. Dahm - * @see Code - * @see LocalVariable - */ -public class LocalVariableTable extends Attribute { - private int local_variable_table_length; // Table of local - private LocalVariable[] local_variable_table; // variables - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use copy() for a physical copy. - */ - public LocalVariableTable(LocalVariableTable c) { - this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), - c.getConstantPool()); - } - - /** - * @param name_index Index in constant pool to `LocalVariableTable' - * @param length Content length in bytes - * @param local_variable_table Table of local variables - * @param constant_pool Array of constants - */ - public LocalVariableTable(int name_index, int length, - LocalVariable[] local_variable_table, - ConstantPool constant_pool) - { - super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool); - setLocalVariableTable(local_variable_table); - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - LocalVariableTable(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (LocalVariable[])null, constant_pool); - - local_variable_table_length = (file.readUnsignedShort()); - local_variable_table = new LocalVariable[local_variable_table_length]; - - for(int i=0; i < local_variable_table_length; i++) - local_variable_table[i] = new LocalVariable(file, constant_pool); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitLocalVariableTable(this); - } - - /** - * Dump local variable table attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(local_variable_table_length); - for(int i=0; i < local_variable_table_length; i++) - local_variable_table[i].dump(file); - } - - /** - * @return Array of local variables of method. - */ - public final LocalVariable[] getLocalVariableTable() { - return local_variable_table; - } - - /** @return first matching variable using index - */ - public final LocalVariable getLocalVariable(int index) { - for(int i=0; i < local_variable_table_length; i++) - if(local_variable_table[i].getIndex() == index) - return local_variable_table[i]; - - return null; - } - - public final void setLocalVariableTable(LocalVariable[] local_variable_table) - { - this.local_variable_table = local_variable_table; - local_variable_table_length = (local_variable_table == null)? 0 : - local_variable_table.length; - } - - /** - * @return String representation. - */ - public final String toString() { - StringBuffer buf = new StringBuffer(""); - - for(int i=0; i < local_variable_table_length; i++) { - buf.append(local_variable_table[i].toString()); - - if(i < local_variable_table_length - 1) - buf.append('\n'); - } - - return buf.toString(); - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - LocalVariableTable c = (LocalVariableTable)clone(); - - c.local_variable_table = new LocalVariable[local_variable_table_length]; - for(int i=0; i < local_variable_table_length; i++) - c.local_variable_table[i] = local_variable_table[i].copy(); - - c.constant_pool = constant_pool; - return c; - } - - public final int getTableLength() { return local_variable_table_length; } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Method.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Method.java deleted file mode 100644 index 63d7689e5f0..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Method.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ -import com.sun.org.apache.bcel.internal.Constants; -import com.sun.org.apache.bcel.internal.generic.Type; -import java.io.*; - -/** - * This class represents the method info structure, i.e., the representation - * for a method in the class. See JVM specification for details. - * A method has access flags, a name, a signature and a number of attributes. - * - * @author M. Dahm - */ -public final class Method extends FieldOrMethod { - /** - * Empty constructor, all attributes have to be defined via `setXXX' - * methods. Use at your own risk. - */ - public Method() {} - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public Method(Method c) { - super(c); - } - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - * @throws ClassFormatException - */ - Method(DataInputStream file, ConstantPool constant_pool) - throws IOException, ClassFormatException - { - super(file, constant_pool); - } - - /** - * @param access_flags Access rights of method - * @param name_index Points to field name in constant pool - * @param signature_index Points to encoded signature - * @param attributes Collection of attributes - * @param constant_pool Array of constants - */ - public Method(int access_flags, int name_index, int signature_index, - Attribute[] attributes, ConstantPool constant_pool) - { - super(access_flags, name_index, signature_index, attributes, constant_pool); - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitMethod(this); - } - - /** - * @return Code attribute of method, if any - */ - public final Code getCode() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof Code) - return (Code)attributes[i]; - - return null; - } - - /** - * @return ExceptionTable attribute of method, if any, i.e., list all - * exceptions the method may throw not exception handlers! - */ - public final ExceptionTable getExceptionTable() { - for(int i=0; i < attributes_count; i++) - if(attributes[i] instanceof ExceptionTable) - return (ExceptionTable)attributes[i]; - - return null; - } - - /** @return LocalVariableTable of code attribute if any, i.e. the call is forwarded - * to the Code atribute. - */ - public final LocalVariableTable getLocalVariableTable() { - Code code = getCode(); - - if(code != null) - return code.getLocalVariableTable(); - else - return null; - } - - /** @return LineNumberTable of code attribute if any, i.e. the call is forwarded - * to the Code atribute. - */ - public final LineNumberTable getLineNumberTable() { - Code code = getCode(); - - if(code != null) - return code.getLineNumberTable(); - else - return null; - } - - /** - * Return string representation close to declaration format, - * `public static void _main(String[] args) throws IOException', e.g. - * - * @return String representation of the method. - */ - public final String toString() { - ConstantUtf8 c; - String name, signature, access; // Short cuts to constant pool - StringBuffer buf; - - access = Utility.accessToString(access_flags); - - // Get name and signature from constant pool - c = (ConstantUtf8)constant_pool.getConstant(signature_index, - Constants.CONSTANT_Utf8); - signature = c.getBytes(); - - c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); - name = c.getBytes(); - - signature = Utility.methodSignatureToString(signature, name, access, true, - getLocalVariableTable()); - buf = new StringBuffer(signature); - - for(int i=0; i < attributes_count; i++) { - Attribute a = attributes[i]; - - if(!((a instanceof Code) || (a instanceof ExceptionTable))) - buf.append(" [" + a.toString() + "]"); - } - - ExceptionTable e = getExceptionTable(); - if(e != null) { - String str = e.toString(); - if(!str.equals("")) - buf.append("\n\t\tthrows " + str); - } - - return buf.toString(); - } - - /** - * @return deep copy of this method - */ - public final Method copy(ConstantPool constant_pool) { - return (Method)copy_(constant_pool); - } - - /** - * @return return type of method - */ - public Type getReturnType() { - return Type.getReturnType(getSignature()); - } - - /** - * @return array of method argument types - */ - public Type[] getArgumentTypes() { - return Type.getArgumentTypes(getSignature()); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Node.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Node.java deleted file mode 100644 index 8d239c4949a..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Node.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -/** - * Denote class to have an accept method(); - * - * @author M. Dahm - */ -public interface Node { - public void accept(Visitor obj); -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java deleted file mode 100644 index 999d876bb3b..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/PMGClass.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from Attribute and represents a reference - * to a PMG - * attribute. - * - * @author M. Dahm - * @see Attribute - */ -public final class PMGClass extends Attribute { - private int pmg_class_index, pmg_index; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public PMGClass(PMGClass c) { - this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(), - c.getConstantPool()); - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - PMGClass(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), - constant_pool); - } - - /** - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param constant_pool Array of constants - * @param PMGClass_index Index in constant pool to CONSTANT_Utf8 - */ - public PMGClass(int name_index, int length, int pmg_index, int pmg_class_index, - ConstantPool constant_pool) - { - super(Constants.ATTR_PMG, name_index, length, constant_pool); - this.pmg_index = pmg_index; - this.pmg_class_index = pmg_class_index; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - System.err.println("Visiting non-standard PMGClass object"); - } - - /** - * Dump source file attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(pmg_index); - file.writeShort(pmg_class_index); - } - - /** - * @return Index in constant pool of source file name. - */ - public final int getPMGClassIndex() { return pmg_class_index; } - - /** - * @param PMGClass_index. - */ - public final void setPMGClassIndex(int pmg_class_index) { - this.pmg_class_index = pmg_class_index; - } - - /** - * @return Index in constant pool of source file name. - */ - public final int getPMGIndex() { return pmg_index; } - - /** - * @param PMGClass_index. - */ - public final void setPMGIndex(int pmg_index) { - this.pmg_index = pmg_index; - } - - /** - * @return PMG name. - */ - public final String getPMGName() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * @return PMG class name. - */ - public final String getPMGClassName() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_class_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * @return String representation - */ - public final String toString() { - return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")"; - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - return (PMGClass)clone(); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java deleted file mode 100644 index e0b9cc50c50..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Signature.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from Attribute and represents a reference - * to a GJ attribute. - * - * @author M. Dahm - * @see Attribute - */ -public final class Signature extends Attribute { - private int signature_index; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public Signature(Signature c) { - this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool()); - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - Signature(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, file.readUnsignedShort(), constant_pool); - } - - /** - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param constant_pool Array of constants - * @param Signature_index Index in constant pool to CONSTANT_Utf8 - */ - public Signature(int name_index, int length, int signature_index, - ConstantPool constant_pool) - { - super(Constants.ATTR_SIGNATURE, name_index, length, constant_pool); - this.signature_index = signature_index; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - System.err.println("Visiting non-standard Signature object"); - v.visitSignature(this); - } - - /** - * Dump source file attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(signature_index); - } - - /** - * @return Index in constant pool of source file name. - */ - public final int getSignatureIndex() { return signature_index; } - - /** - * @param Signature_index. - */ - public final void setSignatureIndex(int signature_index) { - this.signature_index = signature_index; - } - - /** - * @return GJ signature. - */ - public final String getSignature() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(signature_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * Extends ByteArrayInputStream to make 'unreading' chars possible. - */ - private static final class MyByteArrayInputStream extends ByteArrayInputStream { - MyByteArrayInputStream(String data) { super(data.getBytes()); } - final int mark() { return pos; } - final String getData() { return new String(buf); } - final void reset(int p) { pos = p; } - final void unread() { if(pos > 0) pos--; } - } - - private static boolean identStart(int ch) { - return ch == 'T' || ch == 'L'; - } - - private static boolean identPart(int ch) { - return ch == '/' || ch == ';'; - } - - private static final void matchIdent(MyByteArrayInputStream in, StringBuffer buf) { - int ch; - - if((ch = in.read()) == -1) - throw new RuntimeException("Illegal signature: " + in.getData() + - " no ident, reaching EOF"); - - //System.out.println("return from ident:" + (char)ch); - - if(!identStart(ch)) { - StringBuffer buf2 = new StringBuffer(); - - int count = 1; - while(Character.isJavaIdentifierPart((char)ch)) { - buf2.append((char)ch); - count++; - ch = in.read(); - } - - if(ch == ':') { // Ok, formal parameter - in.skip("Ljava/lang/Object".length()); - buf.append(buf2); - - ch = in.read(); - in.unread(); - //System.out.println("so far:" + buf2 + ":next:" +(char)ch); - } else { - for(int i=0; i < count; i++) - in.unread(); - } - - return; - } - - StringBuffer buf2 = new StringBuffer(); - ch = in.read(); - - do { - buf2.append((char)ch); - ch = in.read(); - //System.out.println("within ident:"+ (char)ch); - - } while((ch != -1) && (Character.isJavaIdentifierPart((char)ch) || (ch == '/'))); - - buf.append(buf2.toString().replace('/', '.')); - - //System.out.println("regular return ident:"+ (char)ch + ":" + buf2); - - if(ch != -1) - in.unread(); - } - - private static final void matchGJIdent(MyByteArrayInputStream in, - StringBuffer buf) - { - int ch; - - matchIdent(in, buf); - - ch = in.read(); - if((ch == '<') || ch == '(') { // Parameterized or method - //System.out.println("Enter <"); - buf.append((char)ch); - matchGJIdent(in, buf); - - while(((ch = in.read()) != '>') && (ch != ')')) { // List of parameters - if(ch == -1) - throw new RuntimeException("Illegal signature: " + in.getData() + - " reaching EOF"); - - //System.out.println("Still no >"); - buf.append(", "); - in.unread(); - matchGJIdent(in, buf); // Recursive call - } - - //System.out.println("Exit >"); - - buf.append((char)ch); - } else - in.unread(); - - ch = in.read(); - if(identStart(ch)) { - in.unread(); - matchGJIdent(in, buf); - } else if(ch == ')') { - in.unread(); - return; - } else if(ch != ';') - throw new RuntimeException("Illegal signature: " + in.getData() + " read " + - (char)ch); - } - - public static String translate(String s) { - //System.out.println("Sig:" + s); - StringBuffer buf = new StringBuffer(); - - matchGJIdent(new MyByteArrayInputStream(s), buf); - - return buf.toString(); - } - - public static final boolean isFormalParameterList(String s) { - return s.startsWith("<") && (s.indexOf(':') > 0); - } - - public static final boolean isActualParameterList(String s) { - return s.startsWith("L") && s.endsWith(">;"); - } - - /** - * @return String representation - */ - public final String toString() { - String s = getSignature(); - - return "Signature(" + s + ")"; - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - return (Signature)clone(); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java deleted file mode 100644 index 5120cd6b2bc..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/SourceFile.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from Attribute and represents a reference - * to the source file of this class. At most one SourceFile attribute - * should appear per classfile. The intention of this class is that it is - * instantiated from the Attribute.readAttribute() method. - * - * @author M. Dahm - * @see Attribute - */ -public final class SourceFile extends Attribute { - private int sourcefile_index; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public SourceFile(SourceFile c) { - this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), - c.getConstantPool()); - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - SourceFile(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, file.readUnsignedShort(), constant_pool); - } - - /** - * @param name_index Index in constant pool to CONSTANT_Utf8, which - * should represent the string "SourceFile". - * @param length Content length in bytes, the value should be 2. - * @param constant_pool The constant pool that this attribute is - * associated with. - * @param sourcefile_index Index in constant pool to CONSTANT_Utf8. This - * string will be interpreted as the name of the file from which this - * class was compiled. It will not be interpreted as indicating the name - * of the directory contqining the file or an absolute path; this - * information has to be supplied the consumer of this attribute - in - * many cases, the JVM. - */ - public SourceFile(int name_index, int length, int sourcefile_index, - ConstantPool constant_pool) - { - super(Constants.ATTR_SOURCE_FILE, name_index, length, constant_pool); - this.sourcefile_index = sourcefile_index; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitSourceFile(this); - } - - /** - * Dump source file attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(sourcefile_index); - } - - /** - * @return Index in constant pool of source file name. - */ - public final int getSourceFileIndex() { return sourcefile_index; } - - /** - * @param sourcefile_index. - */ - public final void setSourceFileIndex(int sourcefile_index) { - this.sourcefile_index = sourcefile_index; - } - - /** - * @return Source file name. - */ - public final String getSourceFileName() { - ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(sourcefile_index, - Constants.CONSTANT_Utf8); - return c.getBytes(); - } - - /** - * @return String representation - */ - public final String toString() { - return "SourceFile(" + getSourceFileName() + ")"; - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - return (SourceFile)clone(); - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java deleted file mode 100644 index 4d44a6f3107..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMap.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a stack map attribute used for - * preverification of Java classes for the Java 2 Micro Edition - * (J2ME). This attribute is used by the KVM and contained - * within the Code attribute of a method. See CLDC specification - * 5.3.1.2 - * - * @author M. Dahm - * @see Code - * @see StackMapEntry - * @see StackMapType - */ -public final class StackMap extends Attribute implements Node { - private int map_length; - private StackMapEntry[] map; // Table of stack map entries - - /* - * @param name_index Index of name - * @param length Content length in bytes - * @param map Table of stack map entries - * @param constant_pool Array of constants - */ - public StackMap(int name_index, int length, StackMapEntry[] map, - ConstantPool constant_pool) - { - super(Constants.ATTR_STACK_MAP, name_index, length, constant_pool); - - setStackMap(map); - } - - /** - * Construct object from file stream. - * @param name_index Index of name - * @param length Content length in bytes - * @param file Input stream - * @throws IOException - * @param constant_pool Array of constants - */ - StackMap(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (StackMapEntry[])null, constant_pool); - - map_length = file.readUnsignedShort(); - map = new StackMapEntry[map_length]; - - for(int i=0; i < map_length; i++) - map[i] = new StackMapEntry(file, constant_pool); - } - - /** - * Dump line number table attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - file.writeShort(map_length); - for(int i=0; i < map_length; i++) - map[i].dump(file); - } - - /** - * @return Array of stack map entries - */ - public final StackMapEntry[] getStackMap() { return map; } - - /** - * @param map Array of stack map entries - */ - public final void setStackMap(StackMapEntry[] map) { - this.map = map; - - map_length = (map == null)? 0 : map.length; - } - - /** - * @return String representation. - */ - public final String toString() { - StringBuffer buf = new StringBuffer("StackMap("); - - for(int i=0; i < map_length; i++) { - buf.append(map[i].toString()); - - if(i < map_length - 1) - buf.append(", "); - } - - buf.append(')'); - - return buf.toString(); - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - StackMap c = (StackMap)clone(); - - c.map = new StackMapEntry[map_length]; - for(int i=0; i < map_length; i++) - c.map[i] = map[i].copy(); - - c.constant_pool = constant_pool; - return c; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitStackMap(this); - } - - public final int getMapLength() { return map_length; } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java deleted file mode 100644 index 5b5c46fffb7..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapEntry.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents a stack map entry recording the types of - * local variables and the the of stack items at a given byte code offset. - * See CLDC specification 5.3.1.2 - * - * @author M. Dahm - * @see StackMap - * @see StackMapType - */ -public final class StackMapEntry implements Cloneable { - private int byte_code_offset; - private int number_of_locals; - private StackMapType[] types_of_locals; - private int number_of_stack_items; - private StackMapType[] types_of_stack_items; - private ConstantPool constant_pool; - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - */ - StackMapEntry(DataInputStream file, ConstantPool constant_pool) throws IOException - { - this(file.readShort(), file.readShort(), null, -1, null, constant_pool); - - types_of_locals = new StackMapType[number_of_locals]; - for(int i=0; i < number_of_locals; i++) - types_of_locals[i] = new StackMapType(file, constant_pool); - - number_of_stack_items = file.readShort(); - types_of_stack_items = new StackMapType[number_of_stack_items]; - for(int i=0; i < number_of_stack_items; i++) - types_of_stack_items[i] = new StackMapType(file, constant_pool); - } - - public StackMapEntry(int byte_code_offset, int number_of_locals, - StackMapType[] types_of_locals, - int number_of_stack_items, - StackMapType[] types_of_stack_items, - ConstantPool constant_pool) { - this.byte_code_offset = byte_code_offset; - this.number_of_locals = number_of_locals; - this.types_of_locals = types_of_locals; - this.number_of_stack_items = number_of_stack_items; - this.types_of_stack_items = types_of_stack_items; - this.constant_pool = constant_pool; - } - - /** - * Dump stack map entry - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeShort(byte_code_offset); - - file.writeShort(number_of_locals); - for(int i=0; i < number_of_locals; i++) - types_of_locals[i].dump(file); - - file.writeShort(number_of_stack_items); - for(int i=0; i < number_of_stack_items; i++) - types_of_stack_items[i].dump(file); - } - - /** - * @return String representation. - */ - public final String toString() { - StringBuffer buf = new StringBuffer("(offset=" + byte_code_offset); - - if(number_of_locals > 0) { - buf.append(", locals={"); - - for(int i=0; i < number_of_locals; i++) { - buf.append(types_of_locals[i]); - if(i < number_of_locals - 1) - buf.append(", "); - } - - buf.append("}"); - } - - if(number_of_stack_items > 0) { - buf.append(", stack items={"); - - for(int i=0; i < number_of_stack_items; i++) { - buf.append(types_of_stack_items[i]); - if(i < number_of_stack_items - 1) - buf.append(", "); - } - - buf.append("}"); - } - - buf.append(")"); - - return buf.toString(); - } - - - public void setByteCodeOffset(int b) { byte_code_offset = b; } - public int getByteCodeOffset() { return byte_code_offset; } - public void setNumberOfLocals(int n) { number_of_locals = n; } - public int getNumberOfLocals() { return number_of_locals; } - public void setTypesOfLocals(StackMapType[] t) { types_of_locals = t; } - public StackMapType[] getTypesOfLocals() { return types_of_locals; } - public void setNumberOfStackItems(int n) { number_of_stack_items = n; } - public int getNumberOfStackItems() { return number_of_stack_items; } - public void setTypesOfStackItems(StackMapType[] t) { types_of_stack_items = t; } - public StackMapType[] getTypesOfStackItems() { return types_of_stack_items; } - - /** - * @return deep copy of this object - */ - public StackMapEntry copy() { - try { - return (StackMapEntry)clone(); - } catch(CloneNotSupportedException e) {} - - return null; - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitStackMapEntry(this); - } - - /** - * @return Constant pool used by this object. - */ - public final ConstantPool getConstantPool() { return constant_pool; } - - /** - * @param constant_pool Constant pool to be used for this object. - */ - public final void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java deleted file mode 100644 index 357d53d825d..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/StackMapType.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class represents the type of a local variable or item on stack - * used in the StackMap entries. - * - * @author M. Dahm - * @see StackMapEntry - * @see StackMap - * @see Constants - */ -public final class StackMapType implements Cloneable { - private byte type; - private int index = -1; // Index to CONSTANT_Class or offset - private ConstantPool constant_pool; - - /** - * Construct object from file stream. - * @param file Input stream - * @throws IOException - */ - StackMapType(DataInputStream file, ConstantPool constant_pool) throws IOException - { - this(file.readByte(), -1, constant_pool); - - if(hasIndex()) - setIndex(file.readShort()); - - setConstantPool(constant_pool); - } - - /** - * @param type type tag as defined in the Constants interface - * @param index index to constant pool, or byte code offset - */ - public StackMapType(byte type, int index, ConstantPool constant_pool) { - setType(type); - setIndex(index); - setConstantPool(constant_pool); - } - - public void setType(byte t) { - if((t < Constants.ITEM_Bogus) || (t > Constants.ITEM_NewObject)) - throw new RuntimeException("Illegal type for StackMapType: " + t); - type = t; - } - - public byte getType() { return type; } - public void setIndex(int t) { index = t; } - - /** @return index to constant pool if type == ITEM_Object, or offset - * in byte code, if type == ITEM_NewObject, and -1 otherwise - */ - public int getIndex() { return index; } - - /** - * Dump type entries to file. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - file.writeByte(type); - if(hasIndex()) - file.writeShort(getIndex()); - } - - /** @return true, if type is either ITEM_Object or ITEM_NewObject - */ - public final boolean hasIndex() { - return ((type == Constants.ITEM_Object) || - (type == Constants.ITEM_NewObject)); - } - - private String printIndex() { - if(type == Constants.ITEM_Object) - return ", class=" + constant_pool.constantToString(index, Constants.CONSTANT_Class); - else if(type == Constants.ITEM_NewObject) - return ", offset=" + index; - else - return ""; - } - - /** - * @return String representation - */ - public final String toString() { - return "(type=" + Constants.ITEM_NAMES[type] + printIndex() + ")"; - } - - /** - * @return deep copy of this object - */ - public StackMapType copy() { - try { - return (StackMapType)clone(); - } catch(CloneNotSupportedException e) {} - - return null; - } - - /** - * @return Constant pool used by this object. - */ - public final ConstantPool getConstantPool() { return constant_pool; } - - /** - * @param constant_pool Constant pool to be used for this object. - */ - public final void setConstantPool(ConstantPool constant_pool) { - this.constant_pool = constant_pool; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java deleted file mode 100644 index 4b743a66c87..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Synthetic.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; - -/** - * This class is derived from Attribute and declares this class as - * `synthetic', i.e., it needs special handling. The JVM specification - * states "A class member that does not appear in the source code must be - * marked using a Synthetic attribute." It may appear in the ClassFile - * attribute table, a field_info table or a method_info table. This class - * is intended to be instantiated from the - * Attribute.readAttribute() method. - * - * @author M. Dahm - * @see Attribute - */ -public final class Synthetic extends Attribute { - private byte[] bytes; - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use copy() for a physical copy. - */ - public Synthetic(Synthetic c) { - this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); - } - - /** - * @param name_index Index in constant pool to CONSTANT_Utf8, which - * should represent the string "Synthetic". - * @param length Content length in bytes - should be zero. - * @param bytes Attribute contents - * @param constant_pool The constant pool this attribute is associated - * with. - */ - public Synthetic(int name_index, int length, byte[] bytes, - ConstantPool constant_pool) - { - super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool); - this.bytes = bytes; - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool to CONSTANT_Utf8 - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - Synthetic(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) throws IOException - { - this(name_index, length, (byte [])null, constant_pool); - - if(length > 0) { - bytes = new byte[length]; - file.readFully(bytes); - System.err.println("Synthetic attribute with length > 0"); - } - } - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitSynthetic(this); - } - /** - * Dump source file attribute to file stream in binary format. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - if(length > 0) - file.write(bytes, 0, length); - } - /** - * @return data bytes. - */ - public final byte[] getBytes() { return bytes; } - - /** - * @param bytes. - */ - public final void setBytes(byte[] bytes) { - this.bytes = bytes; - } - - /** - * @return String representation. - */ - public final String toString() { - StringBuffer buf = new StringBuffer("Synthetic"); - - if(length > 0) - buf.append(" " + Utility.toHexString(bytes)); - - return buf.toString(); - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - Synthetic c = (Synthetic)clone(); - - if(bytes != null) - c.bytes = (byte[])bytes.clone(); - - c.constant_pool = constant_pool; - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java deleted file mode 100644 index 16fc4760fd4..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Unknown.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import java.io.*; -import java.util.*; - -/** - * This class represents a reference to an unknown (i.e., - * application-specific) attribute of a class. It is instantiated from the - * Attribute.readAttribute() method. Applications that need to - * read in application-specific attributes should create an AttributeReader implementation and - * attach it via Attribute.addAttributeReader. - - * - * @see com.sun.org.apache.bcel.internal.classfile.Attribute - * @see com.sun.org.apache.bcel.internal.classfile.AttributeReader - * @author M. Dahm - */ -public final class Unknown extends Attribute { - private byte[] bytes; - private String name; - - private static HashMap unknown_attributes = new HashMap(); - - /** @return array of unknown attributes, but just one for each kind. - */ - static Unknown[] getUnknownAttributes() { - Unknown[] unknowns = new Unknown[unknown_attributes.size()]; - Iterator entries = unknown_attributes.values().iterator(); - - for(int i=0; entries.hasNext(); i++) - unknowns[i] = (Unknown)entries.next(); - - unknown_attributes.clear(); - return unknowns; - } - - /** - * Initialize from another object. Note that both objects use the same - * references (shallow copy). Use clone() for a physical copy. - */ - public Unknown(Unknown c) { - this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool()); - } - - /** - * Create a non-standard attribute. - * - * @param name_index Index in constant pool - * @param length Content length in bytes - * @param bytes Attribute contents - * @param constant_pool Array of constants - */ - public Unknown(int name_index, int length, byte[] bytes, - ConstantPool constant_pool) - { - super(Constants.ATTR_UNKNOWN, name_index, length, constant_pool); - this.bytes = bytes; - - name = ((ConstantUtf8)constant_pool.getConstant(name_index, - Constants.CONSTANT_Utf8)).getBytes(); - unknown_attributes.put(name, this); - } - - /** - * Construct object from file stream. - * @param name_index Index in constant pool - * @param length Content length in bytes - * @param file Input stream - * @param constant_pool Array of constants - * @throws IOException - */ - Unknown(int name_index, int length, DataInputStream file, - ConstantPool constant_pool) - throws IOException - { - this(name_index, length, (byte [])null, constant_pool); - - if(length > 0) { - bytes = new byte[length]; - file.readFully(bytes); - } - } - - /** - * Called by objects that are traversing the nodes of the tree implicitely - * defined by the contents of a Java class. I.e., the hierarchy of methods, - * fields, attributes, etc. spawns a tree of objects. - * - * @param v Visitor object - */ - public void accept(Visitor v) { - v.visitUnknown(this); - } - /** - * Dump unknown bytes to file stream. - * - * @param file Output file stream - * @throws IOException - */ - public final void dump(DataOutputStream file) throws IOException - { - super.dump(file); - if(length > 0) - file.write(bytes, 0, length); - } - /** - * @return data bytes. - */ - public final byte[] getBytes() { return bytes; } - - /** - * @return name of attribute. - */ - public final String getName() { return name; } - - /** - * @param bytes. - */ - public final void setBytes(byte[] bytes) { - this.bytes = bytes; - } - - /** - * @return String representation. - */ - public final String toString() { - if(length == 0 || bytes == null) - return "(Unknown attribute " + name + ")"; - - String hex; - if(length > 10) { - byte[] tmp = new byte[10]; - System.arraycopy(bytes, 0, tmp, 0, 10); - hex = Utility.toHexString(tmp) + "... (truncated)"; - } - else - hex = Utility.toHexString(bytes); - - return "(Unknown attribute " + name + ": " + hex + ")"; - } - - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) { - Unknown c = (Unknown)clone(); - - if(bytes != null) - c.bytes = (byte[])bytes.clone(); - - c.constant_pool = constant_pool; - return c; - } -} diff --git a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java b/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java deleted file mode 100644 index 9ba80211e56..00000000000 --- a/jaxp/src/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java +++ /dev/null @@ -1,1397 +0,0 @@ -/* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -package com.sun.org.apache.bcel.internal.classfile; - -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -import com.sun.org.apache.bcel.internal.Constants; -import com.sun.org.apache.bcel.internal.util.ByteSequence; -import java.io.*; -import java.util.ArrayList; -import java.util.zip.*; - -/** - * Utility functions that do not really belong to any class in particular. - * - * @author M. Dahm - */ -public abstract class Utility { - private static int consumed_chars; /* How many chars have been consumed - * during parsing in signatureToString(). - * Read by methodSignatureToString(). - * Set by side effect,but only internally. - */ - private static boolean wide=false; /* The `WIDE' instruction is used in the - * byte code to allow 16-bit wide indices - * for local variables. This opcode - * precedes an `ILOAD', e.g.. The opcode - * immediately following takes an extra - * byte which is combined with the - * following byte to form a - * 16-bit value. - */ - /** - * Convert bit field of flags into string such as `static final'. - * - * @param access_flags Access flags - * @return String representation of flags - */ - public static final String accessToString(int access_flags) { - return accessToString(access_flags, false); - } - - /** - * Convert bit field of flags into string such as `static final'. - * - * Special case: Classes compiled with new compilers and with the - * `ACC_SUPER' flag would be said to be "synchronized". This is - * because SUN used the same value for the flags `ACC_SUPER' and - * `ACC_SYNCHRONIZED'. - * - * @param access_flags Access flags - * @param for_class access flags are for class qualifiers ? - * @return String representation of flags - */ - public static final String accessToString(int access_flags, - boolean for_class) - { - StringBuffer buf = new StringBuffer(); - - int p = 0; - for(int i=0; p < Constants.MAX_ACC_FLAG; i++) { // Loop through known flags - p = pow2(i); - - if((access_flags & p) != 0) { - /* Special case: Classes compiled with new compilers and with the - * `ACC_SUPER' flag would be said to be "synchronized". This is - * because SUN used the same value for the flags `ACC_SUPER' and - * `ACC_SYNCHRONIZED'. - */ - if(for_class && ((p == Constants.ACC_SUPER) || (p == Constants.ACC_INTERFACE))) - continue; - - buf.append(Constants.ACCESS_NAMES[i] + " "); - } - } - - return buf.toString().trim(); - } - - /** - * @return "class" or "interface", depending on the ACC_INTERFACE flag - */ - public static final String classOrInterface(int access_flags) { - return ((access_flags & Constants.ACC_INTERFACE) != 0)? "interface" : "class"; - } - - /** - * Disassemble a byte array of JVM byte codes starting from code line - * `index' and return the disassembled string representation. Decode only - * `num' opcodes (including their operands), use -1 if you want to - * decompile everything. - * - * @param code byte code array - * @param constant_pool Array of constants - * @param index offset in `code' array - * (number of opcodes, not bytes!) - * @param length number of opcodes to decompile, -1 for all - * @param verbose be verbose, e.g. print constant pool index - * @return String representation of byte codes - */ - public static final String codeToString(byte[] code, - ConstantPool constant_pool, - int index, int length, boolean verbose) - { - StringBuffer buf = new StringBuffer(code.length * 20); // Should be sufficient - ByteSequence stream = new ByteSequence(code); - - try { - for(int i=0; i < index; i++) // Skip `index' lines of code - codeToString(stream, constant_pool, verbose); - - for(int i=0; stream.available() > 0; i++) { - if((length < 0) || (i < length)) { - String indices = fillup(stream.getIndex() + ":", 6, true, ' '); - buf.append(indices + codeToString(stream, constant_pool, verbose) + '\n'); - } - } - } catch(IOException e) { - System.out.println(buf.toString()); - e.printStackTrace(); - throw new ClassFormatException("Byte code error: " + e); - } - - return buf.toString(); - } - - public static final String codeToString(byte[] code, - ConstantPool constant_pool, - int index, int length) { - return codeToString(code, constant_pool, index, length, true); - } - - /** - * Disassemble a stream of byte codes and return the - * string representation. - * - * @param bytes stream of bytes - * @param constant_pool Array of constants - * @param verbose be verbose, e.g. print constant pool index - * @return String representation of byte code - */ - public static final String codeToString(ByteSequence bytes, - ConstantPool constant_pool, boolean verbose) - throws IOException - { - short opcode = (short)bytes.readUnsignedByte(); - int default_offset=0, low, high, npairs; - int index, vindex, constant; - int[] match, jump_table; - int no_pad_bytes=0, offset; - StringBuffer buf = new StringBuffer(Constants.OPCODE_NAMES[opcode]); - - /* Special case: Skip (0-3) padding bytes, i.e., the - * following bytes are 4-byte-aligned - */ - if((opcode == Constants.TABLESWITCH) || (opcode == Constants.LOOKUPSWITCH)) { - int remainder = bytes.getIndex() % 4; - no_pad_bytes = (remainder == 0)? 0 : 4 - remainder; - - for(int i=0; i < no_pad_bytes; i++) { - byte b; - - if((b=bytes.readByte()) != 0) - System.err.println("Warning: Padding byte != 0 in " + - Constants.OPCODE_NAMES[opcode] + ":" + b); - } - - // Both cases have a field default_offset in common - default_offset = bytes.readInt(); - } - - switch(opcode) { - /* Table switch has variable length arguments. - */ - case Constants.TABLESWITCH: - low = bytes.readInt(); - high = bytes.readInt(); - - offset = bytes.getIndex() - 12 - no_pad_bytes - 1; - default_offset += offset; - - buf.append("\tdefault = " + default_offset + ", low = " + low + - ", high = " + high + "("); - - jump_table = new int[high - low + 1]; - for(int i=0; i < jump_table.length; i++) { - jump_table[i] = offset + bytes.readInt(); - buf.append(jump_table[i]); - - if(i < jump_table.length - 1) - buf.append(", "); - } - buf.append(")"); - - break; - - /* Lookup switch has variable length arguments. - */ - case Constants.LOOKUPSWITCH: { - - npairs = bytes.readInt(); - offset = bytes.getIndex() - 8 - no_pad_bytes - 1; - - match = new int[npairs]; - jump_table = new int[npairs]; - default_offset += offset; - - buf.append("\tdefault = " + default_offset + ", npairs = " + npairs + - " ("); - - for(int i=0; i < npairs; i++) { - match[i] = bytes.readInt(); - - jump_table[i] = offset + bytes.readInt(); - - buf.append("(" + match[i] + ", " + jump_table[i] + ")"); - - if(i < npairs - 1) - buf.append(", "); - } - buf.append(")"); - } - break; - - /* Two address bytes + offset from start of byte stream form the - * jump target - */ - case Constants.GOTO: case Constants.IFEQ: case Constants.IFGE: case Constants.IFGT: - case Constants.IFLE: case Constants.IFLT: case Constants.JSR: case Constants.IFNE: - case Constants.IFNONNULL: case Constants.IFNULL: case Constants.IF_ACMPEQ: - case Constants.IF_ACMPNE: case Constants.IF_ICMPEQ: case Constants.IF_ICMPGE: case Constants.IF_ICMPGT: - case Constants.IF_ICMPLE: case Constants.IF_ICMPLT: case Constants.IF_ICMPNE: - buf.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readShort())); - break; - - /* 32-bit wide jumps - */ - case Constants.GOTO_W: case Constants.JSR_W: - buf.append("\t\t#" + ((bytes.getIndex() - 1) + bytes.readInt())); - break; - - /* Index byte references local variable (register) - */ - case Constants.ALOAD: case Constants.ASTORE: case Constants.DLOAD: case Constants.DSTORE: case Constants.FLOAD: - case Constants.FSTORE: case Constants.ILOAD: case Constants.ISTORE: case Constants.LLOAD: case Constants.LSTORE: - case Constants.RET: - if(wide) { - vindex = bytes.readUnsignedShort(); - wide=false; // Clear flag - } - else - vindex = bytes.readUnsignedByte(); - - buf.append("\t\t%" + vindex); - break; - - /* - * Remember wide byte which is used to form a 16-bit address in the - * following instruction. Relies on that the method is called again with - * the following opcode. - */ - case Constants.WIDE: - wide = true; - buf.append("\t(wide)"); - break; - - /* Array of basic type. - */ - case Constants.NEWARRAY: - buf.append("\t\t<" + Constants.TYPE_NAMES[bytes.readByte()] + ">"); - break; - - /* Access object/class fields. - */ - case Constants.GETFIELD: case Constants.GETSTATIC: case Constants.PUTFIELD: case Constants.PUTSTATIC: - index = bytes.readUnsignedShort(); - buf.append("\t\t" + - constant_pool.constantToString(index, Constants.CONSTANT_Fieldref) + - (verbose? " (" + index + ")" : "")); - break; - - /* Operands are references to classes in constant pool - */ - case Constants.NEW: - case Constants.CHECKCAST: - buf.append("\t"); - case Constants.INSTANCEOF: - index = bytes.readUnsignedShort(); - buf.append("\t<" + constant_pool.constantToString(index, - Constants.CONSTANT_Class) + - ">" + (verbose? " (" + index + ")" : "")); - break; - - /* Operands are references to methods in constant pool - */ - case Constants.INVOKESPECIAL: case Constants.INVOKESTATIC: case Constants.INVOKEVIRTUAL: - index = bytes.readUnsignedShort(); - buf.append("\t" + constant_pool.constantToString(index, - Constants.CONSTANT_Methodref) + - (verbose? " (" + index + ")" : "")); - break; - - case Constants.INVOKEINTERFACE: - index = bytes.readUnsignedShort(); - int nargs = bytes.readUnsignedByte(); // historical, redundant - buf.append("\t" + - constant_pool.constantToString(index, - Constants.CONSTANT_InterfaceMethodref) + - (verbose? " (" + index + ")\t" : "") + nargs + "\t" + - bytes.readUnsignedByte()); // Last byte is a reserved space - break; - - /* Operands are references to items in constant pool - */ - case Constants.LDC_W: case Constants.LDC2_W: - index = bytes.readUnsignedShort(); - - buf.append("\t\t" + constant_pool.constantToString - (index, constant_pool.getConstant(index).getTag()) + - (verbose? " (" + index + ")" : "")); - break; - - case Constants.LDC: - index = bytes.readUnsignedByte(); - - buf.append("\t\t" + - constant_pool.constantToString - (index, constant_pool.getConstant(index).getTag()) + - (verbose? " (" + index + ")" : "")); - break; - - /* Array of references. - */ - case Constants.ANEWARRAY: - index = bytes.readUnsignedShort(); - - buf.append("\t\t<" + compactClassName(constant_pool.getConstantString - (index, Constants.CONSTANT_Class), false) + - ">" + (verbose? " (" + index + ")": "")); - break; - - /* Multidimensional array of references. - */ - case Constants.MULTIANEWARRAY: { - index = bytes.readUnsignedShort(); - int dimensions = bytes.readUnsignedByte(); - - buf.append("\t<" + compactClassName(constant_pool.getConstantString - (index, Constants.CONSTANT_Class), false) + - ">\t" + dimensions + (verbose? " (" + index + ")" : "")); - } - break; - - /* Increment local variable. - */ - case Constants.IINC: - if(wide) { - vindex = bytes.readUnsignedShort(); - constant = bytes.readShort(); - wide = false; - } - else { - vindex = bytes.readUnsignedByte(); - constant = bytes.readByte(); - } - buf.append("\t\t%" + vindex + "\t" + constant); - break; - - default: - if(Constants.NO_OF_OPERANDS[opcode] > 0) { - for(int i=0; i < Constants.TYPE_OF_OPERANDS[opcode].length; i++) { - buf.append("\t\t"); - switch(Constants.TYPE_OF_OPERANDS[opcode][i]) { - case Constants.T_BYTE: buf.append(bytes.readByte()); break; - case Constants.T_SHORT: buf.append(bytes.readShort()); break; - case Constants.T_INT: buf.append(bytes.readInt()); break; - - default: // Never reached - System.err.println("Unreachable default case reached!"); - System.exit(-1); - } - } - } - } - - return buf.toString(); - } - - public static final String codeToString(ByteSequence bytes, ConstantPool constant_pool) - throws IOException - { - return codeToString(bytes, constant_pool, true); - } - - /** - * Shorten long class names, java/lang/String becomes - * String. - * - * @param str The long class name - * @return Compacted class name - */ - public static final String compactClassName(String str) { - return compactClassName(str, true); - } - - /** - * Shorten long class name str, i.e., chop off the prefix, - * if the - * class name starts with this string and the flag chopit is true. - * Slashes / are converted to dots .. - * - * @param str The long class name - * @param prefix The prefix the get rid off - * @param chopit Flag that determines whether chopping is executed or not - * @return Compacted class name - */ - public static final String compactClassName(String str, - String prefix, - boolean chopit) - { - int len = prefix.length(); - - str = str.replace('/', '.'); // Is `/' on all systems, even DOS - - if(chopit) { - // If string starts with `prefix' and contains no further dots - if(str.startsWith(prefix) && - (str.substring(len).indexOf('.') == -1)) - str = str.substring(len); - } - - return str; - } - - /** - * Shorten long class names, java/lang/String becomes - * java.lang.String, - * e.g.. If chopit is true the prefix java.lang - * is also removed. - * - * @param str The long class name - * @param chopit Flag that determines whether chopping is executed or not - * @return Compacted class name - */ - public static final String compactClassName(String str, boolean chopit) { - return compactClassName(str, "java.lang.", chopit); - } - - private static final boolean is_digit(char ch) { - return (ch >= '0') && (ch <= '9'); - } - - private static final boolean is_space(char ch) { - return (ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n'); - } - - /** - * @return `flag' with bit `i' set to 1 - */ - public static final int setBit(int flag, int i) { - return flag | pow2(i); - } - - /** - * @return `flag' with bit `i' set to 0 - */ - public static final int clearBit(int flag, int i) { - int bit = pow2(i); - return (flag & bit) == 0? flag : flag ^ bit; - } - - /** - * @return true, if bit `i' in `flag' is set - */ - public static final boolean isSet(int flag, int i) { - return (flag & pow2(i)) != 0; - } - - /** - * Converts string containing the method return and argument types - * to a byte code method signature. - * - * @param ret Return type of method - * @param argv Types of method arguments - * @return Byte code representation of method signature - */ - public final static String methodTypeToSignature(String ret, String[] argv) - throws ClassFormatException - { - StringBuffer buf = new StringBuffer("("); - String str; - - if(argv != null) - for(int i=0; i < argv.length; i++) { - str = getSignature(argv[i]); - - if(str.endsWith("V")) // void can't be a method argument - throw new ClassFormatException("Invalid type: " + argv[i]); - - buf.append(str); - } - - str = getSignature(ret); - - buf.append(")" + str); - - return buf.toString(); - } - - /** - * @param signature Method signature - * @return Array of argument types - * @throws ClassFormatException - */ - public static final String[] methodSignatureArgumentTypes(String signature) - throws ClassFormatException - { - return methodSignatureArgumentTypes(signature, true); - } - - /** - * @param signature Method signature - * @param chopit Shorten class names ? - * @return Array of argument types - * @throws ClassFormatException - */ - public static final String[] methodSignatureArgumentTypes(String signature, - boolean chopit) - throws ClassFormatException - { - ArrayList vec = new ArrayList(); - int index; - String[] types; - - try { // Read all declarations between for `(' and `)' - if(signature.charAt(0) != '(') - throw new ClassFormatException("Invalid method signature: " + signature); - - index = 1; // current string position - - while(signature.charAt(index) != ')') { - vec.add(signatureToString(signature.substring(index), chopit)); - index += consumed_chars; // update position - } - } catch(StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("Invalid method signature: " + signature); - } - - types = new String[vec.size()]; - vec.toArray(types); - return types; - } - /** - * @param signature Method signature - * @return return type of method - * @throws ClassFormatException - */ - public static final String methodSignatureReturnType(String signature) - throws ClassFormatException - { - return methodSignatureReturnType(signature, true); - } - /** - * @param signature Method signature - * @param chopit Shorten class names ? - * @return return type of method - * @throws ClassFormatException - */ - public static final String methodSignatureReturnType(String signature, - boolean chopit) - throws ClassFormatException - { - int index; - String type; - - try { - // Read return type after `)' - index = signature.lastIndexOf(')') + 1; - type = signatureToString(signature.substring(index), chopit); - } catch(StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("Invalid method signature: " + signature); - } - - return type; - } - - /** - * Converts method signature to string with all class names compacted. - * - * @param signature to convert - * @param name of method - * @param access flags of method - * @return Human readable signature - */ - public static final String methodSignatureToString(String signature, - String name, - String access) { - return methodSignatureToString(signature, name, access, true); - } - - public static final String methodSignatureToString(String signature, - String name, - String access, - boolean chopit) { - return methodSignatureToString(signature, name, access, chopit, null); - } - - /** - * A return type signature represents the return value from a method. - * It is a series of bytes in the following grammar: - * - * ::= | V - * - * The character V indicates that the method returns no value. Otherwise, the - * signature indicates the type of the return value. - * An argument signature represents an argument passed to a method: - * - * ::= - * - * A method signature represents the arguments that the method expects, and - * the value that it returns. - * ::= () - * ::= * - * - * This method converts such a string into a Java type declaration like - * `void _main(String[])' and throws a `ClassFormatException' when the parsed - * type is invalid. - * - * @param signature Method signature - * @param name Method name - * @param access Method access rights - * @return Java type declaration - * @throws ClassFormatException - */ - public static final String methodSignatureToString(String signature, - String name, - String access, - boolean chopit, - LocalVariableTable vars) - throws ClassFormatException - { - StringBuffer buf = new StringBuffer("("); - String type; - int index; - int var_index = (access.indexOf("static") >= 0)? 0 : 1; - - try { // Read all declarations between for `(' and `)' - if(signature.charAt(0) != '(') - throw new ClassFormatException("Invalid method signature: " + signature); - - index = 1; // current string position - - while(signature.charAt(index) != ')') { - String param_type = signatureToString(signature.substring(index), chopit); - buf.append(param_type); - - if(vars != null) { - LocalVariable l = vars.getLocalVariable(var_index); - - if(l != null) - buf.append(" " + l.getName()); - } else - buf.append(" arg" + var_index); - - if("double".equals(param_type) || "long".equals(param_type)) - var_index += 2; - else - var_index++; - - buf.append(", "); - index += consumed_chars; // update position - } - - index++; // update position - - // Read return type after `)' - type = signatureToString(signature.substring(index), chopit); - - } catch(StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("Invalid method signature: " + signature); - } - - if(buf.length() > 1) // Tack off the extra ", " - buf.setLength(buf.length() - 2); - - buf.append(")"); - - return access + ((access.length() > 0)? " " : "") + // May be an empty string - type + " " + name + buf.toString(); - } - - // Guess what this does - private static final int pow2(int n) { - return 1 << n; - } - - /** - * Replace all occurences of old in str with new. - * - * @param str String to permute - * @param old String to be replaced - * @param new Replacement string - * @return new String object - */ - public static final String replace(String str, String old, String new_) { - int index, old_index; - StringBuffer buf = new StringBuffer(); - - try { - if((index = str.indexOf(old)) != -1) { // `old' found in str - old_index = 0; // String start offset - - // While we have something to replace - while((index = str.indexOf(old, old_index)) != -1) { - buf.append(str.substring(old_index, index)); // append prefix - buf.append(new_); // append replacement - - old_index = index + old.length(); // Skip `old'.length chars - } - - buf.append(str.substring(old_index)); // append rest of string - str = buf.toString(); - } - } catch(StringIndexOutOfBoundsException e) { // Should not occur - System.err.println(e); - } - - return str; - } - - /** - * Converts signature to string with all class names compacted. - * - * @param signature to convert - * @return Human readable signature - */ - public static final String signatureToString(String signature) { - return signatureToString(signature, true); - } - - /** - * The field signature represents the value of an argument to a function or - * the value of a variable. It is a series of bytes generated by the - * following grammar: - * - *
    -   *  ::= 
    -   *       ::= ||
    -   *        ::= B|C|D|F|I|J|S|Z
    -   *      ::= L;
    -   *       ::= [
    -   *
    -   * The meaning of the base types is as follows:
    -   * B byte signed byte
    -   * C char character
    -   * D double double precision IEEE float
    -   * F float single precision IEEE float
    -   * I int integer
    -   * J long long integer
    -   * L; ... an object of the given class
    -   * S short signed short
    -   * Z boolean true or false
    -   * [ ... array
    -   * 
    - * - * This method converts this string into a Java type declaration such as - * `String[]' and throws a `ClassFormatException' when the parsed type is - * invalid. - * - * @param signature Class signature - * @param chopit Flag that determines whether chopping is executed or not - * @return Java type declaration - * @throws ClassFormatException - */ - public static final String signatureToString(String signature, - boolean chopit) - { - consumed_chars = 1; // This is the default, read just one char like `B' - - try { - switch(signature.charAt(0)) { - case 'B' : return "byte"; - case 'C' : return "char"; - case 'D' : return "double"; - case 'F' : return "float"; - case 'I' : return "int"; - case 'J' : return "long"; - - case 'L' : { // Full class name - int index = signature.indexOf(';'); // Look for closing `;' - - if(index < 0) - throw new ClassFormatException("Invalid signature: " + signature); - - consumed_chars = index + 1; // "Lblabla;" `L' and `;' are removed - - return compactClassName(signature.substring(1, index), chopit); - } - - case 'S' : return "short"; - case 'Z' : return "boolean"; - - case '[' : { // Array declaration - int n; - StringBuffer buf, brackets; - String type; - char ch; - int consumed_chars; // Shadows global var - - brackets = new StringBuffer(); // Accumulate []'s - - // Count opening brackets and look for optional size argument - for(n=0; signature.charAt(n) == '['; n++) - brackets.append("[]"); - - consumed_chars = n; // Remember value - - // The rest of the string denotes a `' - type = signatureToString(signature.substring(n), chopit); - - Utility.consumed_chars += consumed_chars; - return type + brackets.toString(); - } - - case 'V' : return "void"; - - default : throw new ClassFormatException("Invalid signature: `" + - signature + "'"); - } - } catch(StringIndexOutOfBoundsException e) { // Should never occur - throw new ClassFormatException("Invalid signature: " + e + ":" + signature); - } - } - - /** Parse Java type such as "char", or "java.lang.String[]" and return the - * signature in byte code format, e.g. "C" or "[Ljava/lang/String;" respectively. - * - * @param type Java type - * @return byte code signature - */ - public static String getSignature(String type) { - StringBuffer buf = new StringBuffer(); - char[] chars = type.toCharArray(); - boolean char_found = false, delim = false; - int index = -1; - - loop: - for(int i=0; i < chars.length; i++) { - switch(chars[i]) { - case ' ': case '\t': case '\n': case '\r': case '\f': - if(char_found) - delim = true; - break; - - case '[': - if(!char_found) - throw new RuntimeException("Illegal type: " + type); - - index = i; - break loop; - - default: - char_found = true; - if(!delim) - buf.append(chars[i]); - } - } - - int brackets = 0; - - if(index > 0) - brackets = countBrackets(type.substring(index)); - - type = buf.toString(); - buf.setLength(0); - - for(int i=0; i < brackets; i++) - buf.append('['); - - boolean found = false; - - for(int i=Constants.T_BOOLEAN; (i <= Constants.T_VOID) && !found; i++) { - if(Constants.TYPE_NAMES[i].equals(type)) { - found = true; - buf.append(Constants.SHORT_TYPE_NAMES[i]); - } - } - - if(!found) // Class name - buf.append('L' + type.replace('.', '/') + ';'); - - return buf.toString(); - } - - private static int countBrackets(String brackets) { - char[] chars = brackets.toCharArray(); - int count = 0; - boolean open = false; - - for(int i=0; iConstants - * - * @param signature in format described above - * @return type of method signature - * @see Constants - */ - public static final byte typeOfMethodSignature(String signature) - throws ClassFormatException - { - int index; - - try { - if(signature.charAt(0) != '(') - throw new ClassFormatException("Invalid method signature: " + signature); - - index = signature.lastIndexOf(')') + 1; - return typeOfSignature(signature.substring(index)); - } catch(StringIndexOutOfBoundsException e) { - throw new ClassFormatException("Invalid method signature: " + signature); - } - } - - /** - * Return type of signature as a byte value as defined in Constants - * - * @param signature in format described above - * @return type of signature - * @see Constants - */ - public static final byte typeOfSignature(String signature) - throws ClassFormatException - { - try { - switch(signature.charAt(0)) { - case 'B' : return Constants.T_BYTE; - case 'C' : return Constants.T_CHAR; - case 'D' : return Constants.T_DOUBLE; - case 'F' : return Constants.T_FLOAT; - case 'I' : return Constants.T_INT; - case 'J' : return Constants.T_LONG; - case 'L' : return Constants.T_REFERENCE; - case '[' : return Constants.T_ARRAY; - case 'V' : return Constants.T_VOID; - case 'Z' : return Constants.T_BOOLEAN; - case 'S' : return Constants.T_SHORT; - default: - throw new ClassFormatException("Invalid method signature: " + signature); - } - } catch(StringIndexOutOfBoundsException e) { - throw new ClassFormatException("Invalid method signature: " + signature); - } - } - - /** Map opcode names to opcode numbers. E.g., return Constants.ALOAD for "aload" - */ - public static short searchOpcode(String name) { - name = name.toLowerCase(); - - for(short i=0; i < Constants.OPCODE_NAMES.length; i++) - if(Constants.OPCODE_NAMES[i].equals(name)) - return i; - - return -1; - } - - /** - * Convert (signed) byte to (unsigned) short value, i.e., all negative - * values become positive. - */ - private static final short byteToShort(byte b) { - return (b < 0)? (short)(256 + b) : (short)b; - } - - /** Convert bytes into hexidecimal string - * - * @return bytes as hexidecimal string, e.g. 00 FA 12 ... - */ - public static final String toHexString(byte[] bytes) { - StringBuffer buf = new StringBuffer(); - - for(int i=0; i < bytes.length; i++) { - short b = byteToShort(bytes[i]); - String hex = Integer.toString(b, 0x10); - - if(b < 0x10) // just one digit, prepend '0' - buf.append('0'); - - buf.append(hex); - - if(i < bytes.length - 1) - buf.append(' '); - } - - return buf.toString(); - } - - /** - * Return a string for an integer justified left or right and filled up with - * `fill' characters if necessary. - * - * @param i integer to format - * @param length length of desired string - * @param left_justify format left or right - * @param fill fill character - * @return formatted int - */ - public static final String format(int i, int length, boolean left_justify, char fill) { - return fillup(Integer.toString(i), length, left_justify, fill); - } - - /** - * Fillup char with up to length characters with char `fill' and justify it left or right. - * - * @param str string to format - * @param length length of desired string - * @param left_justify format left or right - * @param fill fill character - * @return formatted string - */ - public static final String fillup(String str, int length, boolean left_justify, char fill) { - int len = length - str.length(); - char[] buf = new char[(len < 0)? 0 : len]; - - for(int j=0; j < buf.length; j++) - buf[j] = fill; - - if(left_justify) - return str + new String(buf); - else - return new String(buf) + str; - } - - static final boolean equals(byte[] a, byte[] b) { - int size; - - if((size=a.length) != b.length) - return false; - - for(int i=0; i < size; i++) - if(a[i] != b[i]) - return false; - - return true; - } - - public static final void printArray(PrintStream out, Object[] obj) { - out.println(printArray(obj, true)); - } - - public static final void printArray(PrintWriter out, Object[] obj) { - out.println(printArray(obj, true)); - } - - public static final String printArray(Object[] obj) { - return printArray(obj, true); - } - - public static final String printArray(Object[] obj, boolean braces) { - return printArray(obj, braces, false); - } - - public static final String printArray(Object[] obj, boolean braces, - boolean quote) { - if(obj == null) - return null; - - StringBuffer buf = new StringBuffer(); - if(braces) - buf.append('{'); - - for(int i=0; i < obj.length; i++) { - if(obj[i] != null) { - buf.append((quote? "\"" : "") + obj[i].toString() + (quote? "\"" : "")); - } else { - buf.append("null"); - } - - if(i < obj.length - 1) { - buf.append(", "); - } - } - - if(braces) - buf.append('}'); - - return buf.toString(); - } - - /** @return true, if character is one of (a, ... z, A, ... Z, 0, ... 9, _) - */ - public static boolean isJavaIdentifierPart(char ch) { - return ((ch >= 'a') && (ch <= 'z')) || - ((ch >= 'A') && (ch <= 'Z')) || - ((ch >= '0') && (ch <= '9')) || - (ch == '_'); - } - - /** Encode byte array it into Java identifier string, i.e., a string - * that only contains the following characters: (a, ... z, A, ... Z, - * 0, ... 9, _, $). The encoding algorithm itself is not too - * clever: if the current byte's ASCII value already is a valid Java - * identifier part, leave it as it is. Otherwise it writes the - * escape character($) followed by