|
42 | 42 | import jdk.graal.compiler.replacements.nodes.MacroNode; |
43 | 43 | import jdk.graal.compiler.replacements.nodes.MethodHandleNode; |
44 | 44 | import jdk.graal.compiler.replacements.nodes.ResolvedMethodHandleCallTargetNode; |
45 | | - |
46 | 45 | import jdk.vm.ci.meta.JavaKind; |
47 | 46 | import jdk.vm.ci.meta.MethodHandleAccessProvider; |
48 | 47 | import jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod; |
@@ -129,21 +128,23 @@ public <T extends ValueNode> T add(T node) { |
129 | 128 | } |
130 | 129 | } |
131 | 130 |
|
132 | | - /* |
133 | | - * After handleReplacedInvoke, a return type according to the signature of |
134 | | - * targetMethod has been pushed. That can be different than the type expected by the |
135 | | - * method handle invoke. Since there cannot be any implicit type conversion, the |
136 | | - * only safe option actually is that the return type is not used at all. If there is |
137 | | - * any other expected return type, the bytecodes are wrong. The JavaDoc of |
138 | | - * MethodHandle.invokeBasic states that this "could crash the JVM", so bailing out |
139 | | - * of compilation seems like a good idea. |
140 | | - */ |
141 | | - JavaKind invokeReturnKind = invokeReturnStamp.getTrustedStamp().getStackKind(); |
142 | | - JavaKind targetMethodReturnKind = targetMethod.getSignature().getReturnKind().getStackKind(); |
143 | | - if (invokeReturnKind != targetMethodReturnKind) { |
144 | | - b.pop(targetMethodReturnKind); |
145 | | - if (invokeReturnKind != JavaKind.Void) { |
146 | | - throw b.bailout("Cannot do any type conversion when invoking method handle, so return value must remain popped"); |
| 131 | + if (!b.hasParseTerminated()) { |
| 132 | + /* |
| 133 | + * After handleReplacedInvoke, a return type according to the signature of |
| 134 | + * targetMethod has been pushed. That can be different than the type expected by |
| 135 | + * the method handle invoke. Since there cannot be any implicit type conversion, |
| 136 | + * the only safe option actually is that the return type is not used at all. If |
| 137 | + * there is any other expected return type, the bytecodes are wrong. The JavaDoc |
| 138 | + * of MethodHandle.invokeBasic states that this "could crash the JVM", so |
| 139 | + * bailing out of compilation seems like a good idea. |
| 140 | + */ |
| 141 | + JavaKind invokeReturnKind = invokeReturnStamp.getTrustedStamp().getStackKind(); |
| 142 | + JavaKind targetMethodReturnKind = targetMethod.getSignature().getReturnKind().getStackKind(); |
| 143 | + if (invokeReturnKind != targetMethodReturnKind) { |
| 144 | + b.pop(targetMethodReturnKind); |
| 145 | + if (invokeReturnKind != JavaKind.Void) { |
| 146 | + throw b.bailout("Cannot do any type conversion when invoking method handle, so return value must remain popped"); |
| 147 | + } |
147 | 148 | } |
148 | 149 | } |
149 | 150 | } |
|
0 commit comments