Use compare and swap for spinlocks

We want spinlocks to have memory barrier semantics, which test_and_set
do not have. Rather than adding manual memory barriers, switching to
this is easier.
Set object type before setting up klass and ivars
Scan the active C-API handles when GC'ing

We might be doing a GC while having objects active in frames in the
C-API. We need to make sure to scan these objects as well.