Search in sources :

Example 1 with RUN_TIME

use of com.oracle.svm.hosted.classinitialization.InitKind.RUN_TIME in project graal by oracle.

the class ClassInitializationFeature method initializeSafeDelayedClasses.

/**
 * Initializes all classes that are considered delayed by the system. Classes specified by the
 * user will not be delayed.
 */
private Set<Class<?>> initializeSafeDelayedClasses(TypeInitializerGraph initGraph) {
    Set<Class<?>> provenSafe = new HashSet<>();
    classInitializationSupport.setConfigurationSealed(false);
    classInitializationSupport.classesWithKind(RUN_TIME).stream().filter(t -> metaAccess.optionalLookupJavaType(t).isPresent()).filter(t -> metaAccess.lookupJavaType(t).isReachable()).filter(t -> classInitializationSupport.canBeProvenSafe(t)).forEach(c -> {
        AnalysisType type = metaAccess.lookupJavaType(c);
        if (!initGraph.isUnsafe(type)) {
            classInitializationSupport.forceInitializeHosted(c, "proven safe to initialize", true);
            /*
                                 * See if initialization worked--it can fail due to implicit
                                 * exceptions.
                                 */
            if (!classInitializationSupport.shouldInitializeAtRuntime(c)) {
                provenSafe.add(c);
                ClassInitializationInfo initializationInfo = type.getClassInitializer() == null ? ClassInitializationInfo.NO_INITIALIZER_INFO_SINGLETON : ClassInitializationInfo.INITIALIZED_INFO_SINGLETON;
                DynamicHub hub = ((SVMHost) universe.hostVM()).dynamicHub(type);
                hub.setClassInitializationInfo(initializationInfo);
                universe.getHeapScanner().rescanField(hub, dynamicHubClassInitializationInfoField);
            }
        }
    });
    return provenSafe;
}
Also used : RUN_TIME(com.oracle.svm.hosted.classinitialization.InitKind.RUN_TIME) BeforeAnalysisAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl) SubstrateOptionsParser(com.oracle.svm.core.option.SubstrateOptionsParser) Arrays(java.util.Arrays) GraalFeature(com.oracle.svm.core.graal.GraalFeature) SubstrateOptions(com.oracle.svm.core.SubstrateOptions) NodeLoweringProvider(com.oracle.svm.core.graal.snippets.NodeLoweringProvider) AutomaticFeature(com.oracle.svm.core.annotate.AutomaticFeature) BUILD_TIME(com.oracle.svm.hosted.classinitialization.InitKind.BUILD_TIME) RERUN(com.oracle.svm.hosted.classinitialization.InitKind.RERUN) AnalysisUniverse(com.oracle.graal.pointsto.meta.AnalysisUniverse) DynamicHub(com.oracle.svm.core.hub.DynamicHub) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Pair(org.graalvm.collections.Pair) SVMHost(com.oracle.svm.hosted.SVMHost) TimerCollection(com.oracle.graal.pointsto.util.TimerCollection) Map(java.util.Map) AnalysisMetaAccess(com.oracle.graal.pointsto.meta.AnalysisMetaAccess) UserError(com.oracle.svm.core.util.UserError) ClassInitializationInfo(com.oracle.svm.core.classinitialization.ClassInitializationInfo) EnsureClassInitializedSnippets(com.oracle.svm.core.classinitialization.EnsureClassInitializedSnippets) AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) PrintWriter(java.io.PrintWriter) OptionValues(org.graalvm.compiler.options.OptionValues) SubstrateForeignCallsProvider(com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider) Timer(com.oracle.graal.pointsto.util.Timer) RuntimeConfiguration(com.oracle.svm.core.graal.meta.RuntimeConfiguration) ReportUtils(com.oracle.graal.pointsto.reports.ReportUtils) Set(java.util.Set) FeatureImpl(com.oracle.svm.hosted.FeatureImpl) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) List(java.util.List) SnippetRuntime(com.oracle.svm.core.snippets.SnippetRuntime) Node(org.graalvm.compiler.graph.Node) UnsupportedFeatureException(com.oracle.graal.pointsto.constraints.UnsupportedFeatureException) Comparator(java.util.Comparator) Providers(org.graalvm.compiler.phases.util.Providers) AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) SVMHost(com.oracle.svm.hosted.SVMHost) DynamicHub(com.oracle.svm.core.hub.DynamicHub) ClassInitializationInfo(com.oracle.svm.core.classinitialization.ClassInitializationInfo) HashSet(java.util.HashSet)

Aggregations

UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)1 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)1 AnalysisUniverse (com.oracle.graal.pointsto.meta.AnalysisUniverse)1 ReportUtils (com.oracle.graal.pointsto.reports.ReportUtils)1 Timer (com.oracle.graal.pointsto.util.Timer)1 TimerCollection (com.oracle.graal.pointsto.util.TimerCollection)1 SubstrateOptions (com.oracle.svm.core.SubstrateOptions)1 AutomaticFeature (com.oracle.svm.core.annotate.AutomaticFeature)1 ClassInitializationInfo (com.oracle.svm.core.classinitialization.ClassInitializationInfo)1 EnsureClassInitializedSnippets (com.oracle.svm.core.classinitialization.EnsureClassInitializedSnippets)1 GraalFeature (com.oracle.svm.core.graal.GraalFeature)1 RuntimeConfiguration (com.oracle.svm.core.graal.meta.RuntimeConfiguration)1 SubstrateForeignCallsProvider (com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider)1 NodeLoweringProvider (com.oracle.svm.core.graal.snippets.NodeLoweringProvider)1 DynamicHub (com.oracle.svm.core.hub.DynamicHub)1 SubstrateOptionsParser (com.oracle.svm.core.option.SubstrateOptionsParser)1 SnippetRuntime (com.oracle.svm.core.snippets.SnippetRuntime)1 UserError (com.oracle.svm.core.util.UserError)1