Interpreter reads last error to late after pinvoke. (#15571)
* Interpreter reads last error to late after pinvoke.
This could lead to clobbered last error since interpreter loop needs to
run two additional IL instructions in order to read out the value. This works
on JIT since the lowering saving the last error will happen right after
pinvoke.
This fix makes sure interpreter will get needed information to read out
last error right after pinvoke (if requested).
It adds a new IL prefix issued in managed->native wrapper that will tell
codegen (and interpreter) that upcoming calli instruction needs to save
last error, meaning that it could be done right after issuing the call,
no need to run any additional IL instructions to do that work, closing
the gap between the return of pinvoke call and save of last error.
Should fix, https://github.com/mono/mono/issues/15541.
* Optimize emit_get_last_error.