public Signature getSignature() { ForeignCallDescriptor d = linkage.getDescriptor(); MetaAccessProvider metaAccess = providers.getMetaAccess(); Class<?>[] arguments = d.getArgumentTypes(); ResolvedJavaType[] parameters = new ResolvedJavaType[arguments.length]; for (int i = 0; i < arguments.length; i++) { parameters[i] = metaAccess.lookupJavaType(arguments[i]); } return new HotSpotSignature( jvmciRuntime, metaAccess.lookupJavaType(d.getResultType()), parameters); }
/** Gets a calling convention for a given descriptor and call type. */ public static CallingConvention createCallingConvention( MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ForeignCallDescriptor descriptor, Type ccType) { assert ccType != null; Class<?>[] argumentTypes = descriptor.getArgumentTypes(); JavaType[] parameterTypes = new JavaType[argumentTypes.length]; for (int i = 0; i < parameterTypes.length; ++i) { parameterTypes[i] = asJavaType(argumentTypes[i], metaAccess, codeCache); } TargetDescription target = codeCache.getTarget(); JavaType returnType = asJavaType(descriptor.getResultType(), metaAccess, codeCache); RegisterConfig regConfig = codeCache.getRegisterConfig(); return regConfig.getCallingConvention(ccType, returnType, parameterTypes, target); }
/** * Creates a stub for a call to code at a given address. * * @param address the address of the code to call * @param descriptor the signature of the call to this stub * @param prependThread true if the JavaThread value for the current thread is to be prepended to * the arguments for the call to {@code address} * @param reexecutable specifies if the stub call can be re-executed without (meaningful) side * effects. Deoptimization will not return to a point before a stub call that cannot be * re-executed. * @param killedLocations the memory locations killed by the stub call */ public ForeignCallStub( HotSpotJVMCIRuntimeProvider runtime, HotSpotProviders providers, long address, ForeignCallDescriptor descriptor, boolean prependThread, Transition transition, boolean reexecutable, LocationIdentity... killedLocations) { super( providers, HotSpotForeignCallLinkageImpl.create( providers.getMetaAccess(), providers.getCodeCache(), providers.getForeignCalls(), descriptor, 0L, PRESERVES_REGISTERS, JavaCall, JavaCallee, transition, reexecutable, killedLocations)); this.jvmciRuntime = runtime; this.prependThread = prependThread; Class<?>[] targetParameterTypes = createTargetParameters(descriptor); ForeignCallDescriptor targetSig = new ForeignCallDescriptor( descriptor.getName() + ":C", descriptor.getResultType(), targetParameterTypes); target = HotSpotForeignCallLinkageImpl.create( providers.getMetaAccess(), providers.getCodeCache(), providers.getForeignCalls(), targetSig, address, DESTROYS_REGISTERS, NativeCall, NativeCall, transition, reexecutable, killedLocations); }