Skip to content

Commit

Permalink
sulong: move enableExternalNativeAccess to SulongNativeOption
Browse files Browse the repository at this point in the history
  • Loading branch information
zapster committed Jan 26, 2021
1 parent 8f3a400 commit efe3683
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -85,7 +85,7 @@ public int getPriority() {

@Override
public List<OptionDescriptor> getOptionDescriptors() {
return Collections.emptyList();
return SulongNativeOption.describeOptions();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean> ENABLE_NFI = new OptionKey<>(true);
// @formatter:on

public static List<OptionDescriptor> describeOptions() {
ArrayList<OptionDescriptor> options = new ArrayList<>();
Iterator<OptionDescriptor> iterator = createDescriptors().iterator();
while (iterator.hasNext()) {
options.add(iterator.next());
}
return options;
}

public static OptionDescriptors createDescriptors() {
return new SulongNativeOptionOptionDescriptors();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ public final class SulongEngineOption {
help = "Enables using C++ code and features via interop.")
public static final OptionKey<Boolean> CXX_INTEROP = new OptionKey<>(false);

@Option(name = "llvm.enableExternalNativeAccess",
category = OptionCategory.INTERNAL,
help = "Enable Sulongs native interface.")
public static final OptionKey<Boolean> ENABLE_NFI = new OptionKey<>(true);

@Option(name = "llvm.debugSysCalls",
category = OptionCategory.INTERNAL,
help = "Turns syscall debugging on/off. " +
Expand Down

0 comments on commit efe3683

Please sign in to comment.