# HG changeset patch # User Chris Seaton # Date 1388435764 0 # Node ID 896c8712c7b498591b8b046171697e3e9b15fb8b # Parent 807ad2134a6bbd5b12d89ce9958fc0e4e12ee3a1# Parent 33f0ac112264f6f07ca04aaf7835ad5df6db6807 Merge. diff -r 807ad2134a6b -r 896c8712c7b4 .hgignore --- a/.hgignore Sun Dec 22 20:06:55 2013 +0000 +++ b/.hgignore Mon Dec 30 20:36:04 2013 +0000 @@ -1,7 +1,9 @@ ^mx/env ^mx/checkstyle-timestamps -^mx/eclipseinit.timestamp -^mx/netbeansinit.timestamp +^mx/eclipse-config.zip +^mx/eclipse-config-libs.zip +^mx/netbeans-config.zip +^mx/netbeans-config-libs.zip ^mx/eclipse-launches ^mx/currentAnnotationProcessors ^mx/ecj.jar diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java Mon Dec 30 20:36:04 2013 +0000 @@ -28,12 +28,13 @@ public interface ConstantReflectionProvider { /** - * Compares two constants for equality. The equality relationship is symmetric. + * Compares two constants for equality. The equality relationship is symmetric. If the constants + * cannot be compared at this point, the return value is {@code null}; * * @return {@code true} if the two parameters represent the same runtime object, {@code false} - * otherwise + * if they are different, or {@code null} if the parameters cannot be compared. */ - boolean constantEquals(Constant x, Constant y); + Boolean constantEquals(Constant x, Constant y); /** * Returns the length of an array that is wrapped in a {@link Constant} object. If {@code array} diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Mon Dec 30 20:36:04 2013 +0000 @@ -23,11 +23,11 @@ package com.oracle.graal.hotspot.amd64; import static com.oracle.graal.amd64.AMD64.*; +import static com.oracle.graal.asm.NumUtil.*; import static com.oracle.graal.hotspot.bridge.Marks.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.lir.*; @@ -68,21 +68,21 @@ */ private static boolean isPollingPageFar(HotSpotVMConfig config) { final long pollingPageAddress = config.safepointPollingAddress; - // TODO return ForceUnreachable || - return !NumUtil.isInt(pollingPageAddress - config.codeCacheLowBoundary()) || !NumUtil.isInt(pollingPageAddress - config.codeCacheHighBoundary()); + return config.forceUnreachable || !isInt(pollingPageAddress - config.codeCacheLowBoundary()) || !isInt(pollingPageAddress - config.codeCacheHighBoundary()); } public static void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { - final int pos = asm.codeBuffer.position(); if (isPollingPageFar(config)) { asm.movq(scratch, config.safepointPollingAddress); crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR); + final int pos = asm.codeBuffer.position(); if (state != null) { crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } asm.testl(rax, new AMD64Address(scratch)); } else { crb.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); + final int pos = asm.codeBuffer.position(); if (state != null) { crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Dec 30 20:36:04 2013 +0000 @@ -190,15 +190,22 @@ protected final HotSpotVMConfig config; private final HotSpotBackend hostBackend; - public final HotSpotResolvedPrimitiveType typeBoolean; - public final HotSpotResolvedPrimitiveType typeByte; - public final HotSpotResolvedPrimitiveType typeChar; - public final HotSpotResolvedPrimitiveType typeShort; - public final HotSpotResolvedPrimitiveType typeInt; - public final HotSpotResolvedPrimitiveType typeLong; - public final HotSpotResolvedPrimitiveType typeFloat; - public final HotSpotResolvedPrimitiveType typeDouble; - public final HotSpotResolvedPrimitiveType typeVoid; + /** + * Graal mirrors are stored as a {@link ClassValue} associated with the {@link Class} of the + * type. This data structure stores both {@link HotSpotResolvedObjectType} and + * {@link HotSpotResolvedPrimitiveType} types. + */ + private final ClassValue graalMirrors = new ClassValue() { + @Override + protected ResolvedJavaType computeValue(Class javaClass) { + if (javaClass.isPrimitive()) { + Kind kind = Kind.fromJavaClass(javaClass); + return new HotSpotResolvedPrimitiveType(kind); + } else { + return new HotSpotResolvedObjectType(javaClass); + } + } + }; private final Map, HotSpotBackend> backends = new HashMap<>(); @@ -212,26 +219,6 @@ vmToCompiler = toCompiler; config = new HotSpotVMConfig(compilerToVm); - typeBoolean = new HotSpotResolvedPrimitiveType(Kind.Boolean); - typeByte = new HotSpotResolvedPrimitiveType(Kind.Byte); - typeChar = new HotSpotResolvedPrimitiveType(Kind.Char); - typeShort = new HotSpotResolvedPrimitiveType(Kind.Short); - typeInt = new HotSpotResolvedPrimitiveType(Kind.Int); - typeLong = new HotSpotResolvedPrimitiveType(Kind.Long); - typeFloat = new HotSpotResolvedPrimitiveType(Kind.Float); - typeDouble = new HotSpotResolvedPrimitiveType(Kind.Double); - typeVoid = new HotSpotResolvedPrimitiveType(Kind.Void); - - initMirror(typeBoolean); - initMirror(typeByte); - initMirror(typeChar); - initMirror(typeShort); - initMirror(typeInt); - initMirror(typeLong); - initMirror(typeFloat); - initMirror(typeDouble); - initMirror(typeVoid); - CompileTheWorld.Options.overrideWithNativeOptions(config); // Only set HotSpotPrintCompilation and HotSpotPrintInlining if they still have their @@ -264,13 +251,6 @@ } } - private void initMirror(HotSpotResolvedPrimitiveType type) { - Class mirror = type.mirror(); - final long offset = config.graalMirrorInClassOffset; - unsafe.putObject(mirror, offset, type); - assert unsafe.getObject(mirror, offset) == type; - } - private HotSpotBackend registerBackend(HotSpotBackend backend) { Class arch = backend.getTarget().arch.getClass(); HotSpotBackend oldValue = backends.put(arch, backend); @@ -279,6 +259,15 @@ } /** + * Gets the Graal mirror for a {@link Class} object. + * + * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} + */ + public ResolvedJavaType fromClass(Class javaClass) { + return graalMirrors.get(javaClass); + } + + /** * Gets the host architecture name for the purpose of finding the corresponding * {@linkplain HotSpotBackendFactory backend}. */ @@ -352,35 +341,36 @@ return compilerToGpu; } - public JavaType lookupType(String name, HotSpotResolvedObjectType accessingClass, boolean eagerResolve) { + /** + * Converts a name to a Java type. + * + * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format + * @param accessingType the context of resolution (may be null) + * @param eagerResolve force resolution to a {@link ResolvedJavaType}. If true, this method will + * either return a {@link ResolvedJavaType} or throw an exception + * @return a Java type for {@code name} which is guaranteed to be of type + * {@link ResolvedJavaType} if {@code eagerResolve == true} + * @throws LinkageError if {@code eagerResolve == true} and the resolution failed + */ + public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean eagerResolve) { + // If the name represents a primitive type we can short-circuit the lookup. if (name.length() == 1) { Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - switch (kind) { - case Boolean: - return typeBoolean; - case Byte: - return typeByte; - case Char: - return typeChar; - case Short: - return typeShort; - case Int: - return typeInt; - case Long: - return typeLong; - case Float: - return typeFloat; - case Double: - return typeDouble; - case Void: - return typeVoid; - case Object: - break; - case Illegal: - break; - } + return HotSpotResolvedPrimitiveType.fromKind(kind); + } + + // Handle non-primitive types. + Class accessingClass = null; + if (accessingType != null) { + accessingClass = accessingType.mirror(); } - return compilerToVm.lookupType(name, accessingClass, eagerResolve); + + // Resolve the type in the VM. + final long metaspaceKlass = compilerToVm.lookupType(name, accessingClass, eagerResolve); + if (metaspaceKlass == 0) { + return vmToCompiler.createUnresolvedJavaType(name); + } + return HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass); } public HotSpotRuntimeInterpreterInterface getRuntimeInterpreterInterface() { diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Dec 30 20:36:04 2013 +0000 @@ -667,6 +667,7 @@ @HotSpotVMFlag(name = "PrintCompilation") @Stable public boolean printCompilation; @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; @HotSpotVMFlag(name = "GraalUseFastLocking") @Stable public boolean useFastLocking; + @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking; @@ -1040,7 +1041,6 @@ @HotSpotVMField(name = "java_lang_Class::_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int klassOffset; @HotSpotVMField(name = "java_lang_Class::_array_klass_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int arrayKlassOffset; - @HotSpotVMField(name = "java_lang_Class::_graal_mirror_offset", type = "int", get = HotSpotVMField.Type.VALUE) @Stable public int graalMirrorInClassOffset; @HotSpotVMField(name = "Method::_method_data", type = "MethodData*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset; @HotSpotVMField(name = "Method::_from_compiled_entry", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset; diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Mon Dec 30 20:36:04 2013 +0000 @@ -79,13 +79,12 @@ long findUniqueConcreteMethod(long metaspaceMethod); /** - * Used to determine if an interface has exactly one implementor. + * Returns the implementor for the given interface class. * - * @param interfaceType interface for which the implementor should be returned - * @return the unique implementor of the interface or null if the interface has 0 or more than 1 - * implementor + * @param metaspaceKlass the metaspace klass to get the implementor for + * @return the implementor as metaspace klass pointer or null if there is no implementor */ - ResolvedJavaType getUniqueImplementor(HotSpotResolvedObjectType interfaceType); + long getKlassImplementor(long metaspaceKlass); /** * Initializes a {@link HotSpotResolvedJavaMethod} object from a metaspace Method object. @@ -96,17 +95,16 @@ void initializeMethod(long metaspaceMethod, HotSpotResolvedJavaMethod method); /** - * Converts a name to a Java type. + * Converts a name to a metaspace klass. * * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format * @param accessingClass the context of resolution (may be null) * @param eagerResolve force resolution to a {@link ResolvedJavaType}. If true, this method will * either return a {@link ResolvedJavaType} or throw an exception - * @return a Java type for {@code name} which is guaranteed to be of type - * {@link ResolvedJavaType} if {@code eagerResolve == true} + * @return a metaspace klass for {@code name} * @throws LinkageError if {@code eagerResolve == true} and the resolution failed */ - JavaType lookupType(String name, HotSpotResolvedObjectType accessingClass, boolean eagerResolve); + long lookupType(String name, Class accessingClass, boolean eagerResolve); Object lookupConstantInPool(long metaspaceConstantPool, int cpi); diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Mon Dec 30 20:36:04 2013 +0000 @@ -59,10 +59,10 @@ public native long findUniqueConcreteMethod(long metaspaceMethod); @Override - public native ResolvedJavaType getUniqueImplementor(HotSpotResolvedObjectType interfaceType); + public native long getKlassImplementor(long metaspaceKlass); @Override - public native JavaType lookupType(String name, HotSpotResolvedObjectType accessingClass, boolean eagerResolve); + public native long lookupType(String name, Class accessingClass, boolean eagerResolve); @Override public native Object lookupConstantInPool(long metaspaceConstantPool, int cpi); diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Dec 30 20:36:04 2013 +0000 @@ -604,28 +604,39 @@ @Override public ResolvedJavaType createPrimitiveJavaType(int basicType) { + Class javaClass; switch (basicType) { case 4: - return runtime.typeBoolean; + javaClass = boolean.class; + break; case 5: - return runtime.typeChar; + javaClass = char.class; + break; case 6: - return runtime.typeFloat; + javaClass = float.class; + break; case 7: - return runtime.typeDouble; + javaClass = double.class; + break; case 8: - return runtime.typeByte; + javaClass = byte.class; + break; case 9: - return runtime.typeShort; + javaClass = short.class; + break; case 10: - return runtime.typeInt; + javaClass = int.class; + break; case 11: - return runtime.typeLong; + javaClass = long.class; + break; case 14: - return runtime.typeVoid; + javaClass = void.class; + break; default: throw new IllegalArgumentException("Unknown basic type: " + basicType); } + return HotSpotResolvedPrimitiveType.fromClass(javaClass); } @Override diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java Mon Dec 30 20:36:04 2013 +0000 @@ -43,7 +43,7 @@ } @Override - public boolean constantEquals(Constant x, Constant y) { + public Boolean constantEquals(Constant x, Constant y) { return x.equals(y); } diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Mon Dec 30 20:36:04 2013 +0000 @@ -363,7 +363,7 @@ int scale = getScalingFactor(componentKind); ConstantLocationNode location = ConstantLocationNode.create(INIT_LOCATION, accessKind, getArrayBaseOffset(componentKind) + i * scale, graph); - BarrierType barrierType = (componentKind == Kind.Object && !useDeferredInitBarriers()) ? BarrierType.IMPRECISE : BarrierType.NONE; + BarrierType barrierType = (componentKind == Kind.Object && !useDeferredInitBarriers()) ? BarrierType.PRECISE : BarrierType.NONE; WriteNode write = new WriteNode(newObject, value, location, barrierType, componentKind == Kind.Object); graph.addAfterFixed(newObject, graph.add(write)); } diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Mon Dec 30 20:36:04 2013 +0000 @@ -22,12 +22,23 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.meta.*; public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { private static final long serialVersionUID = -6410840212023428347L; + /** + * Gets the Graal mirror for a {@link Class} object. + * + * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} + */ + public static ResolvedJavaType fromClass(Class javaClass) { + return runtime().fromClass(javaClass); + } + public HotSpotResolvedJavaType(String name) { super(name); } diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Mon Dec 30 20:36:04 2013 +0000 @@ -85,40 +85,17 @@ } /** - * Gets the Graal mirror from a {@link Class} object. - * - * @return the {@link HotSpotResolvedObjectType} corresponding to {@code javaClass} - */ - public static ResolvedJavaType fromClass(Class javaClass) { - assert javaClass != null; - HotSpotGraalRuntime runtime = runtime(); - ResolvedJavaType type = (ResolvedJavaType) unsafe.getObject(javaClass, (long) runtime.getConfig().graalMirrorInClassOffset); - if (type == null) { - assert !javaClass.isPrimitive() : "primitive type " + javaClass + " should have its mirror initialized"; - type = new HotSpotResolvedObjectType(javaClass); - - // Install the Graal mirror in the Class object. - final long offset = runtime().getConfig().graalMirrorInClassOffset; - if (!unsafe.compareAndSwapObject(javaClass, offset, null, type)) { - // lost the race - return the existing value instead - type = (HotSpotResolvedObjectType) unsafe.getObject(javaClass, offset); - } - - assert type != null; - } - return type; - } - - /** * Creates the Graal mirror for a {@link Class} object. * *

