Skip to content

bpo-46564: Optimize super().meth() calls via adaptive superinstructions #30992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
work with new call convention
  • Loading branch information
Fidget-Spinner committed Jan 28, 2022
commit f4cd3f9aa3f73b34c2bc3a85431d42b993938e70
6 changes: 3 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5078,7 +5078,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
_PyAdaptiveEntry *cache0 = &caches[0].adaptive;
_PyObjectCache *cache1 = &caches[-1].obj;
_PyAdaptiveEntry *lm_adaptive = &caches[-2].adaptive;
int nargs = cache0->original_oparg;
int nargs = call_shape.total_args;
assert(nargs == 0);

/* CALL_NO_KW_SUPER */
Expand Down Expand Up @@ -5119,9 +5119,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
_PyAdaptiveEntry *cache0 = &caches[0].adaptive;
_PyObjectCache *cache1 = &caches[-1].obj;
_PyAdaptiveEntry *lm_adaptive = &caches[-2].adaptive;
int nargs = cache0->original_oparg;
int lm_oparg = cache0->index;
int nargs = call_shape.total_args;
assert(nargs == 2);
assert(call_shape.kwnames == NULL);

/* CALL_NO_KW_SUPER */
/* super(type, obj) - two argument form */
Expand Down
2 changes: 1 addition & 1 deletion Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ specialize_class_call(
}
/* Adaptive super instruction of CALL and LOAD_METHOD_ADAPTIVE. */
if (tp == &PySuper_Type &&
kwnames == NULL &&
_Py_OPCODE(instr[1]) == LOAD_METHOD_ADAPTIVE &&
_Py_OPCODE(instr[-1]) == PRECALL_FUNCTION &&
(nargs == 0 || nargs == 2)) {
Expand Down Expand Up @@ -1430,7 +1431,6 @@ specialize_class_call(
return -1;
}

fail:
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CLASS_MUTABLE);
return -1;
}
Expand Down