I don’t understand how you can remove the calls with copy-and-patch. It seems like you would have to inline evaluate_lhs and evaluate_rhs to remove calls completely.
That's correct. Lua function calls are not that easy to remove, as function is first-class value in Lua so can be redefined at any time. To remove a function call, you need speculative compilation and OSR-exit, which is outside the job of the baseline JIT.