save and restore on function enter/exit and bring in context manipulation inside function