Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfadimounir <fadim@microsoft.com>2017-01-24 22:04:27 +0300
committerfadimounir <fadim@microsoft.com>2017-01-24 22:04:27 +0300
commitcbaa93ad96be175dfe82e8b1b4538021278ca184 (patch)
tree48fc3b0b0979100578bfe09446d9026f3f437e10 /src/Native/Runtime/amd64
parent3e9ccf58f5beaa050910a71290a843b154626c4e (diff)
Enabling the calling convention conversion functionality in the non-portable CoreRT, and adding all the conversion helper stubs
Diffstat (limited to 'src/Native/Runtime/amd64')
-rw-r--r--src/Native/Runtime/amd64/CallingConventionConverterHelpers.asm88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/Native/Runtime/amd64/CallingConventionConverterHelpers.asm b/src/Native/Runtime/amd64/CallingConventionConverterHelpers.asm
new file mode 100644
index 000000000..40a4f0fbe
--- /dev/null
+++ b/src/Native/Runtime/amd64/CallingConventionConverterHelpers.asm
@@ -0,0 +1,88 @@
+;; ==++==
+;;
+;; Copyright (c) Microsoft Corporation. All rights reserved.
+;;
+;; ==--==
+
+;; -----------------------------------------------------------------------------------------------------------
+;; #include "asmmacros.inc"
+;; -----------------------------------------------------------------------------------------------------------
+
+LEAF_ENTRY macro Name, Section
+ Section segment para 'CODE'
+ align 16
+ public Name
+ Name proc
+endm
+
+LEAF_END macro Name, Section
+ Name endp
+ Section ends
+endm
+
+; - TAILCALL_RAX: ("jmp rax") should be used for tailcalls, this emits an instruction
+; sequence which is recognized by the unwinder as a valid epilogue terminator
+TAILJMP_RAX TEXTEQU <DB 048h, 0FFh, 0E0h>
+POINTER_SIZE equ 08h
+
+;;
+;; void CallingConventionConverter_ReturnVoidReturnThunk()
+;;
+LEAF_ENTRY CallingConventionConverter_ReturnVoidReturnThunk, _TEXT
+ ret
+LEAF_END CallingConventionConverter_ReturnVoidReturnThunk, _TEXT
+
+;;
+;; int CallingConventionConverter_ReturnIntegerReturnThunk(int)
+;;
+LEAF_ENTRY CallingConventionConverter_ReturnIntegerReturnThunk, _TEXT
+ mov rax, rcx
+ ret
+LEAF_END CallingConventionConverter_ReturnIntegerReturnThunk, _TEXT
+
+;;
+;; Note: The "__jmpstub__" prefix is used to indicate to debugger
+;; that it must step-through this stub when it encounters it while
+;; stepping.
+;;
+
+;; __jmpstub__CallingConventionConverter_CommonCallingStub
+;;
+;;
+;; struct CallingConventionConverter_CommonCallingStub_PointerData
+;; {
+;; void *ManagedCallConverterThunk;
+;; void *UniversalThunk;
+;; }
+;;
+;; struct CommonCallingStubInputData
+;; {
+;; ULONG_PTR CallingConventionId;
+;; CallingConventionConverter_CommonCallingStub_PointerData *commonData;
+;; }
+;;
+;; r10 - Points at CommonCallingStubInputData
+;;
+;;
+LEAF_ENTRY __jmpstub__CallingConventionConverter_CommonCallingStub, _TEXT
+ mov r11, [r10] ; put CallingConventionId into r11 as "parameter" to universal transition thunk
+ mov r10, [r10 + POINTER_SIZE] ; get pointer to CallingConventionConverter_CommonCallingStub_PointerData into r10
+ mov rax, [r10 + POINTER_SIZE] ; get address of UniversalTransitionThunk
+ mov r10, [r10] ; get address of ManagedCallConverterThunk
+ TAILJMP_RAX
+LEAF_END __jmpstub__CallingConventionConverter_CommonCallingStub, _TEXT
+
+;;
+;; void CallingConventionConverter_GetStubs(IntPtr *returnVoidStub, IntPtr *returnIntegerStub, IntPtr *commonStub)
+;;
+LEAF_ENTRY CallingConventionConverter_GetStubs, _TEXT
+ lea rax, [CallingConventionConverter_ReturnVoidReturnThunk]
+ mov [rcx], rax
+ lea rax, [CallingConventionConverter_ReturnIntegerReturnThunk]
+ mov [rdx], rax
+ lea rax, [__jmpstub__CallingConventionConverter_CommonCallingStub]
+ mov [r8], rax
+ ret
+LEAF_END CallingConventionConverter_GetStubs, _TEXT
+
+end