GH-122029: Break INSTRUMENTED_CALL into micro-ops, so that its behavior is consistent with CALL (GH-122177)

This commit is contained in:
Mark Shannon 2024-07-26 14:35:57 +01:00 committed by GitHub
parent afb0aa6ed2
commit 95a73917cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 341 additions and 153 deletions

View file

@ -3584,15 +3584,45 @@
break;
}
/* _INSTRUMENTED_CALL is not a viable micro-op for tier 2 because it is instrumented */
case _MAYBE_EXPAND_METHOD: {
_PyStackRef *args;
_PyStackRef self_or_null;
_PyStackRef callable;
_PyStackRef func;
_PyStackRef maybe_self;
oparg = CURRENT_OPARG();
args = &stack_pointer[-oparg];
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
if (PyStackRef_TYPE(callable) == &PyMethod_Type && PyStackRef_IsNull(self_or_null)) {
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
PyObject *self = ((PyMethodObject *)callable_o)->im_self;
maybe_self = PyStackRef_FromPyObjectNew(self);
PyObject *method = ((PyMethodObject *)callable_o)->im_func;
func = PyStackRef_FromPyObjectNew(method);
/* 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;
}
stack_pointer[-2 - oparg] = func;
stack_pointer[-1 - oparg] = maybe_self;
break;
}
/* _CALL is not a viable micro-op for tier 2 because it uses the 'this_instr' variable */
/* _DO_CALL is not a viable micro-op for tier 2 because it uses the 'this_instr' variable */
case _CHECK_PERIODIC: {
CHECK_EVAL_BREAKER();
break;
}
/* _MONITOR_CALL is not a viable micro-op for tier 2 because it uses the 'this_instr' variable */
case _PY_FRAME_GENERAL: {
_PyStackRef *args;
_PyStackRef self_or_null;