mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
GH-123996: Explicitly mark 'self_or_null' as an array of size 1 to ensure that it is kept in memory for calls (GH-124003)
This commit is contained in:
parent
3ea51fa2e3
commit
4ed7d1d6ac
7 changed files with 344 additions and 327 deletions
233
Python/generated_cases.c.h
generated
233
Python/generated_cases.c.h
generated
|
@ -834,13 +834,13 @@
|
|||
_Py_CODEUNIT *this_instr = next_instr - 4;
|
||||
(void)this_instr;
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef func;
|
||||
_PyStackRef maybe_self;
|
||||
_PyStackRef *maybe_self;
|
||||
_PyStackRef res;
|
||||
// _SPECIALIZE_CALL
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
uint16_t counter = read_u16(&this_instr[1].cache);
|
||||
|
@ -848,7 +848,7 @@
|
|||
#if ENABLE_SPECIALIZATION
|
||||
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
|
||||
next_instr = this_instr;
|
||||
_Py_Specialize_Call(callable, next_instr, oparg + !PyStackRef_IsNull(self_or_null));
|
||||
_Py_Specialize_Call(callable, next_instr, oparg + !PyStackRef_IsNull(self_or_null[0]));
|
||||
DISPATCH_SAME_OPARG();
|
||||
}
|
||||
OPCODE_DEFERRED_INC(CALL);
|
||||
|
@ -859,23 +859,18 @@
|
|||
// _MAYBE_EXPAND_METHOD
|
||||
args = &stack_pointer[-oparg];
|
||||
{
|
||||
args = &stack_pointer[-oparg];
|
||||
if (PyStackRef_TYPE(callable) == &PyMethod_Type && PyStackRef_IsNull(self_or_null)) {
|
||||
maybe_self = &stack_pointer[-1 - oparg];
|
||||
if (PyStackRef_TYPE(callable) == &PyMethod_Type && PyStackRef_IsNull(self_or_null[0])) {
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self = ((PyMethodObject *)callable_o)->im_self;
|
||||
maybe_self = PyStackRef_FromPyObjectNew(self);
|
||||
stack_pointer[-1 - oparg] = maybe_self;
|
||||
maybe_self[0] = PyStackRef_FromPyObjectNew(self);
|
||||
PyObject *method = ((PyMethodObject *)callable_o)->im_func;
|
||||
func = PyStackRef_FromPyObjectNew(method);
|
||||
stack_pointer[-2 - oparg] = func;
|
||||
/* Make sure that callable and all args are in memory */
|
||||
args[-2] = func;
|
||||
args[-1] = maybe_self;
|
||||
PyStackRef_CLOSE(callable);
|
||||
}
|
||||
else {
|
||||
func = callable;
|
||||
maybe_self = self_or_null;
|
||||
}
|
||||
}
|
||||
// _DO_CALL
|
||||
|
@ -885,7 +880,7 @@
|
|||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
// oparg counts all of the args, but *not* self:
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1066,10 +1061,10 @@
|
|||
INSTRUCTION_STATS(CALL_BOUND_METHOD_EXACT_ARGS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef null;
|
||||
_PyStackRef *null;
|
||||
_PyStackRef func;
|
||||
_PyStackRef self;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyInterpreterFrame *new_frame;
|
||||
/* Skip 1 cache entry */
|
||||
|
@ -1078,18 +1073,18 @@
|
|||
DEOPT_IF(tstate->interp->eval_frame, CALL);
|
||||
}
|
||||
// _CHECK_CALL_BOUND_METHOD_EXACT_ARGS
|
||||
null = stack_pointer[-1 - oparg];
|
||||
null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
DEOPT_IF(!PyStackRef_IsNull(null), CALL);
|
||||
DEOPT_IF(!PyStackRef_IsNull(null[0]), CALL);
|
||||
DEOPT_IF(Py_TYPE(PyStackRef_AsPyObjectBorrow(callable)) != &PyMethod_Type, CALL);
|
||||
}
|
||||
// _INIT_CALL_BOUND_METHOD_EXACT_ARGS
|
||||
{
|
||||
self = &stack_pointer[-1 - oparg];
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
STAT_INC(CALL, hit);
|
||||
self = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
|
||||
stack_pointer[-1 - oparg] = self;
|
||||
self[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
|
||||
func = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
|
||||
stack_pointer[-2 - oparg] = func;
|
||||
PyStackRef_CLOSE(callable);
|
||||
|
@ -1105,13 +1100,13 @@
|
|||
DEOPT_IF(func->func_version != func_version, CALL);
|
||||
}
|
||||
// _CHECK_FUNCTION_EXACT_ARGS
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
assert(PyFunction_Check(callable_o));
|
||||
PyFunctionObject *func = (PyFunctionObject *)callable_o;
|
||||
PyCodeObject *code = (PyCodeObject *)func->func_code;
|
||||
DEOPT_IF(code->co_argcount != oparg + (!PyStackRef_IsNull(self_or_null)), CALL);
|
||||
DEOPT_IF(code->co_argcount != oparg + (!PyStackRef_IsNull(self_or_null[0])), CALL);
|
||||
}
|
||||
// _CHECK_STACK_SPACE
|
||||
{
|
||||
|
@ -1125,12 +1120,12 @@
|
|||
args = &stack_pointer[-oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int has_self = !PyStackRef_IsNull(self_or_null);
|
||||
int has_self = !PyStackRef_IsNull(self_or_null[0]);
|
||||
STAT_INC(CALL, hit);
|
||||
PyFunctionObject *func = (PyFunctionObject *)callable_o;
|
||||
new_frame = _PyFrame_PushUnchecked(tstate, func, oparg + has_self, frame);
|
||||
_PyStackRef *first_non_self_local = new_frame->localsplus + has_self;
|
||||
new_frame->localsplus[0] = self_or_null;
|
||||
new_frame->localsplus[0] = self_or_null[0];
|
||||
for (int i = 0; i < oparg; i++) {
|
||||
first_non_self_local[i] = args[i];
|
||||
}
|
||||
|
@ -1169,10 +1164,10 @@
|
|||
INSTRUCTION_STATS(CALL_BOUND_METHOD_GENERAL);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef null;
|
||||
_PyStackRef *null;
|
||||
_PyStackRef method;
|
||||
_PyStackRef self;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyInterpreterFrame *new_frame;
|
||||
/* Skip 1 cache entry */
|
||||
|
@ -1181,7 +1176,7 @@
|
|||
DEOPT_IF(tstate->interp->eval_frame, CALL);
|
||||
}
|
||||
// _CHECK_METHOD_VERSION
|
||||
null = stack_pointer[-1 - oparg];
|
||||
null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
uint32_t func_version = read_u32(&this_instr[2].cache);
|
||||
|
@ -1190,15 +1185,15 @@
|
|||
PyObject *func = ((PyMethodObject *)callable_o)->im_func;
|
||||
DEOPT_IF(!PyFunction_Check(func), CALL);
|
||||
DEOPT_IF(((PyFunctionObject *)func)->func_version != func_version, CALL);
|
||||
DEOPT_IF(!PyStackRef_IsNull(null), CALL);
|
||||
DEOPT_IF(!PyStackRef_IsNull(null[0]), CALL);
|
||||
}
|
||||
// _EXPAND_METHOD
|
||||
{
|
||||
self = &stack_pointer[-1 - oparg];
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
assert(PyStackRef_IsNull(null));
|
||||
assert(PyStackRef_IsNull(null[0]));
|
||||
assert(Py_TYPE(callable_o) == &PyMethod_Type);
|
||||
self = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
|
||||
stack_pointer[-1 - oparg] = self;
|
||||
self[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
|
||||
method = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
|
||||
stack_pointer[-2 - oparg] = method;
|
||||
assert(PyStackRef_FunctionCheck(method));
|
||||
|
@ -1207,14 +1202,13 @@
|
|||
// flush
|
||||
// _PY_FRAME_GENERAL
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self_or_null_o = PyStackRef_AsPyObjectBorrow(self_or_null);
|
||||
// oparg counts all of the args, but *not* self:
|
||||
int total_args = oparg;
|
||||
if (self_or_null_o != NULL) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1265,19 +1259,19 @@
|
|||
INSTRUCTION_STATS(CALL_BUILTIN_CLASS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_BUILTIN_CLASS
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1288,7 +1282,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -1338,20 +1332,20 @@
|
|||
INSTRUCTION_STATS(CALL_BUILTIN_FAST);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_BUILTIN_FAST
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
/* Builtin METH_FASTCALL functions, without keywords */
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1363,7 +1357,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -1417,20 +1411,20 @@
|
|||
INSTRUCTION_STATS(CALL_BUILTIN_FAST_WITH_KEYWORDS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_BUILTIN_FAST_WITH_KEYWORDS
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
/* Builtin METH_FASTCALL | METH_KEYWORDS functions */
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1444,7 +1438,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -1495,20 +1489,20 @@
|
|||
INSTRUCTION_STATS(CALL_BUILTIN_O);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_BUILTIN_O
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
/* Builtin METH_O functions */
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1711,18 +1705,18 @@
|
|||
INSTRUCTION_STATS(CALL_ISINSTANCE);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
/* isinstance(o, o2) */
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1755,12 +1749,12 @@
|
|||
_Py_CODEUNIT *this_instr = next_instr - 4;
|
||||
(void)this_instr;
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef kwnames;
|
||||
_PyStackRef res;
|
||||
// _SPECIALIZE_CALL_KW
|
||||
self_or_null = stack_pointer[-2 - oparg];
|
||||
self_or_null = &stack_pointer[-2 - oparg];
|
||||
callable = stack_pointer[-3 - oparg];
|
||||
{
|
||||
uint16_t counter = read_u16(&this_instr[1].cache);
|
||||
|
@ -1768,7 +1762,7 @@
|
|||
#if ENABLE_SPECIALIZATION
|
||||
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
|
||||
next_instr = this_instr;
|
||||
_Py_Specialize_CallKw(callable, next_instr, oparg + !PyStackRef_IsNull(self_or_null));
|
||||
_Py_Specialize_CallKw(callable, next_instr, oparg + !PyStackRef_IsNull(self_or_null[0]));
|
||||
DISPATCH_SAME_OPARG();
|
||||
}
|
||||
OPCODE_DEFERRED_INC(CALL_KW);
|
||||
|
@ -1781,15 +1775,14 @@
|
|||
args = &stack_pointer[-1 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self_or_null_o = PyStackRef_AsPyObjectBorrow(self_or_null);
|
||||
PyObject *kwnames_o = PyStackRef_AsPyObjectBorrow(kwnames);
|
||||
// oparg counts all of the args, but *not* self:
|
||||
int total_args = oparg;
|
||||
if (self_or_null_o != NULL) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
if (self_or_null_o == NULL && Py_TYPE(callable_o) == &PyMethod_Type) {
|
||||
else if (Py_TYPE(callable_o) == &PyMethod_Type) {
|
||||
args--;
|
||||
total_args++;
|
||||
PyObject *self = ((PyMethodObject *)callable_o)->im_self;
|
||||
|
@ -1828,7 +1821,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -1886,11 +1879,11 @@
|
|||
INSTRUCTION_STATS(CALL_KW_BOUND_METHOD);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef null;
|
||||
_PyStackRef *null;
|
||||
_PyStackRef kwnames;
|
||||
_PyStackRef method;
|
||||
_PyStackRef self;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyInterpreterFrame *new_frame;
|
||||
/* Skip 1 cache entry */
|
||||
|
@ -1899,7 +1892,7 @@
|
|||
DEOPT_IF(tstate->interp->eval_frame, CALL_KW);
|
||||
}
|
||||
// _CHECK_METHOD_VERSION_KW
|
||||
null = stack_pointer[-2 - oparg];
|
||||
null = &stack_pointer[-2 - oparg];
|
||||
callable = stack_pointer[-3 - oparg];
|
||||
{
|
||||
uint32_t func_version = read_u32(&this_instr[2].cache);
|
||||
|
@ -1908,16 +1901,16 @@
|
|||
PyObject *func = ((PyMethodObject *)callable_o)->im_func;
|
||||
DEOPT_IF(!PyFunction_Check(func), CALL_KW);
|
||||
DEOPT_IF(((PyFunctionObject *)func)->func_version != func_version, CALL_KW);
|
||||
DEOPT_IF(!PyStackRef_IsNull(null), CALL_KW);
|
||||
DEOPT_IF(!PyStackRef_IsNull(null[0]), CALL_KW);
|
||||
}
|
||||
// _EXPAND_METHOD_KW
|
||||
kwnames = stack_pointer[-1];
|
||||
{
|
||||
self = &stack_pointer[-2 - oparg];
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
assert(PyStackRef_IsNull(null));
|
||||
assert(PyStackRef_IsNull(null[0]));
|
||||
assert(Py_TYPE(callable_o) == &PyMethod_Type);
|
||||
self = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
|
||||
stack_pointer[-2 - oparg] = self;
|
||||
self[0] = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_self);
|
||||
method = PyStackRef_FromPyObjectNew(((PyMethodObject *)callable_o)->im_func);
|
||||
stack_pointer[-3 - oparg] = method;
|
||||
assert(PyStackRef_FunctionCheck(method));
|
||||
|
@ -1927,14 +1920,13 @@
|
|||
// _PY_FRAME_KW
|
||||
kwnames = stack_pointer[-1];
|
||||
args = &stack_pointer[-1 - oparg];
|
||||
self_or_null = stack_pointer[-2 - oparg];
|
||||
self_or_null = &stack_pointer[-2 - oparg];
|
||||
callable = stack_pointer[-3 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self_or_null_o = PyStackRef_AsPyObjectBorrow(self_or_null);
|
||||
// oparg counts all of the args, but *not* self:
|
||||
int total_args = oparg;
|
||||
if (self_or_null_o != NULL) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -1989,7 +1981,7 @@
|
|||
static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef kwnames;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
|
@ -2004,15 +1996,14 @@
|
|||
// _CALL_KW_NON_PY
|
||||
kwnames = stack_pointer[-1];
|
||||
args = &stack_pointer[-1 - oparg];
|
||||
self_or_null = stack_pointer[-2 - oparg];
|
||||
self_or_null = &stack_pointer[-2 - oparg];
|
||||
{
|
||||
#if TIER_ONE
|
||||
assert(opcode != INSTRUMENTED_CALL);
|
||||
#endif
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self_or_null_o = PyStackRef_AsPyObjectBorrow(self_or_null);
|
||||
int total_args = oparg;
|
||||
if (self_or_null_o != NULL) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2020,7 +2011,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -2077,7 +2068,7 @@
|
|||
INSTRUCTION_STATS(CALL_KW_PY);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef kwnames;
|
||||
_PyStackRef *args;
|
||||
_PyInterpreterFrame *new_frame;
|
||||
|
@ -2098,13 +2089,12 @@
|
|||
// _PY_FRAME_KW
|
||||
kwnames = stack_pointer[-1];
|
||||
args = &stack_pointer[-1 - oparg];
|
||||
self_or_null = stack_pointer[-2 - oparg];
|
||||
self_or_null = &stack_pointer[-2 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self_or_null_o = PyStackRef_AsPyObjectBorrow(self_or_null);
|
||||
// oparg counts all of the args, but *not* self:
|
||||
int total_args = oparg;
|
||||
if (self_or_null_o != NULL) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2158,18 +2148,18 @@
|
|||
INSTRUCTION_STATS(CALL_LEN);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
/* len(o) */
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2239,19 +2229,19 @@
|
|||
INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_FAST);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_METHOD_DESCRIPTOR_FAST
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2269,7 +2259,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, nargs, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -2320,19 +2310,19 @@
|
|||
INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2350,7 +2340,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, nargs, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -2401,20 +2391,20 @@
|
|||
INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_NOARGS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_METHOD_DESCRIPTOR_NOARGS
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
assert(oparg == 0 || oparg == 1);
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2469,19 +2459,19 @@
|
|||
INSTRUCTION_STATS(CALL_METHOD_DESCRIPTOR_O);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
/* Skip 2 cache entries */
|
||||
// _CALL_METHOD_DESCRIPTOR_O
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2540,7 +2530,7 @@
|
|||
INSTRUCTION_STATS(CALL_NON_PY_GENERAL);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef res;
|
||||
/* Skip 1 cache entry */
|
||||
|
@ -2554,15 +2544,14 @@
|
|||
}
|
||||
// _CALL_NON_PY_GENERAL
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
{
|
||||
#if TIER_ONE
|
||||
assert(opcode != INSTRUMENTED_CALL);
|
||||
#endif
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self_or_null_o = PyStackRef_AsPyObjectBorrow(self_or_null);
|
||||
int total_args = oparg;
|
||||
if (self_or_null_o != NULL) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -2570,7 +2559,7 @@
|
|||
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
|
||||
if (CONVERSION_FAILED(args_o)) {
|
||||
PyStackRef_CLOSE(callable);
|
||||
PyStackRef_CLOSE(self_or_null);
|
||||
PyStackRef_CLOSE(self_or_null[0]);
|
||||
for (int _i = oparg; --_i >= 0;) {
|
||||
PyStackRef_CLOSE(args[_i]);
|
||||
}
|
||||
|
@ -2623,7 +2612,7 @@
|
|||
INSTRUCTION_STATS(CALL_PY_EXACT_ARGS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyInterpreterFrame *new_frame;
|
||||
/* Skip 1 cache entry */
|
||||
|
@ -2641,13 +2630,13 @@
|
|||
DEOPT_IF(func->func_version != func_version, CALL);
|
||||
}
|
||||
// _CHECK_FUNCTION_EXACT_ARGS
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
assert(PyFunction_Check(callable_o));
|
||||
PyFunctionObject *func = (PyFunctionObject *)callable_o;
|
||||
PyCodeObject *code = (PyCodeObject *)func->func_code;
|
||||
DEOPT_IF(code->co_argcount != oparg + (!PyStackRef_IsNull(self_or_null)), CALL);
|
||||
DEOPT_IF(code->co_argcount != oparg + (!PyStackRef_IsNull(self_or_null[0])), CALL);
|
||||
}
|
||||
// _CHECK_STACK_SPACE
|
||||
{
|
||||
|
@ -2661,12 +2650,12 @@
|
|||
args = &stack_pointer[-oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
int has_self = !PyStackRef_IsNull(self_or_null);
|
||||
int has_self = !PyStackRef_IsNull(self_or_null[0]);
|
||||
STAT_INC(CALL, hit);
|
||||
PyFunctionObject *func = (PyFunctionObject *)callable_o;
|
||||
new_frame = _PyFrame_PushUnchecked(tstate, func, oparg + has_self, frame);
|
||||
_PyStackRef *first_non_self_local = new_frame->localsplus + has_self;
|
||||
new_frame->localsplus[0] = self_or_null;
|
||||
new_frame->localsplus[0] = self_or_null[0];
|
||||
for (int i = 0; i < oparg; i++) {
|
||||
first_non_self_local[i] = args[i];
|
||||
}
|
||||
|
@ -2705,7 +2694,7 @@
|
|||
INSTRUCTION_STATS(CALL_PY_GENERAL);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyInterpreterFrame *new_frame;
|
||||
/* Skip 1 cache entry */
|
||||
|
@ -2724,13 +2713,12 @@
|
|||
}
|
||||
// _PY_FRAME_GENERAL
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
{
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self_or_null_o = PyStackRef_AsPyObjectBorrow(self_or_null);
|
||||
// oparg counts all of the args, but *not* self:
|
||||
int total_args = oparg;
|
||||
if (self_or_null_o != NULL) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
@ -4050,43 +4038,38 @@
|
|||
next_instr += 4;
|
||||
INSTRUCTION_STATS(INSTRUMENTED_CALL);
|
||||
_PyStackRef callable;
|
||||
_PyStackRef self_or_null;
|
||||
_PyStackRef *self_or_null;
|
||||
_PyStackRef *args;
|
||||
_PyStackRef func;
|
||||
_PyStackRef maybe_self;
|
||||
_PyStackRef *maybe_self;
|
||||
_PyStackRef res;
|
||||
/* Skip 3 cache entries */
|
||||
// _MAYBE_EXPAND_METHOD
|
||||
args = &stack_pointer[-oparg];
|
||||
self_or_null = stack_pointer[-1 - oparg];
|
||||
self_or_null = &stack_pointer[-1 - oparg];
|
||||
callable = stack_pointer[-2 - oparg];
|
||||
{
|
||||
args = &stack_pointer[-oparg];
|
||||
if (PyStackRef_TYPE(callable) == &PyMethod_Type && PyStackRef_IsNull(self_or_null)) {
|
||||
maybe_self = &stack_pointer[-1 - oparg];
|
||||
if (PyStackRef_TYPE(callable) == &PyMethod_Type && PyStackRef_IsNull(self_or_null[0])) {
|
||||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
PyObject *self = ((PyMethodObject *)callable_o)->im_self;
|
||||
maybe_self = PyStackRef_FromPyObjectNew(self);
|
||||
stack_pointer[-1 - oparg] = maybe_self;
|
||||
maybe_self[0] = PyStackRef_FromPyObjectNew(self);
|
||||
PyObject *method = ((PyMethodObject *)callable_o)->im_func;
|
||||
func = PyStackRef_FromPyObjectNew(method);
|
||||
stack_pointer[-2 - oparg] = func;
|
||||
/* Make sure that callable and all args are in memory */
|
||||
args[-2] = func;
|
||||
args[-1] = maybe_self;
|
||||
PyStackRef_CLOSE(callable);
|
||||
}
|
||||
else {
|
||||
func = callable;
|
||||
maybe_self = self_or_null;
|
||||
}
|
||||
}
|
||||
// _MONITOR_CALL
|
||||
{
|
||||
int is_meth = !PyStackRef_IsNull(maybe_self);
|
||||
int is_meth = !PyStackRef_IsNull(maybe_self[0]);
|
||||
PyObject *function = PyStackRef_AsPyObjectBorrow(func);
|
||||
PyObject *arg0;
|
||||
if (is_meth) {
|
||||
arg0 = PyStackRef_AsPyObjectBorrow(maybe_self);
|
||||
arg0 = PyStackRef_AsPyObjectBorrow(maybe_self[0]);
|
||||
}
|
||||
else if (oparg) {
|
||||
arg0 = PyStackRef_AsPyObjectBorrow(args[0]);
|
||||
|
@ -4107,7 +4090,7 @@
|
|||
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
|
||||
// oparg counts all of the args, but *not* self:
|
||||
int total_args = oparg;
|
||||
if (!PyStackRef_IsNull(self_or_null)) {
|
||||
if (!PyStackRef_IsNull(self_or_null[0])) {
|
||||
args--;
|
||||
total_args++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue