Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81595 - in trunk: boost/context boost/context/detail libs/context/build libs/context/example libs/context/src libs/context/src/asm
From: oliver.kowalke_at_[hidden]
Date: 2012-11-27 15:11:35


Author: olli
Date: 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
New Revision: 81595
URL: http://svn.boost.org/trac/boost/changeset/81595

Log:
context: replace align_stack() bay assembler

Removed:
   trunk/libs/context/src/fcontext.cpp
Text files modified:
   trunk/boost/context/detail/fcontext_x86_64_win.hpp | 15 -----
   trunk/boost/context/fcontext.hpp | 5 --
   trunk/libs/context/build/Jamfile.v2 | 33 ++++--------
   trunk/libs/context/example/exit.cpp | 40 ++++++++-------
   trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm | 1
   trunk/libs/context/src/asm/jump_ppc32_sysv_elf_gas.S | 100 ++++++++++++++++++++--------------------
   trunk/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S | 2
   trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm | 53 ++++++++++++--------
   trunk/libs/context/src/asm/make_arm_aapcs_elf_gas.S | 37 +++++++-------
   trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm | 25 +++------
   trunk/libs/context/src/asm/make_i386_sysv_elf_gas.S | 26 ++-------
   trunk/libs/context/src/asm/make_i386_sysv_macho_gas.S | 24 +++------
   trunk/libs/context/src/asm/make_mips32_o32_elf_gas.S | 28 +++-------
   trunk/libs/context/src/asm/make_ppc32_sysv_elf_gas.S | 58 ++++++++++-------------
   trunk/libs/context/src/asm/make_ppc64_sysv_elf_gas.S | 30 ++++-------
   trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm | 68 +++++++++------------------
   trunk/libs/context/src/asm/make_x86_64_sysv_elf_gas.S | 29 +++--------
   trunk/libs/context/src/asm/make_x86_64_sysv_macho_gas.S | 22 ++------
   18 files changed, 242 insertions(+), 354 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-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -45,25 +45,12 @@
     {}
 };
 
-struct fp_t
-{
- boost::uint32_t fc_freg[2];
- void * fc_xmm;
- char fc_buffer[175];
-
- fp_t() :
- fc_freg(),
- fc_xmm( 0),
- fc_buffer()
- {}
-};
-
 struct fcontext_t
 {
     boost::uint64_t fc_greg[10];
     stack_t fc_stack;
     void * fc_local_storage;
- fp_t fc_fp;
+ boost::uint64_t fc_fp[24];
 
     fcontext_t() :
         fc_greg(),

Modified: trunk/boost/context/fcontext.hpp
==============================================================================
--- trunk/boost/context/fcontext.hpp (original)
+++ trunk/boost/context/fcontext.hpp 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -61,11 +61,6 @@
 
 namespace boost {
 namespace context {
-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 jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp, bool preserve_fpu = true);

Modified: trunk/libs/context/build/Jamfile.v2
==============================================================================
--- trunk/libs/context/build/Jamfile.v2 (original)
+++ trunk/libs/context/build/Jamfile.v2 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -281,7 +281,8 @@
    ;
 
 alias asm_context_sources
- : asm/make_i386_ms_pe_masm.asm
+ : seh.cpp
+ asm/make_i386_ms_pe_masm.asm
      asm/jump_i386_ms_pe_masm.asm
    : <abi>ms
      <address-model>32
@@ -292,7 +293,8 @@
    ;
 
 alias asm_context_sources
- : asm/make_i386_ms_pe_masm.asm
+ : seh.cpp
+ asm/make_i386_ms_pe_masm.asm
      asm/jump_i386_ms_pe_masm.asm
    : <abi>ms
      <address-model>32
@@ -303,7 +305,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/make_i386_ms_pe_masm.o : asm/make_i386_ms_pe_masm.asm : @masm ]
+ : seh.cpp
+ [ make asm/make_i386_ms_pe_masm.o : asm/make_i386_ms_pe_masm.asm : @masm ]
      [ make asm/jump_i386_ms_pe_masm.o : asm/jump_i386_ms_pe_masm.asm : @masm ]
    : <abi>ms
      <address-model>32
@@ -385,7 +388,8 @@
    ;
 
 alias asm_context_sources
- : asm/make_x86_64_ms_pe_masm.asm
+ : seh.cpp
+ asm/make_x86_64_ms_pe_masm.asm
      asm/jump_x86_64_ms_pe_masm.asm
    : <abi>ms
      <address-model>64
@@ -396,7 +400,8 @@
    ;
 
 alias asm_context_sources
- : asm/make_x86_64_ms_pe_masm.asm
+ : seh.cpp
+ asm/make_x86_64_ms_pe_masm.asm
      asm/jump_x86_64_ms_pe_masm.asm
    : <abi>ms
      <address-model>64
@@ -407,7 +412,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/make_x86_64_ms_pe_masm.o : asm/make_x86_64_ms_pe_masm.asm : @masm64 ]
+ : seh.cpp
+ [ make asm/make_x86_64_ms_pe_masm.o : asm/make_x86_64_ms_pe_masm.asm : @masm64 ]
      [ make asm/jump_x86_64_ms_pe_masm.o : asm/jump_x86_64_ms_pe_masm.asm : @masm64 ]
    : <abi>ms
      <address-model>64
@@ -418,32 +424,17 @@
 
 explicit asm_context_sources ;
 
-
 alias select_asm_context_sources
   : asm_context_sources
   : [ architecture.architecture ]
     [ architecture.address-model ]
   ;
 
-
-alias context_sources
- : fcontext.cpp
- seh.cpp
- : <target-os>windows
- ;
-
-alias context_sources
- : fcontext.cpp
- ;
-
 explicit context_sources ;
 
-
 lib boost_context
    : select_asm_context_sources
- context_sources
    : <link>shared:<define>BOOST_CONTEXT_DYN_LINK=1
    ;
 
-
 boost-install boost_context ;

Modified: trunk/libs/context/example/exit.cpp
==============================================================================
--- trunk/libs/context/example/exit.cpp (original)
+++ trunk/libs/context/example/exit.cpp 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -27,36 +27,38 @@
 
 void f1( intptr_t)
 {
- std::cout << "f1: entered" << std::endl;
- std::cout << "f1: call jump_fcontext( fc1, fc2, 0)" << std::endl;
- ctx::jump_fcontext( fc1, fc2, 0);
- std::cout << "f1: return" << std::endl;
+ std::cout << "f1: entered" << std::endl;
+ std::cout << "f1: call jump_fcontext( fc1, fc2, 0)" << std::endl;
+ ctx::jump_fcontext( fc1, fc2, 0);
+ std::cout << "f1: return" << std::endl;
 }
 
 void f2( intptr_t)
 {
- std::cout << "f2: entered" << std::endl;
- std::cout << "f2: call jump_fcontext( fc2, fc1, 0)" << std::endl;
- ctx::jump_fcontext( fc2, fc1, 0);
- BOOST_ASSERT( false && ! "f2: never returns");
+ std::cout << "f2: entered" << std::endl;
+ std::cout << "f2: call jump_fcontext( fc2, fc1, 0)" << std::endl;
+ ctx::jump_fcontext( fc2, fc1, 0);
+ BOOST_ASSERT( false && ! "f2: never returns");
 }
 
 int main( int argc, char * argv[])
 {
- ctx::fcontext_t fcm;
- stack_allocator alloc;
+ std::cout << "size: 0x" << std::hex << sizeof( ctx::fcontext_t) << std::endl;
 
- void * sp1 = alloc.allocate( stack_allocator::default_stacksize());
- fc1 = ctx::make_fcontext( sp1, stack_allocator::default_stacksize(), f1);
+ ctx::fcontext_t fcm;
+ stack_allocator alloc;
 
- void * sp2 = alloc.allocate( stack_allocator::default_stacksize());
- fc2 = ctx::make_fcontext( sp2, stack_allocator::default_stacksize(), f2);
+ void * sp1 = alloc.allocate( stack_allocator::default_stacksize());
+ fc1 = ctx::make_fcontext( sp1, stack_allocator::default_stacksize(), f1);
 
- std::cout << "main: call start_fcontext( & fcm, fc1, 0)" << std::endl;
- ctx::jump_fcontext( & fcm, fc1, 0);
+ void * sp2 = alloc.allocate( stack_allocator::default_stacksize());
+ fc2 = ctx::make_fcontext( sp2, stack_allocator::default_stacksize(), f2);
 
- std::cout << "main: done" << std::endl;
- BOOST_ASSERT( false && ! "main: never returns");
+ std::cout << "main: call start_fcontext( & fcm, fc1, 0)" << std::endl;
+ ctx::jump_fcontext( & fcm, fc1, 0);
 
- return EXIT_SUCCESS;
+ std::cout << "main: done" << std::endl;
+ BOOST_ASSERT( false && ! "main: never returns");
+
+ return EXIT_SUCCESS;
 }

Modified: trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -44,7 +44,6 @@
 .XMM
 .model flat, c
 _exit PROTO, value:SDWORD
-align_stack PROTO, vp:DWORD
 seh_fcontext PROTO, except:DWORD, frame:DWORD, context:DWORD, dispatch:DWORD
 .code
 

Modified: trunk/libs/context/src/asm/jump_ppc32_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/jump_ppc32_sysv_elf_gas.S (original)
+++ trunk/libs/context/src/asm/jump_ppc32_sysv_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -29,37 +29,37 @@
  * | CR | LR | PC | | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 23 | 24 | | *
+ * | 23 | 24 | 25 | | *
  * ------------------------------------------------------------- *
- * | 92 | 96 | | *
+ * | 92 | 96 | 100 | | *
  * ------------------------------------------------------------- *
- * | sp | size| | *
+ * | sp | size|<pad>| | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | *
+ * | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | *
  * ------------------------------------------------------------- *
- * | 100 | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 | 136 | *
+ * | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 | 136 | 140 | *
  * ------------------------------------------------------------- *
  * | F14 | F15 | F16 | F17 | F18 | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | *
+ * | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | *
  * ------------------------------------------------------------- *
- * | 140 | 144 | 148 | 152 | 156 | 160 | 164 | 168 | 172 | 176 | *
+ * | 144 | 148 | 152 | 156 | 160 | 164 | 168 | 172 | 176 | 180 | *
  * ------------------------------------------------------------- *
  * | F19 | F20 | F21 | F22 | F23 | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | *
+ * | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
  * ------------------------------------------------------------- *
- * | 180 | 184 | 188 | 192 | 196 | 200 | 204 | 208 | 212 | 216 | *
+ * | 184 | 188 | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
  * ------------------------------------------------------------- *
  * | F24 | F25 | F26 | F27 | F28 | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | | *
+ * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | | *
  * ------------------------------------------------------------- *
- * | 220 | 224 | 228 | 232 | 236 | 240 | 244 | 248 | | *
+ * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | | *
  * ------------------------------------------------------------- *
  * | F29 | F30 | F31 | fpscr | | *
  * ------------------------------------------------------------- *
@@ -101,46 +101,46 @@
     cmpwi cr7, %r6, 0 # test if fpu env should be preserved
     beq cr7, 1f
 
