use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class CEntryPointCallStubMethod method generateEpilogue.
private InvokeNode generateEpilogue(HostedProviders providers, SubstrateGraphKit kit) {
Class<?> epilogueClass = entryPointData.getEpilogue();
if (epilogueClass == NoEpilogue.class) {
UserError.guarantee(targetMethod.getAnnotation(Uninterruptible.class) != null, CEntryPointOptions.class.getSimpleName() + "." + NoEpilogue.class.getSimpleName() + " is allowed only for methods annotated with @" + Uninterruptible.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
return null;
}
ResolvedJavaType epilogue = providers.getMetaAccess().lookupJavaType(epilogueClass);
ResolvedJavaMethod[] epilogueMethods = epilogue.getDeclaredMethods();
UserError.guarantee(epilogueMethods.length == 1 && epilogueMethods[0].isStatic() && epilogueMethods[0].getSignature().getParameterCount(false) == 0, "Epilogue class must declare exactly one static method without parameters: " + targetMethod.format("%H.%n(%p)") + " -> " + epilogue.toJavaName());
return kit.createInvoke(epilogueMethods[0], InvokeKind.Static, kit.getFrameState(), kit.bci());
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class CEntryPointCallStubMethod method create.
static CEntryPointCallStubMethod create(AnalysisMethod targetMethod, CEntryPointData entryPointData, AnalysisMetaAccess metaAccess) {
ResolvedJavaMethod unwrappedMethod = targetMethod.getWrapped();
MetaAccessProvider unwrappedMetaAccess = metaAccess.getWrapped();
ResolvedJavaType declaringClass = unwrappedMetaAccess.lookupJavaType(CEntryPointCallStubs.class);
ConstantPool constantPool = CEntryPointCallStubs.getConstantPool(unwrappedMetaAccess);
return new CEntryPointCallStubMethod(entryPointData, unwrappedMethod, declaringClass, constantPool);
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class NativeLibraries method findElementInfo.
public ElementInfo findElementInfo(Object e) {
Object element = unwrap(e);
ElementInfo result = elementToInfo.get(element);
if (result == null && element instanceof ResolvedJavaType && ((ResolvedJavaType) element).getInterfaces().length == 1) {
result = findElementInfo(((ResolvedJavaType) element).getInterfaces()[0]);
}
return result;
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class InfoTreeBuilder method accessorValid.
private boolean accessorValid(AccessorInfo accessorInfo) {
ResolvedJavaMethod method = (ResolvedJavaMethod) accessorInfo.getAnnotatedElement();
int expectedParamCount = accessorInfo.parameterCount(false);
int actualParamCount = method.getSignature().getParameterCount(false);
if (actualParamCount != expectedParamCount) {
nativeLibs.addError("Wrong number of parameters: expected " + expectedParamCount + "; found " + actualParamCount, method);
return false;
}
if (accessorInfo.isIndexed()) {
ResolvedJavaType paramType = (ResolvedJavaType) method.getSignature().getParameterType(accessorInfo.indexParameterNumber(false), method.getDeclaringClass());
if (paramType.getJavaKind() != JavaKind.Int && paramType.getJavaKind() != JavaKind.Long && !nativeLibs.isSigned(paramType)) {
nativeLibs.addError("Wrong type of index parameter 0: expected int, long, or Signed; found " + paramType.toJavaName(true), method);
return false;
}
}
if (accessorInfo.hasLocationIdentityParameter() && accessorInfo.hasUniqueLocationIdentity()) {
nativeLibs.addError("Method cannot have annotation @" + UniqueLocationIdentity.class.getSimpleName() + " and a LocationIdentity parameter", method);
return false;
}
if (accessorInfo.hasLocationIdentityParameter()) {
ResolvedJavaType paramType = (ResolvedJavaType) method.getSignature().getParameterType(accessorInfo.locationIdentityParameterNumber(false), method.getDeclaringClass());
if (!nativeLibs.getLocationIdentityType().equals(paramType)) {
nativeLibs.addError("Wrong type of locationIdentity parameter: expected " + nativeLibs.getLocationIdentityType().toJavaName(true) + "; found " + paramType.toJavaName(true), method);
return false;
}
}
ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
if (accessorInfo.getAccessorKind() == AccessorKind.ADDRESS) {
if (!nativeLibs.isPointerBase(returnType) || nativeLibs.isSigned(returnType) || nativeLibs.isUnsigned(returnType)) {
nativeLibs.addError("Wrong return type: expected a pointer type; found " + returnType.toJavaName(true), method);
return false;
}
}
if (accessorInfo.getAccessorKind() == AccessorKind.OFFSET) {
if (!(returnType.getJavaKind().isNumericInteger() || nativeLibs.isUnsigned(returnType))) {
nativeLibs.addError("Wrong return type: expected an integer numeric type or Unsigned; found " + returnType.toJavaName(true), method);
return false;
}
}
if (!checkObjectType(returnType, method)) {
return false;
}
for (int i = 0; i < method.getSignature().getParameterCount(false); i++) {
ResolvedJavaType paramType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
if (!checkObjectType(paramType, method)) {
return false;
}
}
return true;
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class InfoTreeBuilder method createConstantInfo.
protected void createConstantInfo(ResolvedJavaMethod method) {
int actualParamCount = method.getSignature().getParameterCount(false);
if (actualParamCount != 0) {
nativeLibs.addError("Wrong number of parameters: expected 0; found " + actualParamCount, method);
return;
}
ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
if (returnType.getJavaKind() == JavaKind.Void || (returnType.getJavaKind() == JavaKind.Object && !nativeLibs.isString(returnType) && !nativeLibs.isByteArray(returnType) && !nativeLibs.isWordBase(returnType))) {
nativeLibs.addError("Wrong return type: expected a primitive type, String, or a Word type; found " + returnType.toJavaName(true), method);
return;
}
String constantName = getConstantName(method);
ElementKind elementKind = elementKind(returnType);
ConstantInfo constantInfo = new ConstantInfo(constantName, elementKind, method);
nativeCodeInfo.adoptChild(constantInfo);
nativeLibs.registerElementInfo(method, constantInfo);
}
Aggregations