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-05-26 05:30:28 +0300
committerJan Kotas <jkotas@microsoft.com>2016-05-26 19:25:13 +0300
commit4af1c32d50cadc898c50213edbac568ad2b698a2 (patch)
treec592cafa376918dbc0871dd0cad691dc8fd1ff9f /src/Native/Runtime/amd64
parent63c604fb519be2e8fcfbfdda9b8835fdce6647a9 (diff)
Implement PInvoke Unix asm helpers
Diffstat (limited to 'src/Native/Runtime/amd64')
-rw-r--r--src/Native/Runtime/amd64/PInvoke.S59
-rw-r--r--src/Native/Runtime/amd64/PInvoke.asm4
-rw-r--r--src/Native/Runtime/amd64/WriteBarriers.S7
3 files changed, 60 insertions, 10 deletions
diff --git a/src/Native/Runtime/amd64/PInvoke.S b/src/Native/Runtime/amd64/PInvoke.S
new file mode 100644
index 000000000..96ca4e525
--- /dev/null
+++ b/src/Native/Runtime/amd64/PInvoke.S
@@ -0,0 +1,59 @@
+// 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.
+
+.intel_syntax noprefix
+#include <unixasmmacros.inc>
+#include <AsmOffsets.inc> // generated by the build from AsmOffsets.cpp
+
+//
+// RhpPInvoke
+//
+// IN: RDI: address of pinvoke frame
+//
+// This helper assumes that its callsite is as good to start the stackwalk as the actual PInvoke callsite.
+// The codegenerator must treat the callsite of this helper as GC triggering and generate the GC info for it.
+// Also, the codegenerator must ensure that there are no live GC references in callee saved registers.
+//
+NESTED_ENTRY RhpPInvoke, _TEXT, NoHandler
+ push_register rbx
+ mov rbx, rdi
+
+ // RAX = GetThread()
+ INLINE_GETTHREAD
+
+ mov r11, [rsp + 0x8] // r11 <- return address
+ mov qword ptr [rbx + OFFSETOF__PInvokeTransitionFrame__m_pThread], rax
+ mov qword ptr [rbx + OFFSETOF__PInvokeTransitionFrame__m_FramePointer], rbp
+ mov qword ptr [rbx + OFFSETOF__PInvokeTransitionFrame__m_RIP], r11
+
+ lea r11, [rsp + 0x10] // r11 <- caller SP
+ mov dword ptr [rbx + OFFSETOF__PInvokeTransitionFrame__m_dwFlags], PTFF_SAVE_RSP
+ mov qword ptr [rbx + OFFSETOF__PInvokeTransitionFrame__m_PreservedRegs], r11
+
+ mov qword ptr [rax + OFFSETOF__Thread__m_pTransitionFrame], rbx
+
+ cmp dword ptr [C_VAR(RhpTrapThreads)], 0
+ pop_register rbx
+ jne 0f // forward branch - predicted not taken
+ ret
+0:
+ jmp C_FUNC(RhpWaitForSuspend2)
+NESTED_END RhpPInvoke, _TEXT
+
+
+//
+// RhpPInvokeReturn
+//
+// IN: RDI: address of pinvoke frame
+//
+LEAF_ENTRY RhpPInvokeReturn, _TEXT
+ mov rsi, [rdi + OFFSETOF__PInvokeTransitionFrame__m_pThread]
+ mov qword ptr [rsi + OFFSETOF__Thread__m_pTransitionFrame], 0
+ cmp dword ptr [C_VAR(RhpTrapThreads)], 0
+ jne 0f // forward branch - predicted not taken
+ ret
+0:
+ // passing transition frame pointer in rdi
+ jmp C_FUNC(RhpWaitForGC2)
+LEAF_END RhpPInvokeReturn, _TEXT
diff --git a/src/Native/Runtime/amd64/PInvoke.asm b/src/Native/Runtime/amd64/PInvoke.asm
index 78c953a12..9f5be2546 100644
--- a/src/Native/Runtime/amd64/PInvoke.asm
+++ b/src/Native/Runtime/amd64/PInvoke.asm
@@ -260,8 +260,6 @@ LEAF_ENTRY RhpPInvoke, _TEXT
ret
@@:
jmp RhpWaitForSuspend
-
- ret
LEAF_END RhpPInvoke, _TEXT
@@ -278,7 +276,7 @@ LEAF_ENTRY RhpPInvokeReturn, _TEXT
mov rdx, [rcx + OFFSETOF__PInvokeTransitionFrame__m_pThread]
mov qword ptr [rdx + OFFSETOF__Thread__m_pTransitionFrame], 0
cmp [RhpTrapThreads], 0
- jne @f ; forward branch - predicted not taken
+ jne @F ; forward branch - predicted not taken
ret
@@:
; passing transition frame pointer in rcx
diff --git a/src/Native/Runtime/amd64/WriteBarriers.S b/src/Native/Runtime/amd64/WriteBarriers.S
index d2b2c6f26..ca070a6bd 100644
--- a/src/Native/Runtime/amd64/WriteBarriers.S
+++ b/src/Native/Runtime/amd64/WriteBarriers.S
@@ -9,10 +9,6 @@
.macro UPDATE_GC_SHADOW BASENAME, REFREG, DESTREG
- .ifc \REFREG, RAX
- .error "REFREG cannot be RAX since this macro uses RAX as a helper register!"
- .endif
-
// If g_GCShadow is 0, don't perform the check.
cmp qword ptr [C_VAR(g_GCShadow)], 0
je LOCAL_LABEL(\BASENAME\()_UpdateShadowHeap_Done_\REFREG)
@@ -85,9 +81,6 @@ LOCAL_LABEL(\BASENAME\()_UpdateShadowHeap_Done_\REFREG):
// object reference (this should be in upper case as it's used in the definition of the name of the helper).
.macro DEFINE_UNCHECKED_WRITE_BARRIER_CORE BASENAME, REFREG
- .ifc \REFREG, RAX
- .error "REFREG cannot be RAX since this macro uses RAX as a helper register!"
- .endif
// Update the shadow copy of the heap with the same value just written to the same heap. (A no-op unless
// we're in a debug build and write barrier checking has been enabled).
UPDATE_GC_SHADOW \BASENAME, \REFREG, rdi