< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotForeignCallsProviderImpl.java

Print this page
rev 52509 : [mq]: graal2


  92         return linkage;
  93     }
  94 
  95     /**
  96      * Return true if the descriptor has already been registered.
  97      */
  98     public boolean isRegistered(ForeignCallDescriptor descriptor) {
  99         return foreignCalls.containsKey(descriptor);
 100     }
 101 
 102     /**
 103      * Creates and registers the details for linking a foreign call to a {@link Stub}.
 104      *
 105      * @param descriptor the signature of the call to the stub
 106      * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
 107      * @param reexecutability specifies if the stub call can be re-executed without (meaningful)
 108      *            side effects. Deoptimization will not return to a point before a stub call that
 109      *            cannot be re-executed.
 110      * @param killedLocations the memory locations killed by the stub call
 111      */
 112     public HotSpotForeignCallLinkage registerStubCall(ForeignCallDescriptor descriptor, Transition transition, Reexecutability reexecutability,



 113                     LocationIdentity... killedLocations) {
 114         return register(HotSpotForeignCallLinkageImpl.create(metaAccess, codeCache, wordTypes, this, descriptor, 0L, PRESERVES_REGISTERS, JavaCall, JavaCallee, transition, reexecutability,









 115                         killedLocations));
 116     }
 117 
 118     /**
 119      * Creates and registers the linkage for a foreign call.
 120      *
 121      * @param descriptor the signature of the foreign call
 122      * @param address the address of the code to call
 123      * @param outgoingCcType outgoing (caller) calling convention type
 124      * @param effect specifies if the call destroys or preserves all registers (apart from
 125      *            temporaries which are always destroyed)
 126      * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
 127      * @param reexecutability specifies if the foreign call can be re-executed without (meaningful)
 128      *            side effects. Deoptimization will not return to a point before a foreign call that
 129      *            cannot be re-executed.
 130      * @param killedLocations the memory locations killed by the foreign call
 131      */
 132     public HotSpotForeignCallLinkage registerForeignCall(ForeignCallDescriptor descriptor, long address, CallingConvention.Type outgoingCcType, RegisterEffect effect, Transition transition,
 133                     Reexecutability reexecutability, LocationIdentity... killedLocations) {






 134         Class<?> resultType = descriptor.getResultType();
 135         assert address != 0;
 136         assert transition != SAFEPOINT || resultType.isPrimitive() || Word.class.isAssignableFrom(resultType) : "non-leaf foreign calls must return objects in thread local storage: " + descriptor;
 137         return register(HotSpotForeignCallLinkageImpl.create(metaAccess, codeCache, wordTypes, this, descriptor, address, effect, outgoingCcType, null, transition, reexecutability, killedLocations));











 138     }
 139 
 140     /**
 141      * Creates a {@linkplain ForeignCallStub stub} for a foreign call.

 142      *
 143      * @param descriptor the signature of the call to the stub
 144      * @param address the address of the foreign code to call
 145      * @param prependThread true if the JavaThread value for the current thread is to be prepended
 146      *            to the arguments for the call to {@code address}
 147      * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
 148      * @param reexecutability specifies if the foreign call can be re-executed without (meaningful)
 149      *            side effects. Deoptimization will not return to a point before a foreign call that
 150      *            cannot be re-executed.
 151      * @param killedLocations the memory locations killed by the foreign call
 152      */
 153     public void linkForeignCall(OptionValues options, HotSpotProviders providers, ForeignCallDescriptor descriptor, long address, boolean prependThread, Transition transition,
 154                     Reexecutability reexecutability, LocationIdentity... killedLocations) {







 155         ForeignCallStub stub = new ForeignCallStub(options, jvmciRuntime, providers, address, descriptor, prependThread, transition, reexecutability, killedLocations);
 156         HotSpotForeignCallLinkage linkage = stub.getLinkage();
 157         HotSpotForeignCallLinkage targetLinkage = stub.getTargetLinkage();
 158         linkage.setCompiledStub(stub);
 159         register(linkage);
 160         register(targetLinkage);

 161     }
 162 
 163     public static final boolean PREPEND_THREAD = true;
 164     public static final boolean DONT_PREPEND_THREAD = !PREPEND_THREAD;
 165 
 166     public static final LocationIdentity[] NO_LOCATIONS = {};
 167 
 168     @Override
 169     public HotSpotForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
 170         assert foreignCalls != null : descriptor;
 171         HotSpotForeignCallLinkage callTarget = foreignCalls.get(descriptor);
 172         callTarget.finalizeAddress(runtime.getHostBackend());
 173         return callTarget;
 174     }
 175 
 176     @Override
 177     public boolean isReexecutable(ForeignCallDescriptor descriptor) {
 178         assert foreignCalls.containsKey(descriptor) : "unknown foreign call: " + descriptor;
 179         return foreignCalls.get(descriptor).isReexecutable();
 180     }




  92         return linkage;
  93     }
  94 
  95     /**
  96      * Return true if the descriptor has already been registered.
  97      */
  98     public boolean isRegistered(ForeignCallDescriptor descriptor) {
  99         return foreignCalls.containsKey(descriptor);
 100     }
 101 
 102     /**
 103      * Creates and registers the details for linking a foreign call to a {@link Stub}.
 104      *
 105      * @param descriptor the signature of the call to the stub
 106      * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
 107      * @param reexecutability specifies if the stub call can be re-executed without (meaningful)
 108      *            side effects. Deoptimization will not return to a point before a stub call that
 109      *            cannot be re-executed.
 110      * @param killedLocations the memory locations killed by the stub call
 111      */
 112     public HotSpotForeignCallLinkage registerStubCall(
 113                     ForeignCallDescriptor descriptor,
 114                     Transition transition,
 115                     Reexecutability reexecutability,
 116                     LocationIdentity... killedLocations) {
 117         return register(HotSpotForeignCallLinkageImpl.create(metaAccess,
 118                         codeCache,
 119                         wordTypes,
 120                         this,
 121                         descriptor,
 122                         0L, PRESERVES_REGISTERS,
 123                         JavaCall,
 124                         JavaCallee,
 125                         transition,
 126                         reexecutability,
 127                         killedLocations));
 128     }
 129 
 130     /**
 131      * Creates and registers the linkage for a foreign call.
 132      *
 133      * @param descriptor the signature of the foreign call
 134      * @param address the address of the code to call (must be non-zero)
 135      * @param outgoingCcType outgoing (caller) calling convention type
 136      * @param effect specifies if the call destroys or preserves all registers (apart from
 137      *            temporaries which are always destroyed)
 138      * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
 139      * @param reexecutability specifies if the foreign call can be re-executed without (meaningful)
 140      *            side effects. Deoptimization will not return to a point before a foreign call that
 141      *            cannot be re-executed.
 142      * @param killedLocations the memory locations killed by the foreign call
 143      */
 144     public HotSpotForeignCallLinkage registerForeignCall(
 145                     ForeignCallDescriptor descriptor,
 146                     long address,
 147                     CallingConvention.Type outgoingCcType,
 148                     RegisterEffect effect,
 149                     Transition transition,
 150                     Reexecutability reexecutability,
 151                     LocationIdentity... killedLocations) {
 152         Class<?> resultType = descriptor.getResultType();
 153         assert address != 0 : descriptor;
 154         assert transition != SAFEPOINT || resultType.isPrimitive() || Word.class.isAssignableFrom(resultType) : "non-leaf foreign calls must return objects in thread local storage: " + descriptor;
 155         return register(HotSpotForeignCallLinkageImpl.create(metaAccess,
 156                         codeCache,
 157                         wordTypes,
 158                         this,
 159                         descriptor,
 160                         address,
 161                         effect,
 162                         outgoingCcType,
 163                         null, // incomingCcType
 164                         transition,
 165                         reexecutability,
 166                         killedLocations));
 167     }
 168 
 169     /**
 170      * Creates a {@linkplain ForeignCallStub stub} for the foreign call described by
 171      * {@code descriptor} if {@code address != 0}.
 172      *
 173      * @param descriptor the signature of the call to the stub
 174      * @param address the address of the foreign code to call
 175      * @param prependThread true if the JavaThread value for the current thread is to be prepended
 176      *            to the arguments for the call to {@code address}
 177      * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
 178      * @param reexecutability specifies if the foreign call can be re-executed without (meaningful)
 179      *            side effects. Deoptimization will not return to a point before a foreign call that
 180      *            cannot be re-executed.
 181      * @param killedLocations the memory locations killed by the foreign call
 182      */
 183     public void linkForeignCall(OptionValues options,
 184                     HotSpotProviders providers,
 185                     ForeignCallDescriptor descriptor,
 186                     long address,
 187                     boolean prependThread,
 188                     Transition transition,
 189                     Reexecutability reexecutability,
 190                     LocationIdentity... killedLocations) {
 191         if (address != 0) {
 192             ForeignCallStub stub = new ForeignCallStub(options, jvmciRuntime, providers, address, descriptor, prependThread, transition, reexecutability, killedLocations);
 193             HotSpotForeignCallLinkage linkage = stub.getLinkage();
 194             HotSpotForeignCallLinkage targetLinkage = stub.getTargetLinkage();
 195             linkage.setCompiledStub(stub);
 196             register(linkage);
 197             register(targetLinkage);
 198         }
 199     }
 200 
 201     public static final boolean PREPEND_THREAD = true;
 202     public static final boolean DONT_PREPEND_THREAD = !PREPEND_THREAD;
 203 
 204     public static final LocationIdentity[] NO_LOCATIONS = {};
 205 
 206     @Override
 207     public HotSpotForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
 208         assert foreignCalls != null : descriptor;
 209         HotSpotForeignCallLinkage callTarget = foreignCalls.get(descriptor);
 210         callTarget.finalizeAddress(runtime.getHostBackend());
 211         return callTarget;
 212     }
 213 
 214     @Override
 215     public boolean isReexecutable(ForeignCallDescriptor descriptor) {
 216         assert foreignCalls.containsKey(descriptor) : "unknown foreign call: " + descriptor;
 217         return foreignCalls.get(descriptor).isReexecutable();
 218     }


< prev index next >