[PATCH] D53120: Implement sized deallocation for std::allocator and friends.

Eric Fiselier via Phabricator reviews at reviews.llvm.org
Wed Oct 10 17:33:28 PDT 2018


EricWF created this revision.
EricWF added reviewers: ldionne, mclow.lists.
Herald added a subscriber: christof.

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 and when the size is not 0 (The size 0 is used as a sentinel value to mean "we don't know the size").

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.


Repository:
  rCXX libc++

https://reviews.llvm.org/D53120

Files:
  include/__sso_allocator
  include/memory
  include/new
  include/valarray
  src/experimental/memory_resource.cpp
  test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53120.169135.patch
Type: text/x-patch
Size: 11951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20181011/1e86c87d/attachment-0001.bin>


More information about the libcxx-commits mailing list