Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 18313:6b8bceeecb30
MethodCallTargetNode: also simplify default method calls to virtual calls if possible.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Thu, 06 Nov 2014 12:40:28 +0100 |
parents | 4a41f32ed552 |
children | 3cc813ce3cea |
comparison
equal
deleted
inserted
replaced
18312:a968fd429ee5 | 18313:6b8bceeecb30 |
---|---|
148 return; | 148 return; |
149 } | 149 } |
150 } | 150 } |
151 } | 151 } |
152 ResolvedJavaType declaredReceiverType = targetMethod().getDeclaringClass(); | 152 ResolvedJavaType declaredReceiverType = targetMethod().getDeclaringClass(); |
153 if (declaredReceiverType.isInterface()) { | 153 /* |
154 * We need to check the invoke kind to avoid recursive simplification for default | |
155 * methods calls. | |
156 */ | |
157 if (declaredReceiverType.isInterface() && !invokeKind().equals(InvokeKind.Virtual)) { | |
154 ResolvedJavaType singleImplementor = declaredReceiverType.getSingleImplementor(); | 158 ResolvedJavaType singleImplementor = declaredReceiverType.getSingleImplementor(); |
155 if (singleImplementor != null && !singleImplementor.equals(declaredReceiverType)) { | 159 if (singleImplementor != null && !singleImplementor.equals(declaredReceiverType)) { |
156 ResolvedJavaMethod singleImplementorMethod = singleImplementor.resolveMethod(targetMethod(), invoke().getContextType(), true); | 160 ResolvedJavaMethod singleImplementorMethod = singleImplementor.resolveMethod(targetMethod(), invoke().getContextType(), true); |
157 // TODO (je): we can not yet deal with default methods | 161 if (singleImplementorMethod != null) { |
158 if (singleImplementorMethod != null && !singleImplementorMethod.isDefault()) { | |
159 LogicNode condition = graph().unique(InstanceOfNode.create(singleImplementor, receiver, getProfile())); | 162 LogicNode condition = graph().unique(InstanceOfNode.create(singleImplementor, receiver, getProfile())); |
160 assert graph().getGuardsStage().ordinal() < StructuredGraph.GuardsStage.FIXED_DEOPTS.ordinal() : "Graph already fixed!"; | 163 assert graph().getGuardsStage().ordinal() < StructuredGraph.GuardsStage.FIXED_DEOPTS.ordinal() : "Graph already fixed!"; |
161 GuardNode guard = graph().unique( | 164 GuardNode guard = graph().unique( |
162 GuardNode.create(condition, BeginNode.prevBegin(invoke().asNode()), DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, | 165 GuardNode.create(condition, BeginNode.prevBegin(invoke().asNode()), DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, |
163 false, JavaConstant.NULL_OBJECT)); | 166 false, JavaConstant.NULL_OBJECT)); |