Commit Graph

95 Commits

Author SHA1 Message Date
Noam Cohen 79d81f7cba
gh-131798: Optimize `_ITER_CHECK_TUPLE` (GH-134803) 2025-05-28 02:30:17 +08:00
Mark Shannon f6f4e8a662
GH-132554: "Virtual" iterators (GH-132555)
* FOR_ITER now pushes either the iterator and NULL or leaves the iterable and pushes tagged zero

* NEXT_ITER uses the tagged int as the index into the sequence or, if TOS is NULL, iterates as before.
2025-05-27 15:59:45 +01:00
Tomas R. 484e00379b
GH-131798: Optimize away isinstance calls in the JIT (GH-134369) 2025-05-22 12:52:47 -04:00
Brandt Bucher ec736e7dae
GH-131798: Optimize cached class attributes and methods in the JIT (GH-134403) 2025-05-22 11:15:03 -04:00
Nadeshiko Manju 8c5e5557c6
GH-131798: Turn _LOAD_SMALL_INT into _LOAD_CONST_INLINE_BORROW in the JIT (GH-134406) 2025-05-22 09:54:57 -04:00
Brandt Bucher 2f0570caf4
GH-131798: Narrow types more aggressively in the JIT (GH-134373) 2025-05-20 18:09:51 -04:00
Nadeshiko Manju e1c0c451a2
GH-131798: Narrow the return type of _GET_LEN to int (GH-133345) 2025-05-20 18:02:50 -04:00
Mark Shannon 6dcb0fdfe0
GH-134282: Always borrow references LOAD_CONST (GH-134284) 2025-05-20 11:24:11 -04:00
Tomas R. a7f317d730
GH-131798: Add _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW (GH-134268) 2025-05-19 18:00:53 -04:00
Diego Russo 42d03f3933
GH-131798: Split CALL_LIST_APPEND into several uops (GH-134240) 2025-05-19 15:48:55 -04:00
Tomas R. 8d490b3687
GH-131798: Narrow the return type of isinstance for some known arguments in the JIT (GH-133172) 2025-05-19 13:19:24 -04:00
Tomas R. c492ac7252
GH-131798: Split up and optimize CALL_ISINSTANCE (GH-133339) 2025-05-08 14:26:30 -07:00
Tomas R. 3f2f59a91d
gh-133273: Keep instruction definitions in `bytecodes.c` and `optimizer_bytecodes.c` in sync (GH-133320) 2025-05-09 01:54:49 +08:00
Diego Russo 9cc77aaf9d
GH-131798: Split CALL_LEN into several uops (GH-133180) 2025-05-05 14:31:48 -07:00
Nadeshiko Manju 614d79231d
gh-131798: JIT - Use `sym_new_type` instead of `sym_new_not_null` for _BUILD_STRING, _BUILD_SET (GH-132564)
Signed-off-by: Manjusaka <me@manjusaka.me>
2025-04-27 20:30:28 +08:00
Tomas R. 5e96e4fca8
gh-131798: JIT: Propagate the result in `_BINARY_OP_SUBSCR_TUPLE_INT` (GH-133003) 2025-04-27 02:47:55 +08:00
Diego Russo 4c20f46fa0
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>
2025-04-26 02:57:42 +08:00
Tomas R. 08e3389e8c
GH-131798: Split up and optimize CALL_TUPLE_1 in the JIT (GH-132851) 2025-04-24 15:55:03 -07:00
Tomas R. 0a387b311e
GH-131798: Split up and optimize CALL_STR_1 in the JIT (GH-132849) 2025-04-24 12:54:46 -07:00
Tomas R. a6a3dbb7db
GH-131798: JIT: Split CALL_TYPE_1 into several uops (GH-132419) 2025-04-22 09:30:38 -07:00
Sam Gross da53660f35
gh-131586: Avoid refcount contention in context managers (gh-131851)
This avoid reference count contention in the free threading build
when calling special methods like `__enter__` and `__exit__`.
2025-04-21 15:54:25 -04:00
Brandt Bucher 4f7f72ce34
GH-130415: Improve the JIT's unneeded uop removal pass (GH-132333) 2025-04-21 09:58:55 -07:00
Brandt Bucher 40ae88988c
GH-131498: Replace single-element arrays with scalars in bytecodes.c (GH-132615) 2025-04-18 07:16:28 -07:00
Nadeshiko Manju b9e88ff4cb
gh-131798: Use `sym_new_type` instead of `sym_new_not_null` for `_BUILD_LIST`, `_BUILD_SLICE`, and `_BUILD_MAP` (GH-132434)
---------

Signed-off-by: Manjusaka <me@manjusaka.me>
2025-04-17 01:17:48 +08:00
Brandt Bucher 20926c73b5
GH-131798: Remove JIT guards for dict, frozenset, list, set, and tuple (GH-132289) 2025-04-09 14:32:21 -07:00
Nadeshiko Manju d753d8aed7
GH-131798: Narrow the result of _CONTAINS_OP_DICT to bool in the JIT (GH-132269)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-08 09:12:09 -07:00
Tomas R. 71009cb835
GH-131798: Narrow the result type of _BINARY_OP_SUBSCR_STR_INT to str in the JIT (GH-132153) 2025-04-08 08:22:54 -07:00
Tomas R. 85bc489b64
GH-131798: Narrow the result of _CONTAINS_OP_SET to bool in the JIT (GH-132057) 2025-04-05 15:56:01 -07:00
Mark Shannon ad053d8d6a
GH-131498: Cases generator: Parse down to C statement level. (GH-131948)
* Parse down to statement level in the cases generator

