1 /*
   2  * Copyright (c) 2011, 2015, 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 jdk.vm.ci.hotspot;
  24 
  25 import java.lang.reflect.Modifier;
  26 
  27 import jdk.vm.ci.meta.JavaMethod;
  28 import jdk.vm.ci.meta.ResolvedJavaMethod;
  29 import jdk.vm.ci.meta.ResolvedJavaType;
  30 import jdk.vm.ci.options.Option;
  31 import jdk.vm.ci.options.OptionType;
  32 import jdk.vm.ci.options.OptionValue;
  33 
  34 /**
  35  * Implementation of {@link JavaMethod} for resolved HotSpot methods.
  36  */
  37 public interface HotSpotResolvedJavaMethod extends ResolvedJavaMethod {
  38 
  39     public static class Options {
  40         // @formatter:off
  41         @Option(help = "", type = OptionType.Debug)
  42         public static final OptionValue<Boolean> UseProfilingInformation = new OptionValue<>(true);
  43         // @formatter:on
  44     }
  45 
  46     /**
  47      * Returns true if this method has a {@code CallerSensitive} annotation.
  48      *
  49      * @return true if CallerSensitive annotation present, false otherwise
  50      */
  51     boolean isCallerSensitive();
  52 
  53     HotSpotResolvedObjectType getDeclaringClass();
  54 
  55     /**
  56      * Returns true if this method has a {@code ForceInline} annotation.
  57      *
  58      * @return true if ForceInline annotation present, false otherwise
  59      */
  60     boolean isForceInline();
  61 
  62     /**
  63      * Returns true if this method has a {@code DontInline} annotation.
  64      *
  65      * @return true if DontInline annotation present, false otherwise
  66      */
  67     boolean isDontInline();
  68 
  69     /**
  70      * Manually adds a DontInline annotation to this method.
  71      */
  72     void setNotInlineable();
  73 
  74     /**
  75      * Returns true if this method is one of the special methods that is ignored by security stack
  76      * walks.
  77      *
  78      * @return true if special method ignored by security stack walks, false otherwise
  79      */
  80     boolean ignoredBySecurityStackWalk();
  81 
  82     ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver);
  83 
  84     /**
  85      * Returns whether this method has compiled code.
  86      *
  87      * @return true if this method has compiled code, false otherwise
  88      */
  89     boolean hasCompiledCode();
  90 
  91     /**
  92      * @param level
  93      * @return true if the currently installed code was generated at {@code level}.
  94      */
  95     boolean hasCompiledCodeAtLevel(int level);
  96 
  97     default boolean isDefault() {
  98         if (isConstructor()) {
  99             return false;
 100         }
 101         // Copied from java.lang.Method.isDefault()
 102         int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC;
 103         return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface();
 104     }
 105 
 106     /**
 107      * Returns the offset of this method into the v-table. The method must have a v-table entry as
 108      * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is
 109      * thrown.
 110      *
 111      * @return the offset of this method into the v-table
 112      */
 113     int vtableEntryOffset(ResolvedJavaType resolved);
 114 
 115     int intrinsicId();
 116 
 117     /**
 118      * Allocates a compile id for this method by asking the VM for one.
 119      *
 120      * @param entryBCI entry bci
 121      * @return compile id
 122      */
 123     int allocateCompileId(int entryBCI);
 124 
 125     boolean hasCodeAtLevel(int entryBCI, int level);
 126 }