Skip to content

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Feb 3, 2025

Having automatic insertion and checking of spills in instructions isn't that useful unless we do the same for the rest of the interpreter.
This PR performs spilling and checking on the code in labels as well.

  • Adds a single annotation for labels "spilled", to indicate that the code in a label expects the stack pointer to be spilled
  • Adds checks that the stack pointer is not used when spilled
  • Inserts or checks that the correct spill or reload is inserted when jumping from code with a loaded stack pointer to code with a spilled stack pointer, or vice versa.

PyAPI_FUNC(PyObject *) _Py_uop_symbols_test(PyObject *self, PyObject *ignored);

PyAPI_FUNC(int) _PyOptimizer_Optimize(struct _PyInterpreterFrame *frame, _Py_CODEUNIT *start, _PyStackRef *stack_pointer, _PyExecutorObject **exec_ptr, int chain_depth);
PyAPI_FUNC(int) _PyOptimizer_Optimize(struct _PyInterpreterFrame *frame, _Py_CODEUNIT *start, _PyExecutorObject **exec_ptr, int chain_depth);
Copy link
Member Author

@markshannon markshannon Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stack_pointer parameter was redundant. In fact, since _PyOptimizer_Optimize escapes, the code generator objects to the use of stack_pointer as an argument when called from the interpreter.

@markshannon markshannon closed this Feb 4, 2025
@markshannon markshannon reopened this Feb 4, 2025
@markshannon markshannon merged commit 2effea4 into python:main Feb 4, 2025
96 checks passed
@markshannon markshannon deleted the stack-spill-in-labels branch February 4, 2025 12:44
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Feb 7, 2025
cmaloney pushed a commit to cmaloney/cpython that referenced this pull request Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants