summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-08-25 00:36:00 (GMT)
committerGitHub <noreply@github.com>2023-08-25 00:36:00 (GMT)
commitddf66b54edea1ea59fdf8a496ed0b64e16424375 (patch)
tree0c5d6ae41b76c8a767e87c3737145d02ad1ec7a9 /Python/bytecodes.c
parent546cab84448b892c92e68d9c1a3d3b58c13b3463 (diff)
downloadcpython-ddf66b54edea1ea59fdf8a496ed0b64e16424375.zip
cpython-ddf66b54edea1ea59fdf8a496ed0b64e16424375.tar.gz
cpython-ddf66b54edea1ea59fdf8a496ed0b64e16424375.tar.bz2
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.)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index ae459ca..a5cb117 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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 +