summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-10-25 17:21:30 +0000
committerEric Fiselier <eric@efcs.ca>2018-10-25 17:21:30 +0000
commite09f85bbe50870d97450d262302c44466b28ec37 (patch)
treed7b4dddbc1ef8a337b5647ae5e39311b985e25b6 /src
parent07f95bd10d709b6f287b218aae912dfed1b3ff0c (diff)
downloadlibcxx-e09f85bbe50870d97450d262302c44466b28ec37.tar.gz
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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src')
-rw-r--r--src/experimental/memory_resource.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/experimental/memory_resource.cpp b/src/experimental/memory_resource.cpp
index a3b64cc8b..7f0052f2b 100644
--- a/src/experimental/memory_resource.cpp
+++ b/src/experimental/memory_resource.cpp
@@ -33,8 +33,9 @@ protected:
virtual void* do_allocate(size_t __size, size_t __align)
{ return _VSTD::__libcpp_allocate(__size, __align); /* FIXME */}
- virtual void do_deallocate(void * __p, size_t, size_t __align)
- { _VSTD::__libcpp_deallocate(__p, __align); /* FIXME */ }
+ virtual void do_deallocate(void* __p, size_t __n, size_t __align) {
+ _VSTD::__libcpp_deallocate(__p, __n, __align); /* FIXME */
+ }
virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
{ return &__other == this; }