diff options
author | Diego Russo <diego.russo@arm.com> | 2025-04-25 19:57:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-26 02:57:42 +0800 |
commit | 4c20f46fa011df57190cc19b21bafde1f65e73a7 (patch) | |
tree | db49f24d3d6d165b75b043ba14c8d2a5d8d2b442 /Python | |
parent | f0485de43ad7403bb74824f445d2cf1f3d192904 (diff) | |
download | cpython-4c20f46fa011df57190cc19b21bafde1f65e73a7.tar.gz cpython-4c20f46fa011df57190cc19b21bafde1f65e73a7.zip |
gh-131798: JIT: Narrow the return type of _CALL_LEN to int (#132940)
Reduce unnecessary guards whenever `len()` is called and used
after.
Co-authored-by: Max Bernstein <tekknolagi@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/optimizer_bytecodes.c | 4 | ||||
-rw-r--r-- | Python/optimizer_cases.c.h | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index ff2830d3003..040e54479b7 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -1055,6 +1055,10 @@ dummy_func(void) { sym_set_const(callable, (PyObject *)&PyUnicode_Type); } + op(_CALL_LEN, (callable[1], self_or_null[1], args[oparg] -- res)) { + res = sym_new_type(ctx, &PyLong_Type); + } + // END BYTECODES // } diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 303e402b759..9a5a362ec19 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -2014,7 +2014,7 @@ case _CALL_LEN: { JitOptSymbol *res; - res = sym_new_not_null(ctx); + res = sym_new_type(ctx, &PyLong_Type); stack_pointer[-2 - oparg] = res; stack_pointer += -1 - oparg; assert(WITHIN_STACK_BOUNDS()); |