https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70940

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Mon Jul 23 19:40:28 2018
New Revision: 262935

URL: https://gcc.gnu.org/viewcvs?rev=262935&root=gcc&view=rev
Log:
PR libstdc++/70940 optimize pmr::resource_adaptor for allocators using malloc

pmr::resource_adaptor can avoid allocating an oversized buffer and doing
manual alignment within that buffer when the wrapped allocator is known
to always meet the requested alignment. Specifically, if the allocator
is known to use malloc or new directly, then we can call the allocator
directly for any fundamental alignment.

        PR libstdc++/70940
        * include/experimental/memory_resource
        (__resource_adaptor_common::_AlignMgr::_M_unadjust): Add assertion.
        (__resource_adaptor_common::__guaranteed_alignment): New helper to
        give maximum alignment an allocator guarantees. Specialize for known
        allocators using new and malloc.
        (__resource_adaptor_imp::do_allocate): Use __guaranteed_alignment.
        (__resource_adaptor_imp::do_deallocate): Likewise.
        * testsuite/experimental/memory_resource/new_delete_resource.cc:
        Check that new and delete are called with expected sizes.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/experimental/memory_resource
   
trunk/libstdc++-v3/testsuite/experimental/memory_resource/new_delete_resource.cc

Reply via email to