Implement sized deallocation for std::allocator and friends.
authorEric Fiselier <eric@efcs.ca>
Thu, 25 Oct 2018 17:21:30 +0000 (17:21 +0000)
committerEric Fiselier <eric@efcs.ca>
Thu, 25 Oct 2018 17:21:30 +0000 (17:21 +0000)
commitf25b75b91b2d5906609bb609d39cf0ee3dcc746b
tree2e9ef3bba902796aa4763c731b857b545f2c4343
parent1e6d0aad7e90744dcaa5d9be8644dafd5181834d
Implement sized deallocation for std::allocator and friends.

Summary:
C++14 sized deallocation is disabled by default due to ABI concerns. However, when a user manually enables it then libc++ should take advantage of it since sized deallocation can provide a significant performance win depending on the underlying malloc implementation. (Note that libc++'s definitions of sized delete don't do anything special yet, but users are free to provide their own).

This patch updates __libcpp_deallocate to selectively call sized operator delete when it's available. `__libcpp_deallocate_unsized` should be used when the size of the allocation is unknown.

On Apple this patch makes no attempt to determine if the sized operator delete is unavailable, only that the language feature is enabled. This could cause a compile error when using `std::allocator`, but the same compile error would occur whenever the user calls `new`, so I don't think it's a problem.

Reviewers: ldionne, mclow.lists

Reviewed By: ldionne

Subscribers: rsmith, ckennelly, libcxx-commits, christof

Differential Revision: https://reviews.llvm.org/D53120

llvm-svn: 345281
libcxx/include/__sso_allocator
libcxx/include/experimental/dynarray
libcxx/include/memory
libcxx/include/new
libcxx/include/valarray
libcxx/src/experimental/memory_resource.cpp
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp [new file with mode: 0644]