From 4c20f46fa011df57190cc19b21bafde1f65e73a7 Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Fri, 25 Apr 2025 19:57:42 +0100 Subject: 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 --- Python/optimizer_bytecodes.c | 4 ++++ Python/optimizer_cases.c.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Python') 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()); -- cgit v1.2.3