use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.
the class StubUtil method descriptorFor.
/**
* Looks for a {@link StubForeignCallNode} node intrinsic named {@code name} in
* {@code stubClass} and returns a {@link ForeignCallDescriptor} based on its signature and the
* value of {@code hasSideEffect}.
*/
private static ForeignCallDescriptor descriptorFor(Class<?> stubClass, String name) {
Method found = null;
for (Method method : stubClass.getDeclaredMethods()) {
if (Modifier.isStatic(method.getModifiers()) && method.getAnnotation(NodeIntrinsic.class) != null && method.getName().equals(name)) {
if (method.getAnnotation(NodeIntrinsic.class).value().equals(StubForeignCallNode.class)) {
assert found == null : "found more than one foreign call named " + name + " in " + stubClass;
assert method.getParameterTypes().length != 0 && method.getParameterTypes()[0] == ForeignCallDescriptor.class : "first parameter of foreign call '" + name + "' in " + stubClass + " must be of type " + ForeignCallDescriptor.class.getSimpleName();
found = method;
}
}
}
assert found != null : "could not find foreign call named " + name + " in " + stubClass;
List<Class<?>> paramList = Arrays.asList(found.getParameterTypes());
Class<?>[] cCallTypes = paramList.subList(1, paramList.size()).toArray(new Class<?>[paramList.size() - 1]);
return new ForeignCallDescriptor(name, found.getReturnType(), cCallTypes);
}
use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerBinaryMath.
private void lowerBinaryMath(BinaryMathIntrinsicNode math, LoweringTool tool) {
if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
return;
}
ResolvedJavaMethod method = math.graph().method();
if (method != null) {
if (method.getAnnotation(Snippet.class) != null) {
/*
* In the context of the snippet use the LIR lowering instead of the Node lowering.
*/
return;
}
if (method.getName().equalsIgnoreCase(math.getOperation().name()) && tool.getMetaAccess().lookupJavaType(Math.class).equals(method.getDeclaringClass())) {
/*
* A root compilation of the intrinsic method should emit the full assembly
* implementation.
*/
return;
}
}
ForeignCallDescriptor foreignCall = toForeignCall(math.getOperation());
if (foreignCall != null) {
StructuredGraph graph = math.graph();
ForeignCallNode call = graph.add(new ForeignCallNode(foreignCalls, toForeignCall(math.getOperation()), math.getX(), math.getY()));
graph.addAfterFixed(tool.lastFixedNode(), call);
math.replaceAtUsages(call);
}
}
use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.
the class HotSpotHostForeignCallsProvider method buildDescriptor.
private ForeignCallDescriptor buildDescriptor(JavaKind kind, boolean aligned, boolean disjoint, boolean uninit, boolean killAny, long routine) {
assert !killAny || kind == JavaKind.Object;
String name = kind + (aligned ? "Aligned" : "") + (disjoint ? "Disjoint" : "") + (uninit ? "Uninit" : "") + "Arraycopy" + (killAny ? "KillAny" : "");
ForeignCallDescriptor desc = new ForeignCallDescriptor(name, void.class, Word.class, Word.class, Word.class);
LocationIdentity killed = killAny ? LocationIdentity.any() : NamedLocationIdentity.getArrayLocation(kind);
registerForeignCall(desc, routine, NativeCall, DESTROYS_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, killed);
return desc;
}
use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerUnaryMath.
private void lowerUnaryMath(UnaryMathIntrinsicNode math, LoweringTool tool) {
if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
return;
}
ResolvedJavaMethod method = math.graph().method();
if (method != null) {
if (method.getAnnotation(Snippet.class) != null) {
/*
* In the context of the snippet use the LIR lowering instead of the Node lowering.
*/
return;
}
if (method.getName().equalsIgnoreCase(math.getOperation().name()) && tool.getMetaAccess().lookupJavaType(Math.class).equals(method.getDeclaringClass())) {
/*
* A root compilation of the intrinsic method should emit the full assembly
* implementation.
*/
return;
}
}
ForeignCallDescriptor foreignCall = toForeignCall(math.getOperation());
if (foreignCall != null) {
StructuredGraph graph = math.graph();
ForeignCallNode call = math.graph().add(new ForeignCallNode(foreignCalls, foreignCall, math.getValue()));
graph.addAfterFixed(tool.lastFixedNode(), call);
math.replaceAtUsages(call);
}
}
Aggregations