- stfd %f14, 100(%r3) # save F14
- stfd %f15, 108(%r3) # save F15
- stfd %f16, 116(%r3) # save F16
- stfd %f17, 124(%r3) # save F17
- stfd %f18, 132(%r3) # save F18
- stfd %f19, 140(%r3) # save F19
- stfd %f20, 148(%r3) # save F20
- stfd %f21, 156(%r3) # save F21
- stfd %f22, 164(%r3) # save F22
- stfd %f23, 172(%r3) # save F23
- stfd %f24, 180(%r3) # save F24
- stfd %f25, 188(%r3) # save F25
- stfd %f26, 196(%r3) # save F26
- stfd %f27, 204(%r3) # save F27
- stfd %f28, 212(%r3) # save F28
- stfd %f29, 220(%r3) # save F29
- stfd %f30, 228(%r3) # save F30
- stfd %f31, 236(%r3) # save F31
+ stfd %f14, 104(%r3) # save F14
+ stfd %f15, 112(%r3) # save F15
+ stfd %f16, 120(%r3) # save F16
+ stfd %f17, 128(%r3) # save F17
+ stfd %f18, 136(%r3) # save F18
+ stfd %f19, 144(%r3) # save F19
+ stfd %f20, 152(%r3) # save F20
+ stfd %f21, 160(%r3) # save F21
+ stfd %f22, 168(%r3) # save F22
+ stfd %f23, 176(%r3) # save F23
+ stfd %f24, 184(%r3) # save F24
+ stfd %f25, 192(%r3) # save F25
+ stfd %f26, 200(%r3) # save F26
+ stfd %f27, 208(%r3) # save F27
+ stfd %f28, 216(%r3) # save F28
+ stfd %f29, 224(%r3) # save F29
+ stfd %f30, 232(%r3) # save F30
+ stfd %f31, 240(%r3) # save F31
     mffs %f0 # load FPSCR
- stfd %f0, 244(%r3) # save FPSCR
+ stfd %f0, 248(%r3) # save FPSCR
 
- lfd %f14, 100(%r4) # restore F14
- lfd %f15, 108(%r4) # restore F15
- lfd %f16, 116(%r4) # restore F16
- lfd %f17, 124(%r4) # restore F17
- lfd %f18, 132(%r4) # restore F18
- lfd %f19, 140(%r4) # restore F19
- lfd %f20, 148(%r4) # restore F20
- lfd %f21, 156(%r4) # restore F21
- lfd %f22, 164(%r4) # restore F22
- lfd %f23, 172(%r4) # restore F23
- lfd %f24, 180(%r4) # restore F24
- lfd %f25, 188(%r4) # restore F25
- lfd %f26, 196(%r4) # restore F26
- lfd %f27, 204(%r4) # restore F27
- lfd %f28, 212(%r4) # restore F28
- lfd %f29, 220(%r4) # restore F29
- lfd %f30, 228(%r4) # restore F30
- lfd %f31, 236(%r4) # restore F31
- lfd %f0, 244(%r4) # load FPSCR
+ lfd %f14, 104(%r4) # restore F14
+ lfd %f15, 112(%r4) # restore F15
+ lfd %f16, 120(%r4) # restore F16
+ lfd %f17, 128(%r4) # restore F17
+ lfd %f18, 136(%r4) # restore F18
+ lfd %f19, 144(%r4) # restore F19
+ lfd %f20, 152(%r4) # restore F20
+ lfd %f21, 160(%r4) # restore F21
+ lfd %f22, 168(%r4) # restore F22
+ lfd %f23, 176(%r4) # restore F23
+ lfd %f24, 184(%r4) # restore F24
+ lfd %f25, 192(%r4) # restore F25
+ lfd %f26, 200(%r4) # restore F26
+ lfd %f27, 208(%r4) # restore F27
+ lfd %f28, 216(%r4) # restore F28
+ lfd %f29, 224(%r4) # restore F29
+ lfd %f30, 232(%r4) # restore F30
+ lfd %f31, 240(%r4) # restore F31
+ lfd %f0, 248(%r4) # load FPSCR
     mtfsf 0xff, %f0 # restore FPSCR
 1:
 
@@ -170,7 +170,7 @@
     lwz %r0, 84(%r4) # load LR
     mtlr %r0 # restore LR
 
- mr. %r3, %r5 # use third arg as return value after jump
+ mr %r3, %r5 # use third arg as return value after jump
                                 # and as first arg in context function
 
     lwz %r0, 88(%r4) # load PC

Modified: trunk/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S (original)
+++ trunk/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -191,7 +191,7 @@
     ld %r0, 168(%r4) # load LR
     mtlr %r0 # restore LR
 
- mr. %r3, %r5 # use third arg as return value after jump
+ mr %r3, %r5 # use third arg as return value after jump
                                 # and as first arg in context function
 
     ld %r0, 176(%r4) # load PC

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-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -40,50 +40,49 @@
 ; | fbr_strg | |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 28 | 29 | 30 | 31 | |
+; | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
 ; ----------------------------------------------------------------------------------
-; | 0x70 | 0x74 | 0x78 | 0x7c | |
+; | 0x70 | 0x74 | 0x78 | 0x7c | 0x80 | 0x84 | 0x88 | 0x8c |
 ; ----------------------------------------------------------------------------------
-; | fc_mxcsr|fc_x87_cw| fc_xmm | |
+; | fc_mxcsr|fc_x87_cw| fc_xmm | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
+; | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
 ; ----------------------------------------------------------------------------------
-; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
+; | 0x90 | 0x94 | 0x98 | 0x9c | 0x100 | 0x104 | 0x108 | 0x10c |
 ; ----------------------------------------------------------------------------------
-; | XMM6 | XMM7 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
+; | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
 ; ----------------------------------------------------------------------------------
-; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
+; | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c |
 ; ----------------------------------------------------------------------------------
-; | XMM8 | XMM9 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
+; | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
 ; ----------------------------------------------------------------------------------
-; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
+; | 0x130 | 0x134 | 0x138 | 0x13c| 0x140 | 0x144 | 0x148 | 0x14c |
 ; ----------------------------------------------------------------------------------
-; | XMM10 | XMM11 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
+; | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
 ; ----------------------------------------------------------------------------------
-; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
+; | 0x150 | 0x154 | 0x158 | 0x15c | 0x160 | 0x164 | 0x168 | 0x16c |
 ; ----------------------------------------------------------------------------------
-; | XMM12 | XMM13 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
+; | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
 ; ----------------------------------------------------------------------------------
