gh-120619: Optimize through _Py_FRAME_GENERAL (GH-124518)

* Optimize through _Py_FRAME_GENERAL

* refactor
This commit is contained in:
Ken Jin 2024-10-03 01:10:51 +08:00 committed by GitHub
parent 8cc5aa47ee
commit b84a763dca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 54 additions and 47 deletions

View file

@ -385,6 +385,30 @@ get_code(_PyUOpInstruction *op)
return co;
}
static PyCodeObject *
get_code_with_logging(_PyUOpInstruction *op)
{
PyCodeObject *co = NULL;
uint64_t push_operand = op->operand;
if (push_operand & 1) {
co = (PyCodeObject *)(push_operand & ~1);
DPRINTF(3, "code=%p ", co);
assert(PyCode_Check(co));
}
else {
PyFunctionObject *func = (PyFunctionObject *)push_operand;
DPRINTF(3, "func=%p ", func);
if (func == NULL) {
DPRINTF(3, "\n");
DPRINTF(1, "Missing function\n");
return NULL;
}
co = (PyCodeObject *)func->func_code;
DPRINTF(3, "code=%p ", co);
}
return co;
}
/* 1 for success, 0 for not ready, cannot error at the moment. */
static int
optimize_uops(