Cleanup x86_patch and amd64_patch. (mono/mono#16474)
* Cleanup x86_patch and amd64_patch.
amd64_patch has two incorrect looking probably unused cases.
g_assert(0) and fix them.
call and jmp indirect (one case)
move reg RIP relative
x86_patch is large-ish inline macro.
Presumably for sharing with amd64, not inlining.
Restructure as an inline function, called once.
Try to make the code a little clearer also, with same functionality and efficiency
(modulo the optimized perf of "if i == 4" vs. "if i")
i.e. speak of instruction_size and offset_size, not pos and boolean size.
Add to x86_patch the ability to patch jmp/call indirect,
as amd64_patch has, but which was incorrect.
This would seem useful for a later change (using "thunks"
to patch nearby data instead of patching aligned instructions,
indirect call/jmp vs. direct).
amd64_patch largely delegates to x86_patch.
One case asserts and delegates.
Move the assert to the x86 side, where an optimizing
compiler should know to remove it for x86 anyway.
Change some assert to g_assert.
Remove some unnecessary casts.
Fix an assert (https://github.com/mono/mono/pull/16471).
* Change g_assert back to assert except where making larger changes
and less expansion.
Commit migrated from https://github.com/mono/mono/commit/
f735571f27738e3354f6d92650a0517d0482039d