Skip to content

Commit

Permalink
inlining with local offset calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner committed Dec 10, 2024
1 parent e79ad55 commit 7644afe
Show file tree
Hide file tree
Showing 14 changed files with 318 additions and 231 deletions.
1 change: 1 addition & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ PyAPI_FUNC(PyObject *)_PyEval_MatchKeys(PyThreadState *tstate, PyObject *map, Py
PyAPI_FUNC(void) _PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr);
PyAPI_FUNC(int) _PyEval_UnpackIterableStackRef(PyThreadState *tstate, _PyStackRef v, int argcnt, int argcntafter, _PyStackRef *sp);
PyAPI_FUNC(void) _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame *frame);
PyAPI_FUNC(void) _PyEval_InlinedFrameClear(_PyStackRef *start, int to_pop);
PyAPI_FUNC(PyObject **) _PyObjectArray_FromStackRefArray(_PyStackRef *input, Py_ssize_t nargs, PyObject **scratch);

PyAPI_FUNC(void) _PyObjectArray_Free(PyObject **array, PyObject **scratch);
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ struct _Py_UOpsPEAbstractFrame {
// Usually _INIT_CALL_PY_EXACT_ARGS
// If it's not NULL that indicates it's virtual.
_PyUOpInstruction *init_frame_inst;

// If inlined, where the localsplus starts relative to caller's localsplus.
int inline_localsplus_offset_from_caller;
};

typedef struct _Py_UOpsPEAbstractFrame _Py_UOpsPEAbstractFrame;
Expand Down
242 changes: 122 additions & 120 deletions Include/internal/pycore_uop_ids.h

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

8 changes: 8 additions & 0 deletions Include/internal/pycore_uop_metadata.h

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

16 changes: 16 additions & 0 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5065,6 +5065,22 @@ dummy_func(
GOTO_UNWIND();
}

tier2 op(_GROW_STACK, (unused/4, null_out_count/2 --)) {
for (int i = 0; i < null_out_count; i++) {
stack_pointer[i] = PyStackRef_NULL;
}
stack_pointer += null_out_count;
}

tier2 op(_SHRINK_STACK, (unused/4, shrink_count/2 --)) {
_PyStackRef tos = stack_pointer[-1];
stack_pointer--;
_PyEval_InlinedFrameClear(stack_pointer, shrink_count);
stack_pointer -= shrink_count;
stack_pointer++;
stack_pointer[-1] = tos;
}

/* Progress is guaranteed if we DEOPT on the eval breaker, because
* ENTER_EXECUTOR will not re-enter tier 2 with the eval breaker set. */
tier2 op(_TIER2_RESUME_CHECK, (--)) {
Expand Down
Loading

0 comments on commit 7644afe

Please sign in to comment.