Skip to content

Commit fe5b174

Browse files
committed
Don't check whethed non-methods are methods
1 parent e2b35ee commit fe5b174

File tree

3 files changed

+40
-113
lines changed

3 files changed

+40
-113
lines changed

Python/bytecodes.c

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3912,10 +3912,10 @@ dummy_func(
39123912
PyObject *arg_o = PyStackRef_AsPyObjectBorrow(arg);
39133913

39143914
assert(oparg == 1);
3915-
DEOPT_IF(!PyStackRef_IsNull(null));
3916-
DEAD(null);
39173915
DEOPT_IF(callable_o != (PyObject *)&PyType_Type);
39183916
DEAD(callable);
3917+
assert(PyStackRef_IsNull(null));
3918+
DEAD(null);
39193919
STAT_INC(CALL, hit);
39203920
res = PyStackRef_FromPyObjectNew(Py_TYPE(arg_o));
39213921
PyStackRef_CLOSE(arg);
@@ -3926,8 +3926,8 @@ dummy_func(
39263926
PyObject *arg_o = PyStackRef_AsPyObjectBorrow(arg);
39273927

39283928
assert(oparg == 1);
3929-
DEOPT_IF(!PyStackRef_IsNull(null));
39303929
DEOPT_IF(callable_o != (PyObject *)&PyUnicode_Type);
3930+
assert(PyStackRef_IsNull(null));
39313931
STAT_INC(CALL, hit);
39323932
PyObject *res_o = PyObject_Str(arg_o);
39333933
DEAD(null);
@@ -3948,8 +3948,8 @@ dummy_func(
39483948
PyObject *arg_o = PyStackRef_AsPyObjectBorrow(arg);
39493949

39503950
assert(oparg == 1);
3951-
DEOPT_IF(!PyStackRef_IsNull(null));
39523951
DEOPT_IF(callable_o != (PyObject *)&PyTuple_Type);
3952+
assert(PyStackRef_IsNull(null));
39533953
STAT_INC(CALL, hit);
39543954
PyObject *res_o = PySequence_Tuple(arg_o);
39553955
DEAD(null);
@@ -4036,20 +4036,15 @@ dummy_func(
40364036
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]);
40374037
DEOPT_IF(!PyType_Check(callable_o));
40384038
PyTypeObject *tp = (PyTypeObject *)callable_o;
4039-
int total_args = oparg;
4040-
_PyStackRef *arguments = args;
4041-
if (!PyStackRef_IsNull(self_or_null[0])) {
4042-
arguments--;
4043-
total_args++;
4044-
}
4039+
DEOPT_IF(!PyStackRef_IsNull(self_or_null[0]));
40454040
DEOPT_IF(tp->tp_vectorcall == NULL);
40464041
STAT_INC(CALL, hit);
4047-
STACKREFS_TO_PYOBJECTS(arguments, total_args, args_o);
4042+
STACKREFS_TO_PYOBJECTS(args, oparg, args_o);
40484043
if (CONVERSION_FAILED(args_o)) {
40494044
DECREF_INPUTS();
40504045
ERROR_IF(true, error);
40514046
}
4052-
PyObject *res_o = tp->tp_vectorcall((PyObject *)tp, args_o, total_args, NULL);
4047+
PyObject *res_o = tp->tp_vectorcall((PyObject *)tp, args_o, oparg, NULL);
40534048
STACKREFS_TO_PYOBJECTS_CLEANUP(args_o);
40544049
DECREF_INPUTS();
40554050
ERROR_IF(res_o == NULL, error);
@@ -4175,14 +4170,10 @@ dummy_func(
41754170
/* len(o) */
41764171
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]);
41774172

4178-
int total_args = oparg;
4179-
if (!PyStackRef_IsNull(self_or_null[0])) {
4180-
args--;
4181-
total_args++;
4182-
}
4183-
DEOPT_IF(total_args != 1);
4173+
assert(oparg == 1);
41844174
PyInterpreterState *interp = tstate->interp;
41854175
DEOPT_IF(callable_o != interp->callable_cache.len);
4176+
assert(PyStackRef_IsNull(self_or_null[0]));
41864177
STAT_INC(CALL, hit);
41874178
_PyStackRef arg_stackref = args[0];
41884179
PyObject *arg = PyStackRef_AsPyObjectBorrow(arg_stackref);
@@ -4206,24 +4197,18 @@ dummy_func(
42064197
/* isinstance(o, o2) */
42074198
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
42084199

4209-
int total_args = oparg;
4210-
_PyStackRef *arguments = args;
4211-
if (!PyStackRef_IsNull(self_or_null[0])) {
4212-
arguments--;
4213-
total_args++;
4214-
}
4215-
DEOPT_IF(total_args != 2);
4200+
assert(oparg == 2);
42164201
PyInterpreterState *interp = tstate->interp;
42174202
DEOPT_IF(callable_o != interp->callable_cache.isinstance);
4203+
assert(PyStackRef_IsNull(self_or_null[0]));
42184204
STAT_INC(CALL, hit);
4219-
_PyStackRef cls_stackref = arguments[1];
4220-
_PyStackRef inst_stackref = arguments[0];
4205+
_PyStackRef cls_stackref = args[1];
4206+
_PyStackRef inst_stackref = args[0];
42214207
int retval = PyObject_IsInstance(PyStackRef_AsPyObjectBorrow(inst_stackref), PyStackRef_AsPyObjectBorrow(cls_stackref));
42224208
if (retval < 0) {
42234209
ERROR_NO_POP();
42244210
}
42254211
res = retval ? PyStackRef_True : PyStackRef_False;
4226-
assert((!PyStackRef_IsNull(res)) ^ (_PyErr_Occurred(tstate) != NULL));
42274212
DECREF_INPUTS();
42284213
}
42294214

Python/executor_cases.c.h

Lines changed: 13 additions & 40 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: 14 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)