Skip to content

Commit 2b3e6f2

Browse files
committed
Example split of CALL_PY_EXACT_ARGS.
1 parent a5a2d8f commit 2b3e6f2

File tree

4 files changed

+162
-40
lines changed

4 files changed

+162
-40
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,32 +2928,55 @@ dummy_func(
29282928
GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
29292929
}
29302930

2931-
inst(CALL_PY_EXACT_ARGS, (unused/1, func_version/2, callable, self_or_null, args[oparg] -- unused)) {
2932-
ASSERT_KWNAMES_IS_NULL();
2931+
2932+
op(_CHECK_PEP523, (--)) {
29332933
DEOPT_IF(tstate->interp->eval_frame, CALL);
2934-
int argcount = oparg;
2935-
if (self_or_null) {
2936-
args--;
2937-
argcount++;
2938-
}
2934+
}
2935+
2936+
op(_CHECK_FUNCTION, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
29392937
DEOPT_IF(!PyFunction_Check(callable), CALL);
29402938
PyFunctionObject *func = (PyFunctionObject *)callable;
29412939
DEOPT_IF(func->func_version != func_version, CALL);
29422940
PyCodeObject *code = (PyCodeObject *)func->func_code;
2941+
int argcount = oparg + (self_or_null != NULL);
29432942
DEOPT_IF(code->co_argcount != argcount, CALL);
29442943
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
29452944
STAT_INC(CALL, hit);
2946-
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, func, argcount);
2945+
}
2946+
2947+
op(_MAKE_FRAME, (callable, self_or_null, args[oparg] -- new_frame: _PyInterpreterFrame*)) {
2948+
int argcount = oparg;
2949+
if (self_or_null) {
2950+
args--;
2951+
argcount++;
2952+
}
2953+
PyFunctionObject *func = (PyFunctionObject *)callable;
2954+
new_frame = _PyFrame_PushUnchecked(tstate, func, argcount);
29472955
for (int i = 0; i < argcount; i++) {
29482956
new_frame->localsplus[i] = args[i];
29492957
}
2950-
// Manipulate stack directly since we leave using DISPATCH_INLINED().
2951-
STACK_SHRINK(oparg + 2);
2952-
SKIP_OVER(INLINE_CACHE_ENTRIES_CALL);
2958+
SAVE_FRAME_STATE(); /* Special macro */
2959+
}
2960+
2961+
op(_PUSH_FRAME, (new_frame: _PyInterpreterFrame* -- unused)) {
29532962
frame->return_offset = 0;
2954-
DISPATCH_INLINED(new_frame);
2963+
/* Link in new frame */
2964+
new_frame->previous = frame;
2965+
frame = cframe.current_frame = new_frame;
2966+
CALL_STAT_INC(inlined_py_calls);
2967+
if (_Py_EnterRecursivePy(tstate)) {
2968+
goto exit_unwind;
2969+
}
2970+
START_FRAME(); /* Special macro */
29552971
}
29562972

2973+
macro(CALL_PY_EXACT_ARGS) =
2974+
unused/1 + // Skip over the counter
2975+
_CHECK_PEP523 +
2976+
_CHECK_FUNCTION +
2977+
_MAKE_FRAME +
2978+
_PUSH_FRAME;
2979+
29572980
inst(CALL_PY_WITH_DEFAULTS, (unused/1, func_version/2, callable, self_or_null, args[oparg] -- unused)) {
29582981
ASSERT_KWNAMES_IS_NULL();
29592982
DEOPT_IF(tstate->interp->eval_frame, CALL);

Python/executor_cases.c.h

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 52 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)