mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-106581: Split CALL_BOUND_METHOD_EXACT_ARGS into uops (#108462)
Instead of using `GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS)` we just add the macro elements of the latter to the macro for the former. This requires lengthening the uops array in struct opcode_macro_expansion. (It also required changes to stacking.py that were merged already.)
This commit is contained in:
parent
546cab8444
commit
ddf66b54ed
6 changed files with 171 additions and 35 deletions
|
@ -2940,19 +2940,18 @@ dummy_func(
|
|||
CHECK_EVAL_BREAKER();
|
||||
}
|
||||
|
||||
// Start out with [NULL, bound_method, arg1, arg2, ...]
|
||||
// Transform to [callable, self, arg1, arg2, ...]
|
||||
// Then fall through to CALL_PY_EXACT_ARGS
|
||||
inst(CALL_BOUND_METHOD_EXACT_ARGS, (unused/1, unused/2, callable, null, unused[oparg] -- unused)) {
|
||||
op(_CHECK_CALL_BOUND_METHOD_EXACT_ARGS, (callable, null, unused[oparg] -- callable, null, unused[oparg])) {
|
||||
DEOPT_IF(null != NULL, CALL);
|
||||
DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL);
|
||||
}
|
||||
|
||||
op(_INIT_CALL_BOUND_METHOD_EXACT_ARGS, (callable, unused, unused[oparg] -- func, self, unused[oparg])) {
|
||||
STAT_INC(CALL, hit);
|
||||
PyObject *self = ((PyMethodObject *)callable)->im_self;
|
||||
PEEK(oparg + 1) = Py_NewRef(self); // self_or_null
|
||||
PyObject *meth = ((PyMethodObject *)callable)->im_func;
|
||||
PEEK(oparg + 2) = Py_NewRef(meth); // callable
|
||||
self = Py_NewRef(((PyMethodObject *)callable)->im_self);
|
||||
stack_pointer[-1 - oparg] = self; // Patch stack as it is used by _INIT_CALL_PY_EXACT_ARGS
|
||||
func = Py_NewRef(((PyMethodObject *)callable)->im_func);
|
||||
stack_pointer[-2 - oparg] = func; // This is used by CALL, upon deoptimization
|
||||
Py_DECREF(callable);
|
||||
GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
|
||||
}
|
||||
|
||||
op(_CHECK_PEP_523, (--)) {
|
||||
|
@ -3010,6 +3009,18 @@ dummy_func(
|
|||
#endif
|
||||
}
|
||||
|
||||
macro(CALL_BOUND_METHOD_EXACT_ARGS) =
|
||||
unused/1 + // Skip over the counter
|
||||
_CHECK_PEP_523 +
|
||||
_CHECK_CALL_BOUND_METHOD_EXACT_ARGS +
|
||||
_INIT_CALL_BOUND_METHOD_EXACT_ARGS +
|
||||
_CHECK_FUNCTION_EXACT_ARGS +
|
||||
_CHECK_STACK_SPACE +
|
||||
_INIT_CALL_PY_EXACT_ARGS +
|
||||
SAVE_IP + // Tier 2 only; special-cased oparg
|
||||
SAVE_CURRENT_IP + // Sets frame->prev_instr
|
||||
_PUSH_FRAME;
|
||||
|
||||
macro(CALL_PY_EXACT_ARGS) =
|
||||
unused/1 + // Skip over the counter
|
||||
_CHECK_PEP_523 +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue