tcg: move tcg_exec_all and helpers above thread fn