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:
authorJan Kotas <jkotas@microsoft.com>2016-06-01 03:41:11 +0300
committerJan Kotas <jkotas@microsoft.com>2016-06-01 03:41:11 +0300
commitf8c15e4921eacb4c8f96ecea1c02c907a0418745 (patch)
tree1167cd4a3e32baf9097be762e234f1a9634ec549 /src/Native/Runtime/i386
parentd34aaaaf70dc1a2d13b5f9f2b8e8a84b53fceb34 (diff)
Reduce assembly code in alloc helpers
- Use extern "C" names for methods called from asm helper to avoid dealing with name mangling for ports - Move hooking up of the PInvoke tunnel to C++ - Change arm assembly code to follow same naming pattern as x86 and arm64 [tfs-changeset: 1609408]
Diffstat (limited to 'src/Native/Runtime/i386')
-rw-r--r--src/Native/Runtime/i386/AllocFast.asm55
-rw-r--r--src/Native/Runtime/i386/AsmMacros.inc19
2 files changed, 29 insertions, 45 deletions
diff --git a/src/Native/Runtime/i386/AllocFast.asm b/src/Native/Runtime/i386/AllocFast.asm
index bc6b57ecb..ce817ff02 100644
--- a/src/Native/Runtime/i386/AllocFast.asm
+++ b/src/Native/Runtime/i386/AllocFast.asm
@@ -46,31 +46,26 @@ FASTCALL_FUNC RhpNewFast, 4
AllocFailed:
;;
- ;; SLOW PATH, PInvoke to redhawku!RedhawkGCInterface::Alloc(Thread* pThread, UIntNative cbSize, Uint32 uFlags)
+ ;; SLOW PATH, call RhpGcAlloc(EEType *pEEType, UInt32 uFlags, UIntNative cbSize, void * pTransitionFrame)
;;
;; ecx: EEType pointer
- ;; edx: Thread pointer
;;
push ebp
mov ebp, esp
PUSH_COOP_PINVOKE_FRAME edx
-ifdef _DEBUG
- ;; save the Thread pointer in ebx
- mov ebx, edx
-endif ; _DEBUG
-
- ;; Push alloc helper arguments (thread, size, flags, EEType).
- push ecx ; EEType
- push 0 ; Flags
- push dword ptr [ecx + OFFSETOF__EEType__m_uBaseSize] ; Size
- push edx ; Current thread
-
;; Preserve EEType in ESI.
mov esi, ecx
- call REDHAWKGCINTERFACE__ALLOC
+ ;; Push alloc helper arguments
+ push edx ; transition frame
+ push dword ptr [ecx + OFFSETOF__EEType__m_uBaseSize] ; Size
+ xor edx, edx ; Flags
+ ;; Passing EEType in ecx
+
+ ;; void* RhpGcAlloc(EEType *pEEType, UInt32 uFlags, UIntNative cbSize, void * pTransitionFrame)
+ call RhpGcAlloc
;; Set the new object's EEType pointer on success.
test eax, eax
@@ -115,22 +110,19 @@ FASTCALL_FUNC RhpNewFinalizable, 4
push ebp
mov ebp, esp
- ;; edx = GetThread(), TRASHES eax
- INLINE_GETTHREAD edx, eax
-
PUSH_COOP_PINVOKE_FRAME edx
- ;; Push alloc helper arguments (thread, size, flags, EEType).
- push ecx ; EEType
- push GC_ALLOC_FINALIZE ; Flags
- push dword ptr [ecx + OFFSETOF__EEType__m_uBaseSize] ; Size
- push edx ; Current thread
-
;; Preserve EEType in ESI
mov esi, ecx
- ;; Call the common allocation helper.
- call REDHAWKGCINTERFACE__ALLOC
+ ;; Push alloc helper arguments
+ push edx ; transition frame
+ push dword ptr [ecx + OFFSETOF__EEType__m_uBaseSize] ; Size
+ mov edx, GC_ALLOC_FINALIZE ; Flags
+ ;; Passing EEType in ecx
+
+ ;; void* RhpGcAlloc(EEType *pEEType, UInt32 uFlags, UIntNative cbSize, void * pTransitionFrame)
+ call RhpGcAlloc
;; Set the new object's EEType pointer on success.
test eax, eax
@@ -238,7 +230,6 @@ ArraySizeBig:
ArrayAllocContextOverflow:
; ECX == array size
- ; EDX == thread
; original ECX pushed
; original EDX pushed
@@ -258,13 +249,13 @@ ArrayAllocContextOverflow:
mov ecx, dword ptr [ebp - 8]
; Push alloc helper arguments (thread, size, flags, EEType).
- push ecx ; EEType
- push 0 ; Flags
- push edi ; Size
- push edx ; Current thread
+ push edx ; transition frame
+ push edi ; Size
+ xor edx, edx ; Flags
+ ;; Passing EEType in ecx
- ; Call the rest of the allocation helper.
- call REDHAWKGCINTERFACE__ALLOC
+ ;; void* RhpGcAlloc(EEType *pEEType, UInt32 uFlags, UIntNative cbSize, void * pTransitionFrame)
+ call RhpGcAlloc
; Set the new object's EEType pointer and length on success.
test eax, eax
diff --git a/src/Native/Runtime/i386/AsmMacros.inc b/src/Native/Runtime/i386/AsmMacros.inc
index 4552d364a..69c262010 100644
--- a/src/Native/Runtime/i386/AsmMacros.inc
+++ b/src/Native/Runtime/i386/AsmMacros.inc
@@ -78,8 +78,7 @@ endm
;; interesting GC references. In all our helper cases this corresponds to the most recent managed frame (e.g.
;; the helper's caller).
;;
-;; This macro builds a frame describing the current state of managed code and stashes a pointer to this frame
-;; on the current thread, ready to be used if and when the helper needs to transition to pre-emptive mode.
+;; This macro builds a frame describing the current state of managed code.
;;
;; The macro assumes it is called from a helper that has already set up an EBP frame and that the values of
;; EBX, ESI and EDI remain unchanged from their values in managed code. It pushes the frame at the top of the
@@ -87,21 +86,20 @@ endm
;;
;; EAX is trashed by this macro.
;;
-PUSH_COOP_PINVOKE_FRAME macro threadReg
+PUSH_COOP_PINVOKE_FRAME macro transitionFrameReg
lea eax, [ebp + 8] ; get the ESP of the caller
push eax ; save ESP
push edi
push esi
push ebx
push PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_RSP
- push threadReg ; Thread * (unused by stackwalker)
+ push eax ; Thread * (unused by stackwalker)
mov eax, [ebp + 0] ; Find previous EBP value
push eax ; save EBP
mov eax, [ebp + 4] ; Find the return address
push eax ; save m_RIP
- lea eax, [esp + 0] ; EAX == address of frame
- mov [threadReg + OFFSETOF__Thread__m_pHackPInvokeTunnel], eax ; Link frame to thread
+ lea transitionFrameReg, [esp + 0] ; transitionFrameReg == address of frame
endm
;;
@@ -111,11 +109,6 @@ endm
;; TRASHES ECX
;;
POP_COOP_PINVOKE_FRAME macro
- ;; We do not need to clear m_pHackPInvokeTunnel here because it is 'on the side' information.
- ;; The actual transition to/from preemptive mode is done elsewhere (EnablePreemptiveMode,
- ;; DisablePreemptiveMode) and m_pHackPInvokeTunnel need only be valid when that happens,
- ;; so as long as we always set it on the way into a "cooperative pinvoke" method, we're fine
- ;; because it is only looked at inside these "cooperative pinvoke" methods.
add esp, 4*4
pop ebx
pop esi
@@ -162,7 +155,7 @@ OFFSETOF__Thread__m_alloc_context__alloc_limit equ OFFSETOF__Thread__m_rgbA
;;
PALDEBUGBREAK equ ?PalDebugBreak@@YGXXZ
-REDHAWKGCINTERFACE__ALLOC equ ?Alloc@RedhawkGCInterface@@SGPAXPAVThread@@IIPAVEEType@@@Z
+RhpGcAlloc equ @RhpGcAlloc@16
G_LOWEST_ADDRESS equ _g_lowest_address
G_HIGHEST_ADDRESS equ _g_highest_address
G_EPHEMERAL_LOW equ _g_ephemeral_low
@@ -182,7 +175,7 @@ endif ;; FEATURE_GC_STRESS
;;
;; IMPORTS
;;
-EXTERN REDHAWKGCINTERFACE__ALLOC : PROC
+EXTERN RhpGcAlloc : PROC
EXTERN PALDEBUGBREAK : PROC
EXTERN RhpWaitForSuspend2 : PROC
EXTERN RhpWaitForGC2 : PROC