Skip to content

Commit ed50e8f

Browse files
committed
Fix locations & get graalpytest running without crashing again
1 parent 41bbd27 commit ed50e8f

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

Diff for: graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ public static final class MakeSet {
14811481
public static PSet perform(VirtualFrame frame, Object[] elements,
14821482
@Bind("$root") PBytecodeDSLRootNode rootNode,
14831483
@Bind("this") Node node,
1484-
@Cached(value = "elements.length", neverDefault = true) int length,
1484+
@Cached(value = "elements.length", neverDefault = false) int length,
14851485
@Cached SetNodes.AddNode addNode,
14861486
@Cached HashingCollectionNodes.SetItemNode setItemNode) {
14871487
// TODO (GR-52217): make length a DSL constant.

Diff for: graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,25 @@ private static void processBytecodeFrame(Frame frameToMaterialize, PFrame pyFram
182182
if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
183183
BytecodeDSLFrameInfo bytecodeDSLFrameInfo = (BytecodeDSLFrameInfo) info;
184184
PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode();
185-
if (location instanceof PBytecodeDSLRootNode) {
186-
throw new AssertionError("The root node was passed as a location, but the root node is insufficient for identifying a bytecode location.");
187-
} else if (location.getRootNode() != rootNode) {
185+
186+
if (location.getRootNode() != rootNode) {
188187
throw new AssertionError("A node that did not belong to this root node was passed as a location.");
189188
}
190-
BytecodeNode bytecodeNode = BytecodeNode.get(location);
191-
pyFrame.setBci(bytecodeNode.getBytecodeLocation(frameToMaterialize, location).getBytecodeIndex());
192-
pyFrame.setLocation(bytecodeNode);
189+
190+
if (location instanceof PBytecodeDSLRootNode) {
191+
/**
192+
* Sometimes we don't have a precise location (see
193+
* {@link ReadCallerFrameNode#getFrame}). Set bci to -1 to mark the location as
194+
* unknown.
195+
*/
196+
pyFrame.setBci(-1);
197+
pyFrame.setLocation(location);
198+
} else {
199+
BytecodeNode bytecodeNode = BytecodeNode.get(location);
200+
assert bytecodeNode != null;
201+
pyFrame.setBci(bytecodeNode.getBytecodeLocation(frameToMaterialize, location).getBytecodeIndex());
202+
pyFrame.setLocation(bytecodeNode);
203+
}
193204
} else {
194205
BytecodeFrameInfo bytecodeFrameInfo = (BytecodeFrameInfo) info;
195206
pyFrame.setBci(bytecodeFrameInfo.getBci(frameToMaterialize));

Diff for: mx.graalpython/mx_graalpython.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,10 @@ def update_unittest_tags(args):
752752
# These test would work on JVM too, but they are prohibitively slow due to a large amount of subprocesses
753753
AOT_ONLY_TESTS = ["test_patched_pip.py", "test_multiprocessing_spawn.py"]
754754

755-
# This test hangs the test runner.
756-
BYTECODE_DSL_INCOMPATIBLE_TESTS = ["test_pdb.py"]
755+
BYTECODE_DSL_INCOMPATIBLE_TESTS = [
756+
"test_pdb.py", # This test hangs the test runner.
757+
"test_codeobject.py", # Relies on getBytecodeNode support for continuations
758+
]
757759

758760
GINSTALL_GATE_PACKAGES = {
759761
"numpy": "numpy",
@@ -1116,15 +1118,22 @@ def graalpytest(args):
11161118
parser.add_argument('--python', type=str, action='store', default="", help='Run tests with custom Python binary.')
11171119
parser.add_argument('-v', "--verbose", action="store_true", help='Verbose output.', default=True)
11181120
parser.add_argument('-k', dest="filter", default='', help='Test pattern.')
1121+
parser.add_argument("--use-bytecode-dsl-interpreter", action='store_true')
11191122
parser.add_argument('test', nargs="*", default=[], help='Test file to run (specify absolute or relative; e.g. "/path/to/test_file.py" or "cpyext/test_object.py") ')
11201123
args, unknown_args = parser.parse_known_args(args)
11211124

11221125
# ensure that the test distribution is up-to-date
11231126
if not DISABLE_REBUILD:
11241127
mx.command_function("build")(["--only", "com.oracle.graal.python.test"])
11251128

1126-
testfiles = _list_graalpython_unittests(args.test)
11271129
cmd_args = []
1130+
excludes = []
1131+
1132+
if args.use_bytecode_dsl_interpreter:
1133+
cmd_args += ["--vm.Dpython.EnableBytecodeDSLInterpreter=true"]
1134+
excludes = BYTECODE_DSL_INCOMPATIBLE_TESTS
1135+
1136+
testfiles = _list_graalpython_unittests(args.test, exclude=excludes)
11281137
# if we got a binary path it's most likely CPython, so don't add graalpython args
11291138
if not args.python:
11301139
cmd_args += ["--experimental-options=true", "--python.EnableDebuggingBuiltins"]
@@ -1133,7 +1142,7 @@ def graalpytest(args):
11331142
mx.log(f"Executable seems to be GraalPy, prepending arguments: {gp_args}")
11341143
cmd_args += gp_args
11351144
# we assume that unknown args are polyglot arguments and just prepend them to the test driver
1136-
cmd_args += unknown_args + [_graalpytest_driver()]
1145+
cmd_args += unknown_args + [_graalpytest_driver(), "--report", "test_report.json"]
11371146
if args.verbose:
11381147
cmd_args += ["-v"]
11391148
cmd_args += testfiles

0 commit comments

Comments
 (0)