# HG changeset patch # User Thomas Wuerthinger # Date 1434758203 -7200 # Node ID 1f07c19e7d8354b04b9e69bd7f5e67d0324998e2 # Parent 0571d4a8d7cce9e9fa534956bcbaef49a700b3b1# Parent 95c7ad0634c7e831518a533f6aeb6d993c11779f Merge. diff -r 0571d4a8d7cc -r 1f07c19e7d83 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java Sat Jun 20 01:29:17 2015 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java Sat Jun 20 01:56:43 2015 +0200 @@ -40,7 +40,11 @@ protected AbstractObjectStamp(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull) { super(nonNull, alwaysNull); this.type = type; - this.exactType = exactType; + if (!exactType && type != null && type.isLeaf()) { + this.exactType = true; + } else { + this.exactType = exactType; + } } protected abstract AbstractObjectStamp copyWith(ResolvedJavaType newType, boolean newExactType, boolean newNonNull, boolean newAlwaysNull); diff -r 0571d4a8d7cc -r 1f07c19e7d83 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Sat Jun 20 01:29:17 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Sat Jun 20 01:56:43 2015 +0200 @@ -105,15 +105,18 @@ graph.disableInlinedMethodRecording(); if (SnippetGraphUnderConstruction != null) { - assert SnippetGraphUnderConstruction.get() == null; + assert SnippetGraphUnderConstruction.get() == null : SnippetGraphUnderConstruction.get().toString() + " " + graph; SnippetGraphUnderConstruction.set(graph); } - IntrinsicContext initialIntrinsicContext = new IntrinsicContext(method, method, INLINE_AFTER_PARSING); - new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), config, OptimisticOptimizations.NONE, initialIntrinsicContext).apply(graph); + try { + IntrinsicContext initialIntrinsicContext = new IntrinsicContext(method, method, INLINE_AFTER_PARSING); + new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), config, OptimisticOptimizations.NONE, initialIntrinsicContext).apply(graph); - if (SnippetGraphUnderConstruction != null) { - SnippetGraphUnderConstruction.set(null); + } finally { + if (SnippetGraphUnderConstruction != null) { + SnippetGraphUnderConstruction.set(null); + } } graph.setGuardsStage(GuardsStage.FLOATING_GUARDS); diff -r 0571d4a8d7cc -r 1f07c19e7d83 graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Sat Jun 20 01:29:17 2015 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Sat Jun 20 01:56:43 2015 +0200 @@ -28,7 +28,6 @@ import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.*; import static com.oracle.graal.java.BytecodeParser.Options.*; import static com.oracle.graal.nodes.type.StampTool.*; -import static com.oracle.jvmci.code.TypeCheckHints.*; import static com.oracle.jvmci.common.JVMCIError.*; import static com.oracle.jvmci.meta.DeoptimizationAction.*; import static com.oracle.jvmci.meta.DeoptimizationReason.*; @@ -2925,7 +2924,7 @@ } private JavaTypeProfile getProfileForTypeCheck(ResolvedJavaType type) { - if (parsingIntrinsic() || profilingInfo == null || !optimisticOpts.useTypeCheckHints() || !canHaveSubtype(type)) { + if (parsingIntrinsic() || profilingInfo == null || !optimisticOpts.useTypeCheckHints() || type.isLeaf()) { return null; } else { return profilingInfo.getTypeProfile(bci()); diff -r 0571d4a8d7cc -r 1f07c19e7d83 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Sat Jun 20 01:29:17 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Sat Jun 20 01:56:43 2015 +0200 @@ -140,7 +140,7 @@ } } - if (type.isFinal() && nonNull) { + if (type.isLeaf() && nonNull) { return TypeCheckNode.create(type, object); } return null; diff -r 0571d4a8d7cc -r 1f07c19e7d83 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeCheckNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeCheckNode.java Sat Jun 20 01:29:17 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeCheckNode.java Sat Jun 20 01:56:43 2015 +0200 @@ -149,7 +149,7 @@ if (objectType != null) { ResolvedJavaType instanceofType = type; if (instanceofType.equals(objectType)) { - if (objectStamp.nonNull() && (objectStamp.isExactType() || objectType.isFinal())) { + if (objectStamp.nonNull() && (objectStamp.isExactType() || objectType.isLeaf())) { return TriState.TRUE; } } else { diff -r 0571d4a8d7cc -r 1f07c19e7d83 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Sat Jun 20 01:29:17 2015 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Sat Jun 20 01:56:43 2015 +0200 @@ -727,7 +727,7 @@ if (!Objects.equals(type, StampTool.typeOrNull(receiver))) { ResolvedJavaMethod method = type.resolveConcreteMethod(callTarget.targetMethod(), invoke.getContextType()); if (method != null) { - if (method.canBeStaticallyBound() || type.isFinal()) { + if (method.canBeStaticallyBound() || type.isLeaf() || type.isArray()) { callTarget.setInvokeKind(InvokeKind.Special); callTarget.setTargetMethod(method); } diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.code/src/com/oracle/jvmci/code/TypeCheckHints.java --- a/jvmci/com.oracle.jvmci.code/src/com/oracle/jvmci/code/TypeCheckHints.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.code/src/com/oracle/jvmci/code/TypeCheckHints.java Sat Jun 20 01:56:43 2015 +0200 @@ -95,7 +95,7 @@ */ public TypeCheckHints(ResolvedJavaType targetType, JavaTypeProfile profile, Assumptions assumptions, double minHintHitProbability, int maxHints) { this.profile = profile; - if (targetType != null && !canHaveSubtype(targetType)) { + if (targetType != null && !!targetType.isLeaf()) { exact = targetType; } else { if (assumptions != null) { @@ -147,14 +147,4 @@ hitProbability[0] = hitProb; return hintsBuf; } - - /** - * Determines if a given type can have subtypes other than itself. This analysis is purely - * static; no assumptions are made. - * - * @return true if {@code type} can have subtypes - */ - public static boolean canHaveSubtype(ResolvedJavaType type) { - return !type.getElementalType().isFinal(); - } } diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java --- a/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Sat Jun 20 01:56:43 2015 +0200 @@ -188,7 +188,7 @@ @Override public boolean canBeStaticallyBound() { - return (isFinal() || isPrivate() || isStatic() || holder.isFinal()) && isConcrete(); + return (isFinal() || isPrivate() || isStatic() || holder.isLeaf()) && isConcrete(); } @Override diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java --- a/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java Sat Jun 20 01:56:43 2015 +0200 @@ -148,7 +148,7 @@ public AssumptionResult findLeafConcreteSubtype() { HotSpotVMConfig config = runtime().getConfig(); if (isArray()) { - return getElementalType().isFinal() ? new AssumptionResult<>(this) : null; + return getElementalType().isLeaf() ? new AssumptionResult<>(this) : null; } else if (isInterface()) { HotSpotResolvedObjectTypeImpl implementor = getSingleImplementor(); /* @@ -284,10 +284,7 @@ @Override public HotSpotResolvedObjectType asExactType() { - if (isArray()) { - return getComponentType().asExactType() != null ? this : null; - } - return isFinal() ? this : null; + return isLeaf() ? this : null; } @Override diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Assumptions.java --- a/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Assumptions.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Assumptions.java Sat Jun 20 01:56:43 2015 +0200 @@ -127,7 +127,7 @@ this.subtype = subtype; assert context.isAbstract(); assert subtype.isConcrete() || context.isInterface() : subtype.toString() + " : " + context.toString(); - assert !subtype.isArray() || subtype.getElementalType().isFinal() : subtype.toString() + " : " + context.toString(); + assert !subtype.isArray() || subtype.getElementalType().isFinalFlagSet() : subtype.toString() + " : " + context.toString(); } @Override diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ModifiersProvider.java --- a/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ModifiersProvider.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ModifiersProvider.java Sat Jun 20 01:56:43 2015 +0200 @@ -67,9 +67,14 @@ } /** + * The setting of the final modifier bit for types is somewhat confusing, so don't export + * isFinal by default. Subclasses like {@link ResolvedJavaField} and {@link ResolvedJavaMethod} + * can export it as isFinal, but {@link ResolvedJavaType} can provide a more sensible equivalent + * like {@link ResolvedJavaType#isLeaf}. + * * @see Modifier#isFinal(int) */ - default boolean isFinal() { + default boolean isFinalFlagSet() { return Modifier.isFinal(getModifiers()); } diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaField.java --- a/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaField.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaField.java Sat Jun 20 01:56:43 2015 +0200 @@ -39,6 +39,10 @@ */ int getModifiers(); + default boolean isFinal() { + return ModifiersProvider.super.isFinalFlagSet(); + } + /** * Determines if this field was injected by the VM. Such a field, for example, is not derived * from a class file. @@ -68,7 +72,7 @@ /** * Returns an object representing the unique location identity of this resolved Java field. - * + * * @return the location identity of the field */ LocationIdentity getLocationIdentity(); diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java --- a/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java Sat Jun 20 01:56:43 2015 +0200 @@ -77,6 +77,10 @@ */ int getModifiers(); + default boolean isFinal() { + return ModifiersProvider.super.isFinalFlagSet(); + } + /** * Determines if this method is a synthetic method as defined by the Java Language * Specification. diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaType.java --- a/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaType.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaType.java Sat Jun 20 01:56:43 2015 +0200 @@ -97,6 +97,14 @@ */ int getModifiers(); + /* + * The setting of the final bit for types is a bit confusing since arrays are marked as final. + * This method provides a semantically equivalent test that appropriate for types. + */ + default boolean isLeaf() { + return getElementalType().isFinalFlagSet(); + } + /** * Checks whether this type is initialized. If a type is initialized it implies that it was * {@link #isLinked() linked} and that the static initializer has run. diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaField.java --- a/jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaField.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaField.java Sat Jun 20 01:56:43 2015 +0200 @@ -120,7 +120,8 @@ // @formatter:off private static final String[] untestedApiMethods = { "getDeclaringClass", - "isInternal" + "isInternal", + "isFinal" }; // @formatter:on diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaMethod.java --- a/jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaMethod.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaMethod.java Sat Jun 20 01:56:43 2015 +0200 @@ -403,6 +403,7 @@ "toParameterTypes", "getParameterAnnotation", "getSpeculationLog", + "isFinal", "$jacocoInit" }; // @formatter:on diff -r 0571d4a8d7cc -r 1f07c19e7d83 jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaType.java --- a/jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaType.java Sat Jun 20 01:29:17 2015 +0200 +++ b/jvmci/com.oracle.jvmci.runtime.test/src/com/oracle/jvmci/runtime/test/TestResolvedJavaType.java Sat Jun 20 01:56:43 2015 +0200 @@ -838,6 +838,23 @@ } @Test + public void isLeafTest() { + for (Class c : classes) { + ResolvedJavaType type = metaAccess.lookupJavaType(c); + ResolvedJavaType arrayType = c != void.class ? metaAccess.lookupJavaType(getArrayClass(c)) : null; + if (c.isPrimitive()) { + assertTrue(type.isLeaf()); + assertTrue(arrayType == null || arrayType.isLeaf()); + } else { + assertTrue(c.toString(), type.isLeaf() == arrayType.isLeaf()); + if (!c.isArray()) { + assertTrue(c.toString(), type.isLeaf() == Modifier.isFinal(c.getModifiers())); + } + } + } + } + + @Test public void findMethodTest() { try { ResolvedJavaMethod findFoo = metaAccess.lookupJavaType(D.class).findMethod("foo", metaAccess.parseMethodDescriptor("()V")); diff -r 0571d4a8d7cc -r 1f07c19e7d83 mx.graal/suite.py --- a/mx.graal/suite.py Sat Jun 20 01:29:17 2015 +0200 +++ b/mx.graal/suite.py Sat Jun 20 01:56:43 2015 +0200 @@ -152,9 +152,9 @@ "TRUFFLE" : { "path" : "lib/truffle-0.8-SNAPSHOT.jar", "urls" : [ - "http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots/com/oracle/truffle/0.8-dd4050aadaf8d91301b159cb30a609d8bb99feeb-SNAPSHOT/truffle-0.8-dd4050aadaf8d91301b159cb30a609d8bb99feeb-20150616.114821-1.jar", + "http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots/com/oracle/truffle/0.8-d5d416ced577720b9354bfbf4092b4480af55dbb-SNAPSHOT/truffle-0.8-d5d416ced577720b9354bfbf4092b4480af55dbb-20150619.210629-1.jar", ], - "sha1" : "34be0993d8fcaa21129749a329e4bb7841cf27e1", + "sha1" : "0970218476e21c17b90d9f45eb5910b781b12a31", }, "TRUFFLE_TCK" : { "path" : "lib/truffle-tck-0.8-SNAPSHOT.jar",