10000 gh-134584: Decref elimination for float ops in the JIT by Fidget-Spinner · Pull Request #134588 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-134584: Decref elimination for float ops in the JIT #134588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9466417
Skip refcounting where possible for common float ops
Fidget-Spinner May 23, 2025
ad03b1e
Add for common list ops
Fidget-Spinner May 23, 2025
7f90d0c
Fix test, rename
Fidget-Spinner May 23, 2025
a42b434
Remove list optimizations to minimize PR
Fidget-Spinner May 23, 2025
f456740
📜🤖 Added by blurb_it.
blurb-it[bot] May 23, 2025
16f9dee
Merge remote-tracking branch 'upstream/main' into decref_elimination_…
Fidget-Spinner May 27, 2025
5c429b6
Rename things to make things clearer
Fidget-Spinner May 27, 2025
1535133
Revert "Rename things to make things clearer"
Fidget-Spinner May 27, 2025
8f62067
Massive refactor from JitOptSymbol to JitRef
Fidget-Spinner May 28, 2025
a158835
refactor more
Fidget-Spinner May 28, 2025
e77f842
fix debug build
Fidget-Spinner May 28, 2025
01004c2
lint
Fidget-Spinner May 28, 2025
24f98d5
Merge remote-tracking branch 'upstream/main' into decref_elimination_…
Fidget-Spinner May 28, 2025
0189413
fix upstream
Fidget-Spinner May 28, 2025
4a386bf
reduce diff
Fidget-Spinner May 28, 2025
ac034a0
fix for FT
Fidget-Spinner May 28, 2025
b6e467e
fix failing tests
Fidget-Spinner May 28, 2025
3a3fa9d
Fix for disabled GIL
Fidget-Spinner May 29, 2025
ab1ad9c
fix on FT again
Fidget-Spinner May 29, 2025
5d82489
Try fix windows
Fidget-Spinner May 29, 2025
4d9a68e
Apply code review suggestions from Tomas
Fidget-Spinner Jun 4, 2025
2bbd47a
call the functions sym instead of ref
Fidget-Spinner Jun 4, 2025
2d779c4
rename jitref functions
Fidget-Spinner Jun 4, 2025
b74e160
Address review
Fidget-Spinner Jun 4, 2025
3ebcc20
Update comment
Fidget-Spinner Jun 4, 2025
673d5c8
Merge remote-tracking branch 'upstream/main' into decref_elimination_…
Fidget-Spinner Jun 17, 2025
914f1ff
Fix changes from upstream (no more casts)
Fidget-Spinner Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review
  • Loading branch information
Fidget-Spinner committed Jun 4, 2025
commit b74e160f9d0810732b470ce707615d2a2810ccbc
17 changes: 7 additions & 10 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ typedef union {
uintptr_t bits;
} JitOptRef;

#define JIT_BITS_TO_PTR(REF) ((JitOptSymbol *)((REF).bits))
#define JIT_BITS_TO_PTR_MASKED(REF) ((JitOptSymbol *)(((REF).bits) & (~Py_TAG_REFCNT)))
#define REF_IS_BORROWED 1

#define JIT_BITS_TO_PTR_MASKED(REF) ((JitOptSymbol *)(((REF).bits) & (~REF_IS_BORROWED)))

static inline JitOptSymbol *
PyJitRef_Unwrap(JitOptRef ref)
Expand All @@ -242,22 +243,18 @@ static inline JitOptRef
PyJitRef_Wrap(JitOptSymbol *sym)
{
if (sym == NULL || _Py_uop_symbol_is_immortal(sym)) {
return (JitOptRef){.bits=(uintptr_t)sym | Py_TAG_REFCNT};
return (JitOptRef){.bits=(uintptr_t)sym | REF_IS_BORROWED};
}
return (JitOptRef){.bits=(uintptr_t)sym};
}

static inline JitOptRef
PyJitRef_Borrow(JitOptRef ref)
{
return (JitOptRef){ .bits = ref.bits | Py_TAG_REFCNT };
return (JitOptRef){ .bits = ref.bits | REF_IS_BORROWED };
}

#ifndef Py_GIL_DISABLED
static const JitOptRef PyJitRef_NULL = {.bits = PyStackRef_NULL_BITS};
#else
static const JitOptRef PyJitRef_NULL = {.bits = Py_TAG_DEFERRED};
#endif
static const JitOptRef PyJitRef_NULL = {.bits = REF_IS_BORROWED};

static inline bool
PyJitRef_IsNull(JitOptRef ref)
Expand All @@ -268,7 +265,7 @@ PyJitRef_IsNull(JitOptRef ref)
static inline int
PyJitRef_IsBorrowed(JitOptRef ref)
{
return (ref.bits & Py_TAG_REFCNT) == Py_TAG_REFCNT;
return (ref.bits & REF_IS_BORROWED) == REF_IS_BORROWED;
}

struct _Py_UOpsAbstractFrame {
Expand Down
Loading
0