001/*
002 * Copyright (c) 2009, 2012, 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 com.oracle.graal.compiler.common.spi;
024
025import jdk.internal.jvmci.code.*;
026import jdk.internal.jvmci.meta.*;
027
028/**
029 * The runtime specific details of a {@linkplain ForeignCallDescriptor foreign} call.
030 */
031public interface ForeignCallLinkage extends InvokeTarget {
032
033    /**
034     * Gets the details of where parameters are passed and value(s) are returned from the caller's
035     * perspective.
036     */
037    CallingConvention getOutgoingCallingConvention();
038
039    /**
040     * Gets the details of where parameters are passed and value(s) are returned from the callee's
041     * perspective.
042     */
043    CallingConvention getIncomingCallingConvention();
044
045    /**
046     * Returns the maximum absolute offset of PC relative call to this stub from any position in the
047     * code cache or -1 when not applicable. Intended for determining the required size of
048     * address/offset fields.
049     */
050    long getMaxCallTargetOffset();
051
052    ForeignCallDescriptor getDescriptor();
053
054    /**
055     * Gets the values used/killed by this foreign call.
056     */
057    Value[] getTemporaries();
058
059    /**
060     * Determines if the foreign call target destroys all registers.
061     *
062     * @return {@code true} if the register allocator must save all live registers around a call to
063     *         this target
064     */
065    boolean destroysRegisters();
066
067    /**
068     * Determines if debug info needs to be associated with this call. Debug info is required if the
069     * function can raise an exception, try to lock, trigger GC or do anything else that requires
070     * the VM to be able to inspect the thread's execution state.
071     */
072    boolean needsDebugInfo();
073}