* Add handling for #if macros, treating them much like normal ifs.
2025-04-02 16:31:59 +01:00
Brandt Bucher 1a9d4a1fb3
GH-131798: Allow the JIT to remove more int/float/str guards (GH-131800) 2025-04-01 15:10:15 -07:00
mpage 053c285f6b
gh-130704: Strength reduce `LOAD_FAST{_LOAD_FAST}` (#130708)
Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
2025-04-01 10:18:42 -07:00
Amit Lavon 685fd74f81
GH-131798: Remove type checks for _TO_BOOL_STR (GH-131816) 2025-03-30 16:07:25 -07:00
Brandt Bucher 972a295fe3
GH-130415: Remove redundant sym_matches_type calls in the JIT optimizer (GH-131778) 2025-03-27 09:12:30 -07:00
Mark Shannon 1b8bb1ed0c
GH-131729: Code-gen better liveness analysis (GH-131732)
* Rename 'defined' attribute to 'in_local' to more accurately reflect how it is used

* Make death of variables explicit even for array variables.

* Convert in_memory from boolean to stack offset

* Don't apply liveness analysis to optimizer generated code

* Fix RETURN_VALUE in optimizer
2025-03-26 15:21:35 +00:00
Savannah Ostrowski b92ee14b80
GH-130415: Optimize constant comparison in JIT builds (GH-131489) 2025-03-21 11:23:12 -07:00
Mark Shannon 7ebd71ee14
GH-131498: Remove conditional stack effects (GH-131499)
* Adds some missing #includes
2025-03-20 15:39:38 +00:00
Jamie Phan 10cdd7f91f
GH-130903: typo in optimizer DSL for _GUARD_BOTH_UNICODE (#130904)
Typo introduced in gh-118910.
2025-03-06 12:11:08 +01:00
Amit Lavon 691354ccb0
GH-130415: Narrow str to "" based on boolean tests (GH-130476) 2025-03-04 13:20:17 -08:00
Klaus117 c989e74446
GH-130415: Narrow int to 0 based on boolean tests (GH-130772) 2025-03-04 12:44:09 -08:00
Brandt Bucher 7afa476874
GH-130415: Use boolean guards to narrow types to values in the JIT (GH-130659) 2025-03-02 13:21:34 -08:00
Mark Shannon 54965f3fb2
GH-130296: Avoid stack transients in four instructions. (GH-130310)
* Combine _GUARD_GLOBALS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_MODULE_FROM_KEYS into _LOAD_GLOBAL_MODULE

* Combine _GUARD_BUILTINS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_BUILTINS_FROM_KEYS into _LOAD_GLOBAL_BUILTINS

* Combine _CHECK_ATTR_MODULE_PUSH_KEYS and _LOAD_ATTR_MODULE_FROM_KEYS into _LOAD_ATTR_MODULE

* Remove stack transient in LOAD_ATTR_WITH_HINT
2025-02-28 18:00:38 +00:00
Irit Katriel a1417b211f
gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700) 2025-02-07 22:39:54 +00:00
Brandt Bucher 70e387c990
GH-129709: Clean up tier two (GH-129710) 2025-02-07 09:52:49 -08:00
Mark Shannon 808071b994
GH-128682: Make `PyStackRef_CLOSE` escaping. (GH-129404) 2025-02-03 12:41:32 +00:00
Mark Shannon 75b4962157
GH-128914: Remove all but one conditional stack effects (GH-129226)
* Remove all 'if (0)' and 'if (1)' conditional stack effects

* Use array instead of conditional for BUILD_SLICE args

* Refactor LOAD_GLOBAL to use a common conditional uop

* Remove conditional stack effects from LOAD_ATTR specializations

* Replace conditional stack effects in LOAD_ATTR with a 0 or 1 sized array.

* Remove conditional stack effects from CALL_FUNCTION_EX
2025-01-27 16:24:48 +00:00
Sam Gross a10f99375e
Revert "GH-128914: Remove conditional stack effects from `bytecodes.c` and the code generators (GH-128918)" (GH-129202)
The commit introduced a ~2.5-3% regression in the free threading build.

This reverts commit ab61d3f430.
2025-01-23 09:26:25 +00:00
Mark Shannon ab61d3f430
GH-128914: Remove conditional stack effects from `bytecodes.c` and the code generators (GH-128918) 2025-01-20 17:09:23 +00:00
Mark Shannon f0f7b978be
GH-128939: Refactor JIT optimize structs (GH-128940) 2025-01-20 15:49:15 +00:00
mpage b5ee0258bf
gh-115999: Specialize `LOAD_ATTR` for instance and class receivers in free-threaded builds (#128164)
Finish specialization for LOAD_ATTR in the free-threaded build by adding support for class and instance receivers.
2025-01-14 11:56:11 -08:00
Mark Shannon ddd959987c
GH-128685: Specialize (rather than quicken) LOAD_CONST into LOAD_CONST_[IM]MORTAL (GH-128708) 2025-01-13 10:30:28 +00:00