-; | 0x160 | 0x164 | 0x168 | 0x16c | 0x170 | 0x174 | 0x178 | 0x17c |
+; | 0x170 | 0x174 | 0x178 | 0x17c | 0x180 | 0x184 | 0x188 | 0x18c |
 ; ----------------------------------------------------------------------------------
-; | XMM14 | XMM15 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 
 EXTERN _exit:PROC ; standard C library function
-EXTERN align_stack:PROC ; stack alignment
 EXTERN seh_fcontext:PROC ; exception handler
 .code
 
@@ -113,7 +112,12 @@
     stmxcsr [rcx+070h] ; save MMX control and status word
     fnstcw [rcx+074h] ; save x87 control word
     ; save XMM storage
- mov r10, [rcx+078h] ; load start address of XMM storage into R10
+ ; save start address of SSE register block in R10
+ lea r10, [rcx+090h]
+ ; shift address in R10 to lower 16 byte boundary
+ ; == pointer to SEE register block
+ and r10, -0fh
+
     movaps [r10], xmm6
     movaps [r10+010h], xmm7
     movaps [r10+020h], xmm8
@@ -128,7 +132,12 @@
     ldmxcsr [rdx+070h] ; restore MMX control and status word
     fldcw [rdx+074h] ; restore x87 control word
     ; restore XMM storage
- mov r10, [rdx+078h] ; load start address of XMM storage into R10
+ ; save start address of SSE register block in R10
+ lea r10, [rdx+090h]
+ ; shift address in R10 to lower 16 byte boundary
+ ; == pointer to SEE register block
+ and r10, -0fh
+
     movaps xmm6, [r10]
     movaps xmm7, [r10+010h]
     movaps xmm8, [r10+020h]
@@ -139,8 +148,8 @@
     movaps xmm13, [r10+070h]
     movaps xmm14, [r10+080h]
     movaps xmm15, [r10+090h]
-nxt:
 
+nxt:
     lea rax, [rsp+08h] ; exclude the return address
     mov [rcx+040h], rax ; save as stack pointer
     mov rax, [rsp] ; load return address

Modified: trunk/libs/context/src/asm/make_arm_aapcs_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_arm_aapcs_elf_gas.S (original)
+++ trunk/libs/context/src/asm/make_arm_aapcs_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -50,26 +50,27 @@
 .align 2
 .type make_fcontext,%function
 make_fcontext:
