Search in sources :

Example 6 with VMThreadLocalInfo

use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.

the class VMThreadSTFeature method handleSet.

private boolean handleSet(GraphBuilderContext b, Receiver receiver, ValueNode valueNode) {
    VMThreadLocalInfo info = threadLocalCollector.findInfo(b, receiver.get());
    VMThreadLocalSTHolderNode holder = b.add(new VMThreadLocalSTHolderNode(info));
    b.add(new StoreVMThreadLocalNode(info, holder, valueNode, BarrierType.PRECISE));
    return true;
}
Also used : StoreVMThreadLocalNode(com.oracle.svm.core.graal.thread.StoreVMThreadLocalNode) VMThreadLocalSTHolderNode(com.oracle.svm.core.graal.thread.VMThreadLocalSTHolderNode) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo)

Example 7 with VMThreadLocalInfo

use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.

the class VMThreadSTFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess config) {
    List<VMThreadLocalInfo> sortedThreadLocalInfos = threadLocalCollector.sortThreadLocals(config);
    ObjectLayout layout = ConfigurationValues.getObjectLayout();
    int nextObject = 0;
    int nextPrimitive = 0;
    for (VMThreadLocalInfo info : sortedThreadLocalInfos) {
        if (info.isObject) {
            info.offset = layout.getArrayElementOffset(JavaKind.Object, nextObject);
            nextObject += 1;
        } else {
            assert nextPrimitive % Math.min(8, info.sizeInBytes) == 0 : "alignment mismatch: " + info.sizeInBytes + ", " + nextPrimitive;
            info.offset = layout.getArrayElementOffset(JavaKind.Byte, nextPrimitive);
            nextPrimitive += info.sizeInBytes;
        }
    }
    VMThreadLocalSTSupport support = ImageSingletons.lookup(VMThreadLocalSTSupport.class);
    support.objectThreadLocals = new Object[nextObject];
    support.primitiveThreadLocals = new byte[nextPrimitive];
    /* Remember the final sorted list. */
    VMThreadLocalInfos.setInfos(sortedThreadLocalInfos);
}
Also used : VMThreadLocalSTSupport(com.oracle.svm.core.threadlocal.VMThreadLocalSTSupport) ObjectLayout(com.oracle.svm.core.config.ObjectLayout) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo)

Example 8 with VMThreadLocalInfo

use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.

the class VMThreadLocalCollector method findInfo.

public VMThreadLocalInfo findInfo(GraphBuilderContext b, ValueNode threadLocalNode) {
    if (!threadLocalNode.isConstant()) {
        throw shouldNotReachHere("Accessed VMThreadLocal is not a compile time constant: " + b.getMethod().asStackTraceElement(b.bci()));
    }
    FastThreadLocal threadLocal = (FastThreadLocal) SubstrateObjectConstant.asObject(threadLocalNode.asConstant());
    VMThreadLocalInfo result = threadLocals.get(threadLocal);
    assert result != null;
    return result;
}
Also used : FastThreadLocal(com.oracle.svm.core.threadlocal.FastThreadLocal) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo)

Example 9 with VMThreadLocalInfo

use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.

the class VMThreadMTFeature method handleSet.

private boolean handleSet(GraphBuilderContext b, Receiver receiver, ValueNode threadNode, ValueNode valueNode, boolean isVolatile) {
    VMThreadLocalInfo threadLocalInfo = threadLocalCollector.findInfo(b, receiver.get());
    if (isVolatile) {
        b.add(new MembarNode(MemoryBarriers.JMM_PRE_VOLATILE_WRITE));
    }
    b.add(new StoreVMThreadLocalNode(threadLocalInfo, threadNode, valueNode, BarrierType.NONE));
    if (isVolatile) {
        b.add(new MembarNode(MemoryBarriers.JMM_POST_VOLATILE_WRITE));
    }
    return true;
}
Also used : StoreVMThreadLocalNode(com.oracle.svm.core.graal.thread.StoreVMThreadLocalNode) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo)

Example 10 with VMThreadLocalInfo

use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.

the class VMThreadMTFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess config) {
    List<VMThreadLocalInfo> sortedThreadLocalInfos = threadLocalCollector.sortThreadLocals(config, threadLocalAtOffsetZero);
    SubstrateReferenceMap referenceMap = new SubstrateReferenceMap();
    int nextOffset = 0;
    for (VMThreadLocalInfo info : sortedThreadLocalInfos) {
        assert nextOffset % Math.min(8, info.sizeInBytes) == 0 : "alignment mismatch: " + info.sizeInBytes + ", " + nextOffset;
        if (info.isObject) {
            final boolean isCompressed = false;
            referenceMap.markReferenceAtIndex(nextOffset / info.sizeInBytes, isCompressed);
        }
        info.offset = nextOffset;
        nextOffset += info.sizeInBytes;
    }
    VMError.guarantee(threadLocalAtOffsetZero == null || threadLocalCollector.getInfo(threadLocalAtOffsetZero).offset == 0);
    ReferenceMapEncoder encoder = new ReferenceMapEncoder();
    encoder.add(referenceMap);
    objectReferenceWalker.vmThreadReferenceMapEncoding = encoder.encodeAll(null);
    objectReferenceWalker.vmThreadReferenceMapIndex = encoder.lookupEncoding(referenceMap);
    objectReferenceWalker.vmThreadSize = nextOffset;
    /* Remember the final sorted list. */
    VMThreadLocalInfos.setInfos(sortedThreadLocalInfos);
}
Also used : ReferenceMapEncoder(com.oracle.svm.core.heap.ReferenceMapEncoder) SubstrateReferenceMap(com.oracle.svm.core.heap.SubstrateReferenceMap) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo)

Aggregations

VMThreadLocalInfo (com.oracle.svm.core.threadlocal.VMThreadLocalInfo)12 VMThreadLocalSTHolderNode (com.oracle.svm.core.graal.thread.VMThreadLocalSTHolderNode)4 AddressOfVMThreadLocalNode (com.oracle.svm.core.graal.thread.AddressOfVMThreadLocalNode)2 CompareAndSetVMThreadLocalNode (com.oracle.svm.core.graal.thread.CompareAndSetVMThreadLocalNode)2 LoadVMThreadLocalNode (com.oracle.svm.core.graal.thread.LoadVMThreadLocalNode)2 StoreVMThreadLocalNode (com.oracle.svm.core.graal.thread.StoreVMThreadLocalNode)2 FastThreadLocal (com.oracle.svm.core.threadlocal.FastThreadLocal)2 MembarNode (org.graalvm.compiler.nodes.extended.MembarNode)2 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)1 ReferenceMapEncoder (com.oracle.svm.core.heap.ReferenceMapEncoder)1 SubstrateReferenceMap (com.oracle.svm.core.heap.SubstrateReferenceMap)1 SharedField (com.oracle.svm.core.meta.SharedField)1 VMThreadLocalSTSupport (com.oracle.svm.core.threadlocal.VMThreadLocalSTSupport)1 CompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)1 ArrayList (java.util.ArrayList)1 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1