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_cases.c.h | |
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_cases.c.h')
-rw-r--r-- | Python/optimizer_cases.c.h | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 4d172e3..fc0c0ef 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -1663,15 +1663,18 @@ _Py_UopsSymbol *self_or_null; _Py_UopsSymbol *callable; _Py_UOpsAbstractFrame *new_frame; - args = &stack_pointer[-oparg]; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; - /* The _Py_UOpsAbstractFrame design assumes that we can copy arguments across directly */ - (void)callable; - (void)self_or_null; - (void)args; - new_frame = NULL; - ctx->done = true; + (void)(self_or_null); + (void)(callable); + PyCodeObject *co = NULL; + assert((this_instr + 2)->opcode == _PUSH_FRAME); + co = get_code_with_logging((this_instr + 2)); + if (co == NULL) { + ctx->done = true; + break; + } + new_frame = frame_new(ctx, co, 0, NULL, 0); stack_pointer[-2 - oparg] = (_Py_UopsSymbol *)new_frame; stack_pointer += -1 - oparg; assert(WITHIN_STACK_BOUNDS()); @@ -1771,23 +1774,10 @@ (void)callable; PyCodeObject *co = NULL; assert((this_instr + 2)->opcode == _PUSH_FRAME); - uint64_t push_operand = (this_instr + 2)->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"); - ctx->done = true; - break; - } - co = (PyCodeObject *)func->func_code; - DPRINTF(3, "code=%p ", co); + co = get_code_with_logging((this_instr + 2)); + if (co == NULL) { + ctx->done = true; + break; } assert(self_or_null != NULL); assert(args != NULL); |