- stmfd sp!, {a1-a3,lr} @ save arguments of make_fcontext and return address on stack, SP % 8 == 0
- sub a1, #116 @ reserve space for fcontext_t at top of context stack
- bl align_stack_at_PLT @ call align_stack, A1 contains address at 16 byte boundary after return
- @ == pointer to fcontext_t and address of context stack
-
- ldmfd sp!, {a2-a4,lr} @ restore arguments of make_fcontext and return address from stack
- str a2, [a1,#44] @ save address of context stack (base) in fcontext_t
- str a3, [a1,#48] @ save context stack size in fcontext_t
- str a4, [a1,#40] @ save address of context function in fcontext_t
-
- str a1, [a1,#32] @ save address in A1 as stack pointer for context function
-
- adr a2, finish @ compute abs address of label finish
- str a2, [a1,#36] @ save address of finish as return address for context function
- @ entered after context function returns
+ mov a4, a1 @ save address of context stack (base) A4
+ sub a1, #116 @ reserve space for fcontext_t at top of context stack
+
+ @ shift address in A1 to lower 16 byte boundary
+ @ == pointer to fcontext_t and address of context stack
+ bic a1, a1, #15
+
+ str a4, [a1,#44] @ save address of context stack (base) in fcontext_t
+ str a2, [a1,#48] @ save context stack size in fcontext_t
+ str a3, [a1,#40] @ save address of context function in fcontext_t
+
+ str a1, [a1,#32] @ save address in A4 as stack pointer for context function
+
+ adr a2, finish @ compute abs address of label finish
+ str a2, [a1,#36] @ save address of finish as return address for context function
+ @ entered after context function returns
 
     bx lr
 
 finish:
- @ SP points to same address as SP on entry of context function
- mov a1, #0 @ exit code is zero
- bl _exit_at_PLT @ exit application
+ @ SP points to same addras SP on entry of context function
+ mov a1, #0 @ exit code is zero
+ bl _exit_at_PLT @ exit application
 .size make_fcontext,.-make_fcontext

Modified: trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm (original)
+++ trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -43,30 +43,26 @@
 .386
 .XMM
 .model flat, c
-_exit PROTO, value:SDWORD
-align_stack PROTO, vp:DWORD
+_exit PROTO, value:SDWORD
 seh_fcontext PROTO, except:DWORD, frame:DWORD, context:DWORD, dispatch:DWORD
 .code
 
 make_fcontext PROC EXPORT
- push ebp ; save previous frame pointer; get the stack 16 byte aligned
- mov ebp, esp ; set EBP to ESP
- sub esp, 010h ; allocate stack space
-
- mov eax, [ebp+08h] ; load 1. arg of make_fcontext, pointer to context stack (base)
+ mov eax, [esp+04h] ; load 1. arg of make_fcontext, pointer to context stack (base)
     lea eax, [eax-034h] ; reserve space for fcontext_t at top of context stack
- mov [esp], eax ; address in EAX becomes 1.arg of align_stack
- call align_stack ; call align_stack, EAX contains address at 16 byte boundary after return
- ; == pointer to fcontext_t and address of context stack
 
- mov ecx, [ebp+08h] ; load 1. arg of make_fcontext, pointer to context stack (base)
+ ; shift address in EAX to lower 16 byte boundary
+ ; == pointer to fcontext_t and address of context stack
+ and eax, -0fh
+
+ mov ecx, [esp+04h] ; load 1. arg of make_fcontext, pointer to context stack (base)
     mov [eax+018h], ecx ; save address of context stack (base) in fcontext_t
- mov edx, [ebp+0ch] ; load 2. arg of make_fcontext, context stack size
+ mov edx, [esp+08h] ; load 2. arg of make_fcontext, context stack size
     mov [eax+01ch], edx ; save context stack size in fcontext_t
     neg edx ; negate stack size for LEA instruction (== substraction)
     lea ecx, [ecx+edx] ; compute bottom address of context stack (limit)
     mov [eax+020h], ecx ; save address of context stack (limit) in fcontext_t
- mov ecx, [ebp+010h] ; load 3. arg of make_fcontext, pointer to context function
+ mov ecx, [esp+0ch] ; load 3. arg of make_fcontext, pointer to context function
     mov [eax+014h], ecx ; save address of context function in fcontext_t
 
     stmxcsr [eax+02ch] ; save MMX control word
@@ -86,9 +82,6 @@
     mov [edx], ecx ; save address of finish as return address for context function
                                     ; entered after context function returns
 
- add esp, 010h ; deallocate stack space
- pop ebp
-
     ret
 
 finish:

Modified: trunk/libs/context/src/asm/make_i386_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_i386_sysv_elf_gas.S (original)
+++ trunk/libs/context/src/asm/make_i386_sysv_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -36,27 +36,18 @@
 .align 2
 .type make_fcontext,@function
 make_fcontext:
- pushl %ebp /* save previous frame pointer; get the stack 16 byte aligned */
- movl %esp, %ebp /* set EBP to ESP */
- subl $0x10, %esp /* allocate stack space */
-
- movl %ebx, 0x4(%esp) /* save EBX */
- movl 0x8(%ebp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ movl 0x4(%esp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
     leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
- movl %eax, (%esp) /* address in EAX becomes 1. arg of align_stack */
 
- call 1f
-1: popl %ebx /* address of label 1 */
- addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx /* compute address of GOT and store it in EBX */
- call align_stack_at_PLT /* call align_stack, EAX contains address at 16 byte boundary after return */
- /* == pointer to fcontext_t and address of context stack */
- movl 0x4(%esp), %ebx /* restore EBX */
+ /* shift address in EAX to lower 16 byte boundary */
+ /* == pointer to fcontext_t and address of context stack */
+ andl $-0xf, %eax
 
- movl 0x8(%ebp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ movl 0x4(%esp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
     movl %edx, 0x18(%eax) /* save address of context stack (base) in fcontext_t */
- movl 0xc(%ebp), %edx /* load 2. arg of make_fcontext, context stack size */
+ movl 0x8(%esp), %edx /* load 2. arg of make_fcontext, context stack size */
     movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
- movl 0x10(%ebp), %edx /* load 3. arg of make_fcontext, pointer to context function */
+ movl 0xc(%esp), %edx /* load 3. arg of make_fcontext, pointer to context function */
     movl %edx, 0x14(%eax) /* save address of context function in fcontext_t */
 
     stmxcsr 0x20(%eax) /* save MMX control and status word */
@@ -71,9 +62,6 @@
     movl %ecx, (%edx) /* save address of finish as return address for context functions */
                                        /* entered after context function returns */
 
- addl $0x10, %esp /* deallocate stack space */
- pop %ebp
-
     ret
 
 finish:

Modified: trunk/libs/context/src/asm/make_i386_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_i386_sysv_macho_gas.S (original)
+++ trunk/libs/context/src/asm/make_i386_sysv_macho_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -35,21 +35,18 @@
 .globl _make_fcontext
 .align 2
 _make_fcontext:
- pushl %ebp /* save previous frame pointer */
- movl %esp, %ebp /* set EBP to ESP */
- subl $0x8, %esp /* allocate stack space */
-
- movl 0x8(%ebp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ movl 0x4(%esp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
     leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
- movl %eax, (%esp) /* address in EAX becomes 1. arg of align_stack */
- call _align_stack /* call align_stack, EAX contains address at 16 byte boundary after return */
- /* ==pointer to fcontext_t and address of context stack */
 
- movl 0x8(%ebp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ /* shift address in EAX to lower 16 byte boundary */
+ /* == pointer to fcontext_t and address of context stack */
+ andl $-0xf, %eax
+
+ movl 0x4(%esp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
     movl %edx, 0x18(%eax) /* save address of stack pointer (base) in fcontext_t */
- movl 0xc(%ebp), %edx /* load 2. arg of make_fcontext, context stack size */
+ movl 0x8(%esp), %edx /* load 2. arg of make_fcontext, context stack size */
     movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
- movl 0x10(%ebp), %edx /* load 3. arg of make_fcontext, pointer to context function */
+ movl 0xc(%esp), %edx /* load 3. arg of make_fcontext, pointer to context function */
     movl %edx, 0x14(%eax) /* save address of context fcuntion in fcontext_t */
 
     stmxcsr 0x20(%eax) /* save MMX control and status word */
@@ -60,13 +57,10 @@
 
     call 1f
 1: popl %ecx /* address of label 1 */
- addl $finish-1b, %ecx /* compute abs address of label finish */
+ addl $finish-2b, %ecx /* compute abs address of label finish */
     movl %ecx, (%edx) /* save address of finish as return address for context function */
                                         /* entered after context function returns */
 
- addl $0x8, %esp /* deallocate stack space */
- popl %ebp
-
     ret
 
 finish:

Modified: trunk/libs/context/src/asm/make_mips32_o32_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_mips32_o32_elf_gas.S (original)
+++ trunk/libs/context/src/asm/make_mips32_o32_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -49,22 +49,16 @@
 .cpload $t9
 .set reorder
 #endif
- addiu $sp, $sp, -48 # allocate stack space (contains shadow space for subroutines)
- sw $ra, 44($sp) # save return address
- sw $fp, 40($sp) # save frame pointer
-
- sw $a2, 48($sp) # save 3. arg of make_fcontnext, pointer to context function
- sw $a1, 52($sp) # save 2. arg of make_fcontext, context stack size
- sw $a0, 56($sp) # save 1. arg of make_fcontext, pointer to context stack (base)
- addiu $a0, $a0, -104 # reserve space for fcontext_t at top of context stack
- lw $t9, %call16(align_stack)($gp) # compute adddress of align_stack via global pointer
- jalr $t9 # call align_stack, V0 contains address at 16 byte boundary after return
- # == pointer to fcontext_t and address of context stack
- lw $a0, 56($sp) # restore pointer to context stack (base)
- lw $a1, 52($sp) # restore context stack size
- lw $a2, 48($sp) # restore pointer to context function
+ move $v0, $a0
+ addiu $v0, $v0, -104 # reserve space for fcontext_t at top of context stack
 
- sw $a0, 48($v0) # save address of context stack (base) in fcontext_t
+ # shift address in V0 to lower 16 byte boundary
+ # == pointer to fcontext_t and address of context stack
+ move $v1, $v0
+ li $v0, -16 # 0xfffffffffffffff0
+ and $v0, $v1, $v0
+
+ sw $a0, 48($v0) # save address of context stack (base) in fcontext_t
     sw $a1, 52($v0) # save context stack size in fcontext_t
     sw $a2, 44($v0) # save address of context function in fcontext_t
     sw $gp, ($v0) # save global pointer in fcontext_t, S0 will contain address of global pointer
@@ -76,10 +70,6 @@
     sw $t9, 40($v0) # save address of finish as return address for context function
                                 # entered after context function returns
 
- lw $fp, 40($sp) # restore frame pointer
- lw $ra, 44($sp) # restore return address
- addiu $sp, $sp, 48 # deallocate stack space
-
     jr $ra
 
 finish:

Modified: trunk/libs/context/src/asm/make_ppc32_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_ppc32_sysv_elf_gas.S (original)
+++ trunk/libs/context/src/asm/make_ppc32_sysv_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -29,37 +29,37 @@
  * | CR | LR | PC | | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 23 | 24 | | *
+ * | 23 | 24 | 25 | | *
  * ------------------------------------------------------------- *
- * | 92 | 96 | | *
+ * | 92 | 96 | 100 | | *
  * ------------------------------------------------------------- *
- * | sp | size| | *
+ * | sp | size|<pad>| | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | *
+ * | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | *
  * ------------------------------------------------------------- *
- * | 100 | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 | 136 | *
+ * | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 | 136 | 140 | *
  * ------------------------------------------------------------- *
  * | F14 | F15 | F16 | F17 | F18 | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | *
+ * | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | *
  * ------------------------------------------------------------- *
- * | 140 | 144 | 148 | 152 | 156 | 160 | 164 | 168 | 172 | 176 | *
+ * | 144 | 148 | 152 | 156 | 160 | 164 | 168 | 172 | 176 | 180 | *
  * ------------------------------------------------------------- *
  * | F19 | F20 | F21 | F22 | F23 | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | *
+ * | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
  * ------------------------------------------------------------- *
- * | 180 | 184 | 188 | 192 | 196 | 200 | 204 | 208 | 212 | 216 | *
+ * | 184 | 188 | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
  * ------------------------------------------------------------- *
  * | F24 | F25 | F26 | F27 | F28 | *
  * ------------------------------------------------------------- *
  * ------------------------------------------------------------- *
- * | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | | *
+ * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | | *
  * ------------------------------------------------------------- *
- * | 220 | 224 | 228 | 232 | 236 | 240 | 244 | 248 | | *
+ * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | | *
  * ------------------------------------------------------------- *
  * | F29 | F30 | F31 | fpscr | | *
  * ------------------------------------------------------------- *
@@ -71,27 +71,21 @@
 .align 2
 .type make_fcontext,@function
 make_fcontext:
- mflr %r0 # save return address into R0
- stw %r0, 4(%r1) # save return address on stack, set up stack frame
- stwu %r1, -48(%r1) # allocate stack space, SP % 16 == 0
+ mflr %r6 # save return address into R6
+
+ mr %r0, %r3
+ subi %r3, %r3, 256 # reserve space for fcontext_t at top of context stack
+
+ # call align_stack, R3 contains address at 16 byte boundary after return
+ # == pointer to fcontext_t and address of context stack
+ rlwinm %r3, %r3, 0, 0, 27
 
- stw %r5, 32(%r1) # save 3. arg of make_fcontext, pointer to context function
- stw %r4, 28(%r1) # save 2. arg of make_fcontext, context stack size
- stw %r3, 24(%r1) # save 1. arg of make_fcontext, pointer to context stack (base)
-
- subi %r3, %r3, 252 # reserve space for fcontext_t at top of context stack
- bl align_stack_at_plt # call align_stack, R3 contains address at 16 byte boundary after return
- # == pointer to fcontext_t and address of context stack
- lwz %r4, 24(%r1) # restore pointer to context stack (base)
- lwz %r5, 28(%r1) # restore context stack size
- lwz %r6, 32(%r1) # restore pointer to context function
-
- stw %r4, 92(%r3) # save address of context stack (base) in fcontext_t
- stw %r5, 96(%r3) # save context stack size in fcontext_t
- stw %r6, 88(%r3) # save address of context function in fcontext_t
+ stw %r0, 92(%r3) # save address of context stack (base) in fcontext_t
+ stw %r4, 96(%r3) # save context stack size in fcontext_t
+ stw %r5, 88(%r3) # save address of context function in fcontext_t
 
- subi %r0, %r3, 64 # reserve 64 bytes (linkage + parameter area), R0 % 16 == 0
- stw %r0, 76(%r3) # save address in R0 as stack pointer for context function
+ subi %r0, %r3, 64 # reserve 64 bytes (linkage + parameter area), R4 % 16 == 0
+ stw %r0, 76(%r3) # save address in R3 as stack pointer for context function
 
     mflr %r0 # load LR
     bl 1f # jump to label 1
@@ -102,9 +96,7 @@
     stw %r4, 84(%r3) # save address of finish as return address for context function
                                      # entered after context function returns
 
- addi %r1, %r1, 48 # deallocate stack space
- lwz %r0, 4(%r1) # load return address from stack, destroy stack frame
- mtlr %r0 # restore return address
+ mtlr %r6 # restore return address from R6
 
     blr
 

Modified: trunk/libs/context/src/asm/make_ppc64_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_ppc64_sysv_elf_gas.S (original)
+++ trunk/libs/context/src/asm/make_ppc64_sysv_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -92,24 +92,18 @@
 .type .make_fcontext,@function
 .globl .make_fcontext
 .make_fcontext:
- mflr %r0 # save return address into R0
- std %r0, 8(%r1) # save return address on stack, set up stack frame
- stdu %r1, -96(%r1) # allocate stack space, SP % 16 == 0
-
- std %r5, 64(%r1) # save 3. arg of make_fcontext, pointer to context function
- std %r4, 56(%r1) # save 2. arg of make_fcontext, context stack size
- std %r3, 48(%r1) # save 1. arg of make_fcontext, pointer to context stack (base)
+ mflr %r6 # save return address into R6
 
+ mr %r0, %r3
     subi %r3, %r3, 352 # reserve space for fcontext_t at top of context stack
- bl align_stack_at_plt # call align_stack, R3 contains address at 16 byte boundary after return
- # == pointer to fcontext_t and address of context stack
- ld %r4, 48(%r1) # restore pointer to context stack (base)
- ld %r5, 56(%r1) # restore context stack size
- ld %r6, 64(%r1) # restore pointer to context function
-
- std %r4, 184(%r3) # save address of context stack (base) in fcontext_t
- std %r5, 192(%r3) # save context stack size in fcontext_t
- std %r6, 176(%r3) # save address of context function in fcontext_t
+
+ # call align_stack, R3 contains address at 16 byte boundary after return
+ # == pointer to fcontext_t and address of context stack
+ rlwinm %r3, %r3, 0, 0, 27
+
+ std %r0, 184(%r3) # save address of context stack (base) in fcontext_t
+ std %r4, 192(%r3) # save context stack size in fcontext_t
+ std %r5, 176(%r3) # save address of context function in fcontext_t
 
     subf %r0, %r3, 64 # 64 bytes on stack for parameter area (== 8 registers)
     std %r0, 152(%r3) # save the stack base
@@ -123,9 +117,7 @@
     std %r4, 168(%r3) # save address of finish as return address for context function
                                      # entered after context function returns
 
- addi %r1, %r1, 64 # deallocate stack space
- lwz %r0, 8(%r1) # load return address from stack, destroy stack frame
- mtlr %r0 # restore return address
+ mtlr %r6 # restore return address from R6
 
     blr
 

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-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -40,70 +40,59 @@
 ; | fbr_strg | |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 28 | 29 | 30 | 31 | |
+; | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
 ; ----------------------------------------------------------------------------------
-; | 0x70 | 0x74 | 0x78 | 0x7c | |
+; | 0x70 | 0x74 | 0x78 | 0x7c | 0x80 | 0x84 | 0x88 | 0x8c |
 ; ----------------------------------------------------------------------------------
-; | fc_mxcsr|fc_x87_cw| fc_xmm | |
+; | fc_mxcsr|fc_x87_cw| fc_xmm | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
+; | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
 ; ----------------------------------------------------------------------------------
-; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
+; | 0x90 | 0x94 | 0x98 | 0x9c | 0x100 | 0x104 | 0x108 | 0x10c |
 ; ----------------------------------------------------------------------------------
-; | XMM6 | XMM7 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
+; | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
 ; ----------------------------------------------------------------------------------
-; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
+; | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | 0x128 | 0x12c |
 ; ----------------------------------------------------------------------------------
-; | XMM8 | XMM9 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
+; | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
 ; ----------------------------------------------------------------------------------
-; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
+; | 0x130 | 0x134 | 0x138 | 0x13c| 0x140 | 0x144 | 0x148 | 0x14c |
 ; ----------------------------------------------------------------------------------
-; | XMM10 | XMM11 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
+; | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
 ; ----------------------------------------------------------------------------------
-; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
+; | 0x150 | 0x154 | 0x158 | 0x15c | 0x160 | 0x164 | 0x168 | 0x16c |
 ; ----------------------------------------------------------------------------------
-; | XMM12 | XMM13 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 ; ----------------------------------------------------------------------------------
-; | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
+; | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
 ; ----------------------------------------------------------------------------------
-; | 0x160 | 0x164 | 0x168 | 0x16c | 0x170 | 0x174 | 0x178 | 0x17c |
+; | 0x170 | 0x174 | 0x178 | 0x17c | 0x180 | 0x184 | 0x188 | 0x18c |
 ; ----------------------------------------------------------------------------------
-; | XMM14 | XMM15 |
+; | SEE registers (XMM6-XMM15) |
 ; ----------------------------------------------------------------------------------
 
 EXTERN _exit:PROC ; standard C library function
-EXTERN align_stack:PROC ; stack alignment
-EXTERN seh_fcontext:PROC ; exception handler
 .code
 
 make_fcontext PROC EXPORT FRAME ; generate function table entry in .pdata and unwind information in
     .endprolog ; .xdata for a function's structured exception handling unwind behavior
 
- push rbp ; save previous frame pointer; get the stack 16 byte aligned
- mov rbp, rsp ; set RBP to RSP
- sub rsp, 040h ; allocate stack space (contains shadow space for subroutines)
-
- mov [rbp-08h], r8 ; save 3. arg of make_fcontext, pointer to context function
- mov [rbp-010h], rdx ; save 2. arg of make_fcontext, context stack size
- mov [rbp-018h], rcx ; save 1. arg of make_fcontext, pointer to context stack (base)
- lea rcx, [rcx-0180h] ; reserve space for fcontext_t at top of context stack
- call align_stack ; align context stack, RAX contains address at 16 byte boundary
- ; == pointer to fcontext_t and address of context stack
-
- mov r8, [rbp-08h] ; restore pointer to context function
- mov rdx, [rbp-010h] ; restore context stack size
- mov rcx, [rbp-018h] ; restore pointer to context stack (base)
+ lea rax, [rcx-0130h] ; reserve space for fcontext_t at top of context stack
+
+ ; shift address in RAX to lower 16 byte boundary
+ ; == pointer to fcontext_t and address of context stack
+ and rax, -0fh
 
     mov [rax+048h], r8 ; save address of context function in fcontext_t
     mov [rax+058h], rdx ; save context stack size in fcontext_t
@@ -116,14 +105,6 @@
     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
 
@@ -131,9 +112,6 @@
     mov [rdx], rcx ; save address of finish as return address for context function
                                  ; entered after context function returns
 
- add rsp, 040h ; deallocate shadow space
- pop rbp ; restore previous frame pointer
-
     ret
 
 finish:

Modified: trunk/libs/context/src/asm/make_x86_64_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_x86_64_sysv_elf_gas.S (original)
+++ trunk/libs/context/src/asm/make_x86_64_sysv_elf_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -43,23 +43,15 @@
 .type make_fcontext,@function
 .align 16
 make_fcontext:
- pushq %rbp /* save previous frame pointer; get the stack 16 byte aligned */
- movq %rsp, %rbp /* set RBP to RSP */
- subq $0x20, %rsp /* allocate stack space */
-
- movq %rdx, 0x10(%rsp) /* save 3. arg of make_fcontext, pointer to context function */
- movq %rsi, 0x8(%rsp) /* save 2. arg of make_fcontext, context stack size */
- movq %rdi, (%rsp) /* save 1. arg of make_fcontext, pointer to context stack (base) */
- leaq -0x58(%rdi), %rdi /* reserve space for fcontext_t at top of context stack */
- call align_stack_at_PLT /* align context stack, RAX contains address at 16 byte boundary afte return */
- /* == pointer to fcontext_t and address of context stack */
- movq (%rsp), %rdi /* restore pointer to context stack (base) */
- movq 0x8(%rsp), %rsi /* restore context stack size */
- movq 0x10(%rsp), %rdx /* restore pointer to context function */
-
- movq %rdi, 0x40(%rax) /* save address of context stack pointer (base) in fcontext_t */
- movq %rsi, 0x48(%rax) /* save context stack size in fcontext_t */
- movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
+ leaq -0x58(%rdi), %rax /* reserve space for fcontext_t at top of context stack */
+
+ /* shift address in RAX to lower 16 byte boundary */
+ /* == pointer to fcontext_t and address of context stack */
+ andq $-0xf, %rax
+
+ movq %rdi, 0x40(%rax) /* save address of context stack pointer (base) in fcontext_t */
+ movq %rsi, 0x48(%rax) /* save context stack size in fcontext_t */
+ movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
 
     stmxcsr 0x50(%rax) /* save MMX control and status word */
     fnstcw 0x54(%rax) /* save x87 control word */
@@ -71,9 +63,6 @@
     movq %rcx, (%rdx) /* save address of finish as return address for context function */
                                        /* entered after context function returns */
 
- addq $0x20, %rsp /* deallocate shadow space */
- popq %rbp /* restore previous frame pointer */
-
     ret /* return pointer to fcontext_t placed on context stack */
 
 finish:

Modified: trunk/libs/context/src/asm/make_x86_64_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/make_x86_64_sysv_macho_gas.S (original)
+++ trunk/libs/context/src/asm/make_x86_64_sysv_macho_gas.S 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
@@ -41,20 +41,11 @@
 .text
 .globl _make_fcontext
 .align 8
-_make_fcontext:
- pushq %rbp /* save previous frame pointer; get the stack 16 byte aligned */
- movq %rsp, %rbp /* set RBP to RSP */
- subq $0x20, %rsp /* allocate stack space */
-
- movq %rdx, 0x10(%rsp) /* save 3. arg of make_fcontext, pointer to context function */
- movq %rsi, 0x8(%rsp) /* save 2. arg of make_fcontext, context stack size */
- movq %rdi, (%rsp) /* save 1. arg of make_fcontext, pointer to context stack (base) */
- leaq -0x58(%rdi), %rdi /* reserve space for fcontext_t at top of context stack */
- call _align_stack /* align context stack, RAX contains address at 16 byte boundary */
- /* == pointer to fcontext_t and address of context stack */
- movq (%rsp), %rdi /* restore pointer to context stack (base) */
- movq 0x8(%rsp), %rsi /* restore context stack size */
- movq 0x10(%rsp), %rdx /* restore pointer to context function */
+ leaq -0x58(%rdi), %r8 /* reserve space for fcontext_t at top of context stack */
+
+ /* shift address in RAX to lower 16 byte boundary */
+ /* == pointer to fcontext_t and address of context stack */
+ andq $-0xf, %rax
 
     movq %rdi, 0x40(%rax) /* save address of stack pointer (base) in fcontext_t */
     movq %rsi, 0x48(%rax) /* save stack size in fcontext_t */
@@ -70,9 +61,6 @@
     movq %rcx, (%rdx) /* save address of finish as return address for context function */
                                        /* entered after context function returns */
 
- addq $0x20, %rsp /* deallocate shadow space */
- popq %rbp /* restore previous frame pointer */
-
     ret /* return pointer to fcontext_t placed on context stack */
 
 finish:

Deleted: trunk/libs/context/src/fcontext.cpp
==============================================================================
--- trunk/libs/context/src/fcontext.cpp 2012-11-27 15:11:33 EST (Tue, 27 Nov 2012)
+++ (empty file)
@@ -1,36 +0,0 @@
-
-// Copyright Oliver Kowalke 2009.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#define BOOST_CONTEXT_SOURCE
-
-#include <boost/context/fcontext.hpp>
-
-#include <cstddef>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-extern "C" BOOST_CONTEXT_DECL
-void * BOOST_CONTEXT_CALLDECL align_stack( void * vp)
-{
- void * base = vp;
- if ( 0 != ( ( ( uintptr_t) base) & 15) )
- base = ( char * ) ( ( ( ( uintptr_t) base) - 15) & ~0x0F);
- return base;
-}
-
-}
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif


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