Search in sources :

Example 1 with HotSpotReferenceMap

use of jdk.vm.ci.hotspot.HotSpotReferenceMap in project graal by oracle.

the class HotSpotReferenceMapBuilder method finish.

@Override
public ReferenceMap finish(LIRFrameState state) {
    Location[] objects;
    Location[] derivedBase;
    int[] sizeInBytes;
    if (objectCount == 0) {
        objects = NO_LOCATIONS;
        derivedBase = NO_LOCATIONS;
        sizeInBytes = NO_SIZES;
    } else {
        objects = new Location[objectCount];
        derivedBase = new Location[objectCount];
        sizeInBytes = new int[objectCount];
    }
    int idx = 0;
    for (Value obj : objectValues) {
        LIRKind kind = (LIRKind) obj.getValueKind();
        int bytes = bytesPerElement(kind);
        if (kind.isUnknownReference()) {
            throw GraalError.shouldNotReachHere(String.format("unknown reference alive across safepoint: %s", obj));
        } else {
            Location base = null;
            if (kind.isDerivedReference()) {
                Variable baseVariable = (Variable) kind.getDerivedReferenceBase();
                Value baseValue = state.getLiveBasePointers().get(baseVariable.index);
                assert baseValue.getPlatformKind().getVectorLength() == 1 && ((LIRKind) baseValue.getValueKind()).isReference(0) && !((LIRKind) baseValue.getValueKind()).isDerivedReference();
                base = toLocation(baseValue, 0);
            }
            for (int i = 0; i < kind.getPlatformKind().getVectorLength(); i++) {
                if (kind.isReference(i)) {
                    assert kind.isCompressedReference(i) ? (bytes < uncompressedReferenceSize) : (bytes == uncompressedReferenceSize);
                    objects[idx] = toLocation(obj, i * bytes);
                    derivedBase[idx] = base;
                    sizeInBytes[idx] = bytes;
                    idx++;
                }
            }
        }
    }
    return new HotSpotReferenceMap(objects, derivedBase, sizeInBytes, maxRegisterSize);
}
Also used : Variable(org.graalvm.compiler.lir.Variable) Value(jdk.vm.ci.meta.Value) LIRKind(org.graalvm.compiler.core.common.LIRKind) HotSpotReferenceMap(jdk.vm.ci.hotspot.HotSpotReferenceMap) Location(jdk.vm.ci.code.Location)

Aggregations

Location (jdk.vm.ci.code.Location)1 HotSpotReferenceMap (jdk.vm.ci.hotspot.HotSpotReferenceMap)1 Value (jdk.vm.ci.meta.Value)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1 Variable (org.graalvm.compiler.lir.Variable)1