use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class PointstoGraphBuilderPlugins method registerObjectPlugins.
public static void registerObjectPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Object.class);
r.register1("clone", Receiver.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Object, new AnalysisObjectCloneNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), object));
return true;
}
});
}
use of jdk.vm.ci.meta.ResolvedJavaMethod 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 jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class SizeAndSignednessVerifier method visitEnumValueInfo.
@Override
protected void visitEnumValueInfo(EnumValueInfo valueInfo) {
ResolvedJavaMethod method = (ResolvedJavaMethod) valueInfo.getAnnotatedElement();
ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
EnumInfo enumInfo = (EnumInfo) valueInfo.getParent();
for (ElementInfo info : enumInfo.getChildren()) {
if (info instanceof EnumConstantInfo) {
EnumConstantInfo constantInfo = (EnumConstantInfo) info;
checkSizeAndSignedness(constantInfo, returnType, method, true);
}
}
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class CEntryPointCallStubMethod method lookupMethodInUniverse.
private ResolvedJavaMethod lookupMethodInUniverse(UniverseMetaAccess metaAccess, ResolvedJavaMethod method) {
ResolvedJavaMethod universeMethod = method;
MetaAccessProvider wrappedMetaAccess = metaAccess.getWrapped();
if (wrappedMetaAccess instanceof UniverseMetaAccess) {
universeMethod = lookupMethodInUniverse((UniverseMetaAccess) wrappedMetaAccess, universeMethod);
}
return metaAccess.getUniverse().lookup(universeMethod);
}
use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.
the class CEntryPointCallStubMethod method generatePrologue.
private InvokeNode generatePrologue(HostedProviders providers, SubstrateGraphKit kit, JavaType[] parameterTypes, ValueNode[] args) {
Class<?> prologueClass = entryPointData.getPrologue();
if (prologueClass == NoPrologue.class) {
UserError.guarantee(targetMethod.getAnnotation(Uninterruptible.class) != null, CEntryPointOptions.class.getSimpleName() + "." + NoPrologue.class.getSimpleName() + " is allowed only for methods annotated with @" + Uninterruptible.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
return null;
}
if (prologueClass == CEntryPointOptions.AutomaticPrologue.class) {
ResolvedJavaType isolateType = providers.getMetaAccess().lookupJavaType(Isolate.class);
ResolvedJavaType threadType = providers.getMetaAccess().lookupJavaType(IsolateThread.class);
ResolvedJavaType matchType = null;
int matchesCount = 0;
for (JavaType parameterType : parameterTypes) {
ResolvedJavaType type = (ResolvedJavaType) parameterType;
if (threadType.isAssignableFrom(type) || isolateType.isAssignableFrom(type)) {
matchType = type;
matchesCount++;
}
}
if (matchesCount == 1) {
if (threadType.isAssignableFrom(matchType)) {
prologueClass = CEntryPointSetup.EnterPrologue.class;
} else {
prologueClass = CEntryPointSetup.EnterIsolatePrologue.class;
}
} else {
throw UserError.abort("@" + CEntryPoint.class.getSimpleName() + " requires exactly one parameter of type " + IsolateThread.class.getSimpleName() + " or " + Isolate.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
}
}
ResolvedJavaType prologue = providers.getMetaAccess().lookupJavaType(prologueClass);
ResolvedJavaMethod[] prologueMethods = prologue.getDeclaredMethods();
UserError.guarantee(prologueMethods.length == 1 && prologueMethods[0].isStatic(), "Prologue class must declare exactly one static method: " + targetMethod.format("%H.%n(%p)") + " -> " + prologue.toJavaName());
ValueNode[] prologueArgs = matchPrologueParameters(providers, parameterTypes, args, prologueMethods[0]);
return kit.createInvoke(prologueMethods[0], InvokeKind.Static, kit.getFrameState(), kit.bci(), prologueArgs);
}
Aggregations