cpython/Python
Guido van Rossum 570a82d46a
gh-117045: Add code object to function version cache (#117028)
Changes to the function version cache:

- In addition to the function object, also store the code object,
  and allow the latter to be retrieved even if the function has been evicted.
- Stop assigning new function versions after a critical attribute (e.g. `__code__`)
  has been modified; the version is permanently reset to zero in this case.
- Changes to `__annotations__` are no longer considered critical. (This fixes gh-109998.)

Changes to the Tier 2 optimization machinery:

- If we cannot map a function version to a function, but it is still mapped to a code object,
  we continue projecting the trace.
  The operand of the `_PUSH_FRAME` and `_POP_FRAME` opcodes can be either NULL,
  a function object, or a code object with the lowest bit set.

This allows us to trace through code that calls an ephemeral function,
i.e., a function that may not be alive when we are constructing the executor,
e.g. a generator expression or certain nested functions.
We will lose globals removal inside such functions,
but we can still do other peephole operations
(and even possibly [call inlining](https://github.com/python/cpython/pull/116290),
if we decide to do it), which only need the code object.
As before, if we cannot retrieve the code object from the cache, we stop projecting.
2024-03-21 12:37:41 -07:00
..
clinic
frozen_modules
_warnings.c
adaptive.md
asdl.c
asm_trampoline.S
assemble.c
ast.c
ast_opt.c
ast_unparse.c
bltinmodule.c
bootstrap_hash.c
brc.c
bytecodes.c
ceval.c
ceval_gil.c gh-116522: Refactor _PyThreadState_DeleteExcept (#117131) 2024-03-21 11:21:02 -07:00
ceval_macros.h
codecs.c
compile.c
condvar.h
context.c
critical_section.c
crossinterp.c
crossinterp_data_lookup.h
crossinterp_exceptions.h
dtoa.c
dup2.c
dynamic_annotations.c
dynload_hpux.c
dynload_shlib.c
dynload_stub.c
dynload_win.c
emscripten_signal.c
emscripten_trampoline.c
errors.c
executor_cases.c.h
fileutils.c
flowgraph.c
formatter_unicode.c
frame.c
frozen.c
frozenmain.c
future.c
gc.c GH-108362: Incremental Cycle GC (GH-116206) 2024-03-20 08:54:42 +00:00
gc_free_threading.c GH-108362: Incremental Cycle GC (GH-116206) 2024-03-20 08:54:42 +00:00
gc_gil.c
generated_cases.c.h
getargs.c
getcompiler.c
getcopyright.c
getopt.c
getplatform.c
getversion.c
hamt.c
hashtable.c
import.c GH-108362: Incremental Cycle GC (GH-116206) 2024-03-20 08:54:42 +00:00
importdl.c
initconfig.c gh-117041: Add "-X gil" in the Python CLI help (GH-117042) 2024-03-19 23:30:25 +02:00
instrumentation.c
intrinsics.c
jit.c GH-116017: Put JIT code and data on the same page (GH-116845) 2024-03-19 08:47:28 -07:00
legacy_tracing.c
lock.c
marshal.c
modsupport.c
mysnprintf.c
mystrtoul.c
object_stack.c
opcode_targets.h
optimizer.c gh-117045: Add code object to function version cache (#117028) 2024-03-21 12:37:41 -07:00
optimizer_analysis.c gh-117045: Add code object to function version cache (#117028) 2024-03-21 12:37:41 -07:00
optimizer_bytecodes.c gh-117045: Add code object to function version cache (#117028) 2024-03-21 12:37:41 -07:00
optimizer_cases.c.h gh-117045: Add code object to function version cache (#117028) 2024-03-21 12:37:41 -07:00
optimizer_symbols.c
parking_lot.c
pathconfig.c
perf_trampoline.c
preconfig.c
pyarena.c
pyctype.c
pyfpe.c
pyhash.c
pylifecycle.c gh-116522: Refactor _PyThreadState_DeleteExcept (#117131) 2024-03-21 11:21:02 -07:00
pymath.c
pystate.c gh-116522: Refactor _PyThreadState_DeleteExcept (#117131) 2024-03-21 11:21:02 -07:00
pystrcmp.c
pystrhex.c
pystrtod.c
Python-ast.c
Python-tokenize.c
pythonrun.c
pytime.c
qsbr.c
README
specialize.c gh-116996: Add pystats about _Py_uop_analyse_and_optimize (GH-116997) 2024-03-22 01:27:46 +08:00
stdlib_module_names.h
structmember.c
suggestions.c
symtable.c
sysmodule.c
thread.c
thread_nt.h
thread_pthread.h
thread_pthread_stubs.h
tier2_engine.md
traceback.c
tracemalloc.c
vm-state.md

Miscellaneous source files for the main Python shared library