summaryrefslogtreecommitdiff
path: root/src/zap/zapimport.cpp
diff options
context:
space:
mode:
authorKyungwoo Lee <kyulee@microsoft.com>2016-05-14 13:06:57 -0700
committerKyungwoo Lee <kyulee@microsoft.com>2016-05-18 14:23:58 -0700
commit3165d8e5bfddd78028c9eb2b5ea3ec995c71a849 (patch)
tree837673d8fa9af6ef39c7c62c54b5c8db4eab4042 /src/zap/zapimport.cpp
parent4716d27c9550f4ce24f32e6248b4b350fe1e08ac (diff)
downloadcoreclr-3165d8e5bfddd78028c9eb2b5ea3ec995c71a849.tar.gz
coreclr-3165d8e5bfddd78028c9eb2b5ea3ec995c71a849.tar.bz2
coreclr-3165d8e5bfddd78028c9eb2b5ea3ec995c71a849.zip
ARM64: Enable End-To-End ReadyToRun (R2R) Crossgen
Fixes https://github.com/dotnet/coreclr/issues/4649 The immediate issues was NYI on genEmitHelperCalls. The initial implementation for the missing part was enough to just crossgen System.dll. But running tests revealed various issues in crossgened binaries (R2R). Most common user/helper calls in R2R are represented as indirect calls similar to interface call using virtual stub dispatch cell -- thunk/helper needs a indirect cell address to update the final target address on the data location. `IsDelayLoadHelper` and `IsLazyHelper` belong to this case. Instead of passing such parameter, x64/x86 uses an encoding trick -- it assumes the call is dispatched like `call [addr]`. So from the return address, runtime could extract indirect cell address. Unfortunately this is not an option for arm64 (actually arm as well but I haven't fixed it in this change) where indirect call on memory is not encodable. So, I made the following changes: 1. For the call requiring that needs to pass indirect cell address, I tagged the call tree via `setR2RRelativeIndir`. Tried to be comprehensive, but I may miss something. Currently, it includes a regular call and various helpers for (virtual) load function pointer/static data access, etc. Hopely we change JIT/EE interface somehow that gives us such explicit information. 2. Use the X11 to record indirect cell address for such call tree in lower similar to VSD. 3. Fixed encodings `ZapIndirectHelperThunk`. In particular the immediate value/offset for `ldr` should be scaled down 4 times since HW will scale it 4 times. 4. Implement `genEmitHelperCalls` for indirect case. This is not the case requiring indirect cell address. This is the case we inlined the indirect helper thunk for the speed. I'm seeing the case for size opt helper call, we invoke a direct call to such thunk which actually uses x12 to dispatch the final target. Likewise, I used x12 for this expansion which seems a trash register that is not overlapped with arugments with jit helpers like writer barriers. With this change, I've tested various cases/scenraios locally. Also I've verified all tests are passed against mscorlib.ni.dll and System.ni.dll.
Diffstat (limited to 'src/zap/zapimport.cpp')
-rw-r--r--src/zap/zapimport.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/zap/zapimport.cpp b/src/zap/zapimport.cpp
index 37226fcc41..323c7dd5cb 100644
--- a/src/zap/zapimport.cpp
+++ b/src/zap/zapimport.cpp
@@ -2146,17 +2146,8 @@ DWORD ZapIndirectHelperThunk::SaveWorker(ZapWriter * pZapWriter)
#elif defined(_TARGET_ARM64_)
if (IsDelayLoadHelper())
{
- if (IsVSD())
- {
- // x11 contains indirection cell
- // Do nothing x11 contains our first param
- }
- else
- {
- // mov x11, x12
- *(DWORD*)p = 0xaa0c03eb;
- p += 4;
- }
+ // x11 contains indirection cell
+ // Do nothing x11 contains our first param
// movz x8, #index
DWORD index = GetSectionIndex();
@@ -2166,9 +2157,9 @@ DWORD ZapIndirectHelperThunk::SaveWorker(ZapWriter * pZapWriter)
// move Module* -> x9
// ldr x9, [PC+0x14]
- *(DWORD*)p = 0x58000289;
+ *(DWORD*)p = 0x580000A9;
p += 4;
-
+
//ldr x9, [x9]
*(DWORD*)p = 0xf9400129;
p += 4;
@@ -2178,7 +2169,7 @@ DWORD ZapIndirectHelperThunk::SaveWorker(ZapWriter * pZapWriter)
{
// Move Module* -> x1
// ldr x1, [PC+0x14]
- *(DWORD*)p = 0x58000289;
+ *(DWORD*)p = 0x580000A1;
p += 4;
// ldr x1, [x1]
@@ -2187,10 +2178,8 @@ DWORD ZapIndirectHelperThunk::SaveWorker(ZapWriter * pZapWriter)
}
// branch to helper
-
- // mov x12, [helper]
// ldr x12, [PC+0x14]
- *(DWORD*)p = 0x58000289;
+ *(DWORD*)p = 0x580000AC;
p += 4;
// ldr x12, [x12]
@@ -2199,12 +2188,13 @@ DWORD ZapIndirectHelperThunk::SaveWorker(ZapWriter * pZapWriter)
// br x12
*(DWORD *)p = 0xd61f0180;
- p += 4;
+ p += 4;
// [Module*]
if (pImage != NULL)
pImage->WriteReloc(buffer, (int)(p - buffer), pImage->GetImportTable()->GetHelperImport(READYTORUN_HELPER_Module), 0, IMAGE_REL_BASED_PTR);
p += 8;
+
// [helper]
if (pImage != NULL)
pImage->WriteReloc(buffer, (int)(p - buffer), pImage->GetImportTable()->GetHelperImport(GetReadyToRunHelper()), 0, IMAGE_REL_BASED_PTR);