[runtime] Refactor and unify tls access