< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/GraphKit.java

Print this page




 221     }
 222 
 223     /**
 224      * Creates and appends an {@link InvokeNode} for a call to a given method with a given set of
 225      * arguments.
 226      */
 227     public InvokeNode createInvoke(ResolvedJavaMethod method, InvokeKind invokeKind, FrameStateBuilder frameStateBuilder, int bci, ValueNode... args) {
 228         assert method.isStatic() == (invokeKind == InvokeKind.Static);
 229         Signature signature = method.getSignature();
 230         JavaType returnType = signature.getReturnType(null);
 231         assert checkArgs(method, args);
 232         StampPair returnStamp = graphBuilderPlugins.getOverridingStamp(this, returnType, false);
 233         if (returnStamp == null) {
 234             returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
 235         }
 236         MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, method, args, returnStamp, bci));
 237         InvokeNode invoke = append(new InvokeNode(callTarget, bci));
 238 
 239         if (frameStateBuilder != null) {
 240             if (invoke.getStackKind() != JavaKind.Void) {
 241                 frameStateBuilder.push(returnType.getJavaKind(), invoke);
 242             }
 243             invoke.setStateAfter(frameStateBuilder.create(bci, invoke));
 244             if (invoke.getStackKind() != JavaKind.Void) {
 245                 frameStateBuilder.pop(returnType.getJavaKind());
 246             }
 247         }
 248         return invoke;
 249     }
 250 
 251     protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, StampPair returnStamp, @SuppressWarnings("unused") int bci) {
 252         return new MethodCallTargetNode(invokeKind, targetMethod, args, returnStamp, null);
 253     }
 254 
 255     /**
 256      * Determines if a given set of arguments is compatible with the signature of a given method.
 257      *
 258      * @return true if {@code args} are compatible with the signature if {@code method}
 259      * @throws AssertionError if {@code args} are not compatible with the signature if
 260      *             {@code method}
 261      */
 262     public boolean checkArgs(ResolvedJavaMethod method, ValueNode... args) {
 263         Signature signature = method.getSignature();
 264         boolean isStatic = method.isStatic();
 265         if (signature.getParameterCount(!isStatic) != args.length) {


 458         JavaType returnType = signature.getReturnType(null);
 459         assert checkArgs(method, args);
 460         StampPair returnStamp = graphBuilderPlugins.getOverridingStamp(this, returnType, false);
 461         if (returnStamp == null) {
 462             returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
 463         }
 464         ExceptionObjectNode exceptionObject = add(new ExceptionObjectNode(getMetaAccess()));
 465         if (frameStateBuilder != null) {
 466             FrameStateBuilder exceptionState = frameStateBuilder.copy();
 467             exceptionState.clearStack();
 468             exceptionState.push(JavaKind.Object, exceptionObject);
 469             exceptionState.setRethrowException(false);
 470             exceptionObject.setStateAfter(exceptionState.create(exceptionEdgeBci, exceptionObject));
 471         }
 472         MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, method, args, returnStamp, invokeBci));
 473         InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionObject, invokeBci));
 474         AbstractBeginNode noExceptionEdge = graph.add(KillingBeginNode.create(LocationIdentity.any()));
 475         invoke.setNext(noExceptionEdge);
 476         if (frameStateBuilder != null) {
 477             if (invoke.getStackKind() != JavaKind.Void) {
 478                 frameStateBuilder.push(returnType.getJavaKind(), invoke);
 479             }
 480             invoke.setStateAfter(frameStateBuilder.create(invokeBci, invoke));
 481             if (invoke.getStackKind() != JavaKind.Void) {
 482                 frameStateBuilder.pop(returnType.getJavaKind());
 483             }
 484         }
 485         lastFixedNode = null;
 486 
 487         InvokeWithExceptionStructure s = new InvokeWithExceptionStructure();
 488         s.state = InvokeWithExceptionStructure.State.INVOKE;
 489         s.noExceptionEdge = noExceptionEdge;
 490         s.exceptionEdge = exceptionObject;
 491         s.exceptionObject = exceptionObject;
 492         pushStructure(s);
 493 
 494         return invoke;
 495     }
 496 
 497     private InvokeWithExceptionStructure saveLastInvokeWithExceptionNode() {
 498         InvokeWithExceptionStructure s = getTopStructure(InvokeWithExceptionStructure.class);
 499         switch (s.state) {
 500             case INVOKE:
 501                 assert lastFixedNode == null;
 502                 break;




 221     }
 222 
 223     /**
 224      * Creates and appends an {@link InvokeNode} for a call to a given method with a given set of
 225      * arguments.
 226      */
 227     public InvokeNode createInvoke(ResolvedJavaMethod method, InvokeKind invokeKind, FrameStateBuilder frameStateBuilder, int bci, ValueNode... args) {
 228         assert method.isStatic() == (invokeKind == InvokeKind.Static);
 229         Signature signature = method.getSignature();
 230         JavaType returnType = signature.getReturnType(null);
 231         assert checkArgs(method, args);
 232         StampPair returnStamp = graphBuilderPlugins.getOverridingStamp(this, returnType, false);
 233         if (returnStamp == null) {
 234             returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
 235         }
 236         MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, method, args, returnStamp, bci));
 237         InvokeNode invoke = append(new InvokeNode(callTarget, bci));
 238 
 239         if (frameStateBuilder != null) {
 240             if (invoke.getStackKind() != JavaKind.Void) {
 241                 frameStateBuilder.push(invoke.getStackKind(), invoke);
 242             }
 243             invoke.setStateAfter(frameStateBuilder.create(bci, invoke));
 244             if (invoke.getStackKind() != JavaKind.Void) {
 245                 frameStateBuilder.pop(invoke.getStackKind());
 246             }
 247         }
 248         return invoke;
 249     }
 250 
 251     protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, StampPair returnStamp, @SuppressWarnings("unused") int bci) {
 252         return new MethodCallTargetNode(invokeKind, targetMethod, args, returnStamp, null);
 253     }
 254 
 255     /**
 256      * Determines if a given set of arguments is compatible with the signature of a given method.
 257      *
 258      * @return true if {@code args} are compatible with the signature if {@code method}
 259      * @throws AssertionError if {@code args} are not compatible with the signature if
 260      *             {@code method}
 261      */
 262     public boolean checkArgs(ResolvedJavaMethod method, ValueNode... args) {
 263         Signature signature = method.getSignature();
 264         boolean isStatic = method.isStatic();
 265         if (signature.getParameterCount(!isStatic) != args.length) {


 458         JavaType returnType = signature.getReturnType(null);
 459         assert checkArgs(method, args);
 460         StampPair returnStamp = graphBuilderPlugins.getOverridingStamp(this, returnType, false);
 461         if (returnStamp == null) {
 462             returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
 463         }
 464         ExceptionObjectNode exceptionObject = add(new ExceptionObjectNode(getMetaAccess()));
 465         if (frameStateBuilder != null) {
 466             FrameStateBuilder exceptionState = frameStateBuilder.copy();
 467             exceptionState.clearStack();
 468             exceptionState.push(JavaKind.Object, exceptionObject);
 469             exceptionState.setRethrowException(false);
 470             exceptionObject.setStateAfter(exceptionState.create(exceptionEdgeBci, exceptionObject));
 471         }
 472         MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, method, args, returnStamp, invokeBci));
 473         InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionObject, invokeBci));
 474         AbstractBeginNode noExceptionEdge = graph.add(KillingBeginNode.create(LocationIdentity.any()));
 475         invoke.setNext(noExceptionEdge);
 476         if (frameStateBuilder != null) {
 477             if (invoke.getStackKind() != JavaKind.Void) {
 478                 frameStateBuilder.push(invoke.getStackKind(), invoke);
 479             }
 480             invoke.setStateAfter(frameStateBuilder.create(invokeBci, invoke));
 481             if (invoke.getStackKind() != JavaKind.Void) {
 482                 frameStateBuilder.pop(invoke.getStackKind());
 483             }
 484         }
 485         lastFixedNode = null;
 486 
 487         InvokeWithExceptionStructure s = new InvokeWithExceptionStructure();
 488         s.state = InvokeWithExceptionStructure.State.INVOKE;
 489         s.noExceptionEdge = noExceptionEdge;
 490         s.exceptionEdge = exceptionObject;
 491         s.exceptionObject = exceptionObject;
 492         pushStructure(s);
 493 
 494         return invoke;
 495     }
 496 
 497     private InvokeWithExceptionStructure saveLastInvokeWithExceptionNode() {
 498         InvokeWithExceptionStructure s = getTopStructure(InvokeWithExceptionStructure.class);
 499         switch (s.state) {
 500             case INVOKE:
 501                 assert lastFixedNode == null;
 502                 break;


< prev index next >