Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81535 - in trunk: boost/context/detail libs/context/src/asm
From: oliver.kowalke_at_[hidden]
Date: 2012-11-25 14:51:31


Author: olli
Date: 2012-11-25 14:51:30 EST (Sun, 25 Nov 2012)
New Revision: 81535
URL: http://svn.boost.org/trac/boost/changeset/81535

Log:
context: fix for XMM storage on x64 Windows

Text files modified:
   trunk/boost/context/detail/fcontext_x86_64_win.hpp | 6 ----
   trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm | 44 ++++++++++++++++++++-------------------
   trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm | 10 ++++++++
   3 files changed, 33 insertions(+), 27 deletions(-)

Modified: trunk/boost/context/detail/fcontext_x86_64_win.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_x86_64_win.hpp (original)
+++ trunk/boost/context/detail/fcontext_x86_64_win.hpp 2012-11-25 14:51:30 EST (Sun, 25 Nov 2012)
@@ -55,11 +55,7 @@
         fc_freg(),
         fc_xmm( 0),
         fc_buffer()
- {
- fc_xmm = fc_buffer;
- if ( 0 != ( ( ( uintptr_t) fc_xmm) & 15) )
- fc_xmm = ( char *) ( ( ( ( uintptr_t) fc_xmm) + 15) & ~0x0F);
- }
+ {}
 };
 
 struct fcontext_t

Modified: trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm 2012-11-25 14:51:30 EST (Sun, 25 Nov 2012)
@@ -44,7 +44,7 @@
 ; ----------------------------------------------------------------------------------
 ; | 0x70 | 0x74 | 0x78 | 0x7c | |
 ; ----------------------------------------------------------------------------------
-; | fc_mxcsr|fc_x87_cw| <padding> | |
+; | fc_mxcsr|fc_x87_cw| fc_xmm | |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
@@ -113,30 +113,32 @@
     stmxcsr [rcx+070h] ; save MMX control and status word
     fnstcw [rcx+074h] ; save x87 control word
     ; save XMM storage
- movaps [rcx+080h], xmm6
- movaps [rcx+090h], xmm7
- movaps [rcx+0100h], xmm8
- movaps [rcx+0110h], xmm9
- movaps [rcx+0120h], xmm10
- movaps [rcx+0130h], xmm11
- movaps [rcx+0140h], xmm12
- movaps [rcx+0150h], xmm13
- movaps [rcx+0160h], xmm14
- movaps [rcx+0170h], xmm15
+ mov r10, [rcx+078h] ; load start address of XMM storage into R10
+ movaps [r10], xmm6
+ movaps [r10+010h], xmm7
+ movaps [r10+020h], xmm8
+ movaps [r10+030h], xmm9
+ movaps [r10+040h], xmm10
+ movaps [r10+050h], xmm11
+ movaps [r10+060h], xmm12
+ movaps [r10+070h], xmm13
+ movaps [r10+080h], xmm14
+ movaps [r10+090h], xmm15
 
     ldmxcsr [rdx+070h] ; restore MMX control and status word
     fldcw [rdx+074h] ; restore x87 control word
     ; restore XMM storage
- movaps xmm6, [rdx+080h]
- movaps xmm7, [rdx+090h]
- movaps xmm8, [rdx+0100h]
- movaps xmm9, [rdx+0110h]
- movaps xmm10, [rdx+0120h]
- movaps xmm11, [rdx+0130h]
- movaps xmm12, [rdx+0140h]
- movaps xmm13, [rdx+0150h]
- movaps xmm14, [rdx+0160h]
- movaps xmm15, [rdx+0170h]
+ mov r10, [rdx+078h] ; load start address of XMM storage into R10
+ movaps xmm6, [r10]
+ movaps xmm7, [r10+010h]
+ movaps xmm8, [r10+020h]
+ movaps xmm9, [r10+030h]
+ movaps xmm10, [r10+040h]
+ movaps xmm11, [r10+050h]
+ movaps xmm12, [r10+060h]
+ movaps xmm13, [r10+070h]
+ movaps xmm14, [r10+080h]
+ movaps xmm15, [r10+090h]
 nxt:
 
     lea rax, [rsp+08h] ; exclude the return address

Modified: trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm 2012-11-25 14:51:30 EST (Sun, 25 Nov 2012)
@@ -44,7 +44,7 @@
 ; ----------------------------------------------------------------------------------
 ; | 0x70 | 0x74 | 0x78 | 0x7c | |
 ; ----------------------------------------------------------------------------------
-; | fc_mxcsr|fc_x87_cw| <padding> | |
+; | fc_mxcsr|fc_x87_cw| fc_xmm | |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
 ; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
@@ -116,6 +116,14 @@
     stmxcsr [rax+070h] ; save MMX control and status word
     fnstcw [rax+074h] ; save x87 control word
 
+
+ mov r8, rax ; preserve pointer to fcontext_t
+ lea rcx, [rax+090h] ; beginning of XMM block
+ call align_stack ; align XMM pointer on 16byte boundary
+ mov [r8 + 078h], rax ; store address of XMM block in fc_xmm
+ mov rax, r8 ; restore pointer to fcontext_t in RAX
+
+
     lea rdx, [rax-028h] ; reserve 32byte shadow space + return address on stack, (RSP - 0x8) % 16 == 0
     mov [rax+040h], rdx ; save address in RDX as stack pointer for context function
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk