Search in sources :

Example 1 with AccessorInfo

use of com.oracle.svm.hosted.c.info.AccessorInfo in project graal by oracle.

the class RawStructureLayoutPlanner method computeSize.

private void computeSize(StructFieldInfo info) {
    AccessorInfo ainfo = info.getAccessorInfo();
    /**
     * Resolve field size using the declared type in its accessors. Note that the field offsets
     * are not calculated before visiting all StructFieldInfos and collecting all field types.
     */
    ResolvedJavaMethod accessor = (ResolvedJavaMethod) ainfo.getAnnotatedElement();
    ResolvedJavaType fieldType;
    if (ainfo.getAccessorKind() == AccessorKind.GETTER) {
        fieldType = (ResolvedJavaType) accessor.getSignature().getReturnType(null);
    } else if (ainfo.getAccessorKind() == AccessorKind.SETTER) {
        fieldType = (ResolvedJavaType) accessor.getSignature().getParameterType(ainfo.valueParameterNumber(false), null);
    } else {
        throw shouldNotReachHere("Unexpected accessor kind " + ainfo.getAccessorKind());
    }
    TargetDescription target = nativeLibs.getTarget();
    int declaredSize = target.arch.getPlatformKind(fieldType.getJavaKind()).getSizeInBytes();
    info.getSizeInfo().setProperty(declaredSize);
    if (info.getKind() == ElementKind.INTEGER) {
        info.getSignednessInfo().setProperty(nativeLibs.isSigned(fieldType) ? SignednessValue.SIGNED : SignednessValue.UNSIGNED);
    }
}
Also used : TargetDescription(jdk.vm.ci.code.TargetDescription) AccessorInfo(com.oracle.svm.hosted.c.info.AccessorInfo) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

AccessorInfo (com.oracle.svm.hosted.c.info.AccessorInfo)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1