Skip to content

Commit d3bd6b5

Browse files
authored
GH-115419: Improve list of escaping functions (GH-118054)
1 parent fefd5d9 commit d3bd6b5

File tree

4 files changed

+37
-25
lines changed

4 files changed

+37
-25
lines changed

Diff for: Include/internal/pycore_opcode_metadata.h

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Include/internal/pycore_uop_metadata.h

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Python/optimizer_analysis.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,9 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
543543
return pc + 1;
544544
default:
545545
{
546-
bool needs_ip = false;
546+
/* _PUSH_FRAME doesn't escape or error, but it
547+
* does need the IP for the return address */
548+
bool needs_ip = opcode == _PUSH_FRAME;
547549
if (_PyUop_Flags[opcode] & HAS_ESCAPES_FLAG) {
548550
needs_ip = true;
549551
may_have_escaped = true;

Diff for: Tools/cases_generator/analyzer.py

+10
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,15 @@ def has_error_without_pop(op: parser.InstDef) -> bool:
358358
"_PyObject_InlineValues",
359359
"_PyDictValues_AddToInsertionOrder",
360360
"Py_DECREF",
361+
"Py_XDECREF",
361362
"_Py_DECREF_SPECIALIZED",
362363
"DECREF_INPUTS_AND_REUSE_FLOAT",
363364
"PyUnicode_Append",
364365
"_PyLong_IsZero",
365366
"Py_SIZE",
366367
"Py_TYPE",
367368
"PyList_GET_ITEM",
369+
"PyList_SET_ITEM",
368370
"PyTuple_GET_ITEM",
369371
"PyList_GET_SIZE",
370372
"PyTuple_GET_SIZE",
@@ -400,8 +402,14 @@ def has_error_without_pop(op: parser.InstDef) -> bool:
400402
"PySlice_New",
401403
"_Py_LeaveRecursiveCallPy",
402404
"CALL_STAT_INC",
405+
"STAT_INC",
403406
"maybe_lltrace_resume_frame",
404407
"_PyUnicode_JoinArray",
408+
"_PyEval_FrameClearAndPop",
409+
"_PyFrame_StackPush",
410+
"PyCell_New",
411+
"PyFloat_AS_DOUBLE",
412+
"_PyFrame_PushUnchecked",
405413
)
406414

407415
ESCAPING_FUNCTIONS = (
@@ -427,6 +435,8 @@ def makes_escaping_api_call(instr: parser.InstDef) -> bool:
427435
continue
428436
if tkn.text in ESCAPING_FUNCTIONS:
429437
return True
438+
if tkn.text == "tp_vectorcall":
439+
return True
430440
if not tkn.text.startswith("Py") and not tkn.text.startswith("_Py"):
431441
continue
432442
if tkn.text.endswith("Check"):

0 commit comments

Comments
 (0)