From e8252dd7b5590427839eae4e4b2d76d2c4d9cff5 Mon Sep 17 00:00:00 2001 From: James Sedgwick Date: Mon, 23 Oct 2017 07:27:04 -0700 Subject: [PATCH] move Arena, ThreadCachedArena, and Malloc to memory/ Summary: all memory/-destined components besides hphp includes Reviewed By: yfeldblum, mzlee Differential Revision: D6121822 fbshipit-source-id: 6c6214d84dcdefe4789ed5200399ae27203d6340 --- CMakeLists.txt | 6 ++++-- folly/Demangle.cpp | 2 +- folly/FBString.h | 2 +- folly/FBVector.h | 2 +- folly/Makefile.am | 14 +++++++------- folly/detail/MemoryIdler.cpp | 2 +- folly/detail/ThreadLocalDetail.h | 2 +- folly/experimental/JemallocNodumpAllocator.cpp | 2 +- .../test/JemallocNodumpAllocatorTest.cpp | 2 +- folly/io/IOBuf.cpp | 4 ++-- folly/io/TypedIOBuf.h | 2 +- folly/io/test/IOBufTest.cpp | 2 +- folly/{ => memory}/Arena-inl.h | 0 folly/{ => memory}/Arena.h | 4 ++-- folly/memory/MallctlHelper.h | 2 +- folly/{ => memory}/Malloc.h | 4 ++-- folly/{ => memory}/ThreadCachedArena.cpp | 2 +- folly/{ => memory}/ThreadCachedArena.h | 2 +- folly/{ => memory}/detail/MallocImpl.cpp | 2 +- folly/{ => memory}/detail/MallocImpl.h | 0 folly/{ => memory}/test/ArenaTest.cpp | 2 +- folly/memory/test/MallctlHelperTest.cpp | 2 +- folly/{ => memory}/test/ThreadCachedArenaTest.cpp | 2 +- folly/small_vector.h | 2 +- folly/test/ArenaSmartPtrTest.cpp | 2 +- folly/test/ConcurrentSkipListTest.cpp | 2 +- folly/test/MemoryTest.cpp | 2 +- 27 files changed, 37 insertions(+), 35 deletions(-) rename folly/{ => memory}/Arena-inl.h (100%) rename folly/{ => memory}/Arena.h (99%) rename folly/{ => memory}/Malloc.h (98%) rename folly/{ => memory}/ThreadCachedArena.cpp (97%) rename folly/{ => memory}/ThreadCachedArena.h (98%) rename folly/{ => memory}/detail/MallocImpl.cpp (97%) rename folly/{ => memory}/detail/MallocImpl.h (100%) rename folly/{ => memory}/test/ArenaTest.cpp (99%) rename folly/{ => memory}/test/ThreadCachedArenaTest.cpp (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3b14ea6..530d6a2a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -463,6 +463,10 @@ if (BUILD_TESTS) DIRECTORY io/async/ssl/test/ TEST ssl_errors_test SOURCES SSLErrorsTest.cpp + DIRECTORY memory/test/ + TEST thread_cached_arena_test SOURCES ThreadCachedArenaTest.cpp + TEST arena_test SOURCES ArenaTest.cpp + DIRECTORY portability/test/ TEST constexpr_test SOURCES ConstexprTest.cpp TEST libgen-test SOURCES LibgenTest.cpp @@ -489,7 +493,6 @@ if (BUILD_TESTS) DIRECTORY test/ TEST ahm_int_stress_test SOURCES AHMIntStressTest.cpp - TEST arena_test SOURCES ArenaTest.cpp TEST arena_smartptr_test SOURCES ArenaSmartPtrTest.cpp TEST array_test SOURCES ArrayTest.cpp TEST ascii_check_test SOURCES AsciiCaseInsensitiveTest.cpp @@ -594,7 +597,6 @@ if (BUILD_TESTS) TEST sparse_byte_set_test SOURCES SparseByteSetTest.cpp TEST string_test SOURCES StringTest.cpp TEST synchronized_test SOURCES SynchronizedTest.cpp - TEST thread_cached_arena_test SOURCES ThreadCachedArenaTest.cpp TEST thread_cached_int_test SOURCES ThreadCachedIntTest.cpp TEST thread_local_test SOURCES ThreadLocalTest.cpp TEST timeout_queue_test SOURCES TimeoutQueueTest.cpp diff --git a/folly/Demangle.cpp b/folly/Demangle.cpp index 12564693..d1f53cfc 100644 --- a/folly/Demangle.cpp +++ b/folly/Demangle.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #if FOLLY_HAVE_CPLUS_DEMANGLE_V3_CALLBACK diff --git a/folly/FBString.h b/folly/FBString.h index af49ebe0..9c9f670b 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -55,8 +55,8 @@ #include #include -#include #include +#include #include // When used in folly, assertions are not disabled. diff --git a/folly/FBVector.h b/folly/FBVector.h index c52c3501..dec58fc0 100644 --- a/folly/FBVector.h +++ b/folly/FBVector.h @@ -37,8 +37,8 @@ #include #include -#include #include +#include #include //============================================================================= diff --git a/folly/Makefile.am b/folly/Makefile.am index eac08817..b6ac6821 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -27,8 +27,6 @@ lib_LTLIBRARIES = \ follyincludedir = $(includedir)/folly nobase_follyinclude_HEADERS = \ - Arena.h \ - Arena-inl.h \ Array.h \ Assume.h \ AtomicBitSet.h \ @@ -72,7 +70,6 @@ nobase_follyinclude_HEADERS = \ detail/GroupVarintDetail.h \ detail/IPAddress.h \ detail/IPAddressSource.h \ - detail/MallocImpl.h \ detail/MemoryIdler.h \ detail/MPMCPipelineDetail.h \ detail/RangeCommon.h \ @@ -322,12 +319,16 @@ nobase_follyinclude_HEADERS = \ LockTraitsBoost.h \ Logging.h \ MacAddress.h \ - Malloc.h \ MapUtil.h \ Math.h \ Memory.h \ + memory/Arena.h \ + memory/Arena-inl.h \ memory/MallctlHelper.h \ + memory/Malloc.h \ + memory/ThreadCachedArena.h \ memory/UninitializedMemoryHacks.h \ + memory/detail/MallocImpl.h \ MicroSpinLock.h \ MicroLock.h \ MoveWrapper.h \ @@ -434,7 +435,6 @@ nobase_follyinclude_HEADERS = \ test/SynchronizedTestLib.h \ test/SynchronizedTestLib-inl.h \ test/TestUtils.h \ - ThreadCachedArena.h \ ThreadCachedInt.h \ ThreadLocal.h \ TimeoutQueue.h \ @@ -562,6 +562,7 @@ libfolly_la_SOURCES = \ detail/MemoryIdler.cpp \ detail/SocketFastOpen.cpp \ MacAddress.cpp \ + memory/ThreadCachedArena.cpp \ portability/Dirent.cpp \ portability/Fcntl.cpp \ portability/Libgen.cpp \ @@ -604,7 +605,6 @@ libfolly_la_SOURCES = \ system/ThreadName.cpp \ system/VersionCheck.cpp \ Subprocess.cpp \ - ThreadCachedArena.cpp \ TimeoutQueue.cpp \ Try.cpp \ Uri.cpp \ @@ -633,7 +633,7 @@ libfolly_la_SOURCES += \ endif if !HAVE_WEAK_SYMBOLS -libfollybase_la_SOURCES += detail/MallocImpl.cpp +libfollybase_la_SOURCES += memory/detail/MallocImpl.cpp endif if HAVE_BOOST_CONTEXT diff --git a/folly/detail/MemoryIdler.cpp b/folly/detail/MemoryIdler.cpp index 0171939c..cef21a13 100644 --- a/folly/detail/MemoryIdler.cpp +++ b/folly/detail/MemoryIdler.cpp @@ -17,11 +17,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include diff --git a/folly/detail/ThreadLocalDetail.h b/folly/detail/ThreadLocalDetail.h index 363196b0..b0a2ae9f 100644 --- a/folly/detail/ThreadLocalDetail.h +++ b/folly/detail/ThreadLocalDetail.h @@ -29,11 +29,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include diff --git a/folly/experimental/JemallocNodumpAllocator.cpp b/folly/experimental/JemallocNodumpAllocator.cpp index 91625a79..5824c11a 100644 --- a/folly/experimental/JemallocNodumpAllocator.cpp +++ b/folly/experimental/JemallocNodumpAllocator.cpp @@ -17,8 +17,8 @@ #include #include -#include #include +#include #include namespace folly { diff --git a/folly/experimental/test/JemallocNodumpAllocatorTest.cpp b/folly/experimental/test/JemallocNodumpAllocatorTest.cpp index 5c665031..cf51106c 100644 --- a/folly/experimental/test/JemallocNodumpAllocatorTest.cpp +++ b/folly/experimental/test/JemallocNodumpAllocatorTest.cpp @@ -16,8 +16,8 @@ #include -#include #include +#include #include TEST(JemallocNodumpAllocatorTest, Basic) { diff --git a/folly/io/IOBuf.cpp b/folly/io/IOBuf.cpp index 40f74e7c..7206fc46 100644 --- a/folly/io/IOBuf.cpp +++ b/folly/io/IOBuf.cpp @@ -27,11 +27,11 @@ #include #include -#include #include #include #include #include +#include using std::unique_ptr; @@ -791,7 +791,7 @@ void IOBuf::reserveSlow(uint64_t minHeadroom, uint64_t minTailroom) { // - If using jemalloc, we can try to expand in place, avoiding a memcpy() // - If not using jemalloc and we don't have too much to copy, // we'll use realloc() (note that realloc might have to copy - // headroom + data + tailroom, see smartRealloc in folly/Malloc.h) + // headroom + data + tailroom, see smartRealloc in folly/memory/Malloc.h) // - Otherwise, bite the bullet and reallocate. if (headroom() + tailroom() >= minHeadroom + minTailroom) { uint8_t* newData = writableBuffer() + minHeadroom; diff --git a/folly/io/TypedIOBuf.h b/folly/io/TypedIOBuf.h index 86df07c4..382151e7 100644 --- a/folly/io/TypedIOBuf.h +++ b/folly/io/TypedIOBuf.h @@ -20,8 +20,8 @@ #include #include -#include #include +#include namespace folly { diff --git a/folly/io/test/IOBufTest.cpp b/folly/io/test/IOBufTest.cpp index 9fd353f4..0235563d 100644 --- a/folly/io/test/IOBufTest.cpp +++ b/folly/io/test/IOBufTest.cpp @@ -21,8 +21,8 @@ #include -#include #include +#include #include using folly::fbstring; diff --git a/folly/Arena-inl.h b/folly/memory/Arena-inl.h similarity index 100% rename from folly/Arena-inl.h rename to folly/memory/Arena-inl.h diff --git a/folly/Arena.h b/folly/memory/Arena.h similarity index 99% rename from folly/Arena.h rename to folly/memory/Arena.h index 25279a7b..ffe9f38b 100644 --- a/folly/Arena.h +++ b/folly/memory/Arena.h @@ -26,8 +26,8 @@ #include #include -#include #include +#include namespace folly { @@ -243,4 +243,4 @@ struct IsArenaAllocator : std::true_type { }; } // namespace folly -#include +#include diff --git a/folly/memory/MallctlHelper.h b/folly/memory/MallctlHelper.h index f883a5f6..7a6b200d 100644 --- a/folly/memory/MallctlHelper.h +++ b/folly/memory/MallctlHelper.h @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include diff --git a/folly/Malloc.h b/folly/memory/Malloc.h similarity index 98% rename from folly/Malloc.h rename to folly/memory/Malloc.h index 71f37ca2..2726c9d8 100644 --- a/folly/Malloc.h +++ b/folly/memory/Malloc.h @@ -45,7 +45,7 @@ // includes and uses fbstring. #if defined(_GLIBCXX_USE_FB) && !defined(_LIBSTDCXX_FBSTRING) -#include +#include #include #include @@ -98,7 +98,7 @@ __attribute__((__weak__)); #else // !defined(_LIBSTDCXX_FBSTRING) -#include /* nolint */ +#include /* nolint */ #include /* nolint */ #endif diff --git a/folly/ThreadCachedArena.cpp b/folly/memory/ThreadCachedArena.cpp similarity index 97% rename from folly/ThreadCachedArena.cpp rename to folly/memory/ThreadCachedArena.cpp index 3869d6c2..f8764642 100644 --- a/folly/ThreadCachedArena.cpp +++ b/folly/memory/ThreadCachedArena.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include diff --git a/folly/ThreadCachedArena.h b/folly/memory/ThreadCachedArena.h similarity index 98% rename from folly/ThreadCachedArena.h rename to folly/memory/ThreadCachedArena.h index d4a5b23b..f4562447 100644 --- a/folly/ThreadCachedArena.h +++ b/folly/memory/ThreadCachedArena.h @@ -18,10 +18,10 @@ #include -#include #include #include #include +#include namespace folly { diff --git a/folly/detail/MallocImpl.cpp b/folly/memory/detail/MallocImpl.cpp similarity index 97% rename from folly/detail/MallocImpl.cpp rename to folly/memory/detail/MallocImpl.cpp index 3daa120a..3c4f6dd9 100644 --- a/folly/detail/MallocImpl.cpp +++ b/folly/memory/detail/MallocImpl.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include extern "C" { diff --git a/folly/detail/MallocImpl.h b/folly/memory/detail/MallocImpl.h similarity index 100% rename from folly/detail/MallocImpl.h rename to folly/memory/detail/MallocImpl.h diff --git a/folly/test/ArenaTest.cpp b/folly/memory/test/ArenaTest.cpp similarity index 99% rename from folly/test/ArenaTest.cpp rename to folly/memory/test/ArenaTest.cpp index a1d324a4..f6a1ed47 100644 --- a/folly/test/ArenaTest.cpp +++ b/folly/memory/test/ArenaTest.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/folly/memory/test/MallctlHelperTest.cpp b/folly/memory/test/MallctlHelperTest.cpp index e2d3c2a7..dc447a7a 100644 --- a/folly/memory/test/MallctlHelperTest.cpp +++ b/folly/memory/test/MallctlHelperTest.cpp @@ -15,8 +15,8 @@ */ #include -#include #include +#include #include #ifdef FOLLY_HAVE_LIBJEMALLOC diff --git a/folly/test/ThreadCachedArenaTest.cpp b/folly/memory/test/ThreadCachedArenaTest.cpp similarity index 99% rename from folly/test/ThreadCachedArenaTest.cpp rename to folly/memory/test/ThreadCachedArenaTest.cpp index 1d24c77a..4401ae0a 100644 --- a/folly/test/ThreadCachedArenaTest.cpp +++ b/folly/memory/test/ThreadCachedArenaTest.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/folly/small_vector.h b/folly/small_vector.h index 71440437..59dd3e54 100644 --- a/folly/small_vector.h +++ b/folly/small_vector.h @@ -48,10 +48,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include diff --git a/folly/test/ArenaSmartPtrTest.cpp b/folly/test/ArenaSmartPtrTest.cpp index 911c3c37..ee94db0e 100644 --- a/folly/test/ArenaSmartPtrTest.cpp +++ b/folly/test/ArenaSmartPtrTest.cpp @@ -18,8 +18,8 @@ * @author: Marcelo Juchem */ -#include #include +#include #include using namespace folly; diff --git a/folly/test/ConcurrentSkipListTest.cpp b/folly/test/ConcurrentSkipListTest.cpp index 671a8341..dc3deda7 100644 --- a/folly/test/ConcurrentSkipListTest.cpp +++ b/folly/test/ConcurrentSkipListTest.cpp @@ -27,10 +27,10 @@ #include -#include #include #include #include +#include #include #include diff --git a/folly/test/MemoryTest.cpp b/folly/test/MemoryTest.cpp index 5ad28d5a..f3e6f8d3 100644 --- a/folly/test/MemoryTest.cpp +++ b/folly/test/MemoryTest.cpp @@ -21,8 +21,8 @@ #include -#include #include +#include #include using namespace folly; -- 2.34.1