Applying WW should be based on a cost model.
While it's hard to say exactly when WW makes things worse we have a rough id.
Generating calls with a lot of arguments is bad. Unboxing variables is good.
So we could perhaps apply a heuristic of where we have:
let cost = (num_args ^ taper_factor) * arg_factor -- We want to avoid "infinite" reboxing so increase cost of each additional argument.
discount = (removed_boxes * boxfactor) + removed_args * dead_arg_factor
benefit = discount - cost
And then unbox if the benefit crosses a certain threshold. We already thread through a boolean that says unbox yes/no. We would just replace it with slightly more complex monoid.
That being said without a good idea if what the cost factors should maybe we off just as good with the current threshold-based approach.