GH-135379: Remove types from stack items in code generator. (GH-135384)

* Make casts explicit in the instruction definitions
This commit is contained in:
Mark Shannon 2025-06-11 15:52:25 +01:00 committed by GitHub
parent 49d72365cd
commit c87b5b2cb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 257 additions and 255 deletions

View file

@ -264,6 +264,32 @@ PyStackRef_IsNullOrInt(_PyStackRef ref);
static const _PyStackRef PyStackRef_ERROR = { .bits = Py_TAG_INVALID };
/* Wrap a pointer in a stack ref.
* The resulting stack reference is not safe and should only be used
* in the interpreter to pass values from one uop to another.
* The GC should never see one of these stack refs. */
static inline _PyStackRef
PyStackRef_Wrap(void *ptr)
{
assert(ptr != NULL);
#ifdef Py_DEBUG
return (_PyStackRef){ .bits = ((uintptr_t)ptr) | Py_TAG_INVALID };
#else
return (_PyStackRef){ .bits = (uintptr_t)ptr };
#endif
}
static inline void *
PyStackRef_Unwrap(_PyStackRef ref)
{
#ifdef Py_DEBUG
assert ((ref.bits & Py_TAG_BITS) == Py_TAG_INVALID);
return (void *)(ref.bits & ~Py_TAG_BITS);
#else
return (void *)(ref.bits);
#endif
}
static inline bool
PyStackRef_IsError(_PyStackRef ref)
{