1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.nodes.graphbuilderconf;
  24 
  25 import org.graalvm.compiler.nodes.FrameState;
  26 import org.graalvm.compiler.nodes.ValueNode;
  27 
  28 import jdk.vm.ci.meta.ResolvedJavaMethod;
  29 import jdk.vm.ci.meta.JavaConstant;
  30 
  31 /**
  32  * {@link GraphBuilderPlugin} interface for static compilation mode, allowing references to dynamic
  33  * types.
  34  */
  35 public interface InvokeDynamicPlugin extends GraphBuilderPlugin {
  36 
  37     /**
  38      * Checks for a resolved dynamic adapter method at the specified index, resulting from either a
  39      * resolved invokedynamic or invokevirtual on a signature polymorphic MethodHandle method
  40      * (HotSpot invokehandle).
  41      *
  42      * @param builder context for the invoke
  43      * @param cpi the constant pool index
  44      * @param opcode the opcode of the instruction for which the lookup is being performed
  45      * @return {@code true} if a signature polymorphic method reference was found, otherwise
  46      *         {@code false}
  47      */
  48     boolean isResolvedDynamicInvoke(GraphBuilderContext builder, int cpi, int opcode);
  49 
  50     /**
  51      * Checks if this plugin instance supports the specified dynamic invoke.
  52      *
  53      * @param builder context for the invoke
  54      * @param cpi the constant pool index
  55      * @param opcode the opcode of the invoke instruction
  56      * @return {@code true} if this dynamic invoke is supported
  57      */
  58     boolean supportsDynamicInvoke(GraphBuilderContext builder, int cpi, int opcode);
  59 
  60     /**
  61      * Notifies this object of the value and context of the dynamic method target (e.g., A HotSpot
  62      * adapter method) for a resolved dynamic invoke.
  63      *
  64      * @param builder context for the invoke
  65      * @param cpi the constant pool index
  66      * @param opcode the opcode of the instruction for which the lookup is being performed
  67      * @param target dynamic target method to record
  68      */
  69     void recordDynamicMethod(GraphBuilderContext builder, int cpi, int opcode, ResolvedJavaMethod target);
  70 
  71     /**
  72      * Notifies this object of the value and context of the dynamic appendix object for a resolved
  73      * dynamic invoke.
  74      *
  75      * @param builder context for the invoke
  76      * @param cpi the constant pool index
  77      * @param opcode the opcode of the instruction for which the lookup is being performed
  78      * @return {@link ValueNode} for appendix constant
  79      */
  80     ValueNode genAppendixNode(GraphBuilderContext builder, int cpi, int opcode, JavaConstant appendix, FrameState frameState);
  81 
  82 }