Skip to content

Commit

Permalink
GH-115419: Improve list of escaping functions (GH-118054)
Browse files Browse the repository at this point in the history
  • Loading branch information
markshannon authored Apr 19, 2024
1 parent fefd5d9 commit d3bd6b5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
24 changes: 12 additions & 12 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,9 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
return pc + 1;
default:
{
bool needs_ip = false;
/* _PUSH_FRAME doesn't escape or error, but it
* does need the IP for the return address */
bool needs_ip = opcode == _PUSH_FRAME;
if (_PyUop_Flags[opcode] & HAS_ESCAPES_FLAG) {
needs_ip = true;
may_have_escaped = true;
Expand Down
10 changes: 10 additions & 0 deletions Tools/cases_generator/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,15 @@ def has_error_without_pop(op: parser.InstDef) -> bool:
"_PyObject_InlineValues",
"_PyDictValues_AddToInsertionOrder",
"Py_DECREF",
"Py_XDECREF",
"_Py_DECREF_SPECIALIZED",
"DECREF_INPUTS_AND_REUSE_FLOAT",
"PyUnicode_Append",
"_PyLong_IsZero",
"Py_SIZE",
"Py_TYPE",
"PyList_GET_ITEM",
"PyList_SET_ITEM",
"PyTuple_GET_ITEM",
"PyList_GET_SIZE",
"PyTuple_GET_SIZE",
Expand Down Expand Up @@ -400,8 +402,14 @@ def has_error_without_pop(op: parser.InstDef) -> bool:
"PySlice_New",
"_Py_LeaveRecursiveCallPy",
"CALL_STAT_INC",
"STAT_INC",
"maybe_lltrace_resume_frame",
"_PyUnicode_JoinArray",
"_PyEval_FrameClearAndPop",
"_PyFrame_StackPush",
"PyCell_New",
"PyFloat_AS_DOUBLE",
"_PyFrame_PushUnchecked",
)

ESCAPING_FUNCTIONS = (
Expand All @@ -427,6 +435,8 @@ def makes_escaping_api_call(instr: parser.InstDef) -> bool:
continue
if tkn.text in ESCAPING_FUNCTIONS:
return True
if tkn.text == "tp_vectorcall":
return True
if not tkn.text.startswith("Py") and not tkn.text.startswith("_Py"):
continue
if tkn.text.endswith("Check"):
Expand Down

0 comments on commit d3bd6b5

Please sign in to comment.