8000 GH-111848: Set the IP when de-optimizing by markshannon · Pull Request #112065 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-111848: Set the IP when de-optimizing #112065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more functions to whitelist
  • Loading branch information
markshannon committed Nov 12, 2023
commit 0a093fdec35ae41eb8a3e77d4100a3f905164f88
16 changes: 8 additions & 8 deletions Include/internal/pycore_opcode_metadata.h

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

20 changes: 16 additions & 4 deletions Tools/cases_generator/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import parsing
from typing import AbstractSet

WHITELIST = (
NON_ESCAPING_FUNCTIONS = (
"Py_INCREF",
"_PyDictOrValues_IsValues",
"_PyObject_DictOrValuesPointer",
Expand Down Expand Up @@ -39,9 +39,20 @@
"Py_NewRef",
"_PyList_ITEMS",
"_PyTuple_ITEMS",
"_PyList_AppendTakeRef",
"_Py_atomic_load_uintptr_relaxed",
"_PyFrame_GetCode",
)

ESCAPING_FUNCTIONS = (
"import_name",
"import_from",
)


def makes_escaping_api_call(instr: parsing.Node) -> bool:
if "CALL_INTRINSIC" in instr.name:
return True;
tkns = iter(instr.tokens)
for tkn in tkns:
if tkn.kind != lx.IDENTIFIER:
Expand All @@ -52,6 +63,8 @@ def makes_escaping_api_call(instr: parsing.Node) -> bool:
return False
if next_tkn.kind != lx.LPAREN:
continue
if tkn.text in ESCAPING_FUNCTIONS:
return True
if not tkn.text.startswith("Py") and not tkn.text.startswith("_Py"):
continue
if tkn.text.endswith("Check"):
Expand All @@ -60,7 +73,7 @@ def makes_escaping_api_call(instr: parsing.Node) -> bool:
continue
if tkn.text.endswith("CheckExact"):
continue
if tkn.text in WHITELIST:
if tkn.text in NON_ESCAPING_FUNCTIONS:
continue
return True
return False
Expand Down Expand Up @@ -111,8 +124,7 @@ def fromInstruction(instr: parsing.Node) -> "InstructionFlags":
or variable_used(instr, "resume_with_error")
),
HAS_ESCAPES_FLAG=(
variable_used(instr, "tstate")
or makes_escaping_api_call(instr)
makes_escaping_api_call(instr)
),
)

Expand Down
0