use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class AnalysisType method resolveMethod.
@Override
public AnalysisMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) {
Object resolvedMethod = resolvedMethods.get(method);
if (resolvedMethod == null) {
ResolvedJavaMethod substMethod = universe.substitutions.resolve(((AnalysisMethod) method).wrapped);
/*
* We do not want any access checks to be performed, so we use the method's declaring
* class as the caller type.
*/
ResolvedJavaType substCallerType = substMethod.getDeclaringClass();
Object newResolvedMethod = universe.lookup(wrapped.resolveMethod(substMethod, substCallerType));
if (newResolvedMethod == null) {
newResolvedMethod = NULL_METHOD;
}
Object oldResolvedMethod = resolvedMethods.putIfAbsent(method, newResolvedMethod);
resolvedMethod = oldResolvedMethod != null ? oldResolvedMethod : newResolvedMethod;
}
return resolvedMethod == NULL_METHOD ? null : (AnalysisMethod) resolvedMethod;
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class AnalysisUniverse method lookupAllowUnresolved.
@Override
public JavaType lookupAllowUnresolved(JavaType rawType) {
if (rawType == null) {
return null;
}
if (!(rawType instanceof ResolvedJavaType)) {
return rawType;
}
assert !(rawType instanceof AnalysisType) : "lookupAllowUnresolved does not support analysis types.";
ResolvedJavaType hostType = (ResolvedJavaType) rawType;
ResolvedJavaType type = substitutions.lookup(hostType);
AnalysisType result = optionalLookup(type);
if (result == null) {
result = createType(type, hostType);
}
assert typesById[result.getId()].equals(result);
return result;
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class UniverseMetaAccess method lookupJavaType0.
private ResolvedJavaType lookupJavaType0(Class<?> clazz) {
ResolvedJavaType result = universe.lookup(wrapped.lookupJavaType(clazz));
ResolvedJavaType existing = typeCache.put(clazz, result);
assert existing == null || existing.equals(result);
return result;
}
use of jdk.vm.ci.meta.ResolvedJavaType 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.ResolvedJavaType 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