src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/InlineInvokePlugin.java
changeset 54601 c40b2a190173
parent 52910 583fd71c47d6
child 58299 6df94ce3ab2f
equal deleted inserted replaced
54600:69cfd80f8706 54601:c40b2a190173
    45 
    45 
    46         /**
    46         /**
    47          * Denotes a call site that must not be inlined and should be implemented by a node that
    47          * Denotes a call site that must not be inlined and should be implemented by a node that
    48          * does not speculate on the call not raising an exception.
    48          * does not speculate on the call not raising an exception.
    49          */
    49          */
    50         public static final InlineInfo DO_NOT_INLINE_WITH_EXCEPTION = new InlineInfo(null, null, null);
    50         public static final InlineInfo DO_NOT_INLINE_WITH_EXCEPTION = new InlineInfo();
    51 
    51 
    52         /**
    52         /**
    53          * Denotes a call site must not be inlined and can be implemented by a node that speculates
    53          * Denotes a call site must not be inlined and can be implemented by a node that speculates
    54          * the call will not throw an exception.
    54          * the call will not throw an exception.
    55          */
    55          */
    56         public static final InlineInfo DO_NOT_INLINE_NO_EXCEPTION = new InlineInfo(null, null, null);
    56         public static final InlineInfo DO_NOT_INLINE_NO_EXCEPTION = new InlineInfo();
    57 
    57 
    58         /**
    58         /**
    59          * Denotes a call site must not be inlined and the execution should be transferred to
    59          * Denotes a call site must not be inlined and the execution should be transferred to
    60          * interpreter in case of an exception.
    60          * interpreter in case of an exception.
    61          */
    61          */
    62         public static final InlineInfo DO_NOT_INLINE_DEOPTIMIZE_ON_EXCEPTION = new InlineInfo(null, null, null);
    62         public static final InlineInfo DO_NOT_INLINE_DEOPTIMIZE_ON_EXCEPTION = new InlineInfo();
    63 
    63 
    64         private final ResolvedJavaMethod methodToInline;
    64         private final ResolvedJavaMethod methodToInline;
    65         private final ResolvedJavaMethod originalMethod;
    65         private final MethodSubstitutionPlugin plugin;
    66         private final BytecodeProvider intrinsicBytecodeProvider;
    66         private final BytecodeProvider intrinsicBytecodeProvider;
    67 
    67 
    68         public static InlineInfo createStandardInlineInfo(ResolvedJavaMethod methodToInline) {
    68         public static InlineInfo createStandardInlineInfo(ResolvedJavaMethod methodToInline) {
    69             return new InlineInfo(methodToInline, null, null);
    69             return new InlineInfo(methodToInline, null, null);
    70         }
    70         }
    71 
    71 
    72         public static InlineInfo createIntrinsicInlineInfo(ResolvedJavaMethod methodToInline, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider) {
    72         public static InlineInfo createIntrinsicInlineInfo(ResolvedJavaMethod methodToInline, BytecodeProvider intrinsicBytecodeProvider) {
    73             return new InlineInfo(methodToInline, originalMethod, intrinsicBytecodeProvider);
    73             return new InlineInfo(methodToInline, null, intrinsicBytecodeProvider);
    74         }
    74         }
    75 
    75 
    76         private InlineInfo(ResolvedJavaMethod methodToInline, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider) {
    76         public static InlineInfo createMethodSubstitutionInlineInfo(ResolvedJavaMethod methodToInline, MethodSubstitutionPlugin plugin) {
       
    77             return new InlineInfo(methodToInline, plugin, plugin.getBytecodeProvider());
       
    78         }
       
    79 
       
    80         private InlineInfo() {
       
    81             this(null, null, null);
       
    82         }
       
    83 
       
    84         private InlineInfo(ResolvedJavaMethod methodToInline, MethodSubstitutionPlugin plugin, BytecodeProvider intrinsicBytecodeProvider) {
    77             this.methodToInline = methodToInline;
    85             this.methodToInline = methodToInline;
    78             this.originalMethod = originalMethod;
    86             this.plugin = plugin;
    79             this.intrinsicBytecodeProvider = intrinsicBytecodeProvider;
    87             this.intrinsicBytecodeProvider = intrinsicBytecodeProvider;
    80         }
    88         }
    81 
    89 
    82         /**
    90         /**
    83          * Returns the method to be inlined, or {@code null} if the call site must not be inlined.
    91          * Returns the method to be inlined, or {@code null} if the call site must not be inlined.
    89         public boolean allowsInlining() {
    97         public boolean allowsInlining() {
    90             return methodToInline != null;
    98             return methodToInline != null;
    91         }
    99         }
    92 
   100 
    93         /**
   101         /**
    94          * Returns the original method if this is an inline of an intrinsic, or {@code null} if the
       
    95          * call site must not be inlined.
       
    96          */
       
    97         public ResolvedJavaMethod getOriginalMethod() {
       
    98             return originalMethod;
       
    99         }
       
   100 
       
   101         /**
       
   102          * Gets the provider of bytecode to be parsed for {@link #getMethodToInline()} if is is an
   102          * Gets the provider of bytecode to be parsed for {@link #getMethodToInline()} if is is an
   103          * intrinsic for the original method (i.e., the {@code method} passed to
   103          * intrinsic for the original method (i.e., the {@code method} passed to
   104          * {@link InlineInvokePlugin#shouldInlineInvoke}). A {@code null} return value indicates
   104          * {@link InlineInvokePlugin#shouldInlineInvoke}). A {@code null} return value indicates
   105          * that this is not an intrinsic inlining.
   105          * that this is not an intrinsic inlining.
   106          */
   106          */
   107         public BytecodeProvider getIntrinsicBytecodeProvider() {
   107         public BytecodeProvider getIntrinsicBytecodeProvider() {
   108             return intrinsicBytecodeProvider;
   108             return intrinsicBytecodeProvider;
       
   109         }
       
   110 
       
   111         public boolean isSubstitution() {
       
   112             return plugin != null;
       
   113         }
       
   114 
       
   115         public MethodSubstitutionPlugin getPlugin() {
       
   116             return plugin;
   109         }
   117         }
   110     }
   118     }
   111 
   119 
   112     /**
   120     /**
   113      * Determines whether a call to a given method is to be inlined. The return value is a
   121      * Determines whether a call to a given method is to be inlined. The return value is a