use of jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod in project graal by oracle.
the class MethodHandlePlugin method handleInvoke.
@Override
public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
IntrinsicMethod intrinsicMethod = methodHandleAccess.lookupMethodHandleIntrinsic(method);
if (intrinsicMethod != null) {
InvokeKind invokeKind = b.getInvokeKind();
if (invokeKind != InvokeKind.Static) {
args[0] = b.nullCheckedValue(args[0]);
}
StampPair invokeReturnStamp = b.getInvokeReturnStamp(b.getAssumptions());
MethodHandleNode.GraphAdder adder = new MethodHandleNode.GraphAdder(b.getGraph()) {
@Override
public <T extends ValueNode> T add(T node) {
return b.add(node);
}
};
InvokeNode invoke = MethodHandleNode.tryResolveTargetInvoke(adder, methodHandleAccess, intrinsicMethod, method, b.bci(), invokeReturnStamp, args);
if (invoke == null) {
MethodHandleNode methodHandleNode = new MethodHandleNode(intrinsicMethod, invokeKind, method, b.bci(), invokeReturnStamp, args);
if (invokeReturnStamp.getTrustedStamp().getStackKind() == JavaKind.Void) {
b.add(methodHandleNode);
} else {
b.addPush(invokeReturnStamp.getTrustedStamp().getStackKind(), methodHandleNode);
}
} else {
CallTargetNode callTarget = invoke.callTarget();
NodeInputList<ValueNode> argumentsList = callTarget.arguments();
for (int i = 0; i < argumentsList.size(); ++i) {
argumentsList.initialize(i, b.append(argumentsList.get(i)));
}
boolean inlineEverything = false;
if (safeForDeoptimization) {
// If a MemberName suffix argument is dropped, the replaced call cannot
// deoptimized since the necessary frame state cannot be reconstructed.
// As such, it needs to recursively inline everything.
inlineEverything = args.length != argumentsList.size();
}
if (inlineEverything && !callTarget.targetMethod().hasBytecodes()) {
// we need to force-inline but we can not, leave the invoke as-is
return false;
}
b.handleReplacedInvoke(invoke.getInvokeKind(), callTarget.targetMethod(), argumentsList.toArray(new ValueNode[argumentsList.size()]), inlineEverything);
}
return true;
}
return false;
}
use of jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod in project graal by oracle.
the class CheckGraalIntrinsics method test.
@Test
@SuppressWarnings("try")
public void test() throws ClassNotFoundException {
HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
HotSpotProviders providers = rt.getHostBackend().getProviders();
Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins();
InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins();
HotSpotVMConfigStore store = rt.getVMConfig().getStore();
List<VMIntrinsicMethod> intrinsics = store.getIntrinsics();
List<String> missing = new ArrayList<>();
EconomicMap<String, List<Binding>> bindings = invocationPlugins.getBindings(true);
for (VMIntrinsicMethod intrinsic : intrinsics) {
InvocationPlugin plugin = findPlugin(bindings, intrinsic);
if (plugin == null) {
ResolvedJavaMethod method = resolveIntrinsic(providers.getMetaAccess(), intrinsic);
if (method != null) {
IntrinsicMethod intrinsicMethod = providers.getConstantReflection().getMethodHandleAccess().lookupMethodHandleIntrinsic(method);
if (intrinsicMethod != null) {
continue;
}
}
String m = String.format("%s.%s%s", intrinsic.declaringClass, intrinsic.name, intrinsic.descriptor);
if (!TO_BE_INVESTIGATED.contains(m) && !IGNORE.contains(m)) {
missing.add(m);
}
}
}
if (!missing.isEmpty()) {
Collections.sort(missing);
String missingString = missing.stream().collect(Collectors.joining(String.format("%n ")));
fail("missing Graal intrinsics for:%n %s", missingString);
}
}
Aggregations