javascript: speed up tailcalls