diff options
author | Ken Jin <kenjin@python.org> | 2024-10-02 17:10:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-02 17:10:51 (GMT) |
commit | b84a763dca412e8dbbc9cf7c6273c11d6c2220a7 (patch) | |
tree | 286ebe937e1a1f23b4b24fdb1bd9deb87e3a845f /Python/optimizer_analysis.c | |
parent | 8cc5aa47ee464ddfd8da5461edecf4a5c72df2ff (diff) | |
download | cpython-b84a763dca412e8dbbc9cf7c6273c11d6c2220a7.zip cpython-b84a763dca412e8dbbc9cf7c6273c11d6c2220a7.tar.gz cpython-b84a763dca412e8dbbc9cf7c6273c11d6c2220a7.tar.bz2 |
gh-120619: Optimize through `_Py_FRAME_GENERAL` (GH-124518)
* Optimize through _Py_FRAME_GENERAL
* refactor
Diffstat (limited to 'Python/optimizer_analysis.c')
-rw-r--r-- | Python/optimizer_analysis.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index f30e873..06826ff 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -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( |