summaryrefslogtreecommitdiff
path: root/src/vm/amd64/getstate.asm
blob: 87642cf4996ff0f320342051f18dda18f3e143d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
;
; Copyright (c) Microsoft. All rights reserved.
; Licensed under the MIT license. See LICENSE file in the project root for full license information. 
;

; ==++==
;

;
; ==--==

include AsmMacros.inc
include AsmConstants.inc


LEAF_ENTRY GetCurrentSP, _TEXT

        mov rax, rsp
        add rax, 8
        ret

LEAF_END GetCurrentSP, _TEXT


LEAF_ENTRY GetCurrentIP, _TEXT

        mov rax, [rsp]
        ret

LEAF_END GetCurrentIP, _TEXT


LEAF_ENTRY GetRBP, _TEXT

        mov rax, rbp
        ret

LEAF_END GetRBP, _TEXT

;// this is the same implementation as the function of the same name in di\amd64\floatconversion.asm and they must 
;// remain in sync.

;// @dbgtodo inspection: remove this function when we remove the ipc event to load the float state 

; extern "C" double FPFillR8(void* fpContextSlot);
LEAF_ENTRY FPFillR8, _TEXT
    movdqa  xmm0, [rcx]
    ret
LEAF_END FPFillR8, _TEXT


LEAF_ENTRY get_cycle_count, _TEXT

        rdtsc                           ; time stamp count ret'd in edx:eax
        shl     rdx, 32
        mov     edx, eax
        mov     rax, rdx                ; return tsc in rax
        ret
LEAF_END get_cycle_count, _TEXT


; EXTERN_C void LazyMachStateCaptureState(struct LazyMachState *pState)
LEAF_ENTRY LazyMachStateCaptureState, _TEXT

        mov     rdx, [rsp]      ; get the return address
        
        mov     [rcx + OFFSETOF__MachState__m_Capture + 0*8], rdi
        mov     [rcx + OFFSETOF__MachState__m_Capture + 1*8], rsi
        mov     [rcx + OFFSETOF__MachState__m_Capture + 2*8], rbx
        mov     [rcx + OFFSETOF__MachState__m_Capture + 3*8], rbp
        mov     [rcx + OFFSETOF__MachState__m_Capture + 4*8], r12
        mov     [rcx + OFFSETOF__MachState__m_Capture + 5*8], r13
        mov     [rcx + OFFSETOF__MachState__m_Capture + 6*8], r14
        mov     [rcx + OFFSETOF__MachState__m_Capture + 7*8], r15

        mov     qword ptr [rcx + OFFSETOF__MachState___pRetAddr], 0

        mov     [rcx + OFFSETOF__LazyMachState__m_CaptureRip], rdx
        mov     [rcx + OFFSETOF__LazyMachState__m_CaptureRsp], rsp

        ret

LEAF_END LazyMachStateCaptureState, _TEXT


        end