gh-154401: Skip fetching the thread state for non-GC types in `_Py_Dealloc` (GH-154430)
_Py_Dealloc() fetched the current thread state and computed the C
recursion margin on every deallocation, but both are only used by the
trashcan mechanism, which applies only to GC-tracked types. Gate them
behind the Py_TPFLAGS_HAVE_GC check so the common non-GC case (int,
float, str and similar atomic types) skips them.
On platforms where _PyThreadState_GET() reads a _Thread_local via a
function call (e.g. macOS TLV), this removes a call from every non-GC
deallocation.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>