Fix JIT_CheckedWriteBarrier for MHR (dotnet/coreclr#26430)
authorJan Vorlicek <janvorli@microsoft.com>
Thu, 29 Aug 2019 13:28:09 +0000 (15:28 +0200)
committerJan Kotas <jkotas@microsoft.com>
Thu, 29 Aug 2019 13:28:09 +0000 (06:28 -0700)
commit533d51e909678ad546ae080d16b559842639579a
treeaa056948b612e0a9c2f400f05a46f5e2c85bf100
parentbb62a7d9a083e579cfb0b330b90f4729d9ca0d04
Fix JIT_CheckedWriteBarrier for MHR (dotnet/coreclr#26430)

When Mojave hardened runtime support is enabled, the runtime places the
JIT_WriteBarrier copy into a dynamically allocated memory page. But
the JIT_CheckedWriteBarrier has a relative jump to the JIT_WriteBarrier
that I've missed when adding the MHR support and so we end up calling
the original unpatched code of the JIT_WriteBarrier from it.
This repros in release build only and causes problems only rarely,
so it was not detected until the corefx was updated to use the latest
coreclr. Even in the corefx tests, it caused problems when compiling
only one of the corefx tests.

This change fixes it in the same way as we handle jump to JIT_WriteBarrier
in the JIT_Stelem_Ref and its helpers - by using an indirect jump.
We do this for OSX only.

Commit migrated from https://github.com/dotnet/coreclr/commit/5b036452e3ed5d8b60435e3423e4fec245827ce1
src/coreclr/src/vm/amd64/jithelpers_fast.S