[coop] Use bitfields for coop state machine state representation (#17298)
* [checked] Mask the thread state in GC thread state assertions
Because we have extra bits (like suspend count and the no_checkpoints bit) on
the thread state, we have to mask it to get the actual thread state enum value
* [coop] Use bitfields to represent coop thread state
Instead of using a 32-bit int, use bitfields and type-punning through a union
type. We need to type pun because we need to access the entire state as a 32-bit int so that we can do atomic CAS.
* use atomic load of thread state in unwrap_thread_state.
Saw one stack trace on CI on the full coop lane where check_thread_state saw STATE_RUNNING
but with a positive suspend count. Another thread was starting a GC a
the time. Seems like we saw the state as runnning, but the suspend
count as if we were already in async_suspend_requested.
Thread 22 (Thread 0x7f43c03ff700 (LWP 39860)):