diff options
author | Fadi Hanna <fadim@microsoft.com> | 2017-08-30 22:53:17 +0300 |
---|---|---|
committer | Fadi Hanna <fadim@microsoft.com> | 2017-08-30 22:53:17 +0300 |
commit | 4dad92cd3294a5511ba8ace84f7caf2379653935 (patch) | |
tree | 86b6fc2bb56e133f6a5d817cef0f6a0b096719e1 /src/Native/Runtime/MiscHelpers.cpp | |
parent | 6a44a21cf36ac61890fca9507658c07ad786d1a3 (diff) |
Fixing CI break caused by previous checkin of the unboxing stubs region to enable the RhGetCodeTarget API:
1) Stubs are still grouped, but by section now. Linker will merge/fold/sort the unboxing stubs by section name.
2) All unboxing stubs are delimited by __unbox_a and __unbox_z symbols
3) __unbox_a and __unbox_z works on all platforms (tested on ProjectN (no regressions verification), ProjectX single and multi-file, Windows CoreRT, Unbuntu CoreRT, and OSX CoreRT)
4) Implementation uses a registration mechanism for unboxing stubs regions, and is multi-file ready for CoreRT (uses a linked list of stub regions)
5) Deleting the R2R section of unboxing stubs since it doesn't work on non-windows. Using extern "C" variables instead.
6) Removing the module enumeration API exposed by the TypeLoaderCallbacks (no longer needed)
[tfs-changeset: 1672333]
Diffstat (limited to 'src/Native/Runtime/MiscHelpers.cpp')
-rw-r--r-- | src/Native/Runtime/MiscHelpers.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/Native/Runtime/MiscHelpers.cpp b/src/Native/Runtime/MiscHelpers.cpp index 49885a5a1..eaf55a79a 100644 --- a/src/Native/Runtime/MiscHelpers.cpp +++ b/src/Native/Runtime/MiscHelpers.cpp @@ -464,28 +464,31 @@ inline Int32 GetThumb2BlRel24(UInt16 * p) // Given a pointer to code, find out if this points to an import stub // or unboxing stub, and if so, return the address that stub jumps to -COOP_PINVOKE_HELPER(UInt8 *, RhGetCodeTarget, (TypeManagerHandle *pTypeManagerHandle, UInt8 * pCodeOrg)) +COOP_PINVOKE_HELPER(UInt8 *, RhGetCodeTarget, (UInt8 * pCodeOrg)) { Module * pModule = NULL; - TypeManagerHandle typeManagerHandle = *pTypeManagerHandle; + bool unboxingStub = false; - if (typeManagerHandle.IsTypeManager()) - { - Int32 length; - UInt8* pUnboxingStubsRegion = (UInt8*)typeManagerHandle.AsTypeManager()->GetModuleSection(ReadyToRunSectionType::UnboxingStubsRegion, &length); - if (pUnboxingStubsRegion == NULL || pCodeOrg < pUnboxingStubsRegion || pCodeOrg >= (pUnboxingStubsRegion + length)) - return pCodeOrg; - } - else + // First, check the unboxing stubs regions known by the runtime (if any exist) + if (!GetRuntimeInstance()->IsUnboxingStub(pCodeOrg)) { - pModule = GetRuntimeInstance()->FindModuleByOsHandle(typeManagerHandle.AsOsModule()); + // Search for the module containing the code + FOREACH_MODULE(pCurrentModule) + { + // If the code pointer doesn't point to a module's stub range, + // it can't be pointing to a stub + if (pCurrentModule->ContainsStubAddress(pCodeOrg)) + { + pModule = pCurrentModule; + break; + } + } + END_FOREACH_MODULE; - if (!pModule->ContainsStubAddress(pCodeOrg)) + if (pModule == NULL) return pCodeOrg; } - bool unboxingStub = false; - #ifdef _TARGET_AMD64_ UInt8 * pCode = pCodeOrg; |