How should we handle the following case? It appears that we cannot simply use ADD_OP as a substitute. Perhaps we still need a REPLACE_OP to handle the new buffer.
@cocolato make REPLACE_OP operate on the new buffer instead of the old one. Ideally you should have two buffers. An old buffer containing the current uops, and a new buffer, containing the uops being written.
If the optimizer stops early, you can just insert an _EXIT_TRACE at that location in the new buffer.
Activity
markshannon commented on Jan 5, 2026
I agree, but let's refactor the JIT structs to be heap allocated first.
Fidget-Spinner commented on Jan 6, 2026
Assigning this to @cocolato
gh-143421: Move `JitOptContext` from stack allocation to per-thread h…
Revert "pythongh-143421: Move `JitOptContext` from stack allocation t…
gh-143421: Lazily allocate tracer code and opt buffers (GH-143597)
gh-143421: Allocate all JIT state in one go (GH-143626)
cocolato commented on Jan 10, 2026
How should we handle the following case? It appears that we cannot simply use ADD_OP as a substitute. Perhaps we still need a REPLACE_OP to handle the new buffer.
cpython/Python/optimizer_bytecodes.c
Line 1512 in e7f5ffa
cpython/Python/optimizer_bytecodes.c
Line 1024 in e7f5ffa
Fidget-Spinner commented on Jan 10, 2026
@cocolato make REPLACE_OP operate on the new buffer instead of the old one. Ideally you should have two buffers. An old buffer containing the current uops, and a new buffer, containing the uops being written.
If the optimizer stops early, you can just insert an _EXIT_TRACE at that location in the new buffer.
pythongh-143421: Move `JitOptContext` from stack allocation to per-th…
pythongh-143421: Lazily allocate tracer code and opt buffers (pythonG…
pythongh-143421: Allocate all JIT state in one go (pythonGH-143626)
gh-143421: Use new buffer to save optimized uops (GH-143682)
pythongh-143421: Move `JitOptContext` from stack allocation to per-th…
pythongh-143421: Lazily allocate tracer code and opt buffers (pythonG…
pythongh-143421: Allocate all JIT state in one go (pythonGH-143626)
pythongh-143421: Use new buffer to save optimized uops (pythonGH-143682)