comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 18822:fad37aaed6d2

Add utilities isDirect and isIndirect to InvokeKind.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 11 Jan 2015 17:46:47 +0100
parents 2885aafd812f
children 5a21cac1968f
comparison
equal deleted inserted replaced
18821:e4b2cbda1ae6 18822:fad37aaed6d2
78 public boolean verify() { 78 public boolean verify() {
79 assert usages().count() <= 1 : "call target may only be used by a single invoke"; 79 assert usages().count() <= 1 : "call target may only be used by a single invoke";
80 for (Node n : usages()) { 80 for (Node n : usages()) {
81 assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n); 81 assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n);
82 } 82 }
83 if (invokeKind() == InvokeKind.Special || invokeKind() == InvokeKind.Static) { 83 if (invokeKind().isDirect()) {
84 assertFalse(targetMethod().isAbstract(), "special calls or static calls are only allowed for concrete methods (%s)", targetMethod()); 84 assertFalse(targetMethod().isAbstract(), "special calls or static calls are only allowed for concrete methods (%s)", targetMethod());
85 } 85 }
86 if (invokeKind() == InvokeKind.Static) { 86 if (invokeKind() == InvokeKind.Static) {
87 assertTrue(targetMethod().isStatic(), "static calls are only allowed for static methods (%s)", targetMethod()); 87 assertTrue(targetMethod().isStatic(), "static calls are only allowed for static methods (%s)", targetMethod());
88 } else { 88 } else {
100 } 100 }
101 } 101 }
102 102
103 @Override 103 @Override
104 public void simplify(SimplifierTool tool) { 104 public void simplify(SimplifierTool tool) {
105 if (invokeKind() == InvokeKind.Interface || invokeKind() == InvokeKind.Virtual) { 105 if (invokeKind().isIndirect()) {
106 // attempt to devirtualize the call 106 // attempt to devirtualize the call
107 107
108 // check for trivial cases (e.g. final methods, nonvirtual methods) 108 // check for trivial cases (e.g. final methods, nonvirtual methods)
109 if (targetMethod().canBeStaticallyBound()) { 109 if (targetMethod().canBeStaticallyBound()) {
110 setInvokeKind(InvokeKind.Special); 110 setInvokeKind(InvokeKind.Special);