Search in sources :

Example 6 with CompilationAccessImpl

use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl 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;
}
Also used : SharedField(com.oracle.svm.core.meta.SharedField) CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) ArrayList(java.util.ArrayList) FastThreadLocal(com.oracle.svm.core.threadlocal.FastThreadLocal) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) VMThreadLocalInfo(com.oracle.svm.core.threadlocal.VMThreadLocalInfo)

Example 7 with CompilationAccessImpl

use of com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl in project graal by oracle.

the class Target_org_graalvm_nativeimage_c_function_CEntryPointLiteral method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess a) {
    CompilationAccessImpl config = (CompilationAccessImpl) a;
    metaAccess = config.getMetaAccess();
    bb = null;
}
Also used : CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)

Aggregations

CompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)7 HostedMetaAccess (com.oracle.svm.hosted.meta.HostedMetaAccess)4 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)1 SharedField (com.oracle.svm.core.meta.SharedField)1 FastThreadLocal (com.oracle.svm.core.threadlocal.FastThreadLocal)1 VMThreadLocalInfo (com.oracle.svm.core.threadlocal.VMThreadLocalInfo)1 HostedUniverse (com.oracle.svm.hosted.meta.HostedUniverse)1 StrengthenStampsPhase (com.oracle.svm.hosted.phases.StrengthenStampsPhase)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Fields (org.graalvm.compiler.core.common.Fields)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 Edges (org.graalvm.compiler.graph.Edges)1 GraphEncoder (org.graalvm.compiler.nodes.GraphEncoder)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)1 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)1