use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class InfoTreeBuilder method elementKind.
private ElementKind elementKind(Collection<AccessorInfo> accessorInfos) {
ElementKind overallKind = ElementKind.UNKNOWN;
AccessorInfo overallKindAccessor = null;
for (AccessorInfo accessorInfo : accessorInfos) {
ResolvedJavaMethod method = (ResolvedJavaMethod) accessorInfo.getAnnotatedElement();
ElementKind newKind;
switch(accessorInfo.getAccessorKind()) {
case GETTER:
newKind = elementKind((ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass()));
break;
case SETTER:
newKind = elementKind((ResolvedJavaType) method.getSignature().getParameterType(accessorInfo.valueParameterNumber(false), method.getDeclaringClass()));
break;
default:
continue;
}
if (overallKind == ElementKind.UNKNOWN) {
overallKind = newKind;
overallKindAccessor = accessorInfo;
} else if (overallKind != newKind) {
nativeLibs.addError("Accessor methods mix integer, floating point, and pointer kinds", overallKindAccessor.getAnnotatedElement(), method);
}
}
return overallKind;
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class QueryResultParser method visitConstantInfo.
@Override
protected void visitConstantInfo(ConstantInfo constantInfo) {
TargetDescription target = nativeLibs.getTarget();
switch(constantInfo.getKind()) {
case INTEGER:
parseIntegerProperty(constantInfo.getSizeInfo());
parseSignedness(constantInfo.getSignednessInfo());
parseIntegerConstantValue(constantInfo.getValueInfo());
/*
* From the point of view of the C compiler, plain #define constants have the type
* int and therefore size 4. But sometimes we want to access such values as short or
* byte to avoid casts. Check the actual value of the constant, and if it fits the
* declared type of the constant, then change the actual size to the declared size.
*/
ResolvedJavaMethod method = (ResolvedJavaMethod) constantInfo.getAnnotatedElement();
ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
JavaKind returnKind = returnType.getJavaKind();
if (returnKind == JavaKind.Object) {
returnKind = target.wordJavaKind;
}
int declaredSize = target.arch.getPlatformKind(returnKind).getSizeInBytes();
int actualSize = constantInfo.getSizeInfo().getProperty();
if (declaredSize != actualSize) {
long value = (long) constantInfo.getValueInfo().getProperty();
if (value >= returnKind.getMinValue() && value <= returnKind.getMaxValue()) {
constantInfo.getSizeInfo().setProperty(declaredSize);
}
}
break;
case POINTER:
parseIntegerProperty(constantInfo.getSizeInfo());
parseIntegerConstantValue(constantInfo.getValueInfo());
break;
case FLOAT:
parseIntegerProperty(constantInfo.getSizeInfo());
parseFloatValue(constantInfo.getValueInfo());
break;
case STRING:
parseStringValue(constantInfo.getValueInfo());
break;
case BYTEARRAY:
parseByteArrayValue(constantInfo.getValueInfo());
break;
default:
throw shouldNotReachHere();
}
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class BytecodeParser method genNewMultiArray.
private void genNewMultiArray(int cpi) {
JavaType type = lookupType(cpi, MULTIANEWARRAY);
int rank = getStream().readUByte(bci() + 3);
ValueNode[] dims = new ValueNode[rank];
if (!(type instanceof ResolvedJavaType)) {
for (int i = rank - 1; i >= 0; i--) {
dims[i] = frameState.pop(JavaKind.Int);
}
handleUnresolvedNewMultiArray(type, dims);
return;
}
ResolvedJavaType resolvedType = (ResolvedJavaType) type;
ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType)) {
FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
classInitializationPlugin.apply(this, resolvedType, stateBefore);
}
for (int i = rank - 1; i >= 0; i--) {
dims[i] = frameState.pop(JavaKind.Int);
}
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleNewMultiArray(this, resolvedType, dims)) {
return;
}
}
frameState.push(JavaKind.Object, append(createNewMultiArray(resolvedType, dims)));
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class BytecodeParser method genNewInstance.
void genNewInstance(JavaType type) {
if (!(type instanceof ResolvedJavaType)) {
handleUnresolvedNewInstance(type);
return;
}
ResolvedJavaType resolvedType = (ResolvedJavaType) type;
ClassInitializationPlugin classInitializationPlugin = graphBuilderConfig.getPlugins().getClassInitializationPlugin();
if (!resolvedType.isInitialized() && classInitializationPlugin == null) {
handleUnresolvedNewInstance(type);
return;
}
ResolvedJavaType[] skippedExceptionTypes = this.graphBuilderConfig.getSkippedExceptionTypes();
if (skippedExceptionTypes != null) {
for (ResolvedJavaType exceptionType : skippedExceptionTypes) {
if (exceptionType.isAssignableFrom(resolvedType)) {
append(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, RuntimeConstraint));
return;
}
}
}
if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType)) {
FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
classInitializationPlugin.apply(this, resolvedType, stateBefore);
}
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleNewInstance(this, resolvedType)) {
return;
}
}
frameState.push(JavaKind.Object, append(createNewInstance(resolvedType, true)));
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class BytecodeParser method lookupField.
protected JavaField lookupField(int cpi, int opcode) {
maybeEagerlyResolve(cpi, opcode);
JavaField result = constantPool.lookupField(cpi, method, opcode);
assert !graphBuilderConfig.unresolvedIsError() || result instanceof ResolvedJavaField : "Not resolved: " + result;
if (parsingIntrinsic() || eagerInitializing) {
if (result instanceof ResolvedJavaField) {
ResolvedJavaType declaringClass = ((ResolvedJavaField) result).getDeclaringClass();
if (!declaringClass.isInitialized()) {
// See StaticInterfaceFieldTest
assert !eagerInitializing || declaringClass.isInterface() : "Declaring class not initialized but not an interface? " + declaringClass;
initialize(declaringClass);
}
}
}
assert !uninitializedIsError || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized()) : result;
return result;
}
Aggregations