# HG changeset patch # User Tom Rodriguez # Date 1434647247 25200 # Node ID d1a41fbfcfd2c250a955b8abbb3e3011a60caa97 # Parent 35b153c2678348b05383a954d3560a5b6ad2dae5 Replace ResolvedJavaType.isFinal with more meaningful and correct isLeaf diff -r 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Thu Jun 18 10:07:27 2015 -0700 @@ -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.*; @@ -2926,7 +2925,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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu Jun 18 10:07:27 2015 -0700 @@ -140,7 +140,7 @@ } } - if (type.isFinal() && nonNull) { + if (type.isLeaf() && nonNull) { return TypeCheckNode.create(type, object); } return null; diff -r 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeCheckNode.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.code/src/com/oracle/jvmci/code/TypeCheckHints.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Assumptions.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ModifiersProvider.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaField.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaMethod.java Thu Jun 18 10:07:27 2015 -0700 @@ -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 35b153c26783 -r d1a41fbfcfd2 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 Wed Apr 29 12:23:48 2015 -0700 +++ b/jvmci/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ResolvedJavaType.java Thu Jun 18 10:07:27 2015 -0700 @@ -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.