Search in sources :

Example 1 with OptionDescriptorsMap

use of org.graalvm.compiler.options.OptionDescriptorsMap in project graal by oracle.

the class Target_org_graalvm_compiler_truffle_compiler_hotspot_libgraal_TruffleToLibGraalEntryPoints method duringSetup.

@Override
public void duringSetup(DuringSetupAccess access) {
    JNIRuntimeAccess.JNIRuntimeAccessibilitySupport registry = ImageSingletons.lookup(JNIRuntimeAccess.JNIRuntimeAccessibilitySupport.class);
    ImageClassLoader imageClassLoader = ((DuringSetupAccessImpl) access).getImageClassLoader();
    registerJNIConfiguration(registry, imageClassLoader);
    EconomicMap<String, OptionDescriptor> descriptors = EconomicMap.create();
    for (Class<? extends OptionDescriptors> optionsClass : imageClassLoader.findSubclasses(OptionDescriptors.class, false)) {
        if (!Modifier.isAbstract(optionsClass.getModifiers()) && !OptionDescriptorsMap.class.isAssignableFrom(optionsClass)) {
            try {
                for (OptionDescriptor d : optionsClass.getDeclaredConstructor().newInstance()) {
                    if (!(d.getOptionKey() instanceof HostedOptionKey)) {
                        descriptors.put(d.getName(), d);
                    }
                }
            } catch (ReflectiveOperationException ex) {
                throw VMError.shouldNotReachHere(ex);
            }
        }
    }
    OptionsParser.setCachedOptionDescriptors(Collections.singletonList(new OptionDescriptorsMap(descriptors)));
}
Also used : OptionDescriptor(org.graalvm.compiler.options.OptionDescriptor) HostedOptionKey(com.oracle.svm.core.option.HostedOptionKey) DuringSetupAccessImpl(com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl) OptionDescriptorsMap(org.graalvm.compiler.options.OptionDescriptorsMap) JNIRuntimeAccess(com.oracle.svm.core.jni.JNIRuntimeAccess) ImageClassLoader(com.oracle.svm.hosted.ImageClassLoader)

Aggregations

JNIRuntimeAccess (com.oracle.svm.core.jni.JNIRuntimeAccess)1 HostedOptionKey (com.oracle.svm.core.option.HostedOptionKey)1 DuringSetupAccessImpl (com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl)1 ImageClassLoader (com.oracle.svm.hosted.ImageClassLoader)1 OptionDescriptor (org.graalvm.compiler.options.OptionDescriptor)1 OptionDescriptorsMap (org.graalvm.compiler.options.OptionDescriptorsMap)1