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