use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class JNIJavaCallWrapperMethod method createInvoke.
private static ValueNode createInvoke(JNIGraphKit kit, ResolvedJavaMethod invokeMethod, InvokeKind kind, FrameStateBuilder state, int bci, ValueNode... args) {
int exceptionEdgeBci = kit.bci();
InvokeWithExceptionNode invoke = kit.startInvokeWithException(invokeMethod, kind, state, bci, exceptionEdgeBci, args);
kit.exceptionPart();
ExceptionObjectNode exceptionObject = kit.exceptionObject();
kit.retainPendingException(exceptionObject);
ValueNode exceptionValue = null;
if (invoke.getStackKind() != JavaKind.Void) {
exceptionValue = kit.unique(ConstantNode.defaultForKind(invoke.getStackKind()));
}
AbstractMergeNode merge = kit.endInvokeWithException();
ValueNode returnValue = null;
JavaKind returnKind = invokeMethod.getSignature().getReturnKind();
if (invoke.getStackKind() != JavaKind.Void) {
ValueNode[] inputs = { invoke, exceptionValue };
returnValue = kit.getGraph().addWithoutUnique(new ValuePhiNode(invoke.stamp(NodeView.DEFAULT), merge, inputs));
state.push(returnKind, returnValue);
}
merge.setStateAfter(state.create(bci, merge));
if (invoke.getStackKind() != JavaKind.Void) {
state.pop(returnKind);
}
return returnValue;
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class CInterfaceEnumTool method invokeEnumLookup.
private InvokeNode invokeEnumLookup(GraphBuilderTool b, CallTargetFactory callTargetFactory, FrameStateBuilder frameState, int bci, EnumInfo enumInfo, JavaKind parameterKind, ValueNode arg) {
ValueNode[] args = new ValueNode[2];
args[0] = ConstantNode.forConstant(snippetReflection.forObject(enumInfo.getRuntimeData()), b.getMetaAccess(), b.getGraph());
assert !Modifier.isStatic(convertCToJavaMethod.getModifiers()) && convertCToJavaMethod.getSignature().getParameterCount(false) == 1;
JavaKind expectedKind = convertCToJavaMethod.getSignature().getParameterType(0, null).getJavaKind();
args[1] = CInterfaceInvocationPlugin.adaptPrimitiveType(b.getGraph(), arg, parameterKind, expectedKind, false);
ResolvedJavaType convertReturnType = (ResolvedJavaType) convertCToJavaMethod.getSignature().getReturnType(null);
StampPair returnStamp = StampFactory.forDeclaredType(null, convertReturnType, false);
MethodCallTargetNode callTargetNode = b.append(callTargetFactory.createMethodCallTarget(InvokeKind.Virtual, convertCToJavaMethod, args, returnStamp, bci));
Stamp invokeStamp = StampFactory.object(TypeReference.createWithoutAssumptions(convertReturnType));
InvokeNode invoke = b.append(new InvokeNode(callTargetNode, bci, invokeStamp));
frameState.push(convertReturnType.getJavaKind(), invoke);
FrameState stateWithInvoke = frameState.create(bci, invoke);
frameState.pop(convertReturnType.getJavaKind());
invoke.setStateAfter(stateWithInvoke);
return invoke;
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class CInterfaceEnumTool method replaceEnumLookupInvoke.
boolean replaceEnumLookupInvoke(BytecodeParser p, EnumInfo enumInfo, ResolvedJavaMethod method, ValueNode[] args) {
assert Modifier.isStatic(method.getModifiers()) && method.getSignature().getParameterCount(false) == 1;
assert args.length == 1;
JavaKind methodParameterKind = method.getSignature().getParameterType(0, null).getJavaKind();
InvokeNode invokeNode = invokeEnumLookup(p, CallTargetFactory.from(p), p.getFrameStateBuilder(), p.bci(), enumInfo, methodParameterKind, args[0]);
Stamp returnStamp = p.getInvokeReturnStamp(null).getTrustedStamp();
assert returnStamp.getStackKind() == JavaKind.Object && invokeNode.stamp(NodeView.DEFAULT).getStackKind() == JavaKind.Object;
assert StampTool.typeOrNull(invokeNode.stamp(NodeView.DEFAULT)).isAssignableFrom(StampTool.typeOrNull(returnStamp));
ValueNode adapted = p.getGraph().unique(new PiNode(invokeNode, returnStamp));
p.push(CInterfaceInvocationPlugin.pushKind(method), adapted);
return true;
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class CInterfaceInvocationPlugin method replaceAccessor.
private boolean replaceAccessor(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, AccessorInfo accessorInfo, int displacement) {
StructuredGraph graph = b.getGraph();
SizableInfo sizableInfo = (SizableInfo) accessorInfo.getParent();
int elementSize = sizableInfo.getSizeInfo().getProperty();
boolean isUnsigned = sizableInfo.isUnsigned();
assert args.length == accessorInfo.parameterCount(true);
ValueNode base = args[accessorInfo.baseParameterNumber(true)];
switch(accessorInfo.getAccessorKind()) {
case ADDRESS:
{
ValueNode address = makeAddress(graph, args, accessorInfo, base, displacement, elementSize);
b.addPush(pushKind(method), address);
return true;
}
case GETTER:
{
JavaKind resultKind = wordTypes.asKind(b.getInvokeReturnType());
JavaKind readKind = kindFromSize(elementSize, resultKind);
if (readKind == JavaKind.Object) {
assert resultKind == JavaKind.Object;
} else if (readKind.getBitCount() > resultKind.getBitCount() && !readKind.isNumericFloat() && resultKind != JavaKind.Boolean) {
readKind = resultKind;
}
ValueNode address = makeAddress(graph, args, accessorInfo, base, displacement, elementSize);
LocationIdentity locationIdentity = makeLocationIdentity(b, method, args, accessorInfo);
Stamp stamp;
if (readKind == JavaKind.Object) {
stamp = b.getInvokeReturnStamp(null).getTrustedStamp();
} else if (readKind == JavaKind.Float || readKind == JavaKind.Double) {
stamp = StampFactory.forKind(readKind);
} else {
stamp = StampFactory.forInteger(readKind.getBitCount());
}
ValueNode read = readOp(b, address, locationIdentity, stamp, accessorInfo);
ValueNode adapted = adaptPrimitiveType(graph, read, readKind, resultKind == JavaKind.Boolean ? resultKind : resultKind.getStackKind(), isUnsigned);
b.push(pushKind(method), adapted);
return true;
}
case SETTER:
{
ValueNode value = args[accessorInfo.valueParameterNumber(true)];
JavaKind valueKind = value.getStackKind();
JavaKind writeKind = kindFromSize(elementSize, valueKind);
ValueNode address = makeAddress(graph, args, accessorInfo, base, displacement, elementSize);
LocationIdentity locationIdentity = makeLocationIdentity(b, method, args, accessorInfo);
ValueNode adaptedValue = adaptPrimitiveType(graph, value, valueKind, writeKind, isUnsigned);
writeOp(b, address, locationIdentity, adaptedValue, accessorInfo);
return true;
}
default:
throw shouldNotReachHere();
}
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class CInterfaceInvocationPlugin method replaceOffsetOf.
private boolean replaceOffsetOf(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, AccessorInfo accessorInfo, int displacement) {
/*
* A method annotated with @OffsetOf can be static, but does not need to be. If it is
* non-static, we just ignore the receiver.
*/
assert args.length == accessorInfo.parameterCount(!method.isStatic());
JavaKind kind = wordTypes.asKind(b.getInvokeReturnType());
b.addPush(pushKind(method), ConstantNode.forIntegerKind(kind, displacement, b.getGraph()));
return true;
}
Aggregations