Skip to content

Commit e56da80

Browse files
committed
Enable specialization of CALL_KW
1 parent e991ac8 commit e56da80

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,15 +4372,15 @@ dummy_func(
43724372
_PUSH_FRAME;
43734373

43744374
specializing op(_SPECIALIZE_CALL_KW, (counter/1, callable[1], self_or_null[1], args[oparg], kwnames -- callable[1], self_or_null[1], args[oparg], kwnames)) {
4375-
#if ENABLE_SPECIALIZATION
4375+
#if ENABLE_SPECIALIZATION_FT
43764376
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
43774377
next_instr = this_instr;
43784378
_Py_Specialize_CallKw(callable[0], next_instr, oparg + !PyStackRef_IsNull(self_or_null[0]));
43794379
DISPATCH_SAME_OPARG();
43804380
}
43814381
OPCODE_DEFERRED_INC(CALL_KW);
43824382
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
4383-
#endif /* ENABLE_SPECIALIZATION */
4383+
#endif /* ENABLE_SPECIALIZATION_FT */
43844384
}
43854385

43864386
macro(CALL_KW) =

Python/generated_cases.c.h

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

Python/specialize.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,7 @@ specialize_py_call_kw(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs,
21042104
return -1;
21052105
}
21062106
write_u32(cache->func_version, version);
2107-
instr->op.code = bound_method ? CALL_KW_BOUND_METHOD : CALL_KW_PY;
2107+
specialize(instr, bound_method ? CALL_KW_BOUND_METHOD : CALL_KW_PY);
21082108
return 0;
21092109
}
21102110

@@ -2199,10 +2199,9 @@ _Py_Specialize_CallKw(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
21992199
{
22002200
PyObject *callable = PyStackRef_AsPyObjectBorrow(callable_st);
22012201

2202-
assert(ENABLE_SPECIALIZATION);
2202+
assert(ENABLE_SPECIALIZATION_FT);
22032203
assert(_PyOpcode_Caches[CALL_KW] == INLINE_CACHE_ENTRIES_CALL_KW);
22042204
assert(_Py_OPCODE(*instr) != INSTRUMENTED_CALL_KW);
2205-
_PyCallCache *cache = (_PyCallCache *)(instr + 1);
22062205
int fail;
22072206
if (PyFunction_Check(callable)) {
22082207
fail = specialize_py_call_kw((PyFunctionObject *)callable, instr, nargs, false);
@@ -2218,19 +2217,11 @@ _Py_Specialize_CallKw(_PyStackRef callable_st, _Py_CODEUNIT *instr, int nargs)
22182217
}
22192218
}
22202219
else {
2221-
instr->op.code = CALL_KW_NON_PY;
2220+
specialize(instr, CALL_KW_NON_PY);
22222221
fail = 0;
22232222
}
22242223
if (fail) {
2225-
STAT_INC(CALL, failure);
2226-
assert(!PyErr_Occurred());
2227-
instr->op.code = CALL_KW;
2228-
cache->counter = adaptive_counter_backoff(cache->counter);
2229-
}
2230-
else {
2231-
STAT_INC(CALL, success);
2232-
assert(!PyErr_Occurred());
2233-
cache->counter = adaptive_counter_cooldown();
2224+
unspecialize(instr);
22342225
}
22352226
}
22362227

0 commit comments

Comments
 (0)