- * NOTE: Creating a Graal mirror does not install the mirror in the {@link Class} object. + * NOTE: Creating an instance of this class does not install the mirror for the + * {@link Class} type. Use {@link #fromClass(Class)}, {@link #fromMetaspaceKlass(Constant)} or + * {@link #fromMetaspaceKlass(long)} instead. *

* * @param javaClass the Class to create the mirror for */ - private HotSpotResolvedObjectType(Class javaClass) { + public HotSpotResolvedObjectType(Class javaClass) { super(getSignatureName(javaClass)); this.javaClass = javaClass; assert getName().charAt(0) != '[' || isArray() : getName(); @@ -171,23 +148,60 @@ if (isArray()) { return isFinal(getElementalType(this).getModifiers()) ? this : null; } else if (isInterface()) { - return runtime().getCompilerToVM().getUniqueImplementor(this); + final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(metaspaceKlass()); + + // No implementor. + if (implementorMetaspaceKlass == 0) { + return null; + } + + HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) fromMetaspaceKlass(implementorMetaspaceKlass); + + /* + * If the implementor field contains itself that indicates that the interface has more + * than one implementors (see: InstanceKlass::add_implementor). The isInterface check + * takes care of this fact since this class is an interface. + */ + if (isAbstract(type.getModifiers()) || type.isInterface() || !type.isLeafClass()) { + return null; + } + return type; } else { HotSpotResolvedObjectType type = this; while (isAbstract(type.getModifiers())) { - long subklass = unsafeReadWord(type.metaspaceKlass() + config.subklassOffset); + long subklass = type.getSubklass(); if (subklass == 0 || unsafeReadWord(subklass + config.nextSiblingOffset) != 0) { return null; } type = (HotSpotResolvedObjectType) fromMetaspaceKlass(subklass); } - if (isAbstract(type.getModifiers()) || type.isInterface() || unsafeReadWord(type.metaspaceKlass() + config.subklassOffset) != 0) { + if (isAbstract(type.getModifiers()) || type.isInterface() || !type.isLeafClass()) { return null; } return type; } } + /** + * Returns if type {@code type} is a leaf class. This is the case if the + * {@code Klass::_subklass} field of the underlying class is zero. + * + * @return true if the type is a leaf class + */ + private boolean isLeafClass() { + return getSubklass() == 0; + } + + /** + * Returns the {@code Klass::_subklass} field of the underlying metaspace klass for the given + * type {@code type}. + * + * @return value of the subklass field as metaspace klass pointer + */ + private long getSubklass() { + return unsafeReadWord(metaspaceKlass() + runtime().getConfig().subklassOffset); + } + @Override public HotSpotResolvedObjectType getSuperclass() { Class javaSuperclass = javaClass.getSuperclass(); diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Mon Dec 30 20:36:04 2013 +0000 @@ -39,11 +39,32 @@ private final Class javaMirror; private final Class javaArrayMirror; + /** + * Gets the Graal mirror for a {@link Kind}. + * + * @return the {@link HotSpotResolvedObjectType} corresponding to {@code kind} + */ + public static ResolvedJavaType fromKind(Kind kind) { + Class javaClass = kind.toJavaClass(); + return fromClass(javaClass); + } + + /** + * Creates the Graal mirror for a primitive {@link Kind}. + * + *

+ * NOTE: Creating an instance of this class does not install the mirror for the + * {@link Class} type. Use {@link #fromKind(Kind)} or {@link #fromClass(Class)} instead. + *

+ * + * @param kind the Kind to create the mirror for + */ public HotSpotResolvedPrimitiveType(Kind kind) { super(String.valueOf(Character.toUpperCase(kind.getTypeChar()))); this.kind = kind; this.javaMirror = kind.toJavaClass(); this.javaArrayMirror = kind == Kind.Void ? null : Array.newInstance(javaMirror, 0).getClass(); + assert javaMirror.isPrimitive() : javaMirror + " not a primitive type"; } @Override diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemIdentityHashCodeNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemIdentityHashCodeNode.java Mon Dec 30 20:36:04 2013 +0000 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.replacements; + +import static com.oracle.graal.phases.GraalOptions.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.replacements.nodes.*; + +public class SystemIdentityHashCodeNode extends PureFunctionMacroNode { + + public SystemIdentityHashCodeNode(Invoke invoke) { + super(invoke); + } + + @Override + protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) { + return ImmutableCode.getValue() || param.isNull() ? null : Constant.forInt(System.identityHashCode(param.asObject())); + } +} diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java Mon Dec 30 20:36:04 2013 +0000 @@ -24,16 +24,13 @@ import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*; -import static com.oracle.graal.phases.GraalOptions.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.replacements.nodes.*; /** * Substitutions for {@link java.lang.System} methods. @@ -57,18 +54,6 @@ return callLong(JAVA_TIME_NANOS); } - public static class SystemIdentityHashCodeNode extends PureFunctionMacroNode { - - public SystemIdentityHashCodeNode(Invoke invoke) { - super(invoke); - } - - @Override - protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) { - return ImmutableCode.getValue() || param.isNull() ? null : Constant.forInt(System.identityHashCode(param.asObject())); - } - } - @MacroSubstitution(macro = SystemIdentityHashCodeNode.class) @MethodSubstitution public static int identityHashCode(Object x) { diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Mon Dec 30 20:36:04 2013 +0000 @@ -320,7 +320,10 @@ private static boolean valuesDistinct(ConstantReflectionProvider constantReflection, ValueNode a, ValueNode b) { if (a.isConstant() && b.isConstant()) { - return !constantReflection.constantEquals(a.asConstant(), b.asConstant()); + Boolean equal = constantReflection.constantEquals(a.asConstant(), b.asConstant()); + if (equal != null) { + return !equal.booleanValue(); + } } Stamp stampA = a.stamp(); diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Mon Dec 30 20:36:04 2013 +0000 @@ -399,13 +399,16 @@ } } case Object: { - switch (this) { - case EQ: - return constantReflection.constantEquals(lt, rt); - case NE: - return !constantReflection.constantEquals(lt, rt); - default: - throw new GraalInternalError("expected condition: %s", this); + Boolean equal = constantReflection.constantEquals(lt, rt); + if (equal != null) { + switch (this) { + case EQ: + return equal.booleanValue(); + case NE: + return !equal.booleanValue(); + default: + throw new GraalInternalError("expected condition: %s", this); + } } } case Float: { diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Sun Dec 22 20:06:55 2013 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Mon Dec 30 20:36:04 2013 +0000 @@ -105,7 +105,11 @@ for (int i = 0; i < keyCount(); i++) { Constant typeHub = keyAt(i); assert constant.getKind() == typeHub.getKind(); - if (tool.getConstantReflection().constantEquals(constant, typeHub)) { + Boolean equal = tool.getConstantReflection().constantEquals(constant, typeHub); + if (equal == null) { + /* We don't know if this key is a match or not, so we cannot simplify. */ + return; + } else if (equal.booleanValue()) { survivingEdge = keySuccessorIndex(i); } } diff -r 807ad2134a6b -r 896c8712c7b4 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/TextMapTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/TextMapTest.java Mon Dec 30 20:36:04 2013 +0000 @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.api.test.utilities; + +import static org.junit.Assert.*; + +import org.junit.*; + +import com.oracle.truffle.api.source.*; + +public class TextMapTest { + + final TextMap emptyTextMap = new TextMap(""); + + final TextMap emptyLineMap = new TextMap("\n"); + + private final TextMap shortMap = new TextMap("01"); + + private final TextMap longMap = new TextMap("01234\n67\n9\n"); + + @Test + public void emptyTextTest0() { + assertEquals(emptyTextMap.lineCount(), 0); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyTextTest1() { + emptyTextMap.offsetToLine(0); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyTextTest2() { + emptyTextMap.offsetToCol(0); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyTextTest3() { + emptyTextMap.lineStartOffset(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyTextTest4() { + emptyTextMap.lineStartOffset(0); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyTextTest5() { + emptyTextMap.lineStartOffset(1); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyTextTest6() { + emptyTextMap.lineLength(1); + } + + @Test + public void emptyLineTest0() { + assertEquals(emptyLineMap.lineCount(), 1); + assertEquals(emptyLineMap.offsetToLine(0), 1); + assertEquals(emptyLineMap.lineStartOffset(1), 0); + assertEquals(emptyLineMap.offsetToCol(0), 1); + assertEquals(emptyLineMap.lineLength(1), 0); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyLineTest1() { + emptyLineMap.offsetToLine(1); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyLineTest2() { + emptyLineMap.lineStartOffset(2); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyLineTest3() { + emptyLineMap.offsetToCol(1); + } + + @Test(expected = IllegalArgumentException.class) + public void emptyLineTest4() { + emptyLineMap.lineLength(2); + } + + @Test + public void shortTextTest0() { + + assertEquals(shortMap.lineCount(), 1); + + assertEquals(shortMap.offsetToLine(0), 1); + assertEquals(shortMap.lineStartOffset(1), 0); + assertEquals(shortMap.offsetToCol(0), 1); + + assertEquals(shortMap.offsetToLine(1), 1); + assertEquals(shortMap.offsetToCol(1), 2); + + assertEquals(shortMap.lineLength(1), 2); + } + + @Test(expected = IllegalArgumentException.class) + public void shortTextTest1() { + shortMap.offsetToLine(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void shortTextTest2() { + shortMap.offsetToCol(-1); + } + + @Test(expected = IllegalArgumentException.class) + public void shortTextTest3() { + shortMap.offsetToLine(2); + } + + @Test(expected = IllegalArgumentException.class) + public void shortTextTest4() { + shortMap.offsetToCol(2); + } + + @Test(expected = IllegalArgumentException.class) + public void shortTextTest5() { + shortMap.lineStartOffset(2); + } + + @Test(expected = IllegalArgumentException.class) + public void shortTextTest6() { + shortMap.lineLength(2); + } + + @Test + public void longTextTest0() { + + assertEquals(longMap.lineCount(), 3); + + assertEquals(longMap.offsetToLine(0), 1); + assertEquals(longMap.lineStartOffset(1), 0); + assertEquals(longMap.offsetToCol(0), 1); + + assertEquals(longMap.offsetToLine(4), 1); + assertEquals(longMap.offsetToCol(4), 5); + + assertEquals(longMap.offsetToLine(5), 1); // newline + assertEquals(longMap.offsetToCol(5), 6); // newline + assertEquals(longMap.lineLength(1), 5); + + assertEquals(longMap.offsetToLine(6), 2); + assertEquals(longMap.lineStartOffset(2), 6); + assertEquals(longMap.offsetToCol(6), 1); + + assertEquals(longMap.offsetToLine(7), 2); + assertEquals(longMap.offsetToCol(7), 2); + + assertEquals(longMap.offsetToLine(8), 2); // newline + assertEquals(longMap.offsetToLine(8), 2); // newline + assertEquals(longMap.lineLength(2), 2); + + assertEquals(longMap.offsetToLine(9), 3); + assertEquals(longMap.lineStartOffset(3), 9); + assertEquals(longMap.offsetToCol(9), 1); + + assertEquals(longMap.offsetToLine(10), 3); // newline + assertEquals(longMap.offsetToCol(10), 2); // newline + assertEquals(longMap.lineLength(3), 1); + + } + + @Test(expected = IllegalArgumentException.class) + public void longTextTest1() { + longMap.offsetToLine(11); + } + + @Test(expected = IllegalArgumentException.class) + public void longTextTest2() { + longMap.offsetToCol(11); + } + + @Test(expected = IllegalArgumentException.class) + public void longTextTest3() { + longMap.lineStartOffset(4); + } + +} diff -r 807ad2134a6b -r 896c8712c7b4 mx/mx_graal.py --- a/mx/mx_graal.py Sun Dec 22 20:06:55 2013 +0000 +++ b/mx/mx_graal.py Mon Dec 30 20:36:04 2013 +0000 @@ -983,7 +983,7 @@ for vmbuild in ['fastdebug', 'product']: for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild): if 'eclipse' in str(test) and mx.java().version >= mx.VersionSpec('1.8'): - # DaCapo eclipse doesn't not run under JDK8 + # DaCapo eclipse doesn't run under JDK8 continue t = Task(str(test) + ':' + vmbuild) diff -r 807ad2134a6b -r 896c8712c7b4 mxtool/mx.py --- a/mxtool/mx.py Sun Dec 22 20:06:55 2013 +0000 +++ b/mxtool/mx.py Mon Dec 30 20:36:04 2013 +0000 @@ -1832,7 +1832,7 @@ javaCompliance = java().javaCompliance - defaultEcjPath = join(_primary_suite.mxDir, 'ecj.jar') + defaultEcjPath = get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar')) parser = parser if parser is not None else ArgumentParser(prog='mx build') parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)') @@ -1855,7 +1855,7 @@ if args.jdt is not None: if args.jdt.endswith('.jar'): jdtJar = args.jdt - if not exists(jdtJar) and os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath): + if not exists(jdtJar) and os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath) and get_env('JDT', None) is None: # Silently ignore JDT if default location is used but not ecj.jar exists there jdtJar = None @@ -2195,11 +2195,11 @@ projs.add(p) if len(projs) <= 0: - return + return [] pnames = [p.name for p in projs] build(['--projects', ",".join(pnames)]) - archive(pnames) + return archive(pnames) def pylint(args): """run pylint (if available) over Python source files (found by 'hg locate' or by tree walk with -walk)""" @@ -2275,6 +2275,7 @@ parser.add_argument('names', nargs=REMAINDER, metavar='[|@]...') args = parser.parse_args(args) + archives = [] for name in args.names: if name.startswith('@'): dname = name[1:] @@ -2341,6 +2342,7 @@ shutil.rmtree(services) # Atomic on Unix shutil.move(tmp, d.path) + archives.append(d.path) # print time.time(), 'move:', tmp, '->', d.path d.notify_updated() finally: @@ -2363,10 +2365,13 @@ zf.close() os.close(fd) # Atomic on Unix - shutil.move(tmp, join(p.dir, p.name + '.jar')) + jarFile = join(p.dir, p.name + '.jar') + shutil.move(tmp, jarFile) + archives.append(jarFile) finally: if exists(tmp): os.remove(tmp) + return archives def canonicalizeprojects(args): """process all project files to canonicalize the dependencies @@ -2620,6 +2625,11 @@ log('Removing {0}...'.format(outputDir)) shutil.rmtree(outputDir) + for configName in ['netbeans-config.zip', 'eclipse-config.zip']: + config = TimeStampFile(join(p.suite.mxDir, configName)) + if config.exists(): + os.unlink(config.path) + if suppliedParser: return args @@ -2771,7 +2781,8 @@ eclipseLaunches = join(suite.mxDir, 'eclipse-launches') if not exists(eclipseLaunches): os.makedirs(eclipseLaunches) - return update_file(join(eclipseLaunches, name + '.launch'), launch) + launchFile = join(eclipseLaunches, name + '.launch') + return update_file(launchFile, launch), launchFile def make_eclipse_launch(javaArgs, jre, name=None, deps=None): """ @@ -2867,16 +2878,19 @@ return True def _eclipseinit_suite(args, suite, buildProcessorJars=True, refreshOnly=False): - timestamp = TimeStampFile(join(suite.mxDir, 'eclipseinit.timestamp')) - if refreshOnly and not timestamp.exists(): + configZip = TimeStampFile(join(suite.mxDir, 'eclipse-config.zip')) + configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') + if refreshOnly and not configZip.exists(): return - if _check_ide_timestamp(suite, timestamp): + if _check_ide_timestamp(suite, configZip): logv('[Eclipse configurations are up to date - skipping]') return + files = [] + libFiles = [] if buildProcessorJars: - _processorjars_suite(suite) + files += _processorjars_suite(suite) projToDist = dict() for dist in _dists.values(): @@ -2905,6 +2919,7 @@ if not exists(genDir): os.mkdir(genDir) out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) + files.append(genDir) # Every Java program depends on the JRE out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-' + str(p.javaCompliance)}) @@ -2939,12 +2954,15 @@ if sourcePath is not None: attributes['sourcepath'] = sourcePath out.element('classpathentry', attributes) + libFiles.append(path) else: out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name}) out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')}) out.close('classpath') - update_file(join(p.dir, '.classpath'), out.xml(indent='\t', newl='\n')) + classpathFile = join(p.dir, '.classpath') + update_file(classpathFile, out.xml(indent='\t', newl='\n')) + files.append(classpathFile) csConfig = join(project(p.checkstyleProj).dir, '.checkstyle_checks.xml') if exists(csConfig): @@ -2977,6 +2995,7 @@ out.close('fileset-config') update_file(dotCheckstyle, out.xml(indent=' ', newl='\n')) + files.append(dotCheckstyle) out = XMLDoc() out.open('projectDescription') @@ -3022,7 +3041,9 @@ out.element('nature', data='org.eclipse.pde.PluginNature') out.close('natures') out.close('projectDescription') - update_file(join(p.dir, '.project'), out.xml(indent='\t', newl='\n')) + projectFile = join(p.dir, '.project') + update_file(projectFile, out.xml(indent='\t', newl='\n')) + files.append(projectFile) settingsDir = join(p.dir, ".settings") if not exists(settingsDir): @@ -3041,6 +3062,7 @@ if len(p.annotation_processors()) > 0: content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled') update_file(join(settingsDir, name), content) + files.append(join(settingsDir, name)) if len(p.annotation_processors()) > 0: out = XMLDoc() @@ -3059,13 +3081,34 @@ # safest to simply use absolute paths. path = join(p.suite.dir, path) out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : 'false'}) + files.append(path) else: out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + dep.name + '/' + dep.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) out.close('factorypath') update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) - - make_eclipse_attach(suite, 'localhost', '8000', deps=projects()) - timestamp.touch() + files.append(join(p.dir, '.factorypath')) + + _, launchFile = make_eclipse_attach(suite, 'localhost', '8000', deps=projects()) + files.append(launchFile) + + _zip_files(files, suite.dir, configZip.path) + _zip_files(libFiles, suite.dir, configLibsZip) + +def _zip_files(files, baseDir, zipPath): + fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(zipPath), dir=baseDir) + try: + zf = zipfile.ZipFile(tmp, 'w') + for f in sorted(set(files)): + relpath = os.path.relpath(f, baseDir) + arcname = relpath.replace(os.sep, '/') + zf.write(f, arcname) + zf.close() + os.close(fd) + # Atomic on Unix + shutil.move(tmp, zipPath) + finally: + if exists(tmp): + os.remove(tmp) def _isAnnotationProcessorDependency(p): """ @@ -3172,7 +3215,7 @@ wsdir = join(wsroot, wsloc) if not exists(wsdir): wsdir = wsroot - log('Could not find Eclipse metadata directory. Please place ' + wsfilename + ' in ' + wsloc + ' manually.') + logv('Could not find Eclipse metadata directory. Please place ' + wsfilename + ' in ' + wsloc + ' manually.') wspath = join(wsdir, wsfilename) # gather working set info from project data @@ -3295,15 +3338,18 @@ _netbeansinit_suite(args, suite, refreshOnly, buildProcessorJars) def _netbeansinit_suite(args, suite, refreshOnly=False, buildProcessorJars=True): - timestamp = TimeStampFile(join(suite.mxDir, 'netbeansinit.timestamp')) - if refreshOnly and not timestamp.exists(): + configZip = TimeStampFile(join(suite.mxDir, 'netbeans-config.zip')) + configLibsZip = join(suite.mxDir, 'eclipse-config-libs.zip') + if refreshOnly and not configZip.exists(): return - if _check_ide_timestamp(suite, timestamp): + if _check_ide_timestamp(suite, configZip): logv('[NetBeans configurations are up to date - skipping]') return updated = False + files = [] + libFiles = [] for p in suite.projects: if p.native: continue @@ -3328,6 +3374,7 @@ out.close('target') out.close('project') updated = update_file(join(p.dir, 'build.xml'), out.xml(indent='\t', newl='\n')) or updated + files.append(join(p.dir, 'build.xml')) out = XMLDoc() out.open('project', {'xmlns' : 'http://www.netbeans.org/ns/project/1'}) @@ -3371,6 +3418,7 @@ out.close('configuration') out.close('project') updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n')) or updated + files.append(join(p.dir, 'nbproject', 'project.xml')) out = StringIO.StringIO() jdkPlatform = 'JDK_' + str(java().version) @@ -3492,6 +3540,7 @@ path = path.replace('\\', '\\\\') ref = 'file.reference.' + dep.name + '-bin' print >> out, ref + '=' + path + libFiles.append(path) else: n = dep.name.replace('.', '_') @@ -3512,13 +3561,15 @@ updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated out.close() + files.append(join(p.dir, 'nbproject', 'project.properties')) if updated: log('If using NetBeans:') log(' 1. Ensure that a platform named "JDK_' + str(java().version) + '" is defined (Tools -> Java Platforms)') log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') - timestamp.touch() + _zip_files(files, suite.dir, configZip.path) + _zip_files(libFiles, suite.dir, configLibsZip) def ideclean(args): """remove all Eclipse and NetBeans project configurations""" @@ -3527,8 +3578,8 @@ os.remove(path) for s in suites(): - rm(join(s.mxDir, 'eclipseinit.timestamp')) - rm(join(s.mxDir, 'netbeansinit.timestamp')) + rm(join(s.mxDir, 'eclipse-config.zip')) + rm(join(s.mxDir, 'netbeans-config.zip')) for p in projects(): if p.native: diff -r 807ad2134a6b -r 896c8712c7b4 src/cpu/x86/vm/graalCodeInstaller_x86.hpp --- a/src/cpu/x86/vm/graalCodeInstaller_x86.hpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/cpu/x86/vm/graalCodeInstaller_x86.hpp Mon Dec 30 20:36:04 2013 +0000 @@ -219,26 +219,25 @@ } } +static void relocate_poll_near(address pc) { + NativeInstruction* ni = nativeInstruction_at(pc); + int32_t* disp = (int32_t*) Assembler::locate_operand(pc, Assembler::disp32_operand); + int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand + intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni; + *disp = (int32_t)new_disp; +} + + inline void CodeInstaller::pd_relocate_poll(address pc, jint mark) { switch (mark) { case MARK_POLL_NEAR: { - NativeInstruction* ni = nativeInstruction_at(pc); - int32_t* disp = (int32_t*) Assembler::locate_operand(pc, Assembler::disp32_operand); - // int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand); - int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand - intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni; - *disp = (int32_t)new_disp; + relocate_poll_near(pc); } case MARK_POLL_FAR: _instructions->relocate(pc, relocInfo::poll_type); break; case MARK_POLL_RETURN_NEAR: { - NativeInstruction* ni = nativeInstruction_at(pc); - int32_t* disp = (int32_t*) Assembler::locate_operand(pc, Assembler::disp32_operand); - // int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand); - int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand - intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni; - *disp = (int32_t)new_disp; + relocate_poll_near(pc); } case MARK_POLL_RETURN_FAR: _instructions->relocate(pc, relocInfo::poll_return_type); diff -r 807ad2134a6b -r 896c8712c7b4 src/share/vm/classfile/javaClasses.cpp --- a/src/share/vm/classfile/javaClasses.cpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/share/vm/classfile/javaClasses.cpp Mon Dec 30 20:36:04 2013 +0000 @@ -674,13 +674,6 @@ return java_class; } -#ifdef GRAAL -oop java_lang_Class::graal_mirror(oop java_class) { - assert(_graal_mirror_offset != 0, "must be set"); - return java_class->obj_field(_graal_mirror_offset); -} -#endif - Klass* java_lang_Class::as_Klass(oop java_class) { //%note memory_2 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); @@ -3065,9 +3058,6 @@ int java_lang_Class::_protection_domain_offset; int java_lang_Class::_init_lock_offset; int java_lang_Class::_signers_offset; -#ifdef GRAAL -int java_lang_Class::_graal_mirror_offset; -#endif GrowableArray* java_lang_Class::_fixup_mirror_list = NULL; int java_lang_Throwable::backtrace_offset; int java_lang_Throwable::detailMessage_offset; diff -r 807ad2134a6b -r 896c8712c7b4 src/share/vm/classfile/javaClasses.hpp --- a/src/share/vm/classfile/javaClasses.hpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/share/vm/classfile/javaClasses.hpp Mon Dec 30 20:36:04 2013 +0000 @@ -207,7 +207,6 @@ #define CLASS_INJECTED_FIELDS(macro) \ macro(java_lang_Class, klass, intptr_signature, false) \ - GRAAL_ONLY(macro(java_lang_Class, graal_mirror, object_signature, false))\ macro(java_lang_Class, array_klass, intptr_signature, false) \ macro(java_lang_Class, oop_size, int_signature, false) \ macro(java_lang_Class, static_oop_field_count, int_signature, false) \ @@ -226,9 +225,6 @@ static int _oop_size_offset; static int _static_oop_field_count_offset; -#ifdef GRAAL - static int _graal_mirror_offset; -#endif static int _protection_domain_offset; static int _init_lock_offset; @@ -287,11 +283,6 @@ static int static_oop_field_count(oop java_class); static void set_static_oop_field_count(oop java_class, int size); -#ifdef GRAAL - static oop graal_mirror(oop java_class); - static int graal_mirror_offset_in_bytes() { return _graal_mirror_offset; } -#endif - static GrowableArray* fixup_mirror_list() { return _fixup_mirror_list; } diff -r 807ad2134a6b -r 896c8712c7b4 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/share/vm/graal/graalCompiler.cpp Mon Dec 30 20:36:04 2013 +0000 @@ -229,7 +229,7 @@ Handle signature_string = java_lang_String::create_from_symbol(signature, CHECK_NH); return VMToCompiler::createUnresolvedJavaType(signature_string, CHECK_NH); } else { - return createHotSpotResolvedObjectType(klass, CHECK_NH); + return VMToCompiler::createResolvedJavaType(klass->java_mirror(), CHECK_NH); } } else { return VMToCompiler::createPrimitiveJavaType(field_type, CHECK_NH); @@ -252,7 +252,7 @@ if (tag.is_klass()) { // The klass has been inserted into the constant pool // very recently. - return GraalCompiler::createHotSpotResolvedObjectType(cp->resolved_klass_at(index), CHECK_NH); + return VMToCompiler::createResolvedJavaType(cp->resolved_klass_at(index)->java_mirror(), CHECK_NH); } else if (tag.is_symbol()) { klass_name = cp->symbol_at(index); } else { @@ -263,7 +263,7 @@ Handle klass_name_string = java_lang_String::create_from_symbol(klass_name, CHECK_NH); return VMToCompiler::createUnresolvedJavaType(klass_name_string, CHECK_NH); } else { - return GraalCompiler::createHotSpotResolvedObjectType(klass, CHECK_NH); + return VMToCompiler::createResolvedJavaType(klass->java_mirror(), CHECK_NH); } } @@ -272,16 +272,6 @@ return VMToCompiler::createJavaField(field_holder, name, field_type, offset, flags, false, CHECK_NH); } -Handle GraalCompiler::createHotSpotResolvedObjectType(KlassHandle klass, TRAPS) { - oop java_class = klass->java_mirror(); - oop graal_mirror = java_lang_Class::graal_mirror(java_class); - if (graal_mirror != NULL) { - assert(graal_mirror->is_a(HotSpotResolvedObjectType::klass()), "unexpected class..."); - return graal_mirror; - } - return VMToCompiler::createResolvedJavaType(java_class, CHECK_NH); -} - BasicType GraalCompiler::kindToBasicType(jchar ch) { switch(ch) { case 'z': return T_BOOLEAN; diff -r 807ad2134a6b -r 896c8712c7b4 src/share/vm/graal/graalCompiler.hpp --- a/src/share/vm/graal/graalCompiler.hpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/share/vm/graal/graalCompiler.hpp Mon Dec 30 20:36:04 2013 +0000 @@ -75,8 +75,6 @@ static Handle get_JavaType(constantPoolHandle cp, int index, KlassHandle accessor, TRAPS); static Handle get_JavaField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, TRAPS); - static Handle createHotSpotResolvedObjectType(KlassHandle klass, TRAPS); - void exit(); static BasicType kindToBasicType(jchar ch); diff -r 807ad2134a6b -r 896c8712c7b4 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Mon Dec 30 20:36:04 2013 +0000 @@ -181,17 +181,9 @@ return (jlong) (address) ucm; C2V_END -C2V_VMENTRY(jobject, getUniqueImplementor, (JNIEnv *, jobject, jobject interface_type)) - InstanceKlass* klass = (InstanceKlass*) java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(interface_type)); - assert(klass->is_interface(), "must be"); - if (klass->nof_implementors() == 1) { - InstanceKlass* implementor = (InstanceKlass*) klass->implementor(); - if (!implementor->is_abstract() && !implementor->is_interface() && implementor->is_leaf_class()) { - Handle type = GraalCompiler::createHotSpotResolvedObjectType(implementor, CHECK_NULL); - return JNIHandles::make_local(THREAD, type()); - } - } - return NULL; +C2V_VMENTRY(jlong, getKlassImplementor, (JNIEnv *, jobject, jlong metaspace_klass)) + InstanceKlass* klass = (InstanceKlass*) asKlass(metaspace_klass); + return (jlong) (address) klass->implementor(); C2V_END C2V_VMENTRY(void, initializeMethod,(JNIEnv *, jobject, jlong metaspace_method, jobject hotspot_method)) @@ -214,41 +206,29 @@ return code == NULL ? 0 : code->insts_size(); C2V_END -C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve)) +C2V_VMENTRY(jlong, lookupType, (JNIEnv *env, jobject, jstring jname, jclass accessing_class, jboolean eagerResolve)) ResourceMark rm; - Handle name = JNIHandles::resolve(jname); - Symbol* nameSymbol = java_lang_String::as_symbol(name, THREAD); - assert(nameSymbol != NULL, "name to symbol creation failed"); - assert(nameSymbol->size() > 1, "primitive types should be handled in Java code"); + Symbol* class_name = java_lang_String::as_symbol(name, THREAD); + assert(class_name != NULL, "name to symbol creation failed"); + assert(class_name->size() > 1, "primitive types should be handled in Java code"); - oop result = NULL; - Klass* resolved_type = NULL; - Handle classloader; - Handle protectionDomain; - if (JNIHandles::resolve(accessingClass) != NULL) { - classloader = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(accessingClass))->class_loader(); - protectionDomain = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaClass(accessingClass))->protection_domain(); + Klass* resolved_klass = NULL; + Handle class_loader; + Handle protection_domain; + if (JNIHandles::resolve(accessing_class) != NULL) { + Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class)); + class_loader = accessing_klass->class_loader(); + protection_domain = accessing_klass->protection_domain(); } if (eagerResolve) { - resolved_type = SystemDictionary::resolve_or_fail(nameSymbol, classloader, protectionDomain, true, THREAD); + resolved_klass = SystemDictionary::resolve_or_fail(class_name, class_loader, protection_domain, true, THREAD); } else { - resolved_type = SystemDictionary::resolve_or_null(nameSymbol, classloader, protectionDomain, THREAD); + resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, THREAD); } - if (!HAS_PENDING_EXCEPTION) { - if (resolved_type == NULL) { - assert(!eagerResolve, "failed eager resolution should have caused an exception"); - Handle type = VMToCompiler::createUnresolvedJavaType(name, THREAD); - result = type(); - } else { - Handle type = GraalCompiler::createHotSpotResolvedObjectType(resolved_type, CHECK_NULL); - result = type(); - } - } - - return JNIHandles::make_local(THREAD, result); + return (jlong) (address) resolved_klass; C2V_END C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) @@ -288,7 +268,7 @@ methodHandle method = GraalEnv::get_method_by_index(cp, cp_index, bc, pool_holder); if (!method.is_null()) { - Handle holder = GraalCompiler::createHotSpotResolvedObjectType(method->method_holder(), CHECK_NULL); + Handle holder = VMToCompiler::createResolvedJavaType(method->method_holder()->java_mirror(), CHECK_NULL); return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD)); } else { // Get the method's name and signature. @@ -363,7 +343,7 @@ flags = result.access_flags(); holder_klass = result.field_holder(); basic_type = result.field_type(); - holder = GraalCompiler::createHotSpotResolvedObjectType(holder_klass, CHECK_NULL); + holder = VMToCompiler::createResolvedJavaType(holder_klass->java_mirror(), CHECK_NULL); } } @@ -839,17 +819,9 @@ #define CC (char*) /*cast a literal from (const char*)*/ #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) -#define RESOLVED_TYPE "Lcom/oracle/graal/api/meta/ResolvedJavaType;" #define TYPE "Lcom/oracle/graal/api/meta/JavaType;" #define METHOD "Lcom/oracle/graal/api/meta/JavaMethod;" #define FIELD "Lcom/oracle/graal/api/meta/JavaField;" -#define SIGNATURE "Lcom/oracle/graal/api/meta/Signature;" -#define CONSTANT_POOL "Lcom/oracle/graal/api/meta/ConstantPool;" -#define CONSTANT "Lcom/oracle/graal/api/meta/Constant;" -#define KIND "Lcom/oracle/graal/api/meta/Kind;" -#define RUNTIME_CALL "Lcom/oracle/graal/api/code/RuntimeCall;" -#define REFLECT_METHOD "Ljava/lang/reflect/Method;" -#define REFLECT_CONSTRUCTOR "Ljava/lang/reflect/Constructor;" #define STRING "Ljava/lang/String;" #define OBJECT "Ljava/lang/Object;" #define CLASS "Ljava/lang/Class;" @@ -859,8 +831,8 @@ #define HS_RESOLVED_FIELD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaField;" #define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;" #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" -#define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;" +#define METASPACE_KLASS "J" #define METASPACE_METHOD "J" #define METASPACE_CONSTANT_POOL "J" @@ -869,13 +841,13 @@ {CC"exceptionTableStart", CC"("METASPACE_METHOD")J", FN_PTR(exceptionTableStart)}, {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)}, {CC"findUniqueConcreteMethod", CC"("METASPACE_METHOD")"METASPACE_METHOD, FN_PTR(findUniqueConcreteMethod)}, - {CC"getUniqueImplementor", CC"("HS_RESOLVED_TYPE")"RESOLVED_TYPE, FN_PTR(getUniqueImplementor)}, + {CC"getKlassImplementor", CC"("METASPACE_KLASS")"METASPACE_KLASS, FN_PTR(getKlassImplementor)}, {CC"getStackTraceElement", CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)}, {CC"initializeMethod", CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V", FN_PTR(initializeMethod)}, {CC"doNotInlineOrCompile", CC"("METASPACE_METHOD")V", FN_PTR(doNotInlineOrCompile)}, {CC"isMethodCompilable", CC"("METASPACE_METHOD")Z", FN_PTR(isMethodCompilable)}, {CC"getCompiledCodeSize", CC"("METASPACE_METHOD")I", FN_PTR(getCompiledCodeSize)}, - {CC"lookupType", CC"("STRING HS_RESOLVED_TYPE"Z)"TYPE, FN_PTR(lookupType)}, + {CC"lookupType", CC"("STRING CLASS"Z)"METASPACE_KLASS, FN_PTR(lookupType)}, {CC"lookupConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupConstantInPool)}, {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"IB)"OBJECT, FN_PTR(lookupAppendixInPool)}, {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METHOD, FN_PTR(lookupMethodInPool)}, diff -r 807ad2134a6b -r 896c8712c7b4 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/share/vm/graal/graalJavaAccess.hpp Mon Dec 30 20:36:04 2013 +0000 @@ -65,8 +65,6 @@ start_class(HotSpotJavaType) \ oop_field(HotSpotJavaType, name, "Ljava/lang/String;") \ end_class \ - start_class(HotSpotResolvedJavaField) \ - end_class \ start_class(HotSpotInstalledCode) \ long_field(HotSpotInstalledCode, codeBlob) \ int_field(HotSpotInstalledCode, size) \ @@ -98,13 +96,6 @@ start_class(HotSpotForeignCallLinkage) \ long_field(HotSpotForeignCallLinkage, address) \ end_class \ - start_class(ExceptionHandler) \ - int_field(ExceptionHandler, startBCI) \ - int_field(ExceptionHandler, endBCI) \ - int_field(ExceptionHandler, handlerBCI) \ - int_field(ExceptionHandler, catchTypeCPI) \ - oop_field(ExceptionHandler, catchType, "Lcom/oracle/graal/api/meta/JavaType;") \ - end_class \ start_class(ExternalCompilationResult) \ long_field(ExternalCompilationResult, entryPoint) \ end_class \ @@ -211,8 +202,6 @@ static_oop_field(Kind, Int, "Lcom/oracle/graal/api/meta/Kind;"); \ static_oop_field(Kind, Long, "Lcom/oracle/graal/api/meta/Kind;"); \ end_class \ - start_class(JavaMethod) \ - end_class \ start_class(Value) \ oop_field(Value, kind, "Lcom/oracle/graal/api/meta/Kind;") \ static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;"); \ diff -r 807ad2134a6b -r 896c8712c7b4 src/share/vm/graal/vmStructs_graal.hpp --- a/src/share/vm/graal/vmStructs_graal.hpp Sun Dec 22 20:06:55 2013 +0000 +++ b/src/share/vm/graal/vmStructs_graal.hpp Mon Dec 30 20:36:04 2013 +0000 @@ -29,7 +29,6 @@ #include "graal/graalEnv.hpp" #define VM_STRUCTS_GRAAL(nonstatic_field, static_field) \ - static_field(java_lang_Class, _graal_mirror_offset, int) \ nonstatic_field(ThreadShadow, _pending_deoptimization, int) \ #define VM_TYPES_GRAAL(declare_type, declare_toplevel_type) \