Skip to content

Commit 5914356

Browse files
committed
[GR-43440] Minor fixes: remove dead code, all lambdas in PBytecodeRootNode as field, mx graalpytest.
PullRequest: graalpython/3283
2 parents 33a4736 + 61211e3 commit 5914356

File tree

6 files changed

+15
-21
lines changed

6 files changed

+15
-21
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
395395
private static final NodeSupplier<FloatBuiltins.PowNode> NODE_FLOAT_POW = FloatBuiltins.PowNode::create;
396396
private static final NodeSupplier<HashingStorageFromListSequenceStorageNode> NODE_HASHING_STORAGE_FROM_SEQUENCE = HashingStorageFromListSequenceStorageNode::create;
397397
private static final NodeSupplier<MatchClassNode> NODE_MATCH_CLASS = MatchClassNode::create;
398+
private static final IntNodeFunction<ListFromStackNode> LIST_FROM_STACK_NODE = ListFromStackNodeGen::create;
399+
private static final IntNodeFunction<TupleFromStackNode> TUPLE_FROM_STACK_NODE = TupleFromStackNodeGen::create;
398400

399401
private static final IntNodeFunction<UnaryOpNode> UNARY_OP_FACTORY = (int op) -> {
400402
switch (op) {
@@ -5570,13 +5572,13 @@ private int bytecodeCollectionFromStack(VirtualFrame virtualFrame, int type, int
55705572
Object res = null;
55715573
switch (type) {
55725574
case CollectionBits.KIND_LIST: {
5573-
ListFromStackNode storageFromStackNode = insertChildNodeInt(localNodes, nodeIndex, ListFromStackNodeGen.class, ListFromStackNodeGen::create, count);
5575+
ListFromStackNode storageFromStackNode = insertChildNodeInt(localNodes, nodeIndex, ListFromStackNodeGen.class, LIST_FROM_STACK_NODE, count);
55745576
SequenceStorage store = storageFromStackNode.execute(virtualFrame, stackTop - count + 1, stackTop + 1);
55755577
res = factory.createList(store, storageFromStackNode);
55765578
break;
55775579
}
55785580
case CollectionBits.KIND_TUPLE: {
5579-
TupleFromStackNode storageFromStackNode = insertChildNodeInt(localNodes, nodeIndex, TupleFromStackNodeGen.class, TupleFromStackNodeGen::create, count);
5581+
TupleFromStackNode storageFromStackNode = insertChildNodeInt(localNodes, nodeIndex, TupleFromStackNodeGen.class, TUPLE_FROM_STACK_NODE, count);
55805582
SequenceStorage store = storageFromStackNode.execute(virtualFrame, stackTop - count + 1, stackTop + 1);
55815583
res = factory.createTuple(store);
55825584
break;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonTernaryBuiltinNode.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -45,9 +45,5 @@
4545

4646
public abstract class PythonTernaryBuiltinNode extends PythonBuiltinBaseNode {
4747

48-
public Object execute(VirtualFrame frame, Object arg, Object arg2, Object arg3) {
49-
return execute1(frame, arg, arg2, arg3);
50-
}
51-
52-
protected abstract Object execute1(VirtualFrame frame, Object arg, Object arg2, Object arg3);
48+
public abstract Object execute(VirtualFrame frame, Object arg, Object arg2, Object arg3);
5349
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -250,7 +250,7 @@ private Object loadLibrary(PythonContext context) {
250250
throw new RuntimeException(String.format(
251251
"Cannot load supporting native library '%s' because the native access is not allowed. " +
252252
"The native access should be allowed when running GraalPython via the graalpython command. " +
253-
"If you are embedding GraalPython using the Context API, make sure to allow native access using 'allowNativeAccess(true)'. %s",
253+
"If you are embedding GraalPy using the Context API, make sure to allow native access using 'allowNativeAccess(true)'. %s",
254254
name,
255255
noNativeAccessHelp));
256256
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private PythonOptions() {
177177
@Option(category = OptionCategory.USER, help = "Equivalent to the Python -B flag. Don't write bytecode files.", usageSyntax = "true|false", stability = OptionStability.STABLE) //
178178
public static final OptionKey<Boolean> DontWriteBytecodeFlag = new OptionKey<>(true);
179179

180-
@Option(category = OptionCategory.USER, help = "If this is set, GraalPython will write .pyc files in a mirror directory tree at this path, " +
180+
@Option(category = OptionCategory.USER, help = "If this is set, GraalPy will write .pyc files in a mirror directory tree at this path, " +
181181
"instead of in __pycache__ directories within the source tree. " +
182182
"Equivalent to setting the PYTHONPYCACHEPREFIX environment variable for the standard launcher.", usageSyntax = "<path>", stability = OptionStability.STABLE) //
183183
public static final OptionKey<TruffleString> PyCachePrefix = new OptionKey<>(T_EMPTY_STRING, TS_OPTION_TYPE);
@@ -320,7 +320,7 @@ private PythonOptions() {
320320
public static final OptionKey<TruffleString> Executable = new OptionKey<>(T_EMPTY_STRING, TS_OPTION_TYPE);
321321

322322
@Option(category = OptionCategory.EXPERT, usageSyntax = "<cmdPart>[" + J_STRING_LIST_SEPARATOR +
323-
"<cmdPart>]", help = "The executed command list as string joined by the executable list separator char. This must always correspond to the real, valid command list used to run GraalPython.") //
323+
"<cmdPart>]", help = "The executed command list as string joined by the executable list separator char. This must always correspond to the real, valid command list used to run GraalPy.") //
324324
public static final OptionKey<TruffleString> ExecutableList = new OptionKey<>(T_EMPTY_STRING, TS_OPTION_TYPE);
325325

326326
@Option(category = OptionCategory.EXPERT, usageSyntax = "", help = "Option used by the venvlauncher to pass on the launcher target command", stability = OptionStability.STABLE) //
@@ -365,7 +365,7 @@ private PythonOptions() {
365365
@Option(category = OptionCategory.EXPERT, usageSyntax = "true|false", help = "Use the experimental panama backend for NFI.", stability = OptionStability.EXPERIMENTAL) //
366366
public static final OptionKey<Boolean> UsePanama = new OptionKey<>(false);
367367

368-
@Option(category = OptionCategory.EXPERT, usageSyntax = "true|false", help = "Set by the launcher to true (false means that GraalPython is being embedded in an application).") //
368+
@Option(category = OptionCategory.EXPERT, usageSyntax = "true|false", help = "Set by the launcher to true (false means that GraalPy is being embedded in an application).") //
369369
public static final OptionKey<Boolean> RunViaLauncher = new OptionKey<>(false);
370370

371371
@Option(category = OptionCategory.EXPERT, usageSyntax = "true|false", help = "Enable built-in functions on the __graalpython__ module that are useful for debugging.") //

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/locale/PythonLocale.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -40,8 +40,6 @@
4040
*/
4141
package com.oracle.graal.python.runtime.locale;
4242

43-
import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
44-
4543
import java.util.Locale;
4644
import java.util.Locale.Category;
4745

@@ -50,7 +48,6 @@
5048
import com.oracle.truffle.api.CompilerAsserts;
5149
import com.oracle.truffle.api.TruffleLanguage.Env;
5250
import com.oracle.truffle.api.TruffleLogger;
53-
import com.oracle.truffle.api.strings.TruffleString;
5451

5552
/**
5653
* Abstraction of the POSIX locale settings.
@@ -64,7 +61,7 @@
6461
*
6562
* <li>
6663
* <ul>
67-
* localeconv builtin, which is thin wrapped around libC's localeconv
64+
* localeconv builtin, which is thin wrapper around libC's localeconv
6865
* </ul>
6966
* <ul>
7067
* from native code: directly locale sensitive libC functions
@@ -89,7 +86,6 @@
8986
* current locale, but get the locale from Python context.
9087
*/
9188
public final class PythonLocale {
92-
public static final TruffleString T_GETDEFAULTLOCALE = tsLiteral("__getdefaultlocale");
9389
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(PythonLocale.class);
9490

9591
public static final int LC_ALL = 6;
@@ -101,7 +97,7 @@ public final class PythonLocale {
10197
public static final int LC_TIME = 2;
10298

10399
// We should have separate fields for each POSIX category and use them in the right places in
104-
// GraalPython codebase. JVM does not recognize this many categories, but the interface of
100+
// GraalPy codebase. JVM does not recognize this many categories, but the interface of
105101
// PythonLocale pretends that we do.
106102

107103
private final Locale displayLocale;

mx.graalpython/mx_graalpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ def graalpytest(args):
10931093
# if we got a binary path it's most likely CPython, so don't add graalpython args
10941094
if not args.python:
10951095
cmd_args += ["--experimental-options=true", "--python.EnableDebuggingBuiltins"]
1096-
elif args.python.endswith('graalpy') or args.python.endswith('graalpy-lt'):
1096+
elif 'graalpy' in os.path.basename(args.python):
10971097
gp_args = ["--vm.ea", "--vm.esa", "--experimental-options=true", "--python.EnableDebuggingBuiltins"]
10981098
mx.log(f"Executable seems to be GraalPy, prepending arguments: {gp_args}")
10991099
cmd_args += gp_args

0 commit comments

Comments
 (0)