use of com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod in project graal by oracle.
the class NativeImageGenerator method checkInvocationPluginMethods.
private static boolean checkInvocationPluginMethods(SubstrateReplacements replacements) {
for (ResolvedJavaMethod method : replacements.getDelayedInvocationPluginMethods()) {
ResolvedJavaMethod unwrapped = method;
while (unwrapped instanceof WrappedJavaMethod) {
unwrapped = ((WrappedJavaMethod) unwrapped).getWrapped();
}
if (method != unwrapped) {
String runtimeDescriptor = method.getSignature().toMethodDescriptor();
String hostedDescriptor = unwrapped.getSignature().toMethodDescriptor();
if (!runtimeDescriptor.equals(hostedDescriptor)) {
String name = method.format("%H.%n");
throw new AssertionError(String.format("Cannot have invocation plugin for a method whose runtime signature is different from its hosted signature:%n" + " method: %s%n" + " hosted signature: %s%n" + " runtime signature: %s", name, runtimeDescriptor, hostedDescriptor));
}
}
assert method == unwrapped || method.getSignature().toMethodDescriptor().equals(unwrapped.getSignature().toMethodDescriptor());
}
return true;
}
use of com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod in project graal by oracle.
the class CEntryPointCallStubMethod method buildGraph.
@Override
public StructuredGraph buildGraph(DebugContext debug, ResolvedJavaMethod method, HostedProviders providers, Purpose purpose) {
UniverseMetaAccess metaAccess = (UniverseMetaAccess) providers.getMetaAccess();
NativeLibraries nativeLibraries = CEntryPointCallStubSupport.singleton().getNativeLibraries();
HostedGraphKit kit = new HostedGraphKit(debug, providers, method);
StructuredGraph graph = kit.getGraph();
JavaType[] parameterTypes = method.toParameterTypes();
JavaType[] parameterLoadTypes = Arrays.copyOf(parameterTypes, parameterTypes.length);
EnumInfo[] parameterEnumInfos;
parameterEnumInfos = adaptParameterTypes(providers, nativeLibraries, kit, parameterTypes, parameterLoadTypes, purpose);
ValueNode[] args = kit.loadArguments(parameterLoadTypes).toArray(new ValueNode[0]);
InvokeNode prologueInvoke = generatePrologue(providers, kit, parameterLoadTypes, args);
adaptArgumentValues(providers, kit, parameterTypes, parameterEnumInfos, args);
ResolvedJavaMethod unwrappedTargetMethod = targetMethod;
while (unwrappedTargetMethod instanceof WrappedJavaMethod) {
unwrappedTargetMethod = ((WrappedJavaMethod) unwrappedTargetMethod).getWrapped();
}
ResolvedJavaMethod universeTargetMethod = lookupMethodInUniverse(metaAccess, unwrappedTargetMethod);
int invokeBci = kit.bci();
int exceptionEdgeBci = kit.bci();
// Also support non-static test methods (they are not allowed to use the receiver)
InvokeKind invokeKind = universeTargetMethod.isStatic() ? InvokeKind.Static : InvokeKind.Special;
ValueNode[] invokeArgs = args;
if (invokeKind != InvokeKind.Static) {
invokeArgs = new ValueNode[args.length + 1];
invokeArgs[0] = kit.createObject(null);
System.arraycopy(args, 0, invokeArgs, 1, args.length);
}
InvokeWithExceptionNode invoke = kit.startInvokeWithException(universeTargetMethod, invokeKind, kit.getFrameState(), invokeBci, exceptionEdgeBci, invokeArgs);
kit.exceptionPart();
ExceptionObjectNode exception = kit.exceptionObject();
generateExceptionHandler(providers, kit, exception, invoke.getStackKind());
kit.endInvokeWithException();
ValueNode returnValue = adaptReturnValue(method, providers, purpose, metaAccess, nativeLibraries, kit, invoke);
InvokeNode epilogueInvoke = generateEpilogue(providers, kit);
kit.createReturn(returnValue, returnValue.getStackKind());
inlinePrologueAndEpilogue(kit, prologueInvoke, epilogueInvoke, invoke.getStackKind());
assert graph.verify();
return graph;
}
use of com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod in project graal by oracle.
the class JNINativeCallWrapperMethod method createLinkage.
private static JNINativeLinkage createLinkage(ResolvedJavaMethod method) {
ResolvedJavaMethod unwrapped = method;
while (unwrapped instanceof WrappedJavaMethod) {
unwrapped = ((WrappedJavaMethod) unwrapped).getWrapped();
}
String className = unwrapped.getDeclaringClass().getName();
String descriptor = unwrapped.getSignature().toMethodDescriptor();
return JNIAccessFeature.singleton().makeLinkage(className, unwrapped.getName(), descriptor);
}
Aggregations