gh-106581: Add 10 new opcodes by allowing assert(kwnames == NULL) (#106707)

By turning `assert(kwnames == NULL)` into a macro that is not in the "forbidden" list, many instructions that formerly were skipped because they contained such an assert (but no other mention of `kwnames`) are now supported in Tier 2. This covers 10 instructions in total (all specializations of `CALL` that invoke some C code):
- `CALL_NO_KW_TYPE_1`
- `CALL_NO_KW_STR_1`
- `CALL_NO_KW_TUPLE_1`
- `CALL_NO_KW_BUILTIN_O`
- `CALL_NO_KW_BUILTIN_FAST`
- `CALL_NO_KW_LEN`
- `CALL_NO_KW_ISINSTANCE`
- `CALL_NO_KW_METHOD_DESCRIPTOR_O`
- `CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS`
- `CALL_NO_KW_METHOD_DESCRIPTOR_FAST`
This commit is contained in:
Guido van Rossum 2023-07-17 11:02:58 -07:00 committed by GitHub
parent b2b261ab2a
commit 2b94a05a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 385 additions and 34 deletions

View file

@ -3462,7 +3462,7 @@
}
TARGET(KW_NAMES) {
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS));
kwnames = GETITEM(FRAME_CO_CONSTS, oparg);
DISPATCH();
@ -3599,7 +3599,7 @@
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
uint32_t func_version = read_u32(&next_instr[1].cache);
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
DEOPT_IF(tstate->interp->eval_frame, CALL);
int is_meth = method != NULL;
int argcount = oparg;
@ -3631,7 +3631,7 @@
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
uint32_t func_version = read_u32(&next_instr[1].cache);
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
DEOPT_IF(tstate->interp->eval_frame, CALL);
int is_meth = method != NULL;
int argcount = oparg;
@ -3673,7 +3673,7 @@
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *null = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
assert(oparg == 1);
DEOPT_IF(null != NULL, CALL);
PyObject *obj = args[0];
@ -3694,7 +3694,7 @@
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *null = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
assert(oparg == 1);
DEOPT_IF(null != NULL, CALL);
DEOPT_IF(callable != (PyObject *)&PyUnicode_Type, CALL);
@ -3717,7 +3717,7 @@
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *null = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
assert(oparg == 1);
DEOPT_IF(null != NULL, CALL);
DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL);
@ -3744,7 +3744,7 @@
* 2. Pushes a shim frame to the frame stack (to cleanup after ``__init__``)
* 3. Pushes the frame for ``__init__`` to the frame stack
* */
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
_PyCallCache *cache = (_PyCallCache *)next_instr;
DEOPT_IF(null != NULL, CALL);
DEOPT_IF(!PyType_Check(callable), CALL);
@ -3844,7 +3844,7 @@
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
/* Builtin METH_O functions */
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
int is_meth = method != NULL;
int total_args = oparg;
if (is_meth) {
@ -3884,7 +3884,7 @@
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
/* Builtin METH_FASTCALL functions, without keywords */
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
int is_meth = method != NULL;
int total_args = oparg;
if (is_meth) {
@ -3971,7 +3971,7 @@
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
/* len(o) */
int is_meth = method != NULL;
int total_args = oparg;
@ -4007,7 +4007,7 @@
PyObject *callable = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
/* isinstance(o, o2) */
int is_meth = method != NULL;
int total_args = oparg;
@ -4044,7 +4044,7 @@
PyObject **args = (stack_pointer - oparg);
PyObject *self = stack_pointer[-(1 + oparg)];
PyObject *method = stack_pointer[-(2 + oparg)];
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
assert(oparg == 1);
assert(method != NULL);
PyInterpreterState *interp = _PyInterpreterState_GET();
@ -4067,7 +4067,7 @@
PyObject **args = (stack_pointer - oparg);
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
int is_meth = method != NULL;
int total_args = oparg;
if (is_meth) {
@ -4149,7 +4149,7 @@
PyObject **args = (stack_pointer - oparg);
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
assert(oparg == 0 || oparg == 1);
int is_meth = method != NULL;
int total_args = oparg;
@ -4189,7 +4189,7 @@
PyObject **args = (stack_pointer - oparg);
PyObject *method = stack_pointer[-(2 + oparg)];
PyObject *res;
assert(kwnames == NULL);
ASSERT_KWNAMES_IS_NULL();
int is_meth = method != NULL;
int total_args = oparg;
if (is_meth) {