diff --git a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/NativeConfigurationFactory.java b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/NativeConfigurationFactory.java index cd08561b8aa5..ed3aa4b385b8 100644 --- a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/NativeConfigurationFactory.java +++ b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/NativeConfigurationFactory.java @@ -31,9 +31,9 @@ import com.oracle.truffle.llvm.nativemode.NativeConfigurationFactory.Key; -import java.util.Collections; import java.util.List; +import com.oracle.truffle.llvm.nativemode.runtime.SulongNativeOption; import org.graalvm.options.OptionDescriptor; import com.oracle.truffle.llvm.runtime.ContextExtension; @@ -52,7 +52,7 @@ public static final class Key { public Key(OptionValues options) { this.loadCxxLibraries = options.get(SulongEngineOption.LOAD_CXX_LIBRARIES); - this.enableNFI = options.get(SulongEngineOption.ENABLE_NFI); + this.enableNFI = options.get(SulongNativeOption.ENABLE_NFI); } @Override @@ -85,7 +85,7 @@ public int getPriority() { @Override public List getOptionDescriptors() { - return Collections.emptyList(); + return SulongNativeOption.describeOptions(); } @Override diff --git a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/NFIContextExtension.java b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/NFIContextExtension.java index c8243423ddf0..599e29aeccba 100644 --- a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/NFIContextExtension.java +++ b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/NFIContextExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. * * All rights reserved. * @@ -55,7 +55,6 @@ import com.oracle.truffle.llvm.runtime.except.LLVMLinkerException; import com.oracle.truffle.llvm.runtime.interop.nfi.LLVMNativeWrapper; import com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode; -import com.oracle.truffle.llvm.runtime.options.SulongEngineOption; import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer; import com.oracle.truffle.llvm.runtime.types.FunctionType; import com.oracle.truffle.llvm.runtime.types.PointerType; @@ -202,7 +201,7 @@ public NativeContextExtension create(Env env) { private Object[] wellKnownFunctionCache; private NFIContextExtension(Env env, SignatureSourceCache signatureSourceCache) { - assert env.getOptions().get(SulongEngineOption.ENABLE_NFI); + assert env.getOptions().get(SulongNativeOption.ENABLE_NFI); this.env = env; this.signatureSourceCache = signatureSourceCache; this.wellKnownFunctionCache = new Object[WELL_KNOWN_CACHE_INITIAL_SIZE]; diff --git a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/SulongNativeOption.java b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/SulongNativeOption.java new file mode 100644 index 000000000000..7d7ba2ee9e16 --- /dev/null +++ b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/SulongNativeOption.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.oracle.truffle.llvm.nativemode.runtime; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.graalvm.options.OptionCategory; +import org.graalvm.options.OptionDescriptor; +import org.graalvm.options.OptionDescriptors; +import org.graalvm.options.OptionKey; + +import com.oracle.truffle.api.Option; + +public final class SulongNativeOption { + + // @formatter:off + @Option(name = "llvm.enableExternalNativeAccess", + category = OptionCategory.INTERNAL, + help = "Enable Sulongs native interface.") + public static final OptionKey ENABLE_NFI = new OptionKey<>(true); + // @formatter:on + + public static List describeOptions() { + ArrayList options = new ArrayList<>(); + Iterator iterator = createDescriptors().iterator(); + while (iterator.hasNext()) { + options.add(iterator.next()); + } + return options; + } + + public static OptionDescriptors createDescriptors() { + return new SulongNativeOptionOptionDescriptors(); + } + +} diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java index 7b0b7e85553e..9b852bb769dc 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/options/SulongEngineOption.java @@ -79,11 +79,6 @@ public final class SulongEngineOption { help = "Enables using C++ code and features via interop.") public static final OptionKey CXX_INTEROP = new OptionKey<>(false); - @Option(name = "llvm.enableExternalNativeAccess", - category = OptionCategory.INTERNAL, - help = "Enable Sulongs native interface.") - public static final OptionKey ENABLE_NFI = new OptionKey<>(true); - @Option(name = "llvm.debugSysCalls", category = OptionCategory.INTERNAL, help = "Turns syscall debugging on/off. " +