Avoid calling alloc wrappers directly, sgen does some initialization when the wrapper method is created.
Use a different function for emitting write barriers for gsharedvt types which can handle reference types too. Fixes #12429.