Skip to content

Commit ba66049

Browse files
committed
Pass frame to CallNode#execute in PE code.
PullRequest: graalpython/3366
2 parents 7eddbcc + c4fff23 commit ba66049

File tree

55 files changed

+153
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+153
-140
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,6 @@ graalpython/graalpy-maven-plugin/target
9090
graalpython/graalpy-archetype-polyglot-app/target
9191
graalpython/graalpy-micronaut-embedding/target
9292
graalpython/com.oracle.graal.python.test/src/tests/standalone/micronaut/hello/target/
93+
graalpython/com.oracle.graal.python.test/src/tests/cpyext/build/
9394
pom-mx.xml
94-
.venv
95+
.venv

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 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
@@ -249,7 +249,7 @@ public void postInitialize(Python3Core core) {
249249
self.setAttribute(CURRENT_TASKS_ATTR, factory.createDict());
250250
Object weakref = AbstractImportNode.importModule(WEAKREF);
251251
Object weakSetCls = PyObjectGetAttr.executeUncached(weakref, WEAKSET);
252-
Object weakSet = CallNode.getUncached().execute(weakSetCls);
252+
Object weakSet = CallNode.executeUncached(weakSetCls);
253253
self.setAttribute(ALL_TASKS_ATTR, weakSet);
254254
}
255255
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ TruffleString sourceAsString(VirtualFrame frame, Node inliningTarget, Object sou
12921292
CodecsModuleBuiltins.TruffleDecoder decoder = new CodecsModuleBuiltins.TruffleDecoder(pythonEncodingNameFromJavaName, charset, bytes, bytesLen, CodingErrorAction.REPORT);
12931293
if (!decoder.decodingStep(true)) {
12941294
try {
1295-
handleDecodingErrorNode.execute(decoder, T_STRICT, factory.createBytes(bytes, bytesLen));
1295+
handleDecodingErrorNode.execute(frame, decoder, T_STRICT, factory.createBytes(bytes, bytesLen));
12961296
throw CompilerDirectives.shouldNotReachHere();
12971297
} catch (PException e) {
12981298
throw raiseInvalidSyntax(filename, "(unicode error) %s", asStrNode.execute(frame, inliningTarget, e.getEscapedException()));
@@ -2487,7 +2487,7 @@ private static Object buildJavaClass(Object namespace, TruffleString name, Objec
24872487
// uncached PythonContext get, since this code path is slow in any case
24882488
Object module = PythonContext.get(null).lookupBuiltinModule(T___GRAALPYTHON__);
24892489
Object buildFunction = PyObjectLookupAttr.executeUncached(module, T_BUILD_JAVA_CLASS);
2490-
return CallNode.getUncached().execute(buildFunction, namespace, name, base);
2490+
return CallNode.executeUncached(buildFunction, namespace, name, base);
24912491
}
24922492

24932493
@Specialization

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static void handle(Node inliningTarget, TruffleEncoder encoder, TruffleString er
248248
if (!fixed) {
249249
int start = encoder.getInputPosition();
250250
int end = start + encoder.getErrorLength();
251-
Object exception = lazyCallNode.execute(UnicodeEncodeError, encoder.getEncodingName(), inputObject, start, end, encoder.getErrorReason());
251+
Object exception = lazyCallNode.executeWithoutFrame(UnicodeEncodeError, encoder.getEncodingName(), inputObject, start, end, encoder.getErrorReason());
252252
if (exception instanceof PBaseException) {
253253
throw raiseNode.get(inliningTarget).raiseExceptionObject((PBaseException) exception);
254254
} else {
@@ -370,7 +370,7 @@ static Object doRaise(Node inliningTarget, TruffleDecoder decoder, Object inputO
370370
@Cached PRaiseNode.Lazy raiseNode) {
371371
int start = decoder.getInputPosition();
372372
int end = start + decoder.getErrorLength();
373-
Object exception = callNode.execute(UnicodeDecodeError, decoder.getEncodingName(), inputObject, start, end, decoder.getErrorReason());
373+
Object exception = callNode.executeWithoutFrame(UnicodeDecodeError, decoder.getEncodingName(), inputObject, start, end, decoder.getErrorReason());
374374
if (justMakeExcept) {
375375
return exception;
376376
}
@@ -420,7 +420,7 @@ public static TruffleString intern(Node inliningTarget, TruffleString errorActio
420420
// "lazily", i.e., not on all code-paths
421421
@GenerateInline(false)
422422
public abstract static class HandleDecodingErrorNode extends Node {
423-
public abstract void execute(TruffleDecoder decoder, TruffleString errorAction, Object inputObject);
423+
public abstract void execute(VirtualFrame frame, TruffleDecoder decoder, TruffleString errorAction, Object inputObject);
424424

425425
@Specialization(guards = "errorAction == T_STRICT")
426426
static void doStrict(TruffleDecoder decoder, @SuppressWarnings("unused") TruffleString errorAction, Object inputObject,
@@ -476,7 +476,7 @@ static void doSurrogateescape(TruffleDecoder decoder, @SuppressWarnings("unused"
476476
}
477477

478478
@Fallback
479-
static void doCustom(TruffleDecoder decoder, TruffleString errorAction, Object inputObject,
479+
static void doCustom(VirtualFrame frame, TruffleDecoder decoder, TruffleString errorAction, Object inputObject,
480480
@Bind("this") Node inliningTarget,
481481
@Cached CallNode callNode,
482482
@Cached BaseExceptionAttrNode attrNode,
@@ -493,7 +493,7 @@ static void doCustom(TruffleDecoder decoder, TruffleString errorAction, Object i
493493
throw raiseNode.get(inliningTarget).raise(LookupError, UNKNOWN_ERROR_HANDLER, errorAction);
494494
}
495495
Object exceptionObject = raiseDecodingErrorNode.makeDecodeException(inliningTarget, decoder, inputObject);
496-
Object restuple = callNode.execute(errorHandler, exceptionObject);
496+
Object restuple = callNode.execute(frame, errorHandler, exceptionObject);
497497

498498
if (!PGuards.isPTuple(restuple)) {
499499
throw raiseNode.get(inliningTarget).raise(TypeError, DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE);
@@ -706,7 +706,7 @@ static Object decode(VirtualFrame frame, Object input, TruffleString encoding, T
706706
try {
707707
decoder = new TruffleDecoder(normalizedEncoding, charset, bytes, len, errorAction);
708708
while (!decoder.decodingStep(finalData)) {
709-
errorHandler.execute(decoder, internErrorAction.execute(inliningTarget, errors), factory.createBytes(bytes, len));
709+
errorHandler.execute(frame, decoder, internErrorAction.execute(inliningTarget, errors), factory.createBytes(bytes, len));
710710
}
711711
} catch (OutOfMemoryError e) {
712712
CompilerDirectives.transferToInterpreterAndInvalidate();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FaulthandlerModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2023, 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
@@ -95,7 +95,7 @@ private static void dumpTraceback(Object callable, Object file) {
9595
f = PNone.NONE;
9696
}
9797
try {
98-
CallNode.getUncached().execute(null, callable, PNone.NONE, PNone.NONE, f);
98+
CallNode.executeUncached(callable, PNone.NONE, PNone.NONE, f);
9999
} catch (RuntimeException e) {
100100
ExceptionUtils.printPythonLikeStackTrace(e);
101101
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private static boolean getImporter(PythonModule sysModule, TruffleString inputFi
370370
int numHooks = storage.length();
371371
for (int i = 0; i < numHooks; i++) {
372372
try {
373-
importer = CallNode.getUncached().execute(hooks[i], inputFilePath);
373+
importer = CallNode.executeUncached(hooks[i], inputFilePath);
374374
break;
375375
} catch (PException e) {
376376
if (!IsSubtypeNode.getUncached().execute(GetClassNode.executeUncached(e.getUnreifiedException()), ImportError)) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private RuntimeException handleCompilationError(RuntimeException e, InteropLibra
420420
int position = sourceSection.getCharIndex();
421421
PythonModule module = context.lookupBuiltinModule(BuiltinNames.T__SRE);
422422
Object errorConstructor = PyObjectLookupAttr.executeUncached(module, T_ERROR);
423-
PBaseException exception = (PBaseException) CallNode.getUncached().execute(errorConstructor, reason, originalPattern, position);
423+
PBaseException exception = (PBaseException) CallNode.executeUncached(errorConstructor, reason, originalPattern, position);
424424
return PRaiseNode.getUncached().raiseExceptionObject(exception);
425425
}
426426
}
@@ -518,15 +518,15 @@ Object localeNonSensitive(PythonObject pattern, PythonMethod method, boolean mus
518518

519519
@Specialization(guards = {"method == cachedMethod", "mustAdvance == cachedMustAdvance", "getTRegexCache(pattern).isLocaleSensitive()"}, limit = "SPECIALIZATION_LIMIT", replaces = "cached")
520520
@SuppressWarnings("truffle-static-method")
521-
Object localeSensitive(PythonObject pattern, PythonMethod method, boolean mustAdvance,
521+
Object localeSensitive(VirtualFrame frame, PythonObject pattern, PythonMethod method, boolean mustAdvance,
522522
@Bind("this") Node inliningTarget,
523523
@Cached("method") @SuppressWarnings("unused") PythonMethod cachedMethod,
524524
@Cached("mustAdvance") @SuppressWarnings("unused") boolean cachedMustAdvance,
525525
@Cached("lookupGetLocaleFunction()") Object getLocale,
526526
@Cached CallNode callGetLocale,
527527
@Cached CastToTruffleStringNode castToTruffleStringNode) {
528528
TRegexCache tRegexCache = getTRegexCache(pattern);
529-
TruffleString locale = castToTruffleStringNode.execute(inliningTarget, callGetLocale.execute(getLocale));
529+
TruffleString locale = castToTruffleStringNode.execute(inliningTarget, callGetLocale.execute(frame, getLocale));
530530
final Object tRegex = tRegexCache.getLocaleSensitiveRegexp(method, mustAdvance, locale);
531531
if (tRegex != null) {
532532
return tRegex;
@@ -673,8 +673,8 @@ protected Object doCached(VirtualFrame frame, PythonObject pattern, Object input
673673
reCheckInputTypeNode.execute(frame, input, tRegexCache.isBinary());
674674

675675
if (fallbackProfile.profile(inliningTarget, libCompiledRegex.isNull(compiledRegex))) {
676-
Object fallbackRegex = getCallFallbackCompileNode().execute(getGetFallbackCompileNode().executeObject(frame, pattern));
677-
return getCallFallbackMethodNode().execute(getFallbackMethodNode.executeObject(frame, fallbackRegex), input, pos, endPos);
676+
Object fallbackRegex = getCallFallbackCompileNode().executeWithoutFrame(getGetFallbackCompileNode().executeObject(frame, pattern));
677+
return getCallFallbackMethodNode().executeWithoutFrame(getFallbackMethodNode.executeObject(frame, fallbackRegex), input, pos, endPos);
678678
}
679679

680680
Object truncatedInput = input;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ Object doHook(VirtualFrame frame, Object[] args, PKeyword[] keywords,
18091809
return PNone.NONE;
18101810
}
18111811

1812-
return callNode.execute(hook, args, keywords);
1812+
return callNode.execute(frame, hook, args, keywords);
18131813
}
18141814
}
18151815

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,8 @@ private static void callShowWarning(PythonContext context, Object category, Obje
752752

753753
assert message != null && category != null && filename != null && source != null;
754754
assert message != PNone.NO_VALUE && category != PNone.NO_VALUE && source != PNone.NO_VALUE;
755-
Object msg = CallNode.getUncached().execute(warnmsgCls, message, category, filename, lineno, PNone.NONE, PNone.NONE, source);
756-
CallNode.getUncached().execute(showFn, msg);
755+
Object msg = CallNode.executeUncached(warnmsgCls, message, category, filename, lineno, PNone.NONE, PNone.NONE, source);
756+
CallNode.executeUncached(showFn, msg);
757757
}
758758

759759
/**
@@ -1182,7 +1182,7 @@ private void executeImpl(Object source, Object category, TruffleString format, i
11821182
} catch (IllegalFormatException e) {
11831183
throw CompilerDirectives.shouldNotReachHere("error while formatting \"" + format + "\"", e);
11841184
}
1185-
CallNode.getUncached().execute(warn, message, category, stackLevel, source);
1185+
CallNode.executeUncached(warn, message, category, stackLevel, source);
11861186
}
11871187
}
11881188
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ <T> T[] lookupAndConvertSequence(Object obj, TruffleString attrName, TruffleStri
181181

182182
static boolean isInstanceOf(Object o, PythonAbstractClass cls) {
183183
Object check = lookupAttr(cls, SpecialMethodNames.T___INSTANCECHECK__);
184-
Object result = CallNode.getUncached().execute(check, o);
184+
Object result = CallNode.executeUncached(check, o);
185185
return CastToJavaBooleanNode.executeUncached(result);
186186
}
187187

0 commit comments

Comments
 (0)