001/*
002 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package jdk.internal.jvmci.hotspot;
024
025import java.lang.reflect.*;
026
027import jdk.internal.jvmci.meta.*;
028
029/**
030 * Implementation of {@link JavaMethod} for resolved HotSpot methods.
031 */
032public interface HotSpotResolvedJavaMethod extends ResolvedJavaMethod {
033
034    /**
035     * Returns true if this method has a {@code CallerSensitive} annotation.
036     *
037     * @return true if CallerSensitive annotation present, false otherwise
038     */
039    boolean isCallerSensitive();
040
041    HotSpotResolvedObjectType getDeclaringClass();
042
043    /**
044     * Returns true if this method has a {@code ForceInline} annotation.
045     *
046     * @return true if ForceInline annotation present, false otherwise
047     */
048    boolean isForceInline();
049
050    /**
051     * Returns true if this method has a {@code DontInline} annotation.
052     *
053     * @return true if DontInline annotation present, false otherwise
054     */
055    boolean isDontInline();
056
057    /**
058     * Manually adds a DontInline annotation to this method.
059     */
060    void setNotInlineable();
061
062    /**
063     * Returns true if this method is one of the special methods that is ignored by security stack
064     * walks.
065     *
066     * @return true if special method ignored by security stack walks, false otherwise
067     */
068    boolean ignoredBySecurityStackWalk();
069
070    boolean hasBalancedMonitors();
071
072    ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver);
073
074    /**
075     * Returns whether this method has compiled code.
076     *
077     * @return true if this method has compiled code, false otherwise
078     */
079    boolean hasCompiledCode();
080
081    /**
082     * @param level
083     * @return true if the currently installed code was generated at {@code level}.
084     */
085    boolean hasCompiledCodeAtLevel(int level);
086
087    default boolean isDefault() {
088        if (isConstructor()) {
089            return false;
090        }
091        // Copied from java.lang.Method.isDefault()
092        int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC;
093        return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface();
094    }
095
096    /**
097     * Returns the offset of this method into the v-table. The method must have a v-table entry as
098     * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is
099     * thrown.
100     *
101     * @return the offset of this method into the v-table
102     */
103    int vtableEntryOffset(ResolvedJavaType resolved);
104
105    int intrinsicId();
106
107    /**
108     * Allocates a compile id for this method by asking the VM for one.
109     *
110     * @param entryBCI entry bci
111     * @return compile id
112     */
113    int allocateCompileId(int entryBCI);
114
115    boolean hasCodeAtLevel(int entryBCI, int level);
116}