# HG changeset patch # User Thomas Wuerthinger # Date 1434756557 -7200 # Node ID 0571d4a8d7cce9e9fa534956bcbaef49a700b3b1 # Parent 0eedd37f45bad5dfb1432706aa36c74cd2d4f4c2 Remove type profile proxy node. diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Sat Jun 20 01:29:17 2015 +0200 @@ -131,7 +131,7 @@ protected Suites createSuites() { Suites ret = backend.getSuites().createSuites(); - ListIterator> iter = ret.getHighTier().findPhase(CleanTypeProfileProxyPhase.class); + ListIterator> iter = ret.getHighTier().findPhase(ConvertDeoptimizeToGuardPhase.class); PhaseSuite.findNextPhase(iter, CanonicalizerPhase.class); iter.add(new Phase("ComputeLoopFrequenciesPhase") { diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EconomyHighTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EconomyHighTier.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/EconomyHighTier.java Sat Jun 20 01:29:17 2015 +0200 @@ -41,7 +41,6 @@ appendPhase(canonicalizer); } - appendPhase(new CleanTypeProfileProxyPhase(canonicalizer)); appendPhase(new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER)); } } diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Sat Jun 20 01:29:17 2015 +0200 @@ -65,8 +65,6 @@ } } - appendPhase(new CleanTypeProfileProxyPhase(canonicalizer)); - if (OptConvertDeoptsToGuards.getValue()) { appendPhase(new ConvertDeoptimizeToGuardPhase()); } diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Sat Jun 20 01:29:17 2015 +0200 @@ -519,7 +519,7 @@ if (nodes.isEmpty()) { // Only insert the nodes if this is the first monitorenter being lowered. JavaType returnType = initCounter.getMethod().getSignature().getReturnType(initCounter.getMethod().getDeclaringClass()); - MethodCallTargetNode callTarget = graph.add(new MethodCallTargetNode(InvokeKind.Static, initCounter.getMethod(), new ValueNode[0], returnType)); + MethodCallTargetNode callTarget = graph.add(new MethodCallTargetNode(InvokeKind.Static, initCounter.getMethod(), new ValueNode[0], returnType, null)); InvokeNode invoke = graph.add(new InvokeNode(callTarget, 0)); invoke.setStateAfter(graph.start().stateAfter()); graph.addAfterFixed(graph.start(), invoke); @@ -532,7 +532,7 @@ returnType = checkCounter.getMethod().getSignature().getReturnType(checkCounter.getMethod().getDeclaringClass()); String msg = "unbalanced monitors in " + graph.method().format("%H.%n(%p)") + ", count = %d"; ConstantNode errMsg = ConstantNode.forConstant(tool.getConstantReflection().forString(msg), providers.getMetaAccess(), graph); - callTarget = graph.add(new MethodCallTargetNode(InvokeKind.Static, checkCounter.getMethod(), new ValueNode[]{errMsg}, returnType)); + callTarget = graph.add(new MethodCallTargetNode(InvokeKind.Static, checkCounter.getMethod(), new ValueNode[]{errMsg}, returnType, null)); invoke = graph.add(new InvokeNode(callTarget, 0)); FrameState stateAfter = new FrameState(null, graph.method(), BytecodeFrame.AFTER_BCI, new ValueNode[0], new ValueNode[0], 0, new ValueNode[0], null, false, false); invoke.setStateAfter(graph.add(stateAfter)); diff -r 0eedd37f45ba -r 0571d4a8d7cc 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 Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Sat Jun 20 01:29:17 2015 +0200 @@ -1273,10 +1273,6 @@ } if (invokeKind.hasReceiver()) { args[0] = emitExplicitExceptions(args[0], null); - if (invokeKind.isIndirect() && profilingInfo != null && this.optimisticOpts.useTypeCheckHints()) { - JavaTypeProfile profile = profilingInfo.getTypeProfile(bci()); - args[0] = TypeProfileProxyNode.proxify(args[0], profile); - } if (args[0].isNullConstant()) { append(new DeoptimizeNode(InvalidateRecompile, NullCheckException)); @@ -1311,7 +1307,11 @@ currentInvokeKind = null; } - MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, targetMethod, args, returnType)); + JavaTypeProfile profile = null; + if (invokeKind.isIndirect() && profilingInfo != null && this.optimisticOpts.useTypeCheckHints()) { + profile = profilingInfo.getTypeProfile(bci()); + } + MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, targetMethod, args, returnType, profile)); // be conservative if information was not recorded (could result in endless // recompiles otherwise) @@ -1553,8 +1553,8 @@ } } - protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, JavaType returnType) { - return new MethodCallTargetNode(invokeKind, targetMethod, args, returnType); + protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, JavaType returnType, JavaTypeProfile profile) { + return new MethodCallTargetNode(invokeKind, targetMethod, args, returnType, profile); } protected InvokeNode createInvoke(CallTargetNode callTarget, Kind resultType) { diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/TypeProfileProxyNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/TypeProfileProxyNode.java Fri Jun 19 15:18:18 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2013, 2014, 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.nodes; - -import java.util.*; - -import com.oracle.graal.graph.*; -import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodeinfo.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; -import com.oracle.jvmci.debug.*; -import com.oracle.jvmci.meta.Assumptions.AssumptionResult; -import com.oracle.jvmci.meta.*; - -/** - * A node that attaches a type profile to a proxied input node. - */ -@NodeInfo -public final class TypeProfileProxyNode extends UnaryNode implements IterableNodeType, ValueProxy { - - public static final NodeClass TYPE = NodeClass.create(TypeProfileProxyNode.class); - protected final JavaTypeProfile profile; - protected transient ResolvedJavaType lastCheckedType; - protected transient JavaTypeProfile lastCheckedProfile; - - public static ValueNode proxify(ValueNode object, JavaTypeProfile profile) { - if (StampTool.isExactType(object)) { - return object; - } - if (profile == null) { - // No profile, so create no node. - return object; - } - if (profile.getTypes().length == 0) { - // Only null profiling is not beneficial enough to keep the node around. - return object; - } - return object.graph().addWithoutUnique(new TypeProfileProxyNode(object, profile)); - } - - protected TypeProfileProxyNode(ValueNode value, JavaTypeProfile profile) { - super(TYPE, value.stamp(), value); - this.profile = profile; - } - - public JavaTypeProfile getProfile() { - return profile; - } - - @Override - public boolean inferStamp() { - return updateStamp(getValue().stamp()); - } - - @Override - public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { - if (StampTool.isExactType(forValue)) { - // The profile is useless - we know the type! - return forValue; - } else if (forValue instanceof TypeProfileProxyNode) { - TypeProfileProxyNode other = (TypeProfileProxyNode) forValue; - JavaTypeProfile otherProfile = other.getProfile(); - if (otherProfile == lastCheckedProfile) { - // We have already incorporated the knowledge about this profile => abort. - return this; - } - lastCheckedProfile = otherProfile; - JavaTypeProfile newProfile = this.profile.restrict(otherProfile); - if (newProfile.equals(otherProfile)) { - // We are useless - just use the other proxy node. - Debug.log("Canonicalize with other proxy node."); - return forValue; - } - if (newProfile != this.profile) { - Debug.log("Improved profile via other profile."); - return new TypeProfileProxyNode(forValue, newProfile); - } - } else if (StampTool.typeOrNull(forValue) != null) { - ResolvedJavaType type = StampTool.typeOrNull(forValue); - AssumptionResult leafConcreteSubtype = type.findLeafConcreteSubtype(); - if (leafConcreteSubtype != null) { - // Profile is useless => remove. - Debug.log("Profile useless, there is enough static type information available."); - return forValue; - } - if (Objects.equals(type, lastCheckedType)) { - // We have already incorporate the knowledge about this type => abort. - return this; - } - lastCheckedType = type; - JavaTypeProfile newProfile = this.profile.restrict(type, StampTool.isPointerNonNull(forValue)); - if (newProfile != this.profile) { - Debug.log("Improved profile via static type information."); - if (newProfile.getTypes().length == 0) { - // Only null profiling is not beneficial enough to keep the node around. - return forValue; - } - return new TypeProfileProxyNode(forValue, newProfile); - } - } - return this; - } - - @Override - public ValueNode getOriginalNode() { - return getValue(); - } -} diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Sat Jun 20 01:29:17 2015 +0200 @@ -37,14 +37,17 @@ public class MethodCallTargetNode extends CallTargetNode implements IterableNodeType, Simplifiable { public static final NodeClass TYPE = NodeClass.create(MethodCallTargetNode.class); protected final JavaType returnType; + protected JavaTypeProfile profile; - public MethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType) { - this(TYPE, invokeKind, targetMethod, arguments, returnType); + public MethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, JavaTypeProfile profile) { + this(TYPE, invokeKind, targetMethod, arguments, returnType, profile); } - protected MethodCallTargetNode(NodeClass c, InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType) { + protected MethodCallTargetNode(NodeClass c, InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, + JavaTypeProfile profile) { super(c, arguments, targetMethod, invokeKind); this.returnType = returnType; + this.profile = profile; } /** @@ -226,15 +229,8 @@ } } - private JavaTypeProfile getProfile() { - assert !isStatic(); - if (receiver() instanceof TypeProfileProxyNode) { - // get profile from TypeProfileProxy - return ((TypeProfileProxyNode) receiver()).getProfile(); - } - // get profile from invoke() - ProfilingInfo profilingInfo = invoke().getContextMethod().getProfilingInfo(); - return profilingInfo.getTypeProfile(invoke().bci()); + public JavaTypeProfile getProfile() { + return profile; } @Override diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CleanTypeProfileProxyPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CleanTypeProfileProxyPhase.java Fri Jun 19 15:18:18 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * 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.phases.common; - -import com.oracle.graal.graph.Graph.NodeEventScope; -import com.oracle.graal.nodes.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.phases.common.util.*; -import com.oracle.graal.phases.tiers.*; - -public class CleanTypeProfileProxyPhase extends BasePhase { - - private CanonicalizerPhase canonicalizer; - - public CleanTypeProfileProxyPhase(CanonicalizerPhase canonicalizer) { - this.canonicalizer = canonicalizer; - } - - @Override - protected void run(StructuredGraph graph, PhaseContext context) { - HashSetNodeEventListener listener = new HashSetNodeEventListener(); - try (NodeEventScope s = graph.trackNodeEvents(listener)) { - for (TypeProfileProxyNode proxy : graph.getNodes(TypeProfileProxyNode.TYPE)) { - graph.replaceFloating(proxy, proxy.getValue()); - } - } - if (!listener.getNodes().isEmpty()) { - canonicalizer.applyIncremental(graph, context, listener.getNodes()); - } - assert graph.getNodes(TypeProfileProxyNode.TYPE).count() == 0; - } -} diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Sat Jun 20 01:29:17 2015 +0200 @@ -185,7 +185,8 @@ public static void replaceInvokeCallTarget(Invoke invoke, StructuredGraph graph, InvokeKind invokeKind, ResolvedJavaMethod targetMethod) { MethodCallTargetNode oldCallTarget = (MethodCallTargetNode) invoke.callTarget(); - MethodCallTargetNode newCallTarget = graph.add(new MethodCallTargetNode(invokeKind, targetMethod, oldCallTarget.arguments().toArray(new ValueNode[0]), oldCallTarget.returnType())); + MethodCallTargetNode newCallTarget = graph.add(new MethodCallTargetNode(invokeKind, targetMethod, oldCallTarget.arguments().toArray(new ValueNode[0]), oldCallTarget.returnType(), + oldCallTarget.getProfile())); invoke.asNode().replaceFirstInput(oldCallTarget, newCallTarget); } diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Sat Jun 20 01:29:17 2015 +0200 @@ -215,12 +215,8 @@ } private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod targetMethod) { - JavaTypeProfile typeProfile; - ValueNode receiver = invoke.callTarget().arguments().get(0); - if (receiver instanceof TypeProfileProxyNode) { - TypeProfileProxyNode typeProfileProxyNode = (TypeProfileProxyNode) receiver; - typeProfile = typeProfileProxyNode.getProfile(); - } else { + JavaTypeProfile typeProfile = ((MethodCallTargetNode) invoke.callTarget()).getProfile(); + if (typeProfile == null) { InliningUtil.logNotInlined(invoke, inliningDepth(), targetMethod, "no type profile exists"); return null; } diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java Sat Jun 20 01:29:17 2015 +0200 @@ -168,7 +168,7 @@ } protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, JavaType returnType, @SuppressWarnings("unused") int bci) { - return new MethodCallTargetNode(invokeKind, targetMethod, args, returnType); + return new MethodCallTargetNode(invokeKind, targetMethod, args, returnType, null); } /** diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Sat Jun 20 01:29:17 2015 +0200 @@ -192,7 +192,7 @@ } protected InvokeNode createInvoke() { - MethodCallTargetNode callTarget = graph().add(new MethodCallTargetNode(invokeKind, targetMethod, arguments.toArray(new ValueNode[arguments.size()]), returnType)); + MethodCallTargetNode callTarget = graph().add(new MethodCallTargetNode(invokeKind, targetMethod, arguments.toArray(new ValueNode[arguments.size()]), returnType, null)); InvokeNode invoke = graph().add(new InvokeNode(callTarget, bci)); if (stateAfter() != null) { invoke.setStateAfter(stateAfter().duplicate()); diff -r 0eedd37f45ba -r 0571d4a8d7cc graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ResolvedMethodHandleCallTargetNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ResolvedMethodHandleCallTargetNode.java Fri Jun 19 15:18:18 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ResolvedMethodHandleCallTargetNode.java Sat Jun 20 01:29:17 2015 +0200 @@ -59,7 +59,7 @@ ValueNode[] originalArguments, JavaType originalReturnType) { if (jdkMajorVersion() >= 1 && jdkMinorVersion() >= 8 && jdkMicroVersion() >= 0 && jdkUpdateVersion() >= 60) { // https://bugs.openjdk.java.net/browse/JDK-8072008 is targeted for 8u60 - return new MethodCallTargetNode(invokeKind, targetMethod, arguments, returnType); + return new MethodCallTargetNode(invokeKind, targetMethod, arguments, returnType, null); } return new ResolvedMethodHandleCallTargetNode(invokeKind, targetMethod, arguments, returnType, originalTargetMethod, originalArguments, originalReturnType); } @@ -70,7 +70,7 @@ protected ResolvedMethodHandleCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, ResolvedJavaMethod originalTargetMethod, ValueNode[] originalArguments, JavaType originalReturnType) { - super(TYPE, invokeKind, targetMethod, arguments, returnType); + super(TYPE, invokeKind, targetMethod, arguments, returnType, null); this.originalTargetMethod = originalTargetMethod; this.originalReturnType = originalReturnType; this.originalArguments = new NodeInputList<>(this, originalArguments); @@ -80,7 +80,7 @@ public void lower(LoweringTool tool) { InvokeKind replacementInvokeKind = originalTargetMethod.isStatic() ? InvokeKind.Static : InvokeKind.Special; MethodCallTargetNode replacement = graph().add( - new MethodCallTargetNode(replacementInvokeKind, originalTargetMethod, originalArguments.toArray(new ValueNode[originalArguments.size()]), originalReturnType)); + new MethodCallTargetNode(replacementInvokeKind, originalTargetMethod, originalArguments.toArray(new ValueNode[originalArguments.size()]), originalReturnType, null)); // Replace myself... this.replaceAndDelete(replacement);