source: libcfa/src/concurrency/CtxSwitch-x86_64.S @ deca0f5

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since deca0f5 was deca0f5, checked in by tdelisle <tdelisle@…>, 5 years ago

x87 and SSE flags are now only saved by threads

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[78b3f52]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// CtxSwitch-x86_64.S --
8//
9// Author           : Thierry Delisle
10// Created On       : Mon Nov 28 12:27:26 2016
[6b0b624]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Fri Jul 21 22:28:11 2017
13// Update Count     : 1
[78b3f52]14//
15// This  library is free  software; you  can redistribute  it and/or  modify it
16// under the terms of the GNU Lesser General Public License as published by the
17// Free Software  Foundation; either  version 2.1 of  the License, or  (at your
18// option) any later version.
[f32e53e]19//
[78b3f52]20// This library is distributed in the  hope that it will be useful, but WITHOUT
21// ANY  WARRANTY;  without even  the  implied  warranty  of MERCHANTABILITY  or
22// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
23// for more details.
[f32e53e]24//
[78b3f52]25// You should  have received a  copy of the  GNU Lesser General  Public License
26// along  with this library.
[f32e53e]27//
[78b3f52]28
29// This context switch routine depends on the fact that the stack of a new
30// thread has been set up to look like the thread has saved its context in
31// the normal manner.
32//
33// void CtxSwitch( machine_context *from, machine_context *to );
34
35// Offsets in the context structure. This needs to be synchronized with the
36// high level code a little better.
37
38#define PTR_BYTE        8
39#define SP_OFFSET       ( 0 * PTR_BYTE )
40#define FP_OFFSET       ( 1 * PTR_BYTE )
41
[3c06bba]42        .text
[78b3f52]43        .align 2
[3c06bba]44        .globl CtxSwitch
45        .type  CtxSwitch, @function
[78b3f52]46CtxSwitch:
47
[7b2c2c5f]48        // Save volatile registers on the stack.
49
[78b3f52]50        pushq %r15
51        pushq %r14
52        pushq %r13
53        pushq %r12
54        pushq %rbx
55
56        // Save old context in the "from" area.
57
58        movq %rsp,SP_OFFSET(%rdi)
59        movq %rbp,FP_OFFSET(%rdi)
60
61        // Load new context from the "to" area.
62
63        movq SP_OFFSET(%rsi),%rsp
64        movq FP_OFFSET(%rsi),%rbp
65
66        // Load volatile registers from the stack.
67
68        popq %rbx
69        popq %r12
70        popq %r13
71        popq %r14
72        popq %r15
[7b2c2c5f]73
[78b3f52]74        // Return to thread.
75
76        ret
[3c06bba]77        .size  CtxSwitch, .-CtxSwitch
78
[78b3f52]79.text
80        .align 2
[b58a5772]81.globl  CtxInvokeStub
82CtxInvokeStub:
[f32e53e]83        movq %rbx, %rdi
[5c81105]84        jmp *%r12
[78b3f52]85
86// Local Variables: //
87// mode: c //
88// tab-width: 4 //
[ffc3b26]89// End: //
Note: See TracBrowser for help on using the repository browser.