# HG changeset patch # User Andreas Woess # Date 1328645758 -3600 # Node ID 14a00ee82980c223b85441930538e5ff09cdd5f0 # Parent 95802b2cec42c2006ff5e0348b756163d0d21a17 Implement eager type resolving. diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java Tue Feb 07 21:15:58 2012 +0100 @@ -728,11 +728,11 @@ return result; } - public static Class[] signatureToTypes(RiSignature signature, RiType accessingClass) { + public static Class[] signatureToTypes(RiSignature signature, RiResolvedType accessingClass) { int count = signature.argumentCount(false); Class[] result = new Class[count]; for (int i = 0; i < result.length; ++i) { - result[i] = ((RiResolvedType) signature.argumentTypeAt(i, accessingClass)).toJava(); + result[i] = signature.argumentTypeAt(i, accessingClass).resolve(accessingClass).toJava(); } return result; } diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiSignature.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiSignature.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiSignature.java Tue Feb 07 21:15:58 2012 +0100 @@ -49,7 +49,7 @@ * not care for a resolved type. * @return the {@code index}'th argument type */ - RiType argumentTypeAt(int index, RiType accessingClass); + RiType argumentTypeAt(int index, RiResolvedType accessingClass); /** * Gets the argument kind at the specified position. diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiType.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiType.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiType.java Tue Feb 07 21:15:58 2012 +0100 @@ -97,4 +97,6 @@ * @return the kind of constants for the specified part of the type */ CiKind getRepresentationKind(Representation r); + + RiResolvedType resolve(RiResolvedType accessingClass); } diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java --- a/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.debug/src/com/oracle/max/graal/debug/internal/DebugScope.java Tue Feb 07 21:15:58 2012 +0100 @@ -73,6 +73,7 @@ this.parent = parent; this.context = context; this.qualifiedName = qualifiedName; + assert context != null; } public boolean isDumpEnabled() { @@ -128,7 +129,7 @@ if (!sandbox && newChild.hasValueMap()) { getValueMap().addChild(newChild.getValueMap()); } - newChild.deactivate(); + newChild.context = null; instanceTL.set(oldContext); setConfig(oldConfig); } @@ -174,10 +175,6 @@ } } - private void deactivate() { - context = null; - } - private RuntimeException interceptException(final Throwable e) { final DebugConfig config = getConfig(); if (config != null) { diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/Compiler.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/Compiler.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/Compiler.java Tue Feb 07 21:15:58 2012 +0100 @@ -34,7 +34,7 @@ CompilerToVM getVMEntries(); VMToCompiler getVMExits(); GraalCompiler getCompiler(); - RiType lookupType(String returnType, HotSpotTypeResolved accessingClass); + RiType lookupType(String returnType, HotSpotTypeResolved accessingClass, boolean eagerResolve); HotSpotVMConfig getConfig(); GraalRuntime getRuntime(); CiTarget getTarget(); diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/CompilerImpl.java Tue Feb 07 21:15:58 2012 +0100 @@ -176,7 +176,7 @@ } @Override - public RiType lookupType(String returnType, HotSpotTypeResolved accessingClass) { + public RiType lookupType(String returnType, HotSpotTypeResolved accessingClass, boolean eagerResolve) { if (returnType.length() == 1 && vmExits instanceof VMToCompilerImpl) { VMToCompilerImpl exitsNative = (VMToCompilerImpl) vmExits; CiKind kind = CiKind.fromPrimitiveOrVoidTypeChar(returnType.charAt(0)); @@ -207,7 +207,7 @@ return exitsNative.typeVoid; } } - return vmEntries.RiSignature_lookupType(returnType, accessingClass); + return vmEntries.RiSignature_lookupType(returnType, accessingClass, eagerResolve); } @Override diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVM.java Tue Feb 07 21:15:58 2012 +0100 @@ -53,7 +53,7 @@ boolean HotSpotMethodData_isMature(HotSpotMethodData methodData); - RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass); + RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass, boolean eagerResolve); Object RiConstantPool_lookupConstant(HotSpotTypeResolved pool, int cpi); diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl.java Tue Feb 07 21:15:58 2012 +0100 @@ -60,7 +60,7 @@ public native int RiMethod_invocationCount(HotSpotMethodResolved method); @Override - public native RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass); + public native RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass, boolean eagerResolve); @Override public native Object RiConstantPool_lookupConstant(HotSpotTypeResolved pool, int cpi); diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotRuntime.java Tue Feb 07 21:15:58 2012 +0100 @@ -437,7 +437,7 @@ private CiTargetMethod createCallbackStub(RiResolvedMethod method, CiGenericCallback callback) { StructuredGraph graph = new StructuredGraph(); - FrameStateBuilder frameState = new FrameStateBuilder(method, method.maxLocals(), method.maxStackSize(), graph); + FrameStateBuilder frameState = new FrameStateBuilder(method, method.maxLocals(), method.maxStackSize(), graph, false); ValueNode local0 = frameState.loadLocal(0); FrameState initialFrameState = frameState.create(0); diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotSignature.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotSignature.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotSignature.java Tue Feb 07 21:15:58 2012 +0100 @@ -117,13 +117,13 @@ } @Override - public RiType argumentTypeAt(int index, RiType accessingClass) { + public RiType argumentTypeAt(int index, RiResolvedType accessingClass) { if (argumentTypes == null) { argumentTypes = new RiType[arguments.size()]; } RiType type = argumentTypes[index]; if (type == null) { - type = compiler.lookupType(arguments.get(index), (HotSpotTypeResolved) accessingClass); + type = compiler.lookupType(arguments.get(index), (HotSpotTypeResolved) accessingClass, false); argumentTypes[index] = type; } return type; @@ -142,7 +142,7 @@ @Override public RiType returnType(RiType accessingClass) { if (returnTypeCache == null) { - returnTypeCache = compiler.lookupType(returnType, (HotSpotTypeResolved) accessingClass); + returnTypeCache = compiler.lookupType(returnType, (HotSpotTypeResolved) accessingClass, false); } return returnTypeCache; } diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypePrimitive.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypePrimitive.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypePrimitive.java Tue Feb 07 21:15:58 2012 +0100 @@ -166,4 +166,9 @@ public Class< ? > toJava() { return kind.toJavaClass(); } + + @Override + public RiResolvedType resolve(RiResolvedType accessingClass) { + return this; + } } diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypeResolvedImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypeResolvedImpl.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypeResolvedImpl.java Tue Feb 07 21:15:58 2012 +0100 @@ -253,4 +253,9 @@ public T getAnnotation(Class annotationClass) { return toJava().getAnnotation(annotationClass); } + + @Override + public RiResolvedType resolve(RiResolvedType accessingClass) { + return this; + } } diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypeUnresolved.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypeUnresolved.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotTypeUnresolved.java Tue Feb 07 21:15:58 2012 +0100 @@ -31,9 +31,6 @@ */ public class HotSpotTypeUnresolved extends HotSpotType { - /** - * - */ private static final long serialVersionUID = -2320936267633521314L; public final String simpleName; public final int dimensions; @@ -46,13 +43,14 @@ assert name.length() > 0 : "name cannot be empty"; int dims = 0; + int startIndex = 0; + while (name.charAt(startIndex) == '[') { + startIndex++; + dims++; + } + // Decode name if necessary. if (name.charAt(name.length() - 1) == ';') { - int startIndex = 0; - while (name.charAt(startIndex) == '[') { - startIndex++; - dims++; - } assert name.charAt(startIndex) == 'L'; this.simpleName = name.substring(startIndex + 1, name.length() - 1); this.name = name; @@ -116,4 +114,9 @@ public CiKind getRepresentationKind(RiType.Representation r) { return CiKind.Object; } + + @Override + public RiResolvedType resolve(RiResolvedType accessingClass) { + return (RiResolvedType) compiler.lookupType(name, (HotSpotTypeResolved) accessingClass, true); + } } diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/FrameStateBuilder.java --- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/FrameStateBuilder.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/FrameStateBuilder.java Tue Feb 07 21:15:58 2012 +0100 @@ -47,7 +47,7 @@ private final RiResolvedMethod method; - public FrameStateBuilder(RiResolvedMethod method, int maxLocals, int maxStackSize, StructuredGraph graph) { + public FrameStateBuilder(RiResolvedMethod method, int maxLocals, int maxStackSize, StructuredGraph graph, boolean eagerResolve) { assert graph != null; this.method = method; this.graph = graph; @@ -67,9 +67,12 @@ } RiSignature sig = method.signature(); int max = sig.argumentCount(false); - RiType accessingClass = method.holder(); + RiResolvedType accessingClass = method.holder(); for (int i = 0; i < max; i++) { RiType type = sig.argumentTypeAt(i, accessingClass); + if (eagerResolve) { + type = type.resolve(accessingClass); + } CiKind kind = type.kind(false).stackKind(); Stamp stamp; if (kind == CiKind.Object && type instanceof RiResolvedType) { diff -r 95802b2cec42 -r 14a00ee82980 graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Tue Feb 07 12:48:19 2012 +0100 +++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java Tue Feb 07 21:15:58 2012 +0100 @@ -128,7 +128,7 @@ methodSynchronizedObject = null; exceptionHandlers = null; this.currentGraph = graph; - this.frameState = new FrameStateBuilder(method, method.maxLocals(), method.maxStackSize(), graph); + this.frameState = new FrameStateBuilder(method, method.maxLocals(), method.maxStackSize(), graph, config.eagerResolving()); build(); } diff -r 95802b2cec42 -r 14a00ee82980 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Tue Feb 07 12:48:19 2012 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue Feb 07 21:15:58 2012 +0100 @@ -240,7 +240,7 @@ } // public RiType RiSignature_lookupType(String returnType, HotSpotTypeResolved accessingClass); -JNIEXPORT jobject JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jobject accessingClass) { +JNIEXPORT jobject JNICALL Java_com_oracle_max_graal_hotspot_bridge_CompilerToVMImpl_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve) { TRACE_graal_3("CompilerToVM::RiSignature_lookupType"); VM_ENTRY_MARK; ResourceMark rm; @@ -275,7 +275,11 @@ classloader = java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(accessingClass))->klass_part()->class_loader(); protectionDomain = java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(accessingClass))->klass_part()->protection_domain(); } - resolved_type = SystemDictionary::resolve_or_null(nameSymbol, classloader, protectionDomain, THREAD); + if (eagerResolve) { + resolved_type = SystemDictionary::resolve_or_null(nameSymbol, classloader, protectionDomain, THREAD); + } else { + resolved_type = SystemDictionary::find(nameSymbol, classloader, protectionDomain, THREAD); + } if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; resolved_type = NULL; @@ -935,7 +939,7 @@ {CC"HotSpotMethodData_isMature", CC"("METHOD_DATA")Z", FN_PTR(HotSpotMethodData_1isMature)}, {CC"RiMethod_invocationCount", CC"("RESOLVED_METHOD")I", FN_PTR(RiMethod_1invocationCount)}, {CC"RiMethod_hasCompiledCode", CC"("RESOLVED_METHOD")Z", FN_PTR(RiMethod_1hasCompiledCode)}, - {CC"RiSignature_lookupType", CC"("STRING RESOLVED_TYPE")"TYPE, FN_PTR(RiSignature_1lookupType)}, + {CC"RiSignature_lookupType", CC"("STRING RESOLVED_TYPE"Z)"TYPE, FN_PTR(RiSignature_1lookupType)}, {CC"RiConstantPool_lookupConstant", CC"("RESOLVED_TYPE"I)"OBJECT, FN_PTR(RiConstantPool_1lookupConstant)}, {CC"RiConstantPool_lookupMethod", CC"("RESOLVED_TYPE"IB)"METHOD, FN_PTR(RiConstantPool_1lookupMethod)}, {CC"RiConstantPool_lookupType", CC"("RESOLVED_TYPE"I)"TYPE, FN_PTR(RiConstantPool_1lookupType)}, diff -r 95802b2cec42 -r 14a00ee82980 src/share/vm/graal/graalVmIds.hpp --- a/src/share/vm/graal/graalVmIds.hpp Tue Feb 07 12:48:19 2012 +0100 +++ b/src/share/vm/graal/graalVmIds.hpp Tue Feb 07 21:15:58 2012 +0100 @@ -72,7 +72,7 @@ } inline Symbol* VmIds::toSymbol(jstring string) { - return java_lang_String::as_symbol_or_null(JNIHandles::resolve(string)); + return java_lang_String::as_symbol(JNIHandles::resolve(string), Thread::current()); } inline jlong VmIds::getBoxedLong(oop obj) {