use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.
the class VMThreadLocalCollector method sortThreadLocals.
public List<VMThreadLocalInfo> sortThreadLocals(Feature.CompilationAccess a, FastThreadLocal first) {
CompilationAccessImpl config = (CompilationAccessImpl) a;
sealed = true;
/*
* Find a unique static field for every VM thread local object. The field name is used to
* make the layout of VMThread deterministic.
*/
for (ResolvedJavaField f : config.getFields()) {
SharedField field = (SharedField) f;
if (field.isStatic() && field.getStorageKind() == JavaKind.Object) {
Object fieldValue = SubstrateObjectConstant.asObject(((ReadableJavaField) field).readValue(null));
if (fieldValue instanceof FastThreadLocal) {
FastThreadLocal threadLocal = (FastThreadLocal) fieldValue;
VMThreadLocalInfo info = threadLocals.get(threadLocal);
String fieldName = field.format("%H.%n");
if (!field.isFinal()) {
throw shouldNotReachHere("VMThreadLocal referenced from non-final field: " + fieldName);
} else if (info.name != null) {
throw shouldNotReachHere("VMThreadLocal referenced from two static final fields: " + info.name + ", " + fieldName);
}
info.name = fieldName;
}
}
}
for (VMThreadLocalInfo info : threadLocals.values()) {
if (info.name == null) {
shouldNotReachHere("VMThreadLocal found that is not referenced from a static final field");
}
assert info.sizeInBytes == -1;
if (info.sizeSupplier != null) {
info.sizeInBytes = NumUtil.roundUp(info.sizeSupplier.getAsInt(), 8);
} else {
info.sizeInBytes = ConfigurationValues.getObjectLayout().sizeInBytes(info.storageKind);
}
}
List<VMThreadLocalInfo> sortedThreadLocals = new ArrayList<>(threadLocals.values());
sortedThreadLocals.sort(VMThreadLocalCollector::compareThreadLocal);
if (first != null) {
VMThreadLocalInfo info = threadLocals.get(first);
assert info != null && sortedThreadLocals.contains(info);
sortedThreadLocals.remove(info);
sortedThreadLocals.add(0, info);
}
return sortedThreadLocals;
}
use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.
the class VMThreadMTFeature method handleCompareAndSet.
private boolean handleCompareAndSet(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode threadNode, ValueNode expect, ValueNode update) {
VMThreadLocalInfo threadLocalInfo = threadLocalCollector.findInfo(b, receiver.get());
b.addPush(targetMethod.getSignature().getReturnKind(), new CompareAndSetVMThreadLocalNode(threadLocalInfo, threadNode, expect, update, BarrierType.NONE));
return true;
}
use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.
the class VMThreadMTFeature method handleGetAddress.
private boolean handleGetAddress(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode threadNode) {
VMThreadLocalInfo threadLocalInfo = threadLocalCollector.findInfo(b, receiver.get());
b.addPush(targetMethod.getSignature().getReturnKind(), new AddressOfVMThreadLocalNode(threadLocalInfo, threadNode));
return true;
}
use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.
the class VMThreadMTFeature method handleGet.
private boolean handleGet(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode threadNode, boolean isVolatile) {
VMThreadLocalInfo threadLocalInfo = threadLocalCollector.findInfo(b, receiver.get());
if (isVolatile) {
b.add(new MembarNode(MemoryBarriers.JMM_PRE_VOLATILE_READ));
}
b.addPush(targetMethod.getSignature().getReturnKind(), new LoadVMThreadLocalNode(b.getMetaAccess(), threadLocalInfo, threadNode, BarrierType.NONE));
if (isVolatile) {
b.add(new MembarNode(MemoryBarriers.JMM_POST_VOLATILE_READ));
}
return true;
}
use of com.oracle.svm.core.threadlocal.VMThreadLocalInfo in project graal by oracle.
the class VMThreadSTFeature method handleGetAddress.
private boolean handleGetAddress(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
VMThreadLocalInfo threadLocalInfo = threadLocalCollector.findInfo(b, receiver.get());
VMThreadLocalSTHolderNode holder = b.add(new VMThreadLocalSTHolderNode(threadLocalInfo));
b.addPush(targetMethod.getSignature().getReturnKind(), new AddressOfVMThreadLocalNode(threadLocalInfo, holder));
return true;
}
Aggregations