Skip to content

Commit dd0b294

Browse files
committed
Replace option HPyUseNativeFastPaths by HPyEnableJNIFastPaths
1 parent 8d66e60 commit dd0b294

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,8 @@ public static GraalHPyNativeSymbol getGetterFunctionName(LLVMType llvmType) {
740740
@CompilationFinal private long wcharSize = -1;
741741

742742
/**
743-
* The value of this field is computed using
744-
* {@link PythonOptions#isHPyUseNativeFastPaths(PythonLanguage)}. We store it in this final
745-
* field because the value is also used in non-PE code paths.
743+
* This field mirrors value of {@link PythonOptions#HPyEnableJNIFastPaths}. We store it in this
744+
* final field because the value is also used in non-PE code paths.
746745
*/
747746
private final boolean useNativeFastPaths;
748747

@@ -766,7 +765,7 @@ public static GraalHPyNativeSymbol getGetterFunctionName(LLVMType llvmType) {
766765
public GraalHPyContext(PythonContext context, Object hpyLibrary) {
767766
super(context, hpyLibrary, GraalHPyConversionNodeSupplier.HANDLE);
768767
this.hpyContextMembers = createMembers(context, getName());
769-
this.useNativeFastPaths = PythonOptions.isHPyUseNativeFastPaths(context.getLanguage());
768+
this.useNativeFastPaths = context.getLanguage().getEngineOption(PythonOptions.HPyEnableJNIFastPaths);
770769
}
771770

772771
protected String getName() {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import com.oracle.truffle.api.Option;
5353
import com.oracle.truffle.api.TruffleLanguage.Env;
5454
import com.oracle.truffle.api.nodes.ExplodeLoop;
55-
import com.oracle.truffle.api.utilities.TriState;
5655

5756
/**
5857
* The options for Python. Note that some options have an effect on the AST structure, and thus must
@@ -76,16 +75,6 @@ public enum HPyBackendMode {
7675
}
7776
});
7877

79-
static final OptionType<TriState> TRI_STATE_OPTION_TYPE = new OptionType<>("TriState",
80-
s -> {
81-
if (TriState.TRUE.name().equalsIgnoreCase(s)) {
82-
return TriState.TRUE;
83-
} else if (TriState.FALSE.name().equalsIgnoreCase(s)) {
84-
return TriState.FALSE;
85-
}
86-
throw new IllegalArgumentException("Backend can be one of: " + Arrays.toString(HPyBackendMode.values()));
87-
});
88-
8978
private PythonOptions() {
9079
// no instances
9180
}
@@ -183,7 +172,7 @@ private PythonOptions() {
183172

184173
@EngineOption @Option(category = OptionCategory.INTERNAL, help = "If {@code true}, code is enabled that tries to reduce expensive upcalls into the runtime" +
185174
"when HPy API functions are used. This is achieved by mirroring data in native memory.", stability = OptionStability.EXPERIMENTAL) //
186-
public static final OptionKey<TriState> HPyUseNativeFastPaths = new OptionKey<>(TriState.UNDEFINED, TRI_STATE_OPTION_TYPE);
175+
public static final OptionKey<Boolean> HPyEnableJNIFastPaths = new OptionKey<>(true);
187176

188177
@Option(category = OptionCategory.INTERNAL, help = "Specify the directory where the JNI library is located.", stability = OptionStability.EXPERIMENTAL) //
189178
public static final OptionKey<String> JNIHome = new OptionKey<>("");
@@ -418,24 +407,6 @@ public static boolean isPExceptionWithJavaStacktrace(PythonLanguage language) {
418407
return language.getEngineOption(WithJavaStacktrace) > 1;
419408
}
420409

421-
/**
422-
* Determines if native fast paths should be used for HPy extensions in ABI mode. Either the
423-
* option is specified explicitly by the user, then this value is taken. If not, fast paths will
424-
* only be used for HPy backend {@link HPyBackendMode#JNI}.
425-
*/
426-
public static boolean isHPyUseNativeFastPaths(PythonLanguage language) {
427-
TriState value = language.getEngineOption(HPyUseNativeFastPaths);
428-
switch (value) {
429-
case TRUE:
430-
return true;
431-
case FALSE:
432-
return false;
433-
case UNDEFINED:
434-
return language.getEngineOption(HPyBackend) == HPyBackendMode.JNI;
435-
}
436-
throw CompilerDirectives.shouldNotReachHere();
437-
}
438-
439410
@TruffleBoundary
440411
public static String[] getExecutableList(PythonContext context) {
441412
String option = context.getOption(ExecutableList);

0 commit comments

Comments
 (0)