Changeset 5b11c25 for libcfa/src/concurrency/CtxSwitch-x86_64.S
- Timestamp:
- Apr 30, 2019, 2:53:41 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8278abf
- Parents:
- 673cd63
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/CtxSwitch-x86_64.S
r673cd63 r5b11c25 40 40 #define FP_OFFSET ( 1 * PTR_BYTE ) 41 41 42 //----------------------------------------------------------------------------- 43 // Regular context switch routine which enables switching from one context to anouther 42 44 .text 43 45 .align 2 … … 77 79 .size CtxSwitch, .-CtxSwitch 78 80 79 .text 81 //----------------------------------------------------------------------------- 82 // Part of a 2 part context switch routine, use with CtxRet, stores the current context and then makes a function call 83 .text 80 84 .align 2 81 .globl CtxInvokeStub 85 .globl CtxStore 86 .type CtxStore, @function 87 CtxStore: 88 89 // Save volatile registers on the stack. 90 91 pushq %r15 92 pushq %r14 93 pushq %r13 94 pushq %r12 95 pushq %rbx 96 97 // Save old context in the "from" area. 98 99 movq %rsp,SP_OFFSET(%rdi) 100 movq %rbp,FP_OFFSET(%rdi) 101 102 // Don't load a new context, directly jump to the desired function 103 104 jmp *%rsi 105 .size CtxStore, .-CtxStore 106 107 //----------------------------------------------------------------------------- 108 // Part of a 2 part context switch routine, use with CtxStore, context switches to the desired target without saving the current context 109 .text 110 .align 2 111 .globl CtxRet 112 .type CtxRet, @function 113 CtxRet: 114 // Load new context from the "to" area. 115 116 movq SP_OFFSET(%rdi),%rsp 117 movq FP_OFFSET(%rdi),%rbp 118 119 // Load volatile registers from the stack. 120 121 popq %rbx 122 popq %r12 123 popq %r13 124 popq %r14 125 popq %r15 126 127 // Return to thread. 128 129 ret 130 .size CtxRet, .-CtxRet 131 132 133 //----------------------------------------------------------------------------- 134 // Stub used to create new stacks which are ready to be context switched to 135 .text 136 .align 2 137 .globl CtxInvokeStub 138 .type CtxInvokeStub, @function 82 139 CtxInvokeStub: 83 140 movq %rbx, %rdi 84 141 jmp *%r12 142 .size CtxInvokeStub, .-CtxInvokeStub 85 143 86 144 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.