Add missing stack checks to stg_ap_* functions (#9001)