From 43a3311df000804ee8a12c70d194d274c8f2cdf0 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Mon, 27 Jan 2014 19:48:28 +0100 Subject: [PATCH] rename simple_stack_allocator into standard_stack_allocator Conflicts: performance/performance_create_standard.cpp --- build/Jamfile.v2 | 2 +- doc/coro.qbk | 2 +- doc/coro.xml | 54 +++--- doc/html/coro_HTML.manifest | 2 +- doc/html/coroutine/performance.html | 4 +- doc/html/coroutine/stack.html | 4 +- .../stack/protected_stack_allocator.html | 6 +- doc/html/coroutine/stack/stack_context.html | 6 +- .../stack/standard_stack_allocator.html | 178 ++++++++++++++++++ doc/html/index.html | 4 +- doc/stack.qbk | 10 +- include/boost/coroutine/all.hpp | 4 +- include/boost/coroutine/stack_allocator.hpp | 5 +- ...cator.hpp => standard_stack_allocator.hpp} | 8 +- performance/Jamfile.v2 | 4 +- ...le.cpp => performance_create_standard.cpp} | 2 +- performance/preallocated_stack_allocator.hpp | 10 +- ...cator.cpp => standard_stack_allocator.cpp} | 16 +- 18 files changed, 249 insertions(+), 72 deletions(-) create mode 100644 doc/html/coroutine/stack/standard_stack_allocator.html rename include/boost/coroutine/{simple_stack_allocator.hpp => standard_stack_allocator.hpp} (79%) rename performance/{performance_create_simple.cpp => performance_create_standard.cpp} (97%) rename src/{simple_stack_allocator.cpp => standard_stack_allocator.cpp} (76%) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 81a5cef..57818ec 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -51,9 +51,9 @@ explicit segmented_allocator_sources ; lib boost_coroutine : detail/coroutine_context.cpp exceptions.cpp - simple_stack_allocator.cpp protected_allocator_sources segmented_allocator_sources + standard_stack_allocator.cpp : shared:../../context/build//boost_context shared:../../system/build//boost_system shared:../../thread/build//boost_thread diff --git a/doc/coro.qbk b/doc/coro.qbk index 003a04d..90376ad 100644 --- a/doc/coro.qbk +++ b/doc/coro.qbk @@ -79,8 +79,8 @@ [def __segmented_allocator__ ['boost::coroutines::segmented_stack_allocator]] [def __server__ ['server]] [def __session__ ['session]] -[def __simple_allocator__ ['boost::coroutines::simple_stack_allocator]] [def __stack_context__ ['boost::coroutines::stack_context]] +[def __standard_allocator__ ['boost::coroutines::standard_stack_allocator]] [def __start__ ['session::start()]] [def __thread__ ['boost::thread]] [def __tie__ ['boost::tie]] diff --git a/doc/coro.xml b/doc/coro.xml index d6d1995..16a79d8 100644 --- a/doc/coro.xml +++ b/doc/coro.xml @@ -1,6 +1,6 @@ - @@ -2450,7 +2450,7 @@ class boost::coroutines::stack_allocator is a typedef - of boost::coroutines::protected_stack_allocator. + of boost::coroutines::standard_stack_allocator.
<link linkend="coroutine.stack.protected_stack_allocator">Class <emphasis>protected_stack_allocator</emphasis></link> @@ -2659,19 +2659,19 @@
-
- <link linkend="coroutine.stack.simple_stack_allocator">Class <emphasis>simple_stack_allocator</emphasis></link> +
+ <link linkend="coroutine.stack.standard_stack_allocator">Class <emphasis>standard_stack_allocator</emphasis></link> - Boost.Coroutine provides the class boost::coroutines::simple_stack_allocator + Boost.Coroutine provides the class boost::coroutines::standard_stack_allocator which models the stack-allocator concept. In contrast to boost::coroutines::protected_stack_allocator it does not append a guard page at the end of each stack. The memory is simply managed by std::calloc() + role="identifier">malloc() and std::free(). -class simple_stack_allocator +class standard_stack_allocator { static bool is_stack_unbound(); @@ -2686,9 +2686,9 @@ void deallocate( stack_context &); } - - + static bool is_stack_unbound() @@ -2704,9 +2704,9 @@ - - + static std::size_t maximum_stacksize() @@ -2731,9 +2731,9 @@ - - + static std::size_t default_stacksize() @@ -2753,9 +2753,9 @@ - - + static std::size_t minimum_stacksize() @@ -2772,9 +2772,9 @@ - - + void allocate( stack_context & sctx - - + void deallocate( stack_context & sctx - 62 ns / 77 cycles + 78 ns / 77 cycles @@ -3012,7 +3012,7 @@ - 17 ns / 47 cycles + 28 ns / 74 cycles diff --git a/doc/html/coro_HTML.manifest b/doc/html/coro_HTML.manifest index bc9de60..2403d2d 100644 --- a/doc/html/coro_HTML.manifest +++ b/doc/html/coro_HTML.manifest @@ -9,7 +9,7 @@ coroutine/coroutine/unidirect/push_coro.html coroutine/attributes.html coroutine/stack.html coroutine/stack/protected_stack_allocator.html -coroutine/stack/simple_stack_allocator.html +coroutine/stack/standard_stack_allocator.html coroutine/stack/stack_context.html coroutine/stack/segmented_stack.html coroutine/performance.html diff --git a/doc/html/coroutine/performance.html b/doc/html/coroutine/performance.html index d25c277..f80cc2c 100644 --- a/doc/html/coroutine/performance.html +++ b/doc/html/coroutine/performance.html @@ -80,7 +80,7 @@

- 62 ns / 77 cycles + 78 ns / 77 cycles

@@ -107,7 +107,7 @@

- 17 ns / 47 cycles + 28 ns / 74 cycles

diff --git a/doc/html/coroutine/stack.html b/doc/html/coroutine/stack.html index 16a96ff..9348d43 100644 --- a/doc/html/coroutine/stack.html +++ b/doc/html/coroutine/stack.html @@ -28,7 +28,7 @@ @@ -155,7 +155,7 @@

class boost::coroutines::stack_allocator is a typedef - of boost::coroutines::protected_stack_allocator. + of boost::coroutines::standard_stack_allocator.

diff --git a/doc/html/coroutine/stack/protected_stack_allocator.html b/doc/html/coroutine/stack/protected_stack_allocator.html index 1edf89c..c0ae8a8 100644 --- a/doc/html/coroutine/stack/protected_stack_allocator.html +++ b/doc/html/coroutine/stack/protected_stack_allocator.html @@ -7,7 +7,7 @@ - +
@@ -20,7 +20,7 @@

-PrevUpHomeNext +PrevUpHomeNext

@@ -192,7 +192,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/html/coroutine/stack/stack_context.html b/doc/html/coroutine/stack/stack_context.html index 5ffeb73..a8bbe41 100644 --- a/doc/html/coroutine/stack/stack_context.html +++ b/doc/html/coroutine/stack/stack_context.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@
-PrevUpHomeNext +PrevUpHomeNext

@@ -79,7 +79,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/html/coroutine/stack/standard_stack_allocator.html b/doc/html/coroutine/stack/standard_stack_allocator.html new file mode 100644 index 0000000..a57addf --- /dev/null +++ b/doc/html/coroutine/stack/standard_stack_allocator.html @@ -0,0 +1,178 @@ + + + +Class standard_stack_allocator + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Boost.Coroutine provides the class boost::coroutines::standard_stack_allocator + which models the stack-allocator concept. In contrast + to boost::coroutines::protected_stack_allocator it does + not append a guard page at the end of each stack. The memory is simply managed + by std::malloc() + and std::free(). +

+
class standard_stack_allocator
+{
+    static bool is_stack_unbound();
+
+    static std::size_t maximum_stacksize();
+
+    static std::size_t default_stacksize();
+
+    static std::size_t minimum_stacksize();
+
+    void allocate( stack_context &, std::size_t size);
+
+    void deallocate( stack_context &);
+}
+
+
+ + static bool is_stack_unbound() +
+
+

+
+
Returns:
+

+ Returns true if the environment + defines no limit for the size of a stack. +

+
+
+
+ + static std::size_t maximum_stacksize() +
+
+

+
+
Preconditions:
+

+ is_stack_unbound() + returns false. +

+
Returns:
+

+ Returns the maximum size in bytes of stack defined by the environment. +

+
+
+
+ + static std::size_t default_stacksize() +
+
+

+
+
Returns:
+

+ Returns a default stack size, which may be platform specific. If the + stack is unbound then the present implementation returns the maximum + of 64 kB + and minimum_stacksize(). +

+
+
+
+ + static std::size_t minimum_stacksize() +
+
+

+
+
Returns:
+

+ Returns the minimum size in bytes of stack defined by the environment + (Win32 4kB/Win64 8kB, defined by rlimit on POSIX). +

+
+
+
+ + void allocate( stack_context + & sctx, std::size_t size) +
+
+

+
+
Preconditions:
+

+ minimum_stacksize() + > size + and ! is_stack_unbound() && + ( maximum_stacksize() < size). +

+
Effects:
+

+ Allocates memory of at least size + Bytes and stores a pointer to the stack and its actual size in sctx. +

+
Returns:
+

+ Returns pointer to the start address of the new stack. Depending on + the architecture the stack grows downwards/upwards the returned address + is the highest/lowest address of the stack. +

+
+
+
+ + void deallocate( stack_context + & sctx) +
+
+

+
+
Preconditions:
+

+ sctx.sp is valid, minimum_stacksize() > sctx.size and ! + is_stack_unbound() + && ( + maximum_stacksize() + < size). +

+
Effects:
+

+ Deallocates the stack space. +

+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/index.html b/doc/html/index.html index d1aecf3..54c76ab 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -51,7 +51,7 @@
Stack allocation
Class protected_stack_allocator
-
Class simple_stack_allocator
+
Class standard_stack_allocator
Class stack_context
Segmented stacks
@@ -62,7 +62,7 @@

- +

Last revised: January 17, 2014 at 16:35:14 GMT

Last revised: January 27, 2014 at 18:43:02 GMT


diff --git a/doc/stack.qbk b/doc/stack.qbk index 91a5e45..cb2528d 100644 --- a/doc/stack.qbk +++ b/doc/stack.qbk @@ -45,7 +45,7 @@ __coro__.] top of the stack (growing downwards) or the bottom of the stack (growing upwards).] -class __coro_allocator__ is a typedef of __protected_allocator__. +class __coro_allocator__ is a typedef of __standard_allocator__. [section:protected_stack_allocator Class ['protected_stack_allocator]] @@ -123,15 +123,15 @@ the highest/lowest address of the stack.]] [endsect] -[section:simple_stack_allocator Class ['simple_stack_allocator]] +[section:standard_stack_allocator Class ['standard_stack_allocator]] -__boost_coroutine__ provides the class __simple_allocator__ which models +__boost_coroutine__ provides the class __standard_allocator__ which models the __stack_allocator_concept__. In contrast to __protected_allocator__ it does not append a guard page at the -end of each stack. The memory is simply managed by `std::calloc()` and +end of each stack. The memory is simply managed by `std::malloc()` and `std::free()`. - class simple_stack_allocator + class standard_stack_allocator { static bool is_stack_unbound(); diff --git a/include/boost/coroutine/all.hpp b/include/boost/coroutine/all.hpp index 0c8b760..d1ccc61 100644 --- a/include/boost/coroutine/all.hpp +++ b/include/boost/coroutine/all.hpp @@ -11,10 +11,10 @@ #include #include #include -#include -#include #include #include +#include #include +#include #endif // BOOST_COROUTINES_ALL_H diff --git a/include/boost/coroutine/stack_allocator.hpp b/include/boost/coroutine/stack_allocator.hpp index 9238628..662533e 100644 --- a/include/boost/coroutine/stack_allocator.hpp +++ b/include/boost/coroutine/stack_allocator.hpp @@ -12,9 +12,8 @@ #include #include -#include #include -#include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -26,7 +25,7 @@ namespace coroutines { #if defined(BOOST_USE_SEGMENTED_STACKS) typedef segmented_stack_allocator stack_allocator; #else -typedef protected_stack_allocator stack_allocator; +typedef standard_stack_allocator stack_allocator; #endif }} diff --git a/include/boost/coroutine/simple_stack_allocator.hpp b/include/boost/coroutine/standard_stack_allocator.hpp similarity index 79% rename from include/boost/coroutine/simple_stack_allocator.hpp rename to include/boost/coroutine/standard_stack_allocator.hpp index c0a4ab7..b05f32a 100644 --- a/include/boost/coroutine/simple_stack_allocator.hpp +++ b/include/boost/coroutine/standard_stack_allocator.hpp @@ -4,8 +4,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_COROUTINES_SIMPLE_STACK_ALLOCATOR_H -#define BOOST_COROUTINES_SIMPLE_STACK_ALLOCATOR_H +#ifndef BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H +#define BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H #include @@ -22,7 +22,7 @@ namespace coroutines { struct stack_context; -class BOOST_COROUTINES_DECL simple_stack_allocator +class BOOST_COROUTINES_DECL standard_stack_allocator { public: static bool is_stack_unbound(); @@ -44,4 +44,4 @@ public: # include BOOST_ABI_SUFFIX #endif -#endif // BOOST_COROUTINES_SIMPLE_STACK_ALLOCATOR_H +#endif // BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H diff --git a/performance/Jamfile.v2 b/performance/Jamfile.v2 index ca43d2c..bc1c9e1 100644 --- a/performance/Jamfile.v2 +++ b/performance/Jamfile.v2 @@ -60,9 +60,9 @@ exe performance_create_protected performance_create_protected.cpp ; -exe performance_create_simple +exe performance_create_standard : sources - performance_create_simple.cpp + performance_create_standard.cpp ; exe performance_create_prealloc diff --git a/performance/performance_create_simple.cpp b/performance/performance_create_standard.cpp similarity index 97% rename from performance/performance_create_simple.cpp rename to performance/performance_create_standard.cpp index ca791a0..61952da 100644 --- a/performance/performance_create_simple.cpp +++ b/performance/performance_create_standard.cpp @@ -17,7 +17,7 @@ #include "clock.hpp" #include "cycle.hpp" -typedef boost::coroutines::simple_stack_allocator stack_allocator; +typedef boost::coroutines::standard_stack_allocator stack_allocator; typedef boost::coroutines::coroutine< void, stack_allocator > coro_type; boost::coroutines::flag_fpu_t preserve_fpu = boost::coroutines::fpu_not_preserved; diff --git a/performance/preallocated_stack_allocator.hpp b/performance/preallocated_stack_allocator.hpp index d4c8796..a2db143 100644 --- a/performance/preallocated_stack_allocator.hpp +++ b/performance/preallocated_stack_allocator.hpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ public: preallocated_stack_allocator() : stack_ctx_() { - boost::coroutines::protected_stack_allocator allocator; + boost::coroutines::standard_stack_allocator allocator; allocator.allocate( stack_ctx_, default_stacksize() ); } @@ -47,13 +47,13 @@ public: } static std::size_t maximum_stacksize() - { return boost::coroutines::protected_stack_allocator::maximum_stacksize(); } + { return boost::coroutines::standard_stack_allocator::maximum_stacksize(); } static std::size_t default_stacksize() - { return boost::coroutines::protected_stack_allocator::default_stacksize(); } + { return boost::coroutines::standard_stack_allocator::default_stacksize(); } static std::size_t minimum_stacksize() - { return boost::coroutines::protected_stack_allocator::minimum_stacksize(); } + { return boost::coroutines::standard_stack_allocator::minimum_stacksize(); } }; #ifdef BOOST_HAS_ABI_HEADERS diff --git a/src/simple_stack_allocator.cpp b/src/standard_stack_allocator.cpp similarity index 76% rename from src/simple_stack_allocator.cpp rename to src/standard_stack_allocator.cpp index e372047..998134b 100644 --- a/src/simple_stack_allocator.cpp +++ b/src/standard_stack_allocator.cpp @@ -4,7 +4,7 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include @@ -22,28 +22,28 @@ namespace boost { namespace coroutines { bool -simple_stack_allocator::is_stack_unbound() +standard_stack_allocator::is_stack_unbound() { return protected_stack_allocator::is_stack_unbound(); } std::size_t -simple_stack_allocator::maximum_stacksize() +standard_stack_allocator::maximum_stacksize() { return protected_stack_allocator::maximum_stacksize(); } std::size_t -simple_stack_allocator::default_stacksize() +standard_stack_allocator::default_stacksize() { return protected_stack_allocator::default_stacksize(); } std::size_t -simple_stack_allocator::minimum_stacksize() +standard_stack_allocator::minimum_stacksize() { return protected_stack_allocator::minimum_stacksize(); } void -simple_stack_allocator::allocate( stack_context & ctx, std::size_t size) +standard_stack_allocator::allocate( stack_context & ctx, std::size_t size) { BOOST_ASSERT( minimum_stacksize() <= size); BOOST_ASSERT( is_stack_unbound() || ( maximum_stacksize() >= size) ); - void * limit = std::calloc( size, sizeof( char) ); + void * limit = std::malloc( size); if ( ! limit) throw std::bad_alloc(); ctx.size = size; @@ -51,7 +51,7 @@ simple_stack_allocator::allocate( stack_context & ctx, std::size_t size) } void -simple_stack_allocator::deallocate( stack_context & ctx) +standard_stack_allocator::deallocate( stack_context & ctx) { BOOST_ASSERT( ctx.sp); BOOST_ASSERT( minimum_stacksize() <= ctx.size);