Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81530 - trunk/boost/coroutine/detail
From: oliver.kowalke_at_[hidden]
Date: 2012-11-25 13:23:17


Author: olli
Date: 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
New Revision: 81530
URL: http://svn.boost.org/trac/boost/changeset/81530

Log:
coroutine: clean-up in coroutine_object

Text files modified:
   trunk/boost/coroutine/detail/coroutine_object.hpp | 22 +--
   trunk/boost/coroutine/detail/coroutine_object_result_0.ipp | 207 +++++++++++++++++++++------------------
   trunk/boost/coroutine/detail/coroutine_object_result_1.ipp | 78 ++++++--------
   trunk/boost/coroutine/detail/coroutine_object_result_arity.ipp | 78 ++++++--------
   trunk/boost/coroutine/detail/coroutine_object_void_0.ipp | 207 +++++++++++++++++++++------------------
   trunk/boost/coroutine/detail/coroutine_object_void_1.ipp | 66 ++++++------
   trunk/boost/coroutine/detail/coroutine_object_void_arity.ipp | 78 ++++++--------
   7 files changed, 362 insertions(+), 374 deletions(-)

Modified: trunk/boost/coroutine/detail/coroutine_object.hpp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_object.hpp (original)
+++ trunk/boost/coroutine/detail/coroutine_object.hpp 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
@@ -34,31 +34,25 @@
 namespace coroutines {
 namespace detail {
 
-template< typename Context >
+template< typename Coroutine >
 void trampoline1( intptr_t vp)
 {
     BOOST_ASSERT( vp);
 
- holder< Context * > * hldr(
- reinterpret_cast< holder< Context * > * >( vp) );
- Context * ctx( hldr->data.get() );
-
- ctx->run( hldr->ctx);
+ reinterpret_cast< Coroutine * >( vp)->run();
 }
 
-template< typename Context, typename Arg >
+template< typename Coroutine, typename Arg >
 void trampoline2( intptr_t vp)
 {
     BOOST_ASSERT( vp);
 
- holder< tuple< Context *, Arg > > * hldr(
- reinterpret_cast< holder< tuple< Context *, Arg > > * >( vp) );
- Context * ctx( get< 0 >( hldr->data.get() ) );
- Arg arg( get< 1 >( hldr->data.get() ) );
-// Context * ctx( hldr->data.get().get< 0 >() );
-// Arg arg( hldr->data.get().get< 1 >() );
+ tuple< Coroutine *, Arg > * tpl(
+ reinterpret_cast< tuple< Coroutine *, Arg > * >( vp) );
+ Coroutine * coro( get< 0 >( * tpl) );
+ Arg arg( get< 1 >( * tpl) );
 
- ctx->run( hldr->ctx, arg);
+ coro->run( arg);
 }
 
 template<

Modified: trunk/boost/coroutine/detail/coroutine_object_result_0.ipp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_object_result_0.ipp (original)
+++ trunk/boost/coroutine/detail/coroutine_object_result_0.ipp 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
@@ -39,17 +39,48 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
         if ( this->except_) rethrow_exception( this->except_);
     }
 
+ void run_( Caller & c)
+ {
+ context::fcontext_t * callee( 0);
+ context::fcontext_t caller;
+ try
+ {
+ fn_( c);
+ holder< Result > hldr_to( & caller);
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ hldr_to.ctx, callee,
+ reinterpret_cast< intptr_t >( & hldr_to),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+ catch ( forced_unwind const&)
+ {}
+ catch (...)
+ { this->except_ = current_exception(); }
+
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ & caller, callee,
+ reinterpret_cast< intptr_t >( & caller),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+
     void unwind_stack_() BOOST_NOEXCEPT
     {
         BOOST_ASSERT( ! this->is_complete() );
@@ -119,36 +150,10 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
- context::fcontext_t caller;
- try
- {
- fn_( c);
- holder< Result > hldr_to( & caller);
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- hldr_to.ctx, callee,
- reinterpret_cast< intptr_t >( & hldr_to),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
- }
- catch ( forced_unwind const&)
- {}
- catch (...)
- { this->except_ = current_exception(); }
-
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- & caller, callee,
- reinterpret_cast< intptr_t >( & caller),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
+ run_( c);
     }
 
     void deallocate_object()
@@ -190,17 +195,48 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
         if ( this->except_) rethrow_exception( this->except_);
     }
 
+ void run_( Caller & c)
+ {
+ context::fcontext_t * callee( 0);
+ context::fcontext_t caller;
+ try
+ {
+ fn_( c);
+ holder< Result > hldr_to( & caller);
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ hldr_to.ctx, callee,
+ reinterpret_cast< intptr_t >( & hldr_to),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+ catch ( forced_unwind const&)
+ {}
+ catch (...)
+ { this->except_ = current_exception(); }
+
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ & caller, callee,
+ reinterpret_cast< intptr_t >( & caller),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+
     void unwind_stack_() BOOST_NOEXCEPT
     {
         BOOST_ASSERT( ! this->is_complete() );
@@ -238,36 +274,10 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
- context::fcontext_t caller;
- try
- {
- fn_( c);
- holder< Result > hldr_to( & caller);
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- hldr_to.ctx, callee,
- reinterpret_cast< intptr_t >( & hldr_to),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
- }
- catch ( forced_unwind const&)
- {}
- catch (...)
- { this->except_ = current_exception(); }
-
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- & caller, callee,
- reinterpret_cast< intptr_t >( & caller),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
+ run_( c);
     }
 
     void deallocate_object()
@@ -309,17 +319,48 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
         if ( this->except_) rethrow_exception( this->except_);
     }
 
+ void run_( Caller & c)
+ {
+ context::fcontext_t * callee( 0);
+ context::fcontext_t caller;
+ try
+ {
+ fn_( c);
+ holder< Result > hldr_to( & caller);
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ hldr_to.ctx, callee,
+ reinterpret_cast< intptr_t >( & hldr_to),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+ catch ( forced_unwind const&)
+ {}
+ catch (...)
+ { this->except_ = current_exception(); }
+
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ & caller, callee,
+ reinterpret_cast< intptr_t >( & caller),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+
     void unwind_stack_() BOOST_NOEXCEPT
     {
         BOOST_ASSERT( ! this->is_complete() );
@@ -357,36 +398,10 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
- context::fcontext_t caller;
- try
- {
- fn_( c);
- holder< Result > hldr_to( & caller);
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- hldr_to.ctx, callee,
- reinterpret_cast< intptr_t >( & hldr_to),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
- }
- catch ( forced_unwind const&)
- {}
- catch (...)
- { this->except_ = current_exception(); }
-
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- & caller, callee,
- reinterpret_cast< intptr_t >( & caller),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
+ run_( c);
     }
 
     void deallocate_object()

Modified: trunk/boost/coroutine/detail/coroutine_object_result_1.ipp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_object_result_1.ipp (original)
+++ trunk/boost/coroutine/detail/coroutine_object_result_1.ipp 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
@@ -40,11 +40,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -53,16 +52,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -215,15 +211,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -268,11 +264,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -281,16 +276,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -381,15 +373,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -434,11 +426,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -447,16 +438,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -547,15 +535,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }

Modified: trunk/boost/coroutine/detail/coroutine_object_result_arity.ipp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_object_result_arity.ipp (original)
+++ trunk/boost/coroutine/detail/coroutine_object_result_arity.ipp 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
@@ -40,11 +40,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -53,16 +52,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -215,15 +211,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -268,11 +264,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -281,16 +276,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -381,15 +373,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -434,11 +426,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -447,16 +438,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< Result > * hldr_from(
             reinterpret_cast< holder< Result > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         this->result_ = hldr_from->data;
@@ -547,15 +535,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }

Modified: trunk/boost/coroutine/detail/coroutine_object_void_0.ipp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_object_void_0.ipp (original)
+++ trunk/boost/coroutine/detail/coroutine_object_void_0.ipp 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
@@ -38,16 +38,47 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
     }
 
+ void run_( Caller & c)
+ {
+ context::fcontext_t * callee( 0);
+ context::fcontext_t caller;
+ try
+ {
+ fn_( c);
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ holder< void > hldr_to( & caller);
+ context::jump_fcontext(
+ hldr_to.ctx, callee,
+ reinterpret_cast< intptr_t >( & hldr_to),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+ catch ( forced_unwind const&)
+ {}
+ catch (...)
+ { this->except_ = current_exception(); }
+
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ & caller, callee,
+ reinterpret_cast< intptr_t >( & caller),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+
     void unwind_stack_() BOOST_NOEXCEPT
     {
         BOOST_ASSERT( ! this->is_complete() );
@@ -117,36 +148,10 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
- context::fcontext_t caller;
- try
- {
- fn_( c);
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- holder< void > hldr_to( & caller);
- context::jump_fcontext(
- hldr_to.ctx, callee,
- reinterpret_cast< intptr_t >( & hldr_to),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
- }
- catch ( forced_unwind const&)
- {}
- catch (...)
- { this->except_ = current_exception(); }
-
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- & caller, callee,
- reinterpret_cast< intptr_t >( & caller),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
+ run_( c);
     }
 
     void deallocate_object()
@@ -187,16 +192,47 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
     }
 
+ void run_( Caller & c)
+ {
+ context::fcontext_t * callee( 0);
+ context::fcontext_t caller;
+ try
+ {
+ fn_( c);
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ holder< void > hldr_to( & caller);
+ context::jump_fcontext(
+ hldr_to.ctx, callee,
+ reinterpret_cast< intptr_t >( & hldr_to),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+ catch ( forced_unwind const&)
+ {}
+ catch (...)
+ { this->except_ = current_exception(); }
+
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ & caller, callee,
+ reinterpret_cast< intptr_t >( & caller),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+
     void unwind_stack_() BOOST_NOEXCEPT
     {
         BOOST_ASSERT( ! this->is_complete() );
@@ -234,36 +270,10 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
- context::fcontext_t caller;
- try
- {
- fn_( c);
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- holder< void > hldr_to( & caller);
- context::jump_fcontext(
- hldr_to.ctx, callee,
- reinterpret_cast< intptr_t >( & hldr_to),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
- }
- catch ( forced_unwind const&)
- {}
- catch (...)
- { this->except_ = current_exception(); }
-
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- & caller, callee,
- reinterpret_cast< intptr_t >( & caller),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
+ run_( c);
     }
 
     void deallocate_object()
@@ -304,16 +314,47 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
     }
 
+ void run_( Caller & c)
+ {
+ context::fcontext_t * callee( 0);
+ context::fcontext_t caller;
+ try
+ {
+ fn_( c);
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ holder< void > hldr_to( & caller);
+ context::jump_fcontext(
+ hldr_to.ctx, callee,
+ reinterpret_cast< intptr_t >( & hldr_to),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+ catch ( forced_unwind const&)
+ {}
+ catch (...)
+ { this->except_ = current_exception(); }
+
+ this->flags_ |= flag_complete;
+ callee = c.impl_->callee_;
+ BOOST_ASSERT( callee);
+ context::jump_fcontext(
+ & caller, callee,
+ reinterpret_cast< intptr_t >( & caller),
+ this->preserve_fpu() );
+ BOOST_ASSERT_MSG( false, "coroutine is complete");
+ }
+
     void unwind_stack_() BOOST_NOEXCEPT
     {
         BOOST_ASSERT( ! this->is_complete() );
@@ -351,36 +392,10 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
- context::fcontext_t caller;
- try
- {
- fn_( c);
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- holder< void > hldr_to( & caller);
- context::jump_fcontext(
- hldr_to.ctx, callee,
- reinterpret_cast< intptr_t >( & hldr_to),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
- }
- catch ( forced_unwind const&)
- {}
- catch (...)
- { this->except_ = current_exception(); }
-
- this->flags_ |= flag_complete;
- callee = c.impl_->callee_;
- BOOST_ASSERT( callee);
- context::jump_fcontext(
- & caller, callee,
- reinterpret_cast< intptr_t >( & caller),
- this->preserve_fpu() );
- BOOST_ASSERT_MSG( false, "coroutine is complete");
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
+ run_( c);
     }
 
     void deallocate_object()

Modified: trunk/boost/coroutine/detail/coroutine_object_void_1.ipp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_object_void_1.ipp (original)
+++ trunk/boost/coroutine/detail/coroutine_object_void_1.ipp 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
@@ -39,11 +39,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -51,12 +50,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder< tuple< coroutine_object *, typename detail::param< arg_type >::type > > hldr_to(
- & this->caller_, tuple< coroutine_object *, typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -208,15 +208,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -260,11 +260,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -272,12 +271,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder< tuple< coroutine_object *, typename detail::param< arg_type >::type > > hldr_to(
- & this->caller_, tuple< coroutine_object *, typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -368,15 +368,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -420,11 +420,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -432,12 +431,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder< tuple< coroutine_object *, typename detail::param< arg_type >::type > > hldr_to(
- & this->caller_, tuple< coroutine_object *, typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -528,15 +528,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }

Modified: trunk/boost/coroutine/detail/coroutine_object_void_arity.ipp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_object_void_arity.ipp (original)
+++ trunk/boost/coroutine/detail/coroutine_object_void_arity.ipp 2012-11-25 13:23:16 EST (Sun, 25 Nov 2012)
@@ -40,11 +40,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -52,16 +51,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -213,15 +209,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -266,11 +262,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -278,16 +273,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -377,15 +369,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }
@@ -430,11 +422,10 @@
 
     void enter_()
     {
- holder< coroutine_object * > hldr_to( & this->caller_, this);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( this),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -442,16 +433,13 @@
 
     void enter_( typename detail::param< arg_type >::type arg)
     {
- holder<
- tuple< coroutine_object *,
- typename detail::param< arg_type >::type >
- > hldr_to(
- & this->caller_, tuple< coroutine_object *,
- typename detail::param< arg_type >::type >( this, arg) );
+ tuple< coroutine_object *,
+ typename detail::param< arg_type >::type
+ > tpl( this, arg);
         holder< void > * hldr_from(
             reinterpret_cast< holder< void > * >( context::jump_fcontext(
- hldr_to.ctx, this->callee_,
- reinterpret_cast< intptr_t >( & hldr_to),
+ & this->caller_, this->callee_,
+ reinterpret_cast< intptr_t >( & tpl),
                 this->preserve_fpu() ) ) );
         this->callee_ = hldr_from->ctx;
         if ( this->except_) rethrow_exception( this->except_);
@@ -541,15 +529,15 @@
         stack_alloc_.deallocate( stack_.sp, stack_.size);
     }
 
- void run( context::fcontext_t * callee)
+ void run()
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         run_( c);
     }
 
- void run( context::fcontext_t * callee, typename detail::param< arg_type >::type arg)
+ void run( typename detail::param< arg_type >::type arg)
     {
- Caller c( callee, false, this->preserve_fpu(), alloc_);
+ Caller c( & this->caller_, false, this->preserve_fpu(), alloc_);
         c.impl_->result_ = arg;
         run_( c);
     }


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