diff options
author | Faizur Rahman <shrah@microsoft.com> | 2017-02-20 05:22:59 +0300 |
---|---|---|
committer | Faizur Rahman <shrah@microsoft.com> | 2017-02-23 23:00:20 +0300 |
commit | 61dbdc79b0ae4f33a48869d9d72cc40a0777ee1c (patch) | |
tree | caa9e700accc6321be90ac384cda025376e30913 /src/Native/Runtime/arm | |
parent | 4d2c17183d335ab54b1b3ead2985c3469bc0de63 (diff) |
Delegate Marshalling
Initital support for delegate marshalling.
- Enabled only in full runtime
- Doesn't work in non-windows platforms
- Only supports open static delegates
Diffstat (limited to 'src/Native/Runtime/arm')
-rw-r--r-- | src/Native/Runtime/arm/InteropThunksHelpers.asm | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/Native/Runtime/arm/InteropThunksHelpers.asm b/src/Native/Runtime/arm/InteropThunksHelpers.asm new file mode 100644 index 000000000..bb1770a70 --- /dev/null +++ b/src/Native/Runtime/arm/InteropThunksHelpers.asm @@ -0,0 +1,84 @@ +;; Licensed to the .NET Foundation under one or more agreements. +;; The .NET Foundation licenses this file to you under the MIT license. +;; See the LICENSE file in the project root for more information. + + +#include "kxarm.h" + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA SECTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +__tls_array equ 0x2C ;; offsetof(TEB, ThreadLocalStoragePointer) + +POINTER_SIZE equ 0x04 + +;; TLS variables + AREA |.tls$|, DATA +ThunkParamSlot % 0x4 + + TEXTAREA + + EXTERN _tls_index + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interop Thunks Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;; + ;; InteropNative_CommonStub + ;; + NESTED_ENTRY InteropNative_CommonStub + ;; Custom calling convention: + ;; red zone has pointer to the current thunk's data block (data contains 2 pointer values: context + target pointers) + ;; Copy red zone value into r12 so that the PROLOG_PUSH doesn't destroy it + PROLOG_NOP ldr r12, [sp, #-4] + PROLOG_PUSH {r0-r3} + + ;; Save context data into the ThunkParamSlot thread-local variable + ;; A pointer to the delegate and function pointer for open static delegate should have been saved in the thunk's context cell during thunk allocation + ldr r3, =_tls_index + ldr r2, [r3] + mrc p15, #0, r3, c13, c0, #2 + ldr r3, [r3, #__tls_array] + ldr r2, [r3, r2, lsl #2] ;; r2 <- our TLS base + + ;; r2 = base address of TLS data + ;; r12 = address of context cell in thunk's data + + ;; store thunk address in thread static + ldr r1, [r12] + ldr r3, =ThunkParamSlot + str r1, [r2, r3] ;; ThunkParamSlot <- context slot data + + ;; Now load the target address and jump to it. + ldr r12, [r12, #POINTER_SIZE] + EPILOG_POP {r0-r3} + bx r12 + NESTED_END InteropNative_CommonStub + + + ;; + ;; IntPtr InteropNative_GetCommonStubAddress() + ;; + LEAF_ENTRY InteropNative_GetCommonStubAddress + ldr r0, =InteropNative_CommonStub + bx lr + LEAF_END InteropNative_GetCommonStubAddress + + + ;; + ;; IntPtr InteropNative_GetCurrentThunkContext() + ;; + LEAF_ENTRY InteropNative_GetCurrentThunkContext + + ldr r3, =_tls_index + ldr r2, [r3] + mrc p15, #0, r3, c13, c0, #2 + ldr r3, [r3, #__tls_array] + ldr r2, [r3, r2, lsl #2] ;; r2 <- our TLS base + + ldr r3, =ThunkParamSlot + ldr r0, [r2, r3] ;; r0 <- ThunkParamSlot + + bx lr + LEAF_END InteropNative_GetCurrentThunkContext + + END |