Topic: First working prototype for static allocation: we can
Author: "dgutson ." <danielgutson@gmail.com>
Date: Tue, 18 Aug 2015 13:51:05 -0300
Raw View
Hi.
We are working in a custom gcc (plus a plugin) which is able to
"statically allocate" memory and modify its content during constexpr
constructors.
We basically provide a "static_alloc<T>(size_t n)" function for this purpos=
e.
With this infrastructure, we were able to write two examples:
- an uppercase_static_string class that receives a C-string in its
constexpr ctor, allocates a (const) char array, copies the content
transforming all the
characters to uppercase. The whole object is stored in the .rodata
section of the binary. The access methods are a subset of the const of
the std::string.
- a static_sorted_array class that receives an initializer_list<int>,
allocates the content and sorts it. The resulting array also is stored
in the .rodata section.
We are working towards applying the same infrastructure for
non-constant objects (of static storage duration) as a superior
solution to
allocators with pre-allocated memory pools, since the exact required
memory is calculated during compile time and out-of-memory detection
can cause a compilation failure.
This work is mainly inspired by embedded and safety systems needs, and
has relation with Andrew's "predynamic storage".
As for our need, we have to provide a "static" version of some STL
containers, though a deeper analysis has to be done in order to
see if this infrastructure (or the "static_alloc" direction) could be
applied to the current STL containers by adding new constexpr
constructors
(I don't think it's possible, but I didn't get into it yet).
If there are people attending the forthcoming meetings interested in
championship this and being a co-author, please let me know (PM) and
we
will provide details and the prototype (which is actively under
development in order to overcome two implementation issues). We are
also
looking for help to implement the static containers (we will implement
only the unordered_map and multiset counterparts).
What is going to happen soon is: we will send some patches to gcc and
I will write a technical report about this with details.
Thanks,
Daniel.
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.