Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions Include/internal/pycore_stackref.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,25 @@ PyStackRef_FromPyObjectBorrow(PyObject *obj)
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_REFCNT};
}

/* Create a stackref from a pre-tagged operand (tag bits already set).
Used by _LOAD_CONST_INLINE_BORROW variants where the operand is
tagged at trace creation time to avoid tagging on every execution. */
static inline _PyStackRef
_PyStackRef_FromPreTagged(uintptr_t tagged)
{
assert(tagged & Py_TAG_REFCNT);
return (_PyStackRef){ .bits = tagged };
}
#define PyStackRef_FromPreTagged(ptr) _PyStackRef_FromPreTagged((uintptr_t)(ptr))

/* Tag a PyObject pointer as a borrowed operand for BORROW variants. */
#define PyStackRef_TagBorrow(ptr) \
((uintptr_t)(ptr) | Py_TAG_REFCNT)

/* Strip tag bits from a pre-tagged operand to recover the PyObject pointer. */
#define PyStackRef_UntagBorrow(tagged) \
((PyObject *)((uintptr_t)(tagged) & ~Py_TAG_BITS))

/* WARNING: This macro evaluates its argument more than once */
#ifdef _WIN32
#define PyStackRef_DUP(REF) \
Expand Down
Loading
Loading