1 /*
   2  * Copyright (c) 2009, 2012, 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 
  24 
  25 package org.graalvm.compiler.core.common.spi;
  26 
  27 import jdk.vm.ci.code.CallingConvention;
  28 import jdk.vm.ci.meta.InvokeTarget;
  29 import jdk.vm.ci.meta.Value;
  30 
  31 /**
  32  * The runtime specific details of a {@linkplain ForeignCallDescriptor foreign} call.
  33  */
  34 public interface ForeignCallLinkage extends InvokeTarget {
  35 
  36     /**
  37      * Gets the details of where parameters are passed and value(s) are returned from the caller's
  38      * perspective.
  39      */
  40     CallingConvention getOutgoingCallingConvention();
  41 
  42     /**
  43      * Gets the details of where parameters are passed and value(s) are returned from the callee's
  44      * perspective.
  45      */
  46     CallingConvention getIncomingCallingConvention();
  47 
  48     /**
  49      * Returns the maximum absolute offset of a PC relative call to this stub from any position in
  50      * the code cache or -1 when not applicable. Intended for determining the required size of
  51      * address/offset fields.
  52      */
  53     long getMaxCallTargetOffset();
  54 
  55     ForeignCallDescriptor getDescriptor();
  56 
  57     /**
  58      * Gets the values used/killed by this foreign call.
  59      */
  60     Value[] getTemporaries();
  61 
  62     /**
  63      * Determines if the foreign call target destroys all registers.
  64      *
  65      * @return {@code true} if the register allocator must save all live registers around a call to
  66      *         this target
  67      */
  68     boolean destroysRegisters();
  69 
  70     /**
  71      * Determines if debug info needs to be associated with this call. Debug info is required if the
  72      * function can raise an exception, try to lock, trigger GC or do anything else that requires
  73      * the VM to be able to inspect the thread's execution state.
  74      */
  75     boolean needsDebugInfo();
  76 }