diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 18250:34cb95edfc97

MethodCallTargetNode: get profile from TypeProfileProxy if available.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 04 Nov 2014 13:22:58 +0100
parents 691e2b53dc63
children 4a41f32ed552
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Wed Nov 05 11:20:39 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Tue Nov 04 13:22:58 2014 +0100
@@ -156,9 +156,7 @@
                     ResolvedJavaMethod newResolvedMethod = single.resolveMethod(targetMethod(), invoke().getContextType(), true);
                     // TODO (je): we can not yet deal with default methods
                     if (newResolvedMethod != null && !newResolvedMethod.isDefault()) {
-                        ProfilingInfo profilingInfo = invoke().getContextMethod().getProfilingInfo();
-                        JavaTypeProfile profile = profilingInfo.getTypeProfile(invoke().bci());
-                        LogicNode condition = graph().unique(InstanceOfNode.create(single, receiver, profile));
+                        LogicNode condition = graph().unique(InstanceOfNode.create(single, receiver, getProfile()));
                         assert graph().getGuardsStage().ordinal() < StructuredGraph.GuardsStage.FIXED_DEOPTS.ordinal() : "Graph already fixed!";
                         GuardNode guard = graph().unique(
                                         GuardNode.create(condition, BeginNode.prevBegin(invoke().asNode()), DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile,
@@ -173,6 +171,17 @@
         }
     }
 
+    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());
+    }
+
     @Override
     public Stamp returnStamp() {
         Kind returnKind = targetMethod().getSignature().getReturnKind();