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;
}
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);
}
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;
}
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;
}
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);
}
Aggregations