|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78082 - in trunk: boost/context boost/context/detail libs/context/src libs/context/src/asm
From: oliver.kowalke_at_[hidden]
Date: 2012-04-19 15:07:51
Author: olli
Date: 2012-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
New Revision: 78082
URL: http://svn.boost.org/trac/boost/changeset/78082
Log:
context: update asm according to calling convetion for FP
Text files modified:
trunk/boost/context/detail/fcontext_x86_64_win.hpp | 15 ++++++
trunk/boost/context/fcontext.hpp | 4 +
trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm | 8 +-
trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S | 8 +-
trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S | 8 +-
trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm | 90 ++++++++++++++++++++++++++++++++++-----
trunk/libs/context/src/fcontext.cpp | 3 +
7 files changed, 111 insertions(+), 25 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-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
@@ -37,6 +37,21 @@
stack_t fc_stack;
fcontext_t * fc_link;
void * fc_local_storage;
+ void * fc_fp;
+ boost::uint8_t fc_buffer[162];
+
+ fcontext_t() :
+ fc_greg(),
+ fc_freg(),
+ fc_stack(),
+ fc_link( 0),
+ fc_local_storage( 0),
+ fc_fp( 0),
+ fc_buffer()
+ {
+ if ( 0 != ( ( ( uintptr_t) fc_buffer) & 15) )
+ fc_fp = ( ( ( ( uintptr_t) fc_buffer) + 16) >> 4) << 4;
+ }
};
}
Modified: trunk/boost/context/fcontext.hpp
==============================================================================
--- trunk/boost/context/fcontext.hpp (original)
+++ trunk/boost/context/fcontext.hpp 2012-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
@@ -61,8 +61,12 @@
namespace boost {
namespace ctx {
+namespace detail {
extern "C" BOOST_CONTEXT_DECL void * BOOST_CONTEXT_CALLDECL align_stack( void * vp);
+
+}
+
extern "C" BOOST_CONTEXT_DECL intptr_t BOOST_CONTEXT_CALLDECL start_fcontext( fcontext_t * ofc, fcontext_t const* nfc);
extern "C" BOOST_CONTEXT_DECL intptr_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp);
extern "C" BOOST_CONTEXT_DECL void BOOST_CONTEXT_CALLDECL make_fcontext( fcontext_t * fc, void (* fn)( intptr_t), intptr_t vp);
Modified: trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm 2012-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
@@ -68,8 +68,8 @@
mov eax, [edx+010h] ; load fiber local storage
mov [ecx+030h], eax ; save fiber local storage
- stmxcsr [ecx+018h] ; save SSE2 control word
- fnstcw [ecx+01ch] ; save x87 control word
+; stmxcsr [ecx+018h] ; save SSE2 control word
+; fnstcw [ecx+01ch] ; save x87 control word
lea eax, [esp+04h] ; exclude the return address
mov [ecx+010h], eax ; save as stack pointer
@@ -95,8 +95,8 @@
mov eax, [ecx+030h] ; load fiber local storage
mov [edx+010h], eax ; restore fiber local storage
- ldmxcsr [ecx+018h] ; restore SSE2 control word
- fldcw [ecx+01ch] ; restore x87 control word
+; ldmxcsr [ecx+018h] ; restore SSE2 control word
+; fldcw [ecx+01ch] ; restore x87 control word
mov eax, [esp+0ch] ; use third arg as return value after jump
Modified: trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S (original)
+++ trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S 2012-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
@@ -49,8 +49,8 @@
movl %ebx, 0x8(%ecx) /* save EBX */
movl %ebp, 0xc(%ecx) /* save EBP */
- stmxcsr 0x18(%ecx) /* save SSE2 control and status word */
- fnstcw 0x1c(%ecx) /* save x87 control word */
+/* stmxcsr 0x18(%ecx) */ /* save SSE2 control and status word */
+/* fnstcw 0x1c(%ecx) */ /* save x87 control word */
leal 0x4(%esp), %eax /* exclude the return address */
movl %eax, 0x10(%ecx) /* save as stack pointer */
@@ -64,8 +64,8 @@
movl 0x8(%ecx), %ebx /* restore EBX */
movl 0xc(%ecx), %ebp /* restore EBP */
- ldmxcsr 0x18(%ecx) /* restore SSE2 control and status word */
- fldcw 0x1c(%ecx) /* restore x87 control word */
+/* ldmxcsr 0x18(%ecx) */ /* restore SSE2 control and status word */
+/* fldcw 0x1c(%ecx) */ /* restore x87 control word */
movl 0xc(%esp), %eax /* use third arg as return value after jump */
Modified: trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S (original)
+++ trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S 2012-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
@@ -48,8 +48,8 @@
movl %ebx, 0x8(%ecx) /* save EBX */
movl %ebp, 0xc(%ecx) /* save EBP */
- stmxcsr 0x18(%ecx) /* save SSE2 control and status word */
- fnstcw 0x1c(%ecx) /* save x87 control word */
+/* stmxcsr 0x18(%ecx) */ /* save SSE2 control and status word */
+/* fnstcw 0x1c(%ecx) */ /* save x87 control word */
leal 0x4(%esp), %eax /* exclude the return address */
movl %eax, 0x10(%ecx) /* save as stack pointer */
@@ -63,8 +63,8 @@
movl 0x8(%ecx), %ebx /* restore EBX */
movl 0xc(%ecx), %ebp /* restore EBP */
- ldmxcsr 0x18(%ecx) /* restore SSE2 control and status word */
- fldcw 0x1c(%ecx) /* restore x87 control word */
+/* ldmxcsr 0x18(%ecx) */ /* restore SSE2 control and status word */
+/* fldcw 0x1c(%ecx) */ /* restore x87 control word */
movl 0xc(%esp), %eax /* use third arg as return value after jump */
Modified: trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm 2012-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
@@ -53,9 +53,51 @@
; ----------------------------------------------------------------------------------
; | fbr_strg | |
; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 30 | 31 | |
+; ----------------------------------------------------------------------------------
+; | 0x78 | 0x7c | |
+; ----------------------------------------------------------------------------------
+; | fc_fp | |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
+; ----------------------------------------------------------------------------------
+; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
+; ----------------------------------------------------------------------------------
+; | XMM6 | XMM7 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
+; ----------------------------------------------------------------------------------
+; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
+; ----------------------------------------------------------------------------------
+; | XMM8 | XMM9 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
+; ----------------------------------------------------------------------------------
+; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
+; ----------------------------------------------------------------------------------
+; | XMM10 | XMM11 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
+; ----------------------------------------------------------------------------------
+; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
+; ----------------------------------------------------------------------------------
+; | XMM12 | XMM13 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
+; ----------------------------------------------------------------------------------
+; | 0x160 | 0x164 | 0x168 | 0x16c | 0x170 | 0x174 | 0x178 | 0x17c |
+; ----------------------------------------------------------------------------------
+; | XMM14 | XMM15 |
+; ----------------------------------------------------------------------------------
-EXTERN _exit:PROC ; standard C library function
-EXTERN align_stack:PROC ; stack alignment
+EXTERN _exit:PROC ; standard C library function
+EXTERN align_stack:PROC ; stack alignment
EXTERN seh_fcontext:PROC ; exception handler
EXTERN start_fcontext:PROC ; start fcontext
.code
@@ -72,9 +114,6 @@
mov [rcx+030h], rbx ; save RBX
mov [rcx+038h], rbp ; save RBP
- stmxcsr [rcx+050h] ; save SSE2 control and status word
- fnstcw [rcx+054h] ; save x87 control word
-
mov r9, gs:[030h] ; load NT_TIB
mov rax, [r9+08h] ; load current stack base
mov [rcx+058h], rax ; save current stack base
@@ -98,8 +137,33 @@
mov rbx, [rdx+030h] ; restore RBX
mov rbp, [rdx+038h] ; restore RBP
- ldmxcsr [rdx+050h] ; restore SSE2 control and status word
- fldcw [rdx+054h] ; restore x87 control word
+; stmxcsr [rcx+050h] ; save SSE2 control and status word
+; fnstcw [rcx+054h] ; save x87 control word
+
+ 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
+
+; ldmxcsr [rdx+050h] ; restore SSE2 control and status word
+; fldcw [rdx+054h] ; restore x87 control word
+
+ 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 r9, gs:[030h] ; load NT_TIB
mov rax, [rdx+058h] ; load stack base
@@ -129,10 +193,10 @@
push rcx ; save pointer to fcontext_t
sub rsp, 028h ; reserve shadow space for boost_fcontext_algin
mov rcx, rdx ; stack pointer as arg for align_stack
- mov [rsp+8], rcx
+ mov [rsp+8], rcx
call align_stack ; align stack
mov rdx, rax ; begin of aligned stack
- add rsp, 028h
+ add rsp, 028h
pop rcx ; restore pointer to fcontext_t
lea rdx, [rdx-028h] ; reserve 32byte shadow space + return address on stack, (RSP + 8) % 16 == 0
@@ -151,7 +215,7 @@
make_fcontext ENDP
link_fcontext PROC FRAME ; generate function table entry in .pdata and unwind information in
- .endprolog ; .xdata for a function's structured exception handling unwind behavior
+ .endprolog ; .xdata for a function's structured exception handling unwind behavior
sub rsp, 028h ; reserve shadow space for boost_fcontext_algin
test r13, r13 ; test if a next context was given
@@ -159,13 +223,13 @@
mov rcx, r12 ; first argument eq. address of current context
mov rdx, r13 ; second argumnet eq. address of next context
- mov [rsp+010h], rdx
- mov [rsp+08h], rcx
+ mov [rsp+010h], rdx
+ mov [rsp+08h], rcx
call start_fcontext ; install next context
finish:
xor rcx, rcx
- mov [rsp+08h], rcx
+ mov [rsp+08h], rcx
call _exit ; exit application
hlt
link_fcontext ENDP
Modified: trunk/libs/context/src/fcontext.cpp
==============================================================================
--- trunk/libs/context/src/fcontext.cpp (original)
+++ trunk/libs/context/src/fcontext.cpp 2012-04-19 15:07:50 EDT (Thu, 19 Apr 2012)
@@ -16,6 +16,7 @@
namespace boost {
namespace ctx {
+namespace detail {
extern "C" BOOST_CONTEXT_DECL void * BOOST_CONTEXT_CALLDECL align_stack( void * vp)
{
@@ -26,6 +27,8 @@
return base;
}
+}
+
# if !defined(__arm__) && !defined(__powerpc__)
extern "C" BOOST_CONTEXT_DECL intptr_t BOOST_CONTEXT_CALLDECL start_fcontext( fcontext_t * ofc, fcontext_t const* nfc)
{ return jump_fcontext( ofc, nfc, 0); }
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