react-native-windows 0.84.0-preview.9 → 0.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/unicode.cpp +36 -0
- package/Common/unicode.h +8 -0
- package/Directory.Build.props +2 -17
- package/Folly/ThreadNameStub.cpp +4 -6
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +91 -23
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +11 -0
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +6 -4
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +28 -6
- package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +80 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.h +17 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +1 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +4 -9
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -3
- package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +33 -25
- package/Microsoft.ReactNative/Utils/LocalBundleReader.h +5 -3
- package/Microsoft.ReactNative/Utils/UwpScriptStore.cpp +2 -2
- package/Microsoft.ReactNative/Utils/UwpScriptStore.h +3 -2
- package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +3 -3
- package/Microsoft.ReactNative.Managed.CodeGen/Microsoft.ReactNative.Managed.CodeGen.csproj +10 -10
- package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Debug.pubxml +1 -1
- package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Release.pubxml +1 -1
- package/PropertySheets/CIBuildOptimizations.props +2 -2
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/PropertySheets/NuGet.LockFile.props +10 -1
- package/PropertySheets/React.Cpp.props +7 -6
- package/PropertySheets/WinUI.props +2 -2
- package/ReactCommon/ReactCommon.vcxproj +0 -5
- package/Scripts/JustMyXaml.ps1 +8 -8
- package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +61 -6
- package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +4 -37
- package/Scripts/UnitTest.ps1 +3 -1
- package/Scripts/UpdateNightlyDependencies.ps1 +47 -0
- package/Scripts/creaternwapp.cmd +5 -8
- package/Scripts/creaternwlib.cmd +10 -23
- package/Scripts/rnw-dependencies.ps1 +15 -16
- package/Shared/DevSupportManager.cpp +55 -48
- package/Shared/DevSupportManager.h +0 -1
- package/Shared/Modules/IWebSocketModuleContentHandler.h +15 -0
- package/Shared/Modules/WebSocketModule.cpp +8 -3
- package/Shared/Networking/DefaultBlobResource.cpp +37 -0
- package/Shared/Networking/DefaultBlobResource.h +12 -0
- package/Shared/Networking/WinRTWebSocketResource.h +5 -1
- package/Shared/Shared.vcxitems +2 -0
- package/{Folly → external}/.clang-format +0 -1
- package/external/External.vcxitems +10 -0
- package/external/fast-float/.syncignore +10 -0
- package/external/fast-float/LICENSE-APACHE +190 -0
- package/external/fast-float/LICENSE-BOOST +23 -0
- package/external/fast-float/LICENSE-MIT +27 -0
- package/external/fast-float/README.md +545 -0
- package/external/fast-float/cgmanifest.json +15 -0
- package/external/fast-float/fast-float.vcxitems +14 -0
- package/external/fast-float/include/fast_float/ascii_number.h +588 -0
- package/external/fast-float/include/fast_float/bigint.h +638 -0
- package/external/fast-float/include/fast_float/constexpr_feature_detect.h +46 -0
- package/external/fast-float/include/fast_float/decimal_to_binary.h +212 -0
- package/external/fast-float/include/fast_float/digit_comparison.h +457 -0
- package/external/fast-float/include/fast_float/fast_float.h +59 -0
- package/external/fast-float/include/fast_float/fast_table.h +708 -0
- package/external/fast-float/include/fast_float/float_common.h +1240 -0
- package/external/fast-float/include/fast_float/parse_number.h +399 -0
- package/external/fast-float/sync-config.json +8 -0
- package/external/fmt/.syncignore +10 -0
- package/external/fmt/CONTRIBUTING.md +20 -0
- package/external/fmt/LICENSE +27 -0
- package/external/fmt/README.md +484 -0
- package/external/fmt/doc/ChangeLog-old.md +3290 -0
- package/external/fmt/doc/api.md +650 -0
- package/external/fmt/doc/fmt.css +61 -0
- package/external/fmt/doc/fmt.js +4 -0
- package/external/fmt/doc/get-started.md +222 -0
- package/external/fmt/doc/index.md +151 -0
- package/external/fmt/doc/perf.svg +1 -0
- package/external/fmt/doc/python-license.txt +290 -0
- package/external/fmt/doc/syntax.md +887 -0
- package/external/fmt/fmt.vcxitems +28 -0
- package/external/fmt/include/fmt/args.h +228 -0
- package/external/fmt/include/fmt/base.h +3077 -0
- package/external/fmt/include/fmt/chrono.h +2432 -0
- package/external/fmt/include/fmt/color.h +612 -0
- package/external/fmt/include/fmt/compile.h +529 -0
- package/external/fmt/include/fmt/core.h +5 -0
- package/external/fmt/include/fmt/format-inl.h +1928 -0
- package/external/fmt/include/fmt/format.h +4427 -0
- package/external/fmt/include/fmt/os.h +439 -0
- package/external/fmt/include/fmt/ostream.h +211 -0
- package/external/fmt/include/fmt/printf.h +656 -0
- package/external/fmt/include/fmt/ranges.h +882 -0
- package/external/fmt/include/fmt/std.h +699 -0
- package/external/fmt/include/fmt/xchar.h +322 -0
- package/external/fmt/src/fmt.cc +135 -0
- package/external/fmt/src/format.cc +43 -0
- package/external/fmt/src/os.cc +403 -0
- package/external/fmt/sync-config.json +8 -0
- package/external/folly/.syncignore +60 -0
- package/external/folly/LICENSE +200 -0
- package/external/folly/README.md +263 -0
- package/{fmt → external/folly/folly}/.clang-format +0 -1
- package/external/folly/folly/AtomicHashArray-inl.h +546 -0
- package/external/folly/folly/AtomicHashArray.h +431 -0
- package/external/folly/folly/AtomicHashMap-inl.h +653 -0
- package/external/folly/folly/AtomicHashMap.h +484 -0
- package/external/folly/folly/AtomicIntrusiveLinkedList.h +206 -0
- package/external/folly/folly/AtomicLinkedList.h +110 -0
- package/external/folly/folly/AtomicUnorderedMap.h +522 -0
- package/external/folly/folly/BUCK +1631 -0
- package/external/folly/folly/BUILD_MODE.bzl +72 -0
- package/external/folly/folly/Benchmark.cpp +986 -0
- package/external/folly/folly/Benchmark.h +680 -0
- package/external/folly/folly/BenchmarkUtil.h +47 -0
- package/external/folly/folly/Bits.h +17 -0
- package/external/folly/folly/CMakeLists.txt +110 -0
- package/external/folly/folly/CPortability.h +338 -0
- package/external/folly/folly/CancellationToken-inl.h +449 -0
- package/external/folly/folly/CancellationToken.cpp +250 -0
- package/external/folly/folly/CancellationToken.h +365 -0
- package/external/folly/folly/Chrono.h +132 -0
- package/external/folly/folly/ClockGettimeWrappers.cpp +93 -0
- package/external/folly/folly/ClockGettimeWrappers.h +29 -0
- package/external/folly/folly/ConcurrentBitSet.h +157 -0
- package/external/folly/folly/ConcurrentLazy.h +74 -0
- package/external/folly/folly/ConcurrentSkipList-inl.h +341 -0
- package/external/folly/folly/ConcurrentSkipList.h +824 -0
- package/external/folly/folly/ConstructorCallbackList.h +158 -0
- package/external/folly/folly/Conv.h +2026 -0
- package/external/folly/folly/CppAttributes.h +170 -0
- package/external/folly/folly/CpuId.h +297 -0
- package/external/folly/folly/DefaultKeepAliveExecutor.h +172 -0
- package/external/folly/folly/Demangle.cpp +255 -0
- package/external/folly/folly/Demangle.h +73 -0
- package/external/folly/folly/DiscriminatedPtr.h +236 -0
- package/external/folly/folly/DynamicConverter.h +17 -0
- package/external/folly/folly/Exception.h +150 -0
- package/external/folly/folly/ExceptionString.cpp +51 -0
- package/external/folly/folly/ExceptionString.h +33 -0
- package/external/folly/folly/ExceptionWrapper-inl.h +264 -0
- package/external/folly/folly/ExceptionWrapper.cpp +37 -0
- package/external/folly/folly/ExceptionWrapper.h +377 -0
- package/external/folly/folly/Executor.cpp +111 -0
- package/external/folly/folly/Executor.h +351 -0
- package/external/folly/folly/Expected.h +1725 -0
- package/external/folly/folly/FBString.h +2888 -0
- package/external/folly/folly/FBVector.h +17 -0
- package/external/folly/folly/File.cpp +180 -0
- package/external/folly/folly/File.h +177 -0
- package/external/folly/folly/FileUtil.cpp +378 -0
- package/external/folly/folly/FileUtil.h +332 -0
- package/external/folly/folly/Fingerprint.cpp +135 -0
- package/external/folly/folly/Fingerprint.h +289 -0
- package/external/folly/folly/FixedString.h +2965 -0
- package/external/folly/folly/FollyMemcpy.cpp +30 -0
- package/external/folly/folly/FollyMemcpy.h +23 -0
- package/external/folly/folly/FollyMemset.cpp +29 -0
- package/external/folly/folly/FollyMemset.h +25 -0
- package/external/folly/folly/Format-inl.h +1152 -0
- package/external/folly/folly/Format.cpp +429 -0
- package/external/folly/folly/Format.h +463 -0
- package/external/folly/folly/FormatArg.h +285 -0
- package/external/folly/folly/FormatTraits.h +65 -0
- package/external/folly/folly/Function.h +1159 -0
- package/external/folly/folly/GLog.h +85 -0
- package/external/folly/folly/GroupVarint.cpp +153 -0
- package/external/folly/folly/GroupVarint.h +630 -0
- package/external/folly/folly/Hash.h +20 -0
- package/external/folly/folly/IPAddress.cpp +490 -0
- package/external/folly/folly/IPAddress.h +667 -0
- package/external/folly/folly/IPAddressException.h +82 -0
- package/external/folly/folly/IPAddressV4.cpp +305 -0
- package/external/folly/folly/IPAddressV4.h +495 -0
- package/external/folly/folly/IPAddressV6.cpp +541 -0
- package/external/folly/folly/IPAddressV6.h +627 -0
- package/external/folly/folly/Indestructible.h +164 -0
- package/external/folly/folly/IndexedMemPool.h +550 -0
- package/external/folly/folly/IntrusiveList.h +17 -0
- package/external/folly/folly/Lazy.h +142 -0
- package/external/folly/folly/Likely.h +76 -0
- package/external/folly/folly/MPMCPipeline.h +280 -0
- package/external/folly/folly/MPMCQueue.h +1556 -0
- package/external/folly/folly/MacAddress.cpp +188 -0
- package/external/folly/folly/MacAddress.h +260 -0
- package/external/folly/folly/MapUtil.h +17 -0
- package/external/folly/folly/Math.h +258 -0
- package/external/folly/folly/MaybeManagedPtr.h +120 -0
- package/external/folly/folly/Memory.h +900 -0
- package/external/folly/folly/MicroLock.cpp +76 -0
- package/external/folly/folly/MicroLock.h +354 -0
- package/external/folly/folly/MicroSpinLock.h +17 -0
- package/external/folly/folly/MoveWrapper.h +76 -0
- package/external/folly/folly/ObserverContainer.h +1026 -0
- package/external/folly/folly/Optional.h +743 -0
- package/external/folly/folly/Overload.h +325 -0
- package/external/folly/folly/PackedSyncPtr.h +147 -0
- package/external/folly/folly/Padded.h +464 -0
- package/external/folly/folly/Poly-inl.h +230 -0
- package/external/folly/folly/Poly.h +1095 -0
- package/external/folly/folly/PolyException.h +43 -0
- package/external/folly/folly/Portability.h +644 -0
- package/external/folly/folly/Preprocessor.h +236 -0
- package/external/folly/folly/ProducerConsumerQueue.h +182 -0
- package/external/folly/folly/RWSpinLock.h +17 -0
- package/external/folly/folly/Random-inl.h +86 -0
- package/external/folly/folly/Random.cpp +184 -0
- package/external/folly/folly/Random.h +434 -0
- package/external/folly/folly/Range.h +1772 -0
- package/external/folly/folly/Replaceable.h +636 -0
- package/external/folly/folly/ScopeGuard.cpp +29 -0
- package/external/folly/folly/ScopeGuard.h +420 -0
- package/external/folly/folly/SharedMutex.cpp +81 -0
- package/external/folly/folly/SharedMutex.h +1751 -0
- package/external/folly/folly/Singleton-inl.h +332 -0
- package/external/folly/folly/Singleton.cpp +512 -0
- package/external/folly/folly/Singleton.h +891 -0
- package/external/folly/folly/SingletonThreadLocal.cpp +53 -0
- package/external/folly/folly/SingletonThreadLocal.h +263 -0
- package/external/folly/folly/SocketAddress.cpp +786 -0
- package/external/folly/folly/SocketAddress.h +768 -0
- package/external/folly/folly/SpinLock.h +55 -0
- package/external/folly/folly/String-inl.h +668 -0
- package/external/folly/folly/String.cpp +777 -0
- package/external/folly/folly/String.h +767 -0
- package/external/folly/folly/Subprocess.cpp +1142 -0
- package/external/folly/folly/Subprocess.h +1055 -0
- package/external/folly/folly/Synchronized.h +1833 -0
- package/external/folly/folly/SynchronizedPtr.h +106 -0
- package/external/folly/folly/ThreadCachedInt.h +175 -0
- package/external/folly/folly/ThreadLocal.h +478 -0
- package/external/folly/folly/TimeoutQueue.cpp +78 -0
- package/external/folly/folly/TimeoutQueue.h +123 -0
- package/external/folly/folly/TokenBucket.h +673 -0
- package/external/folly/folly/Traits.h +1442 -0
- package/external/folly/folly/Try-inl.h +372 -0
- package/external/folly/folly/Try.cpp +23 -0
- package/external/folly/folly/Try.h +728 -0
- package/external/folly/folly/UTF8String.h +56 -0
- package/external/folly/folly/Unicode.cpp +201 -0
- package/external/folly/folly/Unicode.h +94 -0
- package/external/folly/folly/Unit.h +65 -0
- package/external/folly/folly/Uri-inl.h +101 -0
- package/external/folly/folly/Uri.cpp +190 -0
- package/external/folly/folly/Uri.h +142 -0
- package/external/folly/folly/Utility.h +932 -0
- package/external/folly/folly/VERSION +1 -0
- package/external/folly/folly/Varint.h +230 -0
- package/external/folly/folly/VirtualExecutor.h +17 -0
- package/external/folly/folly/algorithm/simd/BUCK +47 -0
- package/external/folly/folly/algorithm/simd/Contains.cpp +42 -0
- package/external/folly/folly/algorithm/simd/Contains.h +116 -0
- package/external/folly/folly/algorithm/simd/FindFixed.h +301 -0
- package/external/folly/folly/algorithm/simd/Ignore.h +52 -0
- package/external/folly/folly/algorithm/simd/Movemask.h +207 -0
- package/external/folly/folly/algorithm/simd/detail/BUCK +70 -0
- package/external/folly/folly/algorithm/simd/detail/ContainsImpl.h +91 -0
- package/external/folly/folly/algorithm/simd/detail/SimdAnyOf.h +83 -0
- package/external/folly/folly/algorithm/simd/detail/SimdForEach.h +209 -0
- package/external/folly/folly/algorithm/simd/detail/SimdPlatform.h +445 -0
- package/external/folly/folly/algorithm/simd/detail/Traits.h +125 -0
- package/external/folly/folly/algorithm/simd/detail/UnrollUtils.h +126 -0
- package/external/folly/folly/base64.h +264 -0
- package/external/folly/folly/chrono/BUCK +29 -0
- package/external/folly/folly/chrono/Clock.h +65 -0
- package/external/folly/folly/chrono/Conv.h +712 -0
- package/external/folly/folly/chrono/test/BUCK +26 -0
- package/external/folly/folly/chrono/test/ClockTest.cpp +68 -0
- package/external/folly/folly/chrono/test/ConvTest.cpp +652 -0
- package/external/folly/folly/concurrency/AtomicSharedPtr.h +387 -0
- package/external/folly/folly/concurrency/BUCK +170 -0
- package/external/folly/folly/concurrency/CacheLocality.h +460 -0
- package/external/folly/folly/concurrency/ConcurrentHashMap.h +822 -0
- package/external/folly/folly/concurrency/CoreCachedSharedPtr.h +232 -0
- package/external/folly/folly/concurrency/DeadlockDetector.cpp +27 -0
- package/external/folly/folly/concurrency/DeadlockDetector.h +44 -0
- package/external/folly/folly/concurrency/DynamicBoundedQueue.h +751 -0
- package/external/folly/folly/concurrency/PriorityUnboundedQueueSet.h +207 -0
- package/external/folly/folly/concurrency/ProcessLocalUniqueId.cpp +46 -0
- package/external/folly/folly/concurrency/ProcessLocalUniqueId.h +38 -0
- package/external/folly/folly/concurrency/SingletonRelaxedCounter.h +325 -0
- package/external/folly/folly/concurrency/ThreadCachedSynchronized.h +227 -0
- package/external/folly/folly/concurrency/UnboundedQueue.h +891 -0
- package/external/folly/folly/concurrency/container/BUCK +77 -0
- package/external/folly/folly/concurrency/container/FlatCombiningPriorityQueue.h +426 -0
- package/external/folly/folly/concurrency/container/LockFreeRingBuffer.h +306 -0
- package/external/folly/folly/concurrency/container/RelaxedConcurrentPriorityQueue.h +1212 -0
- package/external/folly/folly/concurrency/container/SingleWriterFixedHashMap.h +322 -0
- package/external/folly/folly/concurrency/container/atomic_grow_array.h +564 -0
- package/external/folly/folly/concurrency/container/test/BUCK +75 -0
- package/external/folly/folly/concurrency/container/test/FlatCombiningPriorityQueueTest.cpp +570 -0
- package/external/folly/folly/concurrency/container/test/LockFreeRingBufferTest.cpp +276 -0
- package/external/folly/folly/concurrency/container/test/RelaxedConcurrentPriorityQueueTest.cpp +1570 -0
- package/external/folly/folly/concurrency/container/test/SingleWriterFixedHashMapTest.cpp +401 -0
- package/external/folly/folly/concurrency/container/test/atomic_grow_array_test.cpp +187 -0
- package/external/folly/folly/concurrency/detail/AtomicSharedPtr-detail.h +212 -0
- package/external/folly/folly/concurrency/detail/ConcurrentHashMap-detail.h +1911 -0
- package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.cpp +43 -0
- package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.h +190 -0
- package/external/folly/folly/concurrency/memory/BUCK +53 -0
- package/external/folly/folly/concurrency/memory/PrimaryPtr.h +338 -0
- package/external/folly/folly/concurrency/memory/ReadMostlySharedPtr.h +511 -0
- package/external/folly/folly/concurrency/memory/TLRefCount.h +228 -0
- package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrBenchmark.cpp +56 -0
- package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrTest.cpp +454 -0
- package/external/folly/folly/concurrency/memory/test/BUCK +95 -0
- package/external/folly/folly/concurrency/memory/test/PrimaryPtrTest.cpp +303 -0
- package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrBenchmark.cpp +138 -0
- package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrStressTest.cpp +75 -0
- package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrTest.cpp +378 -0
- package/external/folly/folly/concurrency/memory/test/RefCountBenchmark.cpp +90 -0
- package/external/folly/folly/concurrency/memory/test/RefCountTest.cpp +168 -0
- package/external/folly/folly/concurrency/test/AtomicSharedPtrCounted.h +156 -0
- package/external/folly/folly/concurrency/test/AtomicSharedPtrPerformance.cpp +255 -0
- package/external/folly/folly/concurrency/test/AtomicSharedPtrTest.cpp +257 -0
- package/external/folly/folly/concurrency/test/BUCK +229 -0
- package/external/folly/folly/concurrency/test/CacheLocalityBenchmark.cpp +392 -0
- package/external/folly/folly/concurrency/test/CacheLocalityTest.cpp +1229 -0
- package/external/folly/folly/concurrency/test/ConcurrentHashMapBench.cpp +260 -0
- package/external/folly/folly/concurrency/test/ConcurrentHashMapTest.cpp +1242 -0
- package/external/folly/folly/concurrency/test/CoreCachedSharedPtrTest.cpp +408 -0
- package/external/folly/folly/concurrency/test/DynamicBoundedQueueTest.cpp +984 -0
- package/external/folly/folly/concurrency/test/PriorityUnboundedQueueSetTest.cpp +73 -0
- package/external/folly/folly/concurrency/test/ProcessLocalUniqueIdTest.cpp +66 -0
- package/external/folly/folly/concurrency/test/SingletonRelaxedCounterBench.cpp +101 -0
- package/external/folly/folly/concurrency/test/SingletonRelaxedCounterTest.cpp +185 -0
- package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedBench.cpp +76 -0
- package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedTest.cpp +93 -0
- package/external/folly/folly/concurrency/test/UnboundedQueueTest.cpp +1302 -0
- package/external/folly/folly/container/Access.h +57 -0
- package/external/folly/folly/container/Array.h +87 -0
- package/external/folly/folly/container/BUCK +353 -0
- package/external/folly/folly/container/BitIterator.h +203 -0
- package/external/folly/folly/container/Enumerate.h +162 -0
- package/external/folly/folly/container/EvictingCacheMap.h +730 -0
- package/external/folly/folly/container/F14.md +300 -0
- package/external/folly/folly/container/F14Map-fwd.h +113 -0
- package/external/folly/folly/container/F14Map.h +2108 -0
- package/external/folly/folly/container/F14Set-fwd.h +95 -0
- package/external/folly/folly/container/F14Set.h +1603 -0
- package/external/folly/folly/container/FBVector.h +1711 -0
- package/external/folly/folly/container/Foreach-inl.h +316 -0
- package/external/folly/folly/container/Foreach.h +209 -0
- package/external/folly/folly/container/HeterogeneousAccess-fwd.h +33 -0
- package/external/folly/folly/container/HeterogeneousAccess.h +171 -0
- package/external/folly/folly/container/IntrusiveHeap.h +268 -0
- package/external/folly/folly/container/IntrusiveList.h +131 -0
- package/external/folly/folly/container/Iterator.h +843 -0
- package/external/folly/folly/container/MapUtil.h +376 -0
- package/external/folly/folly/container/Merge.h +90 -0
- package/external/folly/folly/container/RegexMatchCache.cpp +521 -0
- package/external/folly/folly/container/RegexMatchCache.h +699 -0
- package/external/folly/folly/container/Reserve.h +109 -0
- package/external/folly/folly/container/SparseByteSet.h +123 -0
- package/external/folly/folly/container/View.h +81 -0
- package/external/folly/folly/container/WeightedEvictingCacheMap.h +651 -0
- package/external/folly/folly/container/detail/BUCK +115 -0
- package/external/folly/folly/container/detail/BitIteratorDetail.h +87 -0
- package/external/folly/folly/container/detail/F14Defaults.h +34 -0
- package/external/folly/folly/container/detail/F14IntrinsicsAvailability.h +67 -0
- package/external/folly/folly/container/detail/F14MapFallback.h +717 -0
- package/external/folly/folly/container/detail/F14Mask.h +235 -0
- package/external/folly/folly/container/detail/F14Policy.h +1523 -0
- package/external/folly/folly/container/detail/F14SetFallback.h +528 -0
- package/external/folly/folly/container/detail/F14Table.cpp +71 -0
- package/external/folly/folly/container/detail/F14Table.h +2680 -0
- package/external/folly/folly/container/detail/Util.h +303 -0
- package/external/folly/folly/container/detail/tape_detail.h +135 -0
- package/external/folly/folly/container/detail/test/BUCK +14 -0
- package/external/folly/folly/container/detail/test/F14DetailTest.cpp +47 -0
- package/external/folly/folly/container/heap_vector_types.h +1683 -0
- package/external/folly/folly/container/range_traits.h +81 -0
- package/external/folly/folly/container/small_vector.h +1476 -0
- package/external/folly/folly/container/sorted_vector_types.h +1652 -0
- package/external/folly/folly/container/span.h +408 -0
- package/external/folly/folly/container/tape.h +608 -0
- package/external/folly/folly/container/test/.clang-tidy +12 -0
- package/external/folly/folly/container/test/AccessTest.cpp +138 -0
- package/external/folly/folly/container/test/ArrayTest.cpp +84 -0
- package/external/folly/folly/container/test/BUCK +568 -0
- package/external/folly/folly/container/test/BitIteratorBench.cpp +112 -0
- package/external/folly/folly/container/test/BitIteratorTest.cpp +109 -0
- package/external/folly/folly/container/test/EnumerateTest.cpp +294 -0
- package/external/folly/folly/container/test/EvictingCacheMapBench.cpp +80 -0
- package/external/folly/folly/container/test/EvictingCacheMapTest.cpp +842 -0
- package/external/folly/folly/container/test/F14AsanSupportTest.cpp +143 -0
- package/external/folly/folly/container/test/F14FwdTest.cpp +37 -0
- package/external/folly/folly/container/test/F14InterprocessTest.cpp +404 -0
- package/external/folly/folly/container/test/F14MapTest.cpp +2543 -0
- package/external/folly/folly/container/test/F14PolicyTest.cpp +49 -0
- package/external/folly/folly/container/test/F14SetTest.cpp +1738 -0
- package/external/folly/folly/container/test/F14SmallOverheads.cpp +215 -0
- package/external/folly/folly/container/test/F14TestUtil.h +117 -0
- package/external/folly/folly/container/test/FBVectorBenchmark.cpp +380 -0
- package/external/folly/folly/container/test/FBVectorBenchmarks.cpp.h +100 -0
- package/external/folly/folly/container/test/FBVectorTest.cpp +326 -0
- package/external/folly/folly/container/test/FBVectorTests.cpp.h +304 -0
- package/external/folly/folly/container/test/ForeachBenchmark.cpp +388 -0
- package/external/folly/folly/container/test/ForeachTest.cpp +338 -0
- package/external/folly/folly/container/test/HashMapsBench.cpp +458 -0
- package/external/folly/folly/container/test/HeterogeneousAccessTest.cpp +242 -0
- package/external/folly/folly/container/test/IntrusiveHeapTest.cpp +262 -0
- package/external/folly/folly/container/test/IteratorTest.cpp +989 -0
- package/external/folly/folly/container/test/MapUtilTest.cpp +365 -0
- package/external/folly/folly/container/test/MergeTest.cpp +66 -0
- package/external/folly/folly/container/test/RegexMatchCacheTest.cpp +634 -0
- package/external/folly/folly/container/test/ReserveTest.cpp +173 -0
- package/external/folly/folly/container/test/SparseByteSetBenchmark.cpp +153 -0
- package/external/folly/folly/container/test/SparseByteSetTest.cpp +117 -0
- package/external/folly/folly/container/test/TrackingTypes.h +584 -0
- package/external/folly/folly/container/test/UtilTest.cpp +609 -0
- package/external/folly/folly/container/test/WeightedEvictingCacheMapTest.cpp +800 -0
- package/external/folly/folly/container/test/heap_vector_types_test.cpp +1774 -0
- package/external/folly/folly/container/test/range_traits_test.cpp +59 -0
- package/external/folly/folly/container/test/small_vector_test.cpp +1571 -0
- package/external/folly/folly/container/test/sorted_vector_test.cpp +1589 -0
- package/external/folly/folly/container/test/span_test.cpp +520 -0
- package/external/folly/folly/container/test/tape_bench.cpp +200 -0
- package/external/folly/folly/container/test/tape_test.cpp +590 -0
- package/external/folly/folly/defs.bzl +238 -0
- package/external/folly/folly/detail/AsyncTrace.cpp +36 -0
- package/external/folly/folly/detail/AsyncTrace.h +44 -0
- package/external/folly/folly/detail/AtomicHashUtils.h +42 -0
- package/external/folly/folly/detail/AtomicUnorderedMapUtils.h +80 -0
- package/external/folly/folly/detail/BUCK +406 -0
- package/external/folly/folly/detail/DiscriminatedPtrDetail.h +172 -0
- package/external/folly/folly/detail/FileUtilDetail.cpp +63 -0
- package/external/folly/folly/detail/FileUtilDetail.h +85 -0
- package/external/folly/folly/detail/FileUtilVectorDetail.h +81 -0
- package/external/folly/folly/detail/FingerprintPolynomial.h +132 -0
- package/external/folly/folly/detail/Futex-inl.h +123 -0
- package/external/folly/folly/detail/Futex.cpp +273 -0
- package/external/folly/folly/detail/Futex.h +109 -0
- package/external/folly/folly/detail/GroupVarintDetail.h +101 -0
- package/external/folly/folly/detail/IPAddress.cpp +37 -0
- package/external/folly/folly/detail/IPAddress.h +57 -0
- package/external/folly/folly/detail/IPAddressSource.h +278 -0
- package/external/folly/folly/detail/Iterators.h +156 -0
- package/external/folly/folly/detail/MPMCPipelineDetail.h +122 -0
- package/external/folly/folly/detail/MemoryIdler.cpp +233 -0
- package/external/folly/folly/detail/MemoryIdler.h +216 -0
- package/external/folly/folly/detail/PerfScoped.cpp +112 -0
- package/external/folly/folly/detail/PerfScoped.h +70 -0
- package/external/folly/folly/detail/PolyDetail.h +921 -0
- package/external/folly/folly/detail/RangeCommon.cpp +55 -0
- package/external/folly/folly/detail/RangeCommon.h +93 -0
- package/external/folly/folly/detail/RangeSse42.cpp +198 -0
- package/external/folly/folly/detail/RangeSse42.h +30 -0
- package/external/folly/folly/detail/SimpleSimdStringUtils.cpp +31 -0
- package/external/folly/folly/detail/SimpleSimdStringUtils.h +27 -0
- package/external/folly/folly/detail/SimpleSimdStringUtilsImpl.h +63 -0
- package/external/folly/folly/detail/Singleton.h +34 -0
- package/external/folly/folly/detail/SlowFingerprint.h +90 -0
- package/external/folly/folly/detail/SocketFastOpen.cpp +175 -0
- package/external/folly/folly/detail/SocketFastOpen.h +89 -0
- package/external/folly/folly/detail/SplitStringSimd.cpp +84 -0
- package/external/folly/folly/detail/SplitStringSimd.h +151 -0
- package/external/folly/folly/detail/SplitStringSimdImpl.h +149 -0
- package/external/folly/folly/detail/Sse.cpp +35 -0
- package/external/folly/folly/detail/Sse.h +45 -0
- package/external/folly/folly/detail/StaticSingletonManager.cpp +119 -0
- package/external/folly/folly/detail/StaticSingletonManager.h +298 -0
- package/external/folly/folly/detail/ThreadLocalDetail.cpp +492 -0
- package/external/folly/folly/detail/ThreadLocalDetail.h +800 -0
- package/external/folly/folly/detail/TrapOnAvx512.cpp +41 -0
- package/external/folly/folly/detail/TrapOnAvx512.h +21 -0
- package/external/folly/folly/detail/TurnSequencer.h +295 -0
- package/external/folly/folly/detail/TypeList.h +551 -0
- package/external/folly/folly/detail/UniqueInstance.cpp +136 -0
- package/external/folly/folly/detail/UniqueInstance.h +68 -0
- package/external/folly/folly/detail/base64_detail/BUCK +102 -0
- package/external/folly/folly/detail/base64_detail/Base64Api.cpp +40 -0
- package/external/folly/folly/detail/base64_detail/Base64Api.h +101 -0
- package/external/folly/folly/detail/base64_detail/Base64Common.h +80 -0
- package/external/folly/folly/detail/base64_detail/Base64Constants.h +79 -0
- package/external/folly/folly/detail/base64_detail/Base64HiddenConstants.h +129 -0
- package/external/folly/folly/detail/base64_detail/Base64SWAR.cpp +161 -0
- package/external/folly/folly/detail/base64_detail/Base64SWAR.h +32 -0
- package/external/folly/folly/detail/base64_detail/Base64Scalar.h +262 -0
- package/external/folly/folly/detail/base64_detail/Base64Simd.h +102 -0
- package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.cpp +42 -0
- package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.h +33 -0
- package/external/folly/folly/detail/base64_detail/Base64_SSE4_2_Platform.h +167 -0
- package/external/folly/folly/detail/base64_detail/README.md +392 -0
- package/external/folly/folly/detail/base64_detail/tests/BUCK +36 -0
- package/external/folly/folly/detail/base64_detail/tests/Base64AgainstScalarTest.cpp +141 -0
- package/external/folly/folly/detail/base64_detail/tests/Base64PlatformTest.cpp +273 -0
- package/external/folly/folly/detail/base64_detail/tests/Base64SpecialCasesTest.cpp +555 -0
- package/external/folly/folly/detail/test/AsyncTraceTest.cpp +43 -0
- package/external/folly/folly/detail/test/BUCK +118 -0
- package/external/folly/folly/detail/test/FileUtilDetailTest.cpp +56 -0
- package/external/folly/folly/detail/test/PerfScopedTest.cpp +107 -0
- package/external/folly/folly/detail/test/SimpleSimdStringUtilsTest.cpp +92 -0
- package/external/folly/folly/detail/test/SplitStringSimdTest.cpp +242 -0
- package/external/folly/folly/detail/test/StaticSingletonManagerTest.cpp +121 -0
- package/external/folly/folly/detail/test/ThreadLocalBenchmark.cpp +116 -0
- package/external/folly/folly/detail/test/ThreadLocalDetailTest.cpp +194 -0
- package/external/folly/folly/detail/test/TrapOnAvx512TestNegative.cpp +29 -0
- package/external/folly/folly/detail/test/UniqueInstanceTest.cpp +60 -0
- package/external/folly/folly/detail/thread_local_globals.cpp +69 -0
- package/external/folly/folly/detail/thread_local_globals.h +36 -0
- package/external/folly/folly/docs/AtomicHashMap.md +134 -0
- package/external/folly/folly/docs/Benchmark.md +310 -0
- package/external/folly/folly/docs/Conv.md +291 -0
- package/external/folly/folly/docs/Dynamic.md +220 -0
- package/external/folly/folly/docs/DynamicConverter.md +71 -0
- package/external/folly/folly/docs/Executors.md +63 -0
- package/external/folly/folly/docs/FBString.md +46 -0
- package/external/folly/folly/docs/FBVector.md +200 -0
- package/external/folly/folly/docs/Fbvector--graphical_solutions.png +0 -0
- package/external/folly/folly/docs/Format.md +177 -0
- package/external/folly/folly/docs/Function.md +92 -0
- package/external/folly/folly/docs/Futures.md +263 -0
- package/external/folly/folly/docs/GroupVarint.md +46 -0
- package/external/folly/folly/docs/Histogram.md +104 -0
- package/external/folly/folly/docs/MapUtils.md +80 -0
- package/external/folly/folly/docs/Overview.md +263 -0
- package/external/folly/folly/docs/PackedSyncPtr.md +77 -0
- package/external/folly/folly/docs/Poly.md +500 -0
- package/external/folly/folly/docs/ProducerConsumerQueue.md +82 -0
- package/external/folly/folly/docs/Rcu.md +218 -0
- package/external/folly/folly/docs/SmallLocks.md +24 -0
- package/external/folly/folly/docs/Synchronized.md +793 -0
- package/external/folly/folly/docs/ThreadCachedInt.md +98 -0
- package/external/folly/folly/docs/ThreadLocal.md +105 -0
- package/external/folly/folly/docs/Traits.md +161 -0
- package/external/folly/folly/docs/small_vector.md +64 -0
- package/external/folly/folly/docs/style.css +23 -0
- package/external/folly/folly/dynamic-inl.h +17 -0
- package/external/folly/folly/dynamic.h +17 -0
- package/external/folly/folly/folly_extended_library.bzl +28 -0
- package/external/folly/folly/functional/ApplyTuple.h +204 -0
- package/external/folly/folly/functional/BUCK +57 -0
- package/external/folly/folly/functional/Invoke.h +880 -0
- package/external/folly/folly/functional/Partial.h +130 -0
- package/external/folly/folly/functional/protocol.h +203 -0
- package/external/folly/folly/functional/test/ApplyTupleTest.cpp +549 -0
- package/external/folly/folly/functional/test/BUCK +57 -0
- package/external/folly/folly/functional/test/InvokeTest.cpp +483 -0
- package/external/folly/folly/functional/test/PartialTest.cpp +141 -0
- package/external/folly/folly/functional/test/protocol_test.cpp +177 -0
- package/external/folly/folly/functional/test/traits_test.cpp +551 -0
- package/external/folly/folly/functional/traits.h +675 -0
- package/external/folly/folly/hash/BUCK +86 -0
- package/external/folly/folly/hash/Checksum.cpp +275 -0
- package/external/folly/folly/hash/Checksum.h +94 -0
- package/external/folly/folly/hash/FarmHash.h +46 -0
- package/external/folly/folly/hash/Hash.h +1045 -0
- package/external/folly/folly/hash/MurmurHash.h +86 -0
- package/external/folly/folly/hash/SpookyHashV1.cpp +391 -0
- package/external/folly/folly/hash/SpookyHashV1.h +307 -0
- package/external/folly/folly/hash/SpookyHashV2.cpp +392 -0
- package/external/folly/folly/hash/SpookyHashV2.h +339 -0
- package/external/folly/folly/hash/detail/BUCK +26 -0
- package/external/folly/folly/hash/detail/ChecksumDetail.cpp +296 -0
- package/external/folly/folly/hash/detail/ChecksumDetail.h +137 -0
- package/external/folly/folly/hash/detail/Crc32CombineDetail.cpp +191 -0
- package/external/folly/folly/hash/detail/Crc32cDetail.cpp +303 -0
- package/external/folly/folly/hash/test/BUCK +132 -0
- package/external/folly/folly/hash/test/ChecksumBenchmark.cpp +91 -0
- package/external/folly/folly/hash/test/ChecksumTest.cpp +587 -0
- package/external/folly/folly/hash/test/FarmHashTest.cpp +41 -0
- package/external/folly/folly/hash/test/HashBenchmark.cpp +238 -0
- package/external/folly/folly/hash/test/HashTest.cpp +997 -0
- package/external/folly/folly/hash/test/MurmurHashTest.cpp +76 -0
- package/external/folly/folly/hash/test/SpookyHashV1Test.cpp +559 -0
- package/external/folly/folly/hash/test/SpookyHashV2Test.cpp +549 -0
- package/external/folly/folly/hash/test/traits_test.cpp +69 -0
- package/external/folly/folly/hash/traits.h +115 -0
- package/external/folly/folly/json/BUCK +155 -0
- package/external/folly/folly/json/DynamicConverter.h +464 -0
- package/external/folly/folly/json/DynamicParser-inl.h +316 -0
- package/external/folly/folly/json/DynamicParser.cpp +198 -0
- package/external/folly/folly/json/DynamicParser.h +394 -0
- package/external/folly/folly/json/JSONSchema.cpp +1030 -0
- package/external/folly/folly/json/JSONSchema.h +73 -0
- package/external/folly/folly/json/JsonMockUtil.h +73 -0
- package/external/folly/folly/json/JsonTestUtil.cpp +167 -0
- package/external/folly/folly/json/JsonTestUtil.h +88 -0
- package/external/folly/folly/json/bser/BUCK +24 -0
- package/external/folly/folly/json/bser/Bser.h +107 -0
- package/external/folly/folly/json/bser/Dump.cpp +253 -0
- package/external/folly/folly/json/bser/Load.cpp +246 -0
- package/external/folly/folly/json/bser/test/BUCK +14 -0
- package/external/folly/folly/json/bser/test/BserTest.cpp +149 -0
- package/external/folly/folly/json/dynamic.cpp +552 -0
- package/external/folly/folly/json/dynamic.h +1346 -0
- package/external/folly/folly/json/json.h +238 -0
- package/external/folly/folly/json/json_patch.cpp +325 -0
- package/external/folly/folly/json/json_patch.h +126 -0
- package/external/folly/folly/json/json_pointer.cpp +114 -0
- package/external/folly/folly/json/json_pointer.h +87 -0
- package/external/folly/folly/json/test/BUCK +147 -0
- package/external/folly/folly/json/test/DynamicBenchmark.cpp +146 -0
- package/external/folly/folly/json/test/DynamicConverterTest.cpp +518 -0
- package/external/folly/folly/json/test/DynamicOtherTest.cpp +344 -0
- package/external/folly/folly/json/test/DynamicParserTest.cpp +443 -0
- package/external/folly/folly/json/test/DynamicTest.cpp +1647 -0
- package/external/folly/folly/json/test/JSONSchemaTest.cpp +450 -0
- package/external/folly/folly/json/test/JsonBenchmark.cpp +264 -0
- package/external/folly/folly/json/test/JsonOtherTest.cpp +51 -0
- package/external/folly/folly/json/test/JsonTest.cpp +1153 -0
- package/external/folly/folly/json/test/JsonTestUtilTest.cpp +97 -0
- package/external/folly/folly/json/test/json_patch_test.cpp +361 -0
- package/external/folly/folly/json/test/json_pointer_test.cpp +58 -0
- package/external/folly/folly/json/tool/BUCK +13 -0
- package/external/folly/folly/json/tool/JSONSchemaTester.cpp +58 -0
- package/external/folly/folly/json.h +17 -0
- package/external/folly/folly/json_patch.h +17 -0
- package/external/folly/folly/json_pointer.h +17 -0
- package/external/folly/folly/lang/Access.h +29 -0
- package/external/folly/folly/lang/Align.h +240 -0
- package/external/folly/folly/lang/Aligned.h +92 -0
- package/external/folly/folly/lang/Assume.h +82 -0
- package/external/folly/folly/lang/BUCK +287 -0
- package/external/folly/folly/lang/Badge.h +108 -0
- package/external/folly/folly/lang/Bits.h +570 -0
- package/external/folly/folly/lang/BitsClass.h +312 -0
- package/external/folly/folly/lang/Builtin.h +74 -0
- package/external/folly/folly/lang/CArray.h +34 -0
- package/external/folly/folly/lang/CString.cpp +86 -0
- package/external/folly/folly/lang/CString.h +55 -0
- package/external/folly/folly/lang/Cast.h +51 -0
- package/external/folly/folly/lang/CheckedMath.h +253 -0
- package/external/folly/folly/lang/CustomizationPoint.h +58 -0
- package/external/folly/folly/lang/Exception.cpp +822 -0
- package/external/folly/folly/lang/Exception.h +716 -0
- package/external/folly/folly/lang/Extern.h +55 -0
- package/external/folly/folly/lang/Hint-inl.h +144 -0
- package/external/folly/folly/lang/Hint.h +238 -0
- package/external/folly/folly/lang/Keep.h +98 -0
- package/external/folly/folly/lang/New.h +124 -0
- package/external/folly/folly/lang/Ordering.h +140 -0
- package/external/folly/folly/lang/Pretty.h +159 -0
- package/external/folly/folly/lang/PropagateConst.h +413 -0
- package/external/folly/folly/lang/RValueReferenceWrapper.h +152 -0
- package/external/folly/folly/lang/SafeAssert.cpp +589 -0
- package/external/folly/folly/lang/StaticConst.h +33 -0
- package/external/folly/folly/lang/Thunk.h +100 -0
- package/external/folly/folly/lang/TypeInfo.h +58 -0
- package/external/folly/folly/lang/UncaughtExceptions.cpp +17 -0
- package/external/folly/folly/lang/UncaughtExceptions.h +19 -0
- package/external/folly/folly/lang/test/AlignTest.cpp +87 -0
- package/external/folly/folly/lang/test/AlignedTest.cpp +130 -0
- package/external/folly/folly/lang/test/BUCK +258 -0
- package/external/folly/folly/lang/test/BadgeTest.cpp +89 -0
- package/external/folly/folly/lang/test/BitsBenchmark.cpp +164 -0
- package/external/folly/folly/lang/test/BitsClassBenchmark.cpp +122 -0
- package/external/folly/folly/lang/test/BitsClassTest.cpp +379 -0
- package/external/folly/folly/lang/test/BitsTest.cpp +577 -0
- package/external/folly/folly/lang/test/CStringTest.cpp +60 -0
- package/external/folly/folly/lang/test/CastTest.cpp +47 -0
- package/external/folly/folly/lang/test/CheckedMathTest.cpp +394 -0
- package/external/folly/folly/lang/test/ExceptionBench.cpp +427 -0
- package/external/folly/folly/lang/test/ExceptionTest.cpp +413 -0
- package/external/folly/folly/lang/test/ExternTest.cpp +39 -0
- package/external/folly/folly/lang/test/HintTest.cpp +100 -0
- package/external/folly/folly/lang/test/NewTest.cpp +38 -0
- package/external/folly/folly/lang/test/OrderingTest.cpp +105 -0
- package/external/folly/folly/lang/test/PrettyTest.cpp +44 -0
- package/external/folly/folly/lang/test/PropagateConstTest.cpp +356 -0
- package/external/folly/folly/lang/test/RValueReferenceWrapperTest.cpp +85 -0
- package/external/folly/folly/lang/test/SafeAssertTest.cpp +75 -0
- package/external/folly/folly/lang/test/ThunkTest.cpp +105 -0
- package/external/folly/folly/lang/test/ToAsciiBench.cpp +466 -0
- package/external/folly/folly/lang/test/ToAsciiTest.cpp +266 -0
- package/external/folly/folly/lang/test/TypeInfoTest.cpp +56 -0
- package/external/folly/folly/memcpy.S +292 -0
- package/external/folly/folly/memcpy_select_aarch64.cpp +145 -0
- package/external/folly/folly/memory/Arena-inl.h +83 -0
- package/external/folly/folly/memory/Arena.h +325 -0
- package/external/folly/folly/memory/BUCK +191 -0
- package/external/folly/folly/memory/JemallocHugePageAllocator.cpp +449 -0
- package/external/folly/folly/memory/JemallocHugePageAllocator.h +105 -0
- package/external/folly/folly/memory/JemallocHugePageAllocatorTest.cpp +341 -0
- package/external/folly/folly/memory/JemallocNodumpAllocator.cpp +176 -0
- package/external/folly/folly/memory/JemallocNodumpAllocator.h +119 -0
- package/external/folly/folly/memory/JemallocNodumpAllocatorTest.cpp +61 -0
- package/external/folly/folly/memory/MallctlHelper.cpp +37 -0
- package/external/folly/folly/memory/MallctlHelper.h +167 -0
- package/external/folly/folly/memory/Malloc.h +551 -0
- package/external/folly/folly/memory/MemoryResource.h +57 -0
- package/external/folly/folly/memory/ReentrantAllocator.cpp +162 -0
- package/external/folly/folly/memory/ReentrantAllocator.h +261 -0
- package/external/folly/folly/memory/SanitizeAddress.cpp +75 -0
- package/external/folly/folly/memory/SanitizeAddress.h +117 -0
- package/external/folly/folly/memory/SanitizeLeak.cpp +119 -0
- package/external/folly/folly/memory/SanitizeLeak.h +108 -0
- package/external/folly/folly/memory/ThreadCachedArena.cpp +53 -0
- package/external/folly/folly/memory/ThreadCachedArena.h +90 -0
- package/external/folly/folly/memory/UninitializedMemoryHacks.h +426 -0
- package/external/folly/folly/memory/detail/BUCK +10 -0
- package/external/folly/folly/memory/detail/MallocImpl.cpp +52 -0
- package/external/folly/folly/memory/detail/MallocImpl.h +97 -0
- package/external/folly/folly/memory/not_null-inl.h +522 -0
- package/external/folly/folly/memory/not_null.h +449 -0
- package/external/folly/folly/memory/test/ArenaTest.cpp +354 -0
- package/external/folly/folly/memory/test/BUCK +146 -0
- package/external/folly/folly/memory/test/MallctlHelperTest.cpp +169 -0
- package/external/folly/folly/memory/test/MallocBenchmark.cpp +91 -0
- package/external/folly/folly/memory/test/MallocTest.cpp +78 -0
- package/external/folly/folly/memory/test/MemoryResourceTest.cpp +31 -0
- package/external/folly/folly/memory/test/ReentrantAllocatorTest.cpp +144 -0
- package/external/folly/folly/memory/test/SanitizeAddressTest.cpp +67 -0
- package/external/folly/folly/memory/test/SanitizeLeakTest.cpp +139 -0
- package/external/folly/folly/memory/test/ThreadCachedArenaTest.cpp +276 -0
- package/external/folly/folly/memory/test/UninitializedMemoryHacksODR.cpp +21 -0
- package/external/folly/folly/memory/test/UninitializedMemoryHacksTest.cpp +327 -0
- package/external/folly/folly/memory/test/not_null_test.cpp +608 -0
- package/external/folly/folly/memset.S +245 -0
- package/external/folly/folly/memset_select_aarch64.cpp +72 -0
- package/external/folly/folly/portability/Asm.h +50 -0
- package/external/folly/folly/portability/Atomic.h +31 -0
- package/external/folly/folly/portability/BUCK +456 -0
- package/external/folly/folly/portability/Builtins.cpp +31 -0
- package/external/folly/folly/portability/Builtins.h +161 -0
- package/external/folly/folly/portability/Config.h +43 -0
- package/external/folly/folly/portability/Constexpr.h +145 -0
- package/external/folly/folly/portability/Dirent.cpp +140 -0
- package/external/folly/folly/portability/Dirent.h +41 -0
- package/external/folly/folly/portability/Event.h +44 -0
- package/external/folly/folly/portability/Fcntl.cpp +120 -0
- package/external/folly/folly/portability/Fcntl.h +67 -0
- package/external/folly/folly/portability/Filesystem.cpp +67 -0
- package/external/folly/folly/portability/Filesystem.h +114 -0
- package/external/folly/folly/portability/FmtCompile.h +40 -0
- package/external/folly/folly/portability/GFlags.h +139 -0
- package/external/folly/folly/portability/GMock.h +35 -0
- package/external/folly/folly/portability/GTest.h +35 -0
- package/external/folly/folly/portability/IOVec.h +34 -0
- package/external/folly/folly/portability/Libgen.cpp +59 -0
- package/external/folly/folly/portability/Libgen.h +29 -0
- package/external/folly/folly/portability/Libunwind.h +21 -0
- package/external/folly/folly/portability/Malloc.cpp +31 -0
- package/external/folly/folly/portability/Malloc.h +53 -0
- package/external/folly/folly/portability/Math.h +90 -0
- package/external/folly/folly/portability/Memory.h +26 -0
- package/external/folly/folly/portability/OpenSSL.cpp +17 -0
- package/external/folly/folly/portability/OpenSSL.h +102 -0
- package/external/folly/folly/portability/PThread.cpp +697 -0
- package/external/folly/folly/portability/PThread.h +148 -0
- package/external/folly/folly/portability/README.md +21 -0
- package/external/folly/folly/portability/Sched.cpp +41 -0
- package/external/folly/folly/portability/Sched.h +45 -0
- package/external/folly/folly/portability/Sockets.cpp +245 -0
- package/external/folly/folly/portability/Sockets.h +155 -0
- package/external/folly/folly/portability/SourceLocation.h +49 -0
- package/external/folly/folly/portability/Stdio.cpp +77 -0
- package/external/folly/folly/portability/Stdio.h +32 -0
- package/external/folly/folly/portability/Stdlib.cpp +172 -0
- package/external/folly/folly/portability/Stdlib.h +64 -0
- package/external/folly/folly/portability/String.cpp +53 -0
- package/external/folly/folly/portability/String.h +39 -0
- package/external/folly/folly/portability/SysFile.cpp +46 -0
- package/external/folly/folly/portability/SysFile.h +27 -0
- package/external/folly/folly/portability/SysMembarrier.cpp +104 -0
- package/external/folly/folly/portability/SysMembarrier.h +26 -0
- package/external/folly/folly/portability/SysMman.cpp +242 -0
- package/external/folly/folly/portability/SysMman.h +68 -0
- package/external/folly/folly/portability/SysResource.cpp +108 -0
- package/external/folly/folly/portability/SysResource.h +71 -0
- package/external/folly/folly/portability/SysStat.cpp +66 -0
- package/external/folly/folly/portability/SysStat.h +52 -0
- package/external/folly/folly/portability/SysSyscall.h +73 -0
- package/external/folly/folly/portability/SysTime.cpp +62 -0
- package/external/folly/folly/portability/SysTime.h +50 -0
- package/external/folly/folly/portability/SysTypes.h +44 -0
- package/external/folly/folly/portability/SysUio.cpp +179 -0
- package/external/folly/folly/portability/SysUio.h +51 -0
- package/external/folly/folly/portability/Syslog.h +39 -0
- package/external/folly/folly/portability/Time.cpp +357 -0
- package/external/folly/folly/portability/Time.h +74 -0
- package/external/folly/folly/portability/Unistd.h +111 -0
- package/external/folly/folly/portability/Windows.h +108 -0
- package/external/folly/folly/portability/openat2.c +30 -0
- package/external/folly/folly/portability/openat2.h +39 -0
- package/external/folly/folly/portability/test/BUCK +59 -0
- package/external/folly/folly/portability/test/ConstexprTest.cpp +102 -0
- package/external/folly/folly/portability/test/FilesystemTest.cpp +35 -0
- package/external/folly/folly/portability/test/LibgenTest.cpp +35 -0
- package/external/folly/folly/portability/test/OpenSSLPortabilityTest.cpp +108 -0
- package/external/folly/folly/portability/test/PThreadTest.cpp +80 -0
- package/external/folly/folly/portability/test/TimeTest.cpp +90 -0
- package/external/folly/folly/small_vector.h +17 -0
- package/external/folly/folly/somerge_defs.bzl +399 -0
- package/external/folly/folly/sorted_vector_types.h +17 -0
- package/external/folly/folly/stop_watch.h +317 -0
- package/external/folly/folly/synchronization/AsymmetricThreadFence.cpp +91 -0
- package/external/folly/folly/synchronization/AsymmetricThreadFence.h +60 -0
- package/external/folly/folly/synchronization/AtomicNotification-inl.h +146 -0
- package/external/folly/folly/synchronization/AtomicNotification.cpp +34 -0
- package/external/folly/folly/synchronization/AtomicNotification.h +117 -0
- package/external/folly/folly/synchronization/AtomicRef.h +181 -0
- package/external/folly/folly/synchronization/AtomicStruct.h +150 -0
- package/external/folly/folly/synchronization/AtomicUtil-inl.h +482 -0
- package/external/folly/folly/synchronization/AtomicUtil.h +179 -0
- package/external/folly/folly/synchronization/BUCK +418 -0
- package/external/folly/folly/synchronization/Baton.h +419 -0
- package/external/folly/folly/synchronization/CallOnce.h +263 -0
- package/external/folly/folly/synchronization/DelayedInit.h +179 -0
- package/external/folly/folly/synchronization/DistributedMutex-inl.h +1744 -0
- package/external/folly/folly/synchronization/DistributedMutex.cpp +27 -0
- package/external/folly/folly/synchronization/DistributedMutex.h +342 -0
- package/external/folly/folly/synchronization/EventCount.h +200 -0
- package/external/folly/folly/synchronization/FlatCombining.h +629 -0
- package/external/folly/folly/synchronization/Hazptr-fwd.h +217 -0
- package/external/folly/folly/synchronization/Hazptr.cpp +36 -0
- package/external/folly/folly/synchronization/Hazptr.h +209 -0
- package/external/folly/folly/synchronization/HazptrDomain.cpp +68 -0
- package/external/folly/folly/synchronization/HazptrDomain.h +832 -0
- package/external/folly/folly/synchronization/HazptrHolder.h +431 -0
- package/external/folly/folly/synchronization/HazptrObj.h +533 -0
- package/external/folly/folly/synchronization/HazptrObjLinked.h +315 -0
- package/external/folly/folly/synchronization/HazptrRec.h +68 -0
- package/external/folly/folly/synchronization/HazptrThrLocal.h +180 -0
- package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.cpp +46 -0
- package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.h +25 -0
- package/external/folly/folly/synchronization/Latch.h +160 -0
- package/external/folly/folly/synchronization/LifoSem.h +767 -0
- package/external/folly/folly/synchronization/Lock.h +887 -0
- package/external/folly/folly/synchronization/MicroSpinLock.h +154 -0
- package/external/folly/folly/synchronization/NativeSemaphore.h +187 -0
- package/external/folly/folly/synchronization/ParkingLot.cpp +37 -0
- package/external/folly/folly/synchronization/ParkingLot.h +330 -0
- package/external/folly/folly/synchronization/PicoSpinLock.h +167 -0
- package/external/folly/folly/synchronization/RWSpinLock.h +549 -0
- package/external/folly/folly/synchronization/Rcu.cpp +26 -0
- package/external/folly/folly/synchronization/Rcu.h +553 -0
- package/external/folly/folly/synchronization/RelaxedAtomic.h +336 -0
- package/external/folly/folly/synchronization/SanitizeThread.cpp +141 -0
- package/external/folly/folly/synchronization/SanitizeThread.h +166 -0
- package/external/folly/folly/synchronization/SaturatingSemaphore.h +324 -0
- package/external/folly/folly/synchronization/SmallLocks.h +36 -0
- package/external/folly/folly/synchronization/ThrottledLifoSem.h +362 -0
- package/external/folly/folly/synchronization/WaitOptions.cpp +25 -0
- package/external/folly/folly/synchronization/WaitOptions.h +75 -0
- package/external/folly/folly/synchronization/detail/AtomicUtils.h +59 -0
- package/external/folly/folly/synchronization/detail/BUCK +104 -0
- package/external/folly/folly/synchronization/detail/Hardware.cpp +192 -0
- package/external/folly/folly/synchronization/detail/Hardware.h +75 -0
- package/external/folly/folly/synchronization/detail/HazptrUtils.h +339 -0
- package/external/folly/folly/synchronization/detail/InlineFunctionRef.h +229 -0
- package/external/folly/folly/synchronization/detail/Sleeper.cpp +27 -0
- package/external/folly/folly/synchronization/detail/Sleeper.h +62 -0
- package/external/folly/folly/synchronization/detail/Spin.h +96 -0
- package/external/folly/folly/synchronization/detail/ThreadCachedLists.h +174 -0
- package/external/folly/folly/synchronization/detail/ThreadCachedReaders.h +189 -0
- package/external/folly/folly/synchronization/detail/ThreadCachedTag.h +26 -0
- package/external/folly/folly/synchronization/detail/test/BUCK +28 -0
- package/external/folly/folly/synchronization/detail/test/HardwareTest.cpp +74 -0
- package/external/folly/folly/synchronization/detail/test/InlineFunctionRefTest.cpp +286 -0
- package/external/folly/folly/synchronization/example/BUCK +27 -0
- package/external/folly/folly/synchronization/example/HazptrLockFreeLIFO.h +88 -0
- package/external/folly/folly/synchronization/example/HazptrSWMRSet.h +133 -0
- package/external/folly/folly/synchronization/example/HazptrWideCAS.h +62 -0
- package/external/folly/folly/synchronization/test/AtomicNotificationTest.cpp +236 -0
- package/external/folly/folly/synchronization/test/AtomicRefTest.cpp +170 -0
- package/external/folly/folly/synchronization/test/AtomicStructTest.cpp +65 -0
- package/external/folly/folly/synchronization/test/AtomicUtilBench.cpp +457 -0
- package/external/folly/folly/synchronization/test/AtomicUtilTest.cpp +650 -0
- package/external/folly/folly/synchronization/test/BUCK +495 -0
- package/external/folly/folly/synchronization/test/Barrier.h +52 -0
- package/external/folly/folly/synchronization/test/BarrierTest.cpp +56 -0
- package/external/folly/folly/synchronization/test/BatonBenchmark.cpp +77 -0
- package/external/folly/folly/synchronization/test/BatonTest.cpp +164 -0
- package/external/folly/folly/synchronization/test/BatonTestHelpers.h +118 -0
- package/external/folly/folly/synchronization/test/CallOnceBenchmark.cpp +72 -0
- package/external/folly/folly/synchronization/test/CallOnceTest.cpp +153 -0
- package/external/folly/folly/synchronization/test/DelayedInitTest.cpp +281 -0
- package/external/folly/folly/synchronization/test/DistributedMutexTest.cpp +2074 -0
- package/external/folly/folly/synchronization/test/EventCountTest.cpp +124 -0
- package/external/folly/folly/synchronization/test/FlatCombiningBenchmark.cpp +1789 -0
- package/external/folly/folly/synchronization/test/FlatCombiningExamples.h +222 -0
- package/external/folly/folly/synchronization/test/FlatCombiningTest.cpp +121 -0
- package/external/folly/folly/synchronization/test/FlatCombiningTestHelpers.h +227 -0
- package/external/folly/folly/synchronization/test/HazptrTest.cpp +1689 -0
- package/external/folly/folly/synchronization/test/LatchTest.cpp +224 -0
- package/external/folly/folly/synchronization/test/LifoSemBench.cpp +185 -0
- package/external/folly/folly/synchronization/test/LifoSemTests.cpp +353 -0
- package/external/folly/folly/synchronization/test/LockTest.cpp +1239 -0
- package/external/folly/folly/synchronization/test/NativeSemaphoreTest.cpp +37 -0
- package/external/folly/folly/synchronization/test/ParkingLotBenchmark.cpp +239 -0
- package/external/folly/folly/synchronization/test/ParkingLotTest.cpp +170 -0
- package/external/folly/folly/synchronization/test/RWSpinLockTest.cpp +235 -0
- package/external/folly/folly/synchronization/test/RcuBench.cpp +66 -0
- package/external/folly/folly/synchronization/test/RcuTest.cpp +330 -0
- package/external/folly/folly/synchronization/test/RelaxedAtomicTest.cpp +389 -0
- package/external/folly/folly/synchronization/test/SaturatingSemaphoreTest.cpp +166 -0
- package/external/folly/folly/synchronization/test/Semaphore.h +242 -0
- package/external/folly/folly/synchronization/test/SemaphoreTest.cpp +271 -0
- package/external/folly/folly/synchronization/test/SmallLocksBenchmark.cpp +1296 -0
- package/external/folly/folly/synchronization/test/SmallLocksTest.cpp +510 -0
- package/external/folly/folly/synchronization/test/ThreadCachedEpochBench.h +67 -0
- package/external/folly/folly/synchronization/test/ThreadCachedReadersBench.cpp +42 -0
- package/external/folly/folly/synchronization/test/ThreadCachedReadersTest.cpp +52 -0
- package/external/folly/folly/synchronization/test/ThrottledLifoSemTest.cpp +243 -0
- package/external/folly/folly/system/AtFork.cpp +205 -0
- package/external/folly/folly/system/AtFork.h +116 -0
- package/external/folly/folly/system/AuxVector.h +198 -0
- package/external/folly/folly/system/BUCK +144 -0
- package/external/folly/folly/system/EnvUtil.cpp +93 -0
- package/external/folly/folly/system/EnvUtil.h +113 -0
- package/external/folly/folly/system/HardwareConcurrency.cpp +39 -0
- package/external/folly/folly/system/HardwareConcurrency.h +23 -0
- package/external/folly/folly/system/MemoryMapping.cpp +477 -0
- package/external/folly/folly/system/MemoryMapping.h +287 -0
- package/external/folly/folly/system/Pid.cpp +87 -0
- package/external/folly/folly/system/Pid.h +34 -0
- package/external/folly/folly/system/Shell.cpp +33 -0
- package/external/folly/folly/system/Shell.h +93 -0
- package/external/folly/folly/system/ThreadId.cpp +89 -0
- package/external/folly/folly/system/ThreadId.h +62 -0
- package/external/folly/folly/system/ThreadName.cpp +330 -0
- package/external/folly/folly/system/ThreadName.h +72 -0
- package/external/folly/folly/system/test/AtForkTest.cpp +309 -0
- package/external/folly/folly/system/test/AuxVectorTest.cpp +55 -0
- package/external/folly/folly/system/test/BUCK +120 -0
- package/external/folly/folly/system/test/EnvUtilSubprocess.cpp +26 -0
- package/external/folly/folly/system/test/EnvUtilTest.cpp +197 -0
- package/external/folly/folly/system/test/MemoryMappingTest.cpp +179 -0
- package/external/folly/folly/system/test/PidTest.cpp +46 -0
- package/external/folly/folly/system/test/ShellTest.cpp +66 -0
- package/external/folly/folly/system/test/ThreadIdTest.cpp +114 -0
- package/external/folly/folly/system/test/ThreadNameTest.cpp +85 -0
- package/external/folly/folly.vcxitems +164 -0
- package/external/folly/static/logo.svg +1 -0
- package/external/folly/sync-config.json +8 -0
- package/just-task.js +13 -2
- package/package.json +7 -7
- package/template/cpp-lib/proj/MyLib.sln +0 -33
- package/template/cs-lib/proj/MyLib.sln +0 -33
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
- package/templates/cpp-app/windows/MyApp.sln +0 -33
- package/templates/cpp-lib/example/metro.config.js +30 -4
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
- package/templates/cpp-lib/windows/MyLib.sln +0 -33
- package/Folly/Folly.vcxproj +0 -378
- package/Folly/Folly.vcxproj.filters +0 -558
- package/fmt/fmt.vcxproj +0 -153
- package/fmt/fmt.vcxproj.filters +0 -59
- package/fmt/pch.cpp +0 -4
- package/fmt/pch.h +0 -2
- /package/{fmt → external/fmt}/cgmanifest.json +0 -0
- /package/{Folly → external/folly}/Folly.natvis +0 -0
- /package/{Folly → external/folly}/cgmanifest.json +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/ConstexprMath.h +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/Conv.cpp +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/chrono/Hardware.h +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/concurrency/CacheLocality.cpp +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/dynamic-inl.h +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/json.cpp +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/SafeAssert.h +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.cpp +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.h +0 -0
- /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/portability/Unistd.cpp +0 -0
|
@@ -0,0 +1,2543 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#include <folly/container/F14Map.h>
|
|
18
|
+
|
|
19
|
+
#include <algorithm>
|
|
20
|
+
#include <chrono>
|
|
21
|
+
#include <random>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <type_traits>
|
|
24
|
+
#include <typeinfo>
|
|
25
|
+
#include <unordered_map>
|
|
26
|
+
|
|
27
|
+
#include <glog/logging.h>
|
|
28
|
+
|
|
29
|
+
#include <folly/Benchmark.h>
|
|
30
|
+
#include <folly/Conv.h>
|
|
31
|
+
#include <folly/FBString.h>
|
|
32
|
+
#include <folly/Portability.h>
|
|
33
|
+
#include <folly/container/test/F14TestUtil.h>
|
|
34
|
+
#include <folly/container/test/TrackingTypes.h>
|
|
35
|
+
#include <folly/hash/Hash.h>
|
|
36
|
+
#include <folly/portability/GTest.h>
|
|
37
|
+
#include <folly/test/TestUtils.h>
|
|
38
|
+
|
|
39
|
+
using namespace folly;
|
|
40
|
+
using namespace folly::f14;
|
|
41
|
+
using namespace folly::string_piece_literals;
|
|
42
|
+
using namespace folly::test;
|
|
43
|
+
|
|
44
|
+
static constexpr bool kFallback = folly::f14::detail::getF14IntrinsicsMode() ==
|
|
45
|
+
folly::f14::detail::F14IntrinsicsMode::None;
|
|
46
|
+
|
|
47
|
+
template <typename T>
|
|
48
|
+
void runSanityChecks(T const& t) {
|
|
49
|
+
(void)t;
|
|
50
|
+
#if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE
|
|
51
|
+
F14TableStats::compute(t);
|
|
52
|
+
#endif
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
template <template <typename, typename, typename, typename, typename>
|
|
56
|
+
class TMap>
|
|
57
|
+
void testCustomSwap() {
|
|
58
|
+
using std::swap;
|
|
59
|
+
|
|
60
|
+
TMap<
|
|
61
|
+
int,
|
|
62
|
+
int,
|
|
63
|
+
DefaultHasher<int>,
|
|
64
|
+
DefaultKeyEqual<int>,
|
|
65
|
+
SwapTrackingAlloc<std::pair<int const, int>>>
|
|
66
|
+
m0, m1;
|
|
67
|
+
resetTracking();
|
|
68
|
+
swap(m0, m1);
|
|
69
|
+
|
|
70
|
+
EXPECT_EQ(0, Tracked<0>::counts().dist(Counts{0, 0, 0, 0}));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
TEST(F14Map, customSwap) {
|
|
74
|
+
testCustomSwap<F14ValueMap>();
|
|
75
|
+
testCustomSwap<F14NodeMap>();
|
|
76
|
+
testCustomSwap<F14VectorMap>();
|
|
77
|
+
testCustomSwap<F14FastMap>();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
template <
|
|
81
|
+
template <typename, typename, typename, typename, typename>
|
|
82
|
+
class TMap,
|
|
83
|
+
typename K,
|
|
84
|
+
typename V>
|
|
85
|
+
void runAllocatedMemorySizeTest() {
|
|
86
|
+
using A = SwapTrackingAlloc<std::pair<const K, V>>;
|
|
87
|
+
|
|
88
|
+
resetTracking();
|
|
89
|
+
{
|
|
90
|
+
TMap<K, V, DefaultHasher<K>, DefaultKeyEqual<K>, A> m;
|
|
91
|
+
|
|
92
|
+
// if F14 intrinsics are not available then we fall back to using
|
|
93
|
+
// std::unordered_map underneath, but in that case the allocation
|
|
94
|
+
// info is only best effort
|
|
95
|
+
if (!kFallback) {
|
|
96
|
+
EXPECT_EQ(testAllocatedMemorySize(), 0);
|
|
97
|
+
EXPECT_EQ(m.getAllocatedMemorySize(), 0);
|
|
98
|
+
}
|
|
99
|
+
auto emptyMapAllocatedMemorySize = testAllocatedMemorySize();
|
|
100
|
+
auto emptyMapAllocatedBlockCount = testAllocatedBlockCount();
|
|
101
|
+
|
|
102
|
+
for (size_t i = 0; i < 1000; ++i) {
|
|
103
|
+
m.insert(std::make_pair(to<K>(i), V{}));
|
|
104
|
+
m.erase(to<K>(i / 10 + 2));
|
|
105
|
+
if (!kFallback) {
|
|
106
|
+
EXPECT_EQ(testAllocatedMemorySize(), m.getAllocatedMemorySize());
|
|
107
|
+
}
|
|
108
|
+
EXPECT_GE(m.getAllocatedMemorySize(), sizeof(std::pair<K, V>) * m.size());
|
|
109
|
+
std::size_t size = 0;
|
|
110
|
+
std::size_t count = 0;
|
|
111
|
+
m.visitAllocationClasses([&](std::size_t, std::size_t) mutable {});
|
|
112
|
+
m.visitAllocationClasses([&](std::size_t bytes, std::size_t n) {
|
|
113
|
+
size += bytes * n;
|
|
114
|
+
count += n;
|
|
115
|
+
});
|
|
116
|
+
if (!kFallback) {
|
|
117
|
+
EXPECT_EQ(testAllocatedMemorySize(), size);
|
|
118
|
+
EXPECT_EQ(testAllocatedBlockCount(), count);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
m = decltype(m){};
|
|
123
|
+
EXPECT_EQ(testAllocatedMemorySize(), emptyMapAllocatedMemorySize);
|
|
124
|
+
EXPECT_EQ(testAllocatedBlockCount(), emptyMapAllocatedBlockCount);
|
|
125
|
+
|
|
126
|
+
m.reserve(5);
|
|
127
|
+
EXPECT_GT(testAllocatedMemorySize(), 0);
|
|
128
|
+
m = {};
|
|
129
|
+
if (!kFallback) {
|
|
130
|
+
EXPECT_GT(testAllocatedMemorySize(), 0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
EXPECT_EQ(testAllocatedMemorySize(), 0);
|
|
134
|
+
EXPECT_EQ(testAllocatedBlockCount(), 0);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
template <typename K, typename V>
|
|
138
|
+
void runAllocatedMemorySizeTests() {
|
|
139
|
+
runAllocatedMemorySizeTest<F14ValueMap, K, V>();
|
|
140
|
+
runAllocatedMemorySizeTest<F14NodeMap, K, V>();
|
|
141
|
+
runAllocatedMemorySizeTest<F14VectorMap, K, V>();
|
|
142
|
+
runAllocatedMemorySizeTest<F14FastMap, K, V>();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
TEST(F14Map, getAllocatedMemorySize) {
|
|
146
|
+
runAllocatedMemorySizeTests<bool, bool>();
|
|
147
|
+
runAllocatedMemorySizeTests<int, int>();
|
|
148
|
+
runAllocatedMemorySizeTests<bool, std::string>();
|
|
149
|
+
runAllocatedMemorySizeTests<double, std::string>();
|
|
150
|
+
runAllocatedMemorySizeTests<std::string, int>();
|
|
151
|
+
runAllocatedMemorySizeTests<std::string, std::string>();
|
|
152
|
+
runAllocatedMemorySizeTests<fbstring, long>();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
template <typename M>
|
|
156
|
+
void runVisitContiguousRangesTest(int n) {
|
|
157
|
+
M map;
|
|
158
|
+
|
|
159
|
+
for (int i = 0; i < n; ++i) {
|
|
160
|
+
makeUnpredictable(i);
|
|
161
|
+
map[i] = i;
|
|
162
|
+
map.erase(i / 2);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
std::unordered_map<uintptr_t, bool> visited;
|
|
166
|
+
for (auto& entry : map) {
|
|
167
|
+
visited[reinterpret_cast<uintptr_t>(&entry)] = false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
map.visitContiguousRanges([&](auto b, auto e) {
|
|
171
|
+
for (auto i = b; i != e; ++i) {
|
|
172
|
+
auto iter = visited.find(reinterpret_cast<uintptr_t>(i));
|
|
173
|
+
ASSERT_TRUE(iter != visited.end());
|
|
174
|
+
EXPECT_FALSE(iter->second);
|
|
175
|
+
iter->second = true;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// ensure no entries were skipped
|
|
180
|
+
for (auto& e : visited) {
|
|
181
|
+
EXPECT_TRUE(e.second);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
template <typename M>
|
|
186
|
+
void runVisitContiguousRangesTest() {
|
|
187
|
+
runVisitContiguousRangesTest<M>(0); // empty
|
|
188
|
+
runVisitContiguousRangesTest<M>(5); // single chunk
|
|
189
|
+
runVisitContiguousRangesTest<M>(1000); // many chunks
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
TEST(F14ValueMap, visitContiguousRanges) {
|
|
193
|
+
runVisitContiguousRangesTest<F14ValueMap<int, int>>();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
TEST(F14NodeMap, visitContiguousRanges) {
|
|
197
|
+
runVisitContiguousRangesTest<F14NodeMap<int, int>>();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
TEST(F14VectorMap, visitContiguousRanges) {
|
|
201
|
+
runVisitContiguousRangesTest<F14VectorMap<int, int>>();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
TEST(F14FastMap, visitContiguousRanges) {
|
|
205
|
+
runVisitContiguousRangesTest<F14FastMap<int, int>>();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
#if FOLLY_HAS_MEMORY_RESOURCE
|
|
209
|
+
TEST(F14Map, pmrEmpty) {
|
|
210
|
+
pmr::F14ValueMap<int, int> m1;
|
|
211
|
+
pmr::F14NodeMap<int, int> m2;
|
|
212
|
+
pmr::F14VectorMap<int, int> m3;
|
|
213
|
+
pmr::F14FastMap<int, int> m4;
|
|
214
|
+
EXPECT_TRUE(m1.empty() && m2.empty() && m3.empty() && m4.empty());
|
|
215
|
+
}
|
|
216
|
+
#endif
|
|
217
|
+
|
|
218
|
+
namespace {
|
|
219
|
+
struct NestedHash {
|
|
220
|
+
template <typename N>
|
|
221
|
+
std::size_t operator()(N const& v) const;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
template <template <class...> class TMap>
|
|
225
|
+
struct Nested {
|
|
226
|
+
std::unique_ptr<TMap<Nested, int, NestedHash>> map_;
|
|
227
|
+
|
|
228
|
+
explicit Nested(int depth)
|
|
229
|
+
: map_(std::make_unique<TMap<Nested, int, NestedHash>>()) {
|
|
230
|
+
if (depth > 0) {
|
|
231
|
+
map_->emplace(Nested{depth - 1}, 0);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
template <typename N>
|
|
237
|
+
std::size_t NestedHash::operator()(N const& v) const {
|
|
238
|
+
std::size_t rv = 0;
|
|
239
|
+
for (auto& kv : *v.map_) {
|
|
240
|
+
rv += Hash{}(operator()(kv.first), kv.second);
|
|
241
|
+
}
|
|
242
|
+
return Hash{}(rv);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
template <template <class...> class TMap>
|
|
246
|
+
bool operator==(Nested<TMap> const& lhs, Nested<TMap> const& rhs) {
|
|
247
|
+
return *lhs.map_ == *rhs.map_;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
template <template <class...> class TMap>
|
|
251
|
+
bool operator!=(Nested<TMap> const& lhs, Nested<TMap> const& rhs) {
|
|
252
|
+
return !(lhs == rhs);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
template <template <class...> class TMap>
|
|
256
|
+
void testNestedMapEquality() {
|
|
257
|
+
auto n1 = Nested<TMap>(100);
|
|
258
|
+
auto n2 = Nested<TMap>(100);
|
|
259
|
+
auto n3 = Nested<TMap>(99);
|
|
260
|
+
EXPECT_TRUE(n1 == n1);
|
|
261
|
+
EXPECT_TRUE(n1 == n2);
|
|
262
|
+
EXPECT_FALSE(n1 == n3);
|
|
263
|
+
EXPECT_FALSE(n1 != n1);
|
|
264
|
+
EXPECT_FALSE(n1 != n2);
|
|
265
|
+
EXPECT_TRUE(n1 != n3);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
template <template <class...> class TMap>
|
|
269
|
+
void testEqualityRefinement() {
|
|
270
|
+
TMap<std::pair<int, int>, int, HashFirst, EqualFirst> m1;
|
|
271
|
+
TMap<std::pair<int, int>, int, HashFirst, EqualFirst> m2;
|
|
272
|
+
m1[std::make_pair(0, 0)] = 0;
|
|
273
|
+
m1[std::make_pair(1, 1)] = 1;
|
|
274
|
+
EXPECT_FALSE(m1.insert(std::make_pair(std::make_pair(0, 2), 0)).second);
|
|
275
|
+
EXPECT_EQ(m1.size(), 2);
|
|
276
|
+
EXPECT_EQ(m1.count(std::make_pair(0, 10)), 1);
|
|
277
|
+
for (auto& kv : m1) {
|
|
278
|
+
m2.emplace(std::make_pair(kv.first.first, kv.first.second + 1), kv.second);
|
|
279
|
+
}
|
|
280
|
+
EXPECT_EQ(m1.size(), m2.size());
|
|
281
|
+
for (auto& kv : m1) {
|
|
282
|
+
EXPECT_EQ(m2.count(kv.first), 1);
|
|
283
|
+
}
|
|
284
|
+
EXPECT_FALSE(m1 == m2);
|
|
285
|
+
EXPECT_TRUE(m1 != m2);
|
|
286
|
+
}
|
|
287
|
+
} // namespace
|
|
288
|
+
|
|
289
|
+
TEST(F14Map, nestedMapEquality) {
|
|
290
|
+
testNestedMapEquality<F14ValueMap>();
|
|
291
|
+
testNestedMapEquality<F14NodeMap>();
|
|
292
|
+
testNestedMapEquality<F14VectorMap>();
|
|
293
|
+
testNestedMapEquality<F14FastMap>();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
TEST(F14Map, equalityRefinement) {
|
|
297
|
+
testEqualityRefinement<F14ValueMap>();
|
|
298
|
+
testEqualityRefinement<F14NodeMap>();
|
|
299
|
+
testEqualityRefinement<F14VectorMap>();
|
|
300
|
+
testEqualityRefinement<F14FastMap>();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
namespace {
|
|
304
|
+
std::string s(char const* p) {
|
|
305
|
+
return p;
|
|
306
|
+
}
|
|
307
|
+
} // namespace
|
|
308
|
+
|
|
309
|
+
template <typename T>
|
|
310
|
+
void runSimple() {
|
|
311
|
+
T h;
|
|
312
|
+
|
|
313
|
+
EXPECT_EQ(h.size(), 0);
|
|
314
|
+
h.reserve(0);
|
|
315
|
+
std::vector<std::pair<std::string const, std::string>> v(
|
|
316
|
+
{{"abc", "first"}, {"abc", "second"}});
|
|
317
|
+
h.insert(v.begin(), v.begin());
|
|
318
|
+
EXPECT_EQ(h.size(), 0);
|
|
319
|
+
if (!kFallback) {
|
|
320
|
+
EXPECT_EQ(h.bucket_count(), 0);
|
|
321
|
+
}
|
|
322
|
+
h.insert(v.begin(), v.end());
|
|
323
|
+
EXPECT_EQ(h.size(), 1);
|
|
324
|
+
EXPECT_EQ(h["abc"], s("first"));
|
|
325
|
+
h = T{};
|
|
326
|
+
if (!kFallback) {
|
|
327
|
+
EXPECT_EQ(h.bucket_count(), 0);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
h.insert(std::make_pair(s("abc"), s("ABC")));
|
|
331
|
+
EXPECT_TRUE(h.find(s("def")) == h.end());
|
|
332
|
+
EXPECT_FALSE(h.find(s("abc")) == h.end());
|
|
333
|
+
EXPECT_EQ(h[s("abc")], s("ABC"));
|
|
334
|
+
h[s("ghi")] = s("GHI");
|
|
335
|
+
EXPECT_EQ(h.size(), 2);
|
|
336
|
+
h.erase(h.find(s("abc")));
|
|
337
|
+
EXPECT_EQ(h.size(), 1);
|
|
338
|
+
|
|
339
|
+
T h2(std::move(h));
|
|
340
|
+
EXPECT_EQ(h.size(), 0);
|
|
341
|
+
EXPECT_TRUE(h.begin() == h.end());
|
|
342
|
+
EXPECT_EQ(h2.size(), 1);
|
|
343
|
+
|
|
344
|
+
EXPECT_TRUE(h2.find(s("abc")) == h2.end());
|
|
345
|
+
EXPECT_EQ(h2.begin()->first, s("ghi"));
|
|
346
|
+
{
|
|
347
|
+
auto i = h2.begin();
|
|
348
|
+
EXPECT_FALSE(i == h2.end());
|
|
349
|
+
++i;
|
|
350
|
+
EXPECT_TRUE(i == h2.end());
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
T h3;
|
|
354
|
+
h3.try_emplace(s("xxx"));
|
|
355
|
+
h3.insert_or_assign(s("yyy"), s("YYY"));
|
|
356
|
+
h3 = std::move(h2);
|
|
357
|
+
EXPECT_EQ(h2.size(), 0);
|
|
358
|
+
EXPECT_EQ(h3.size(), 1);
|
|
359
|
+
EXPECT_TRUE(h3.find(s("xxx")) == h3.end());
|
|
360
|
+
|
|
361
|
+
for (uint64_t i = 0; i < 1000; ++i) {
|
|
362
|
+
h[to<std::string>(i * i * i)] = s("x");
|
|
363
|
+
EXPECT_EQ(h.size(), i + 1);
|
|
364
|
+
}
|
|
365
|
+
{
|
|
366
|
+
using std::swap;
|
|
367
|
+
swap(h, h2);
|
|
368
|
+
}
|
|
369
|
+
for (uint64_t i = 0; i < 1000; ++i) {
|
|
370
|
+
EXPECT_TRUE(h2.find(to<std::string>(i * i * i)) != h2.end());
|
|
371
|
+
EXPECT_EQ(
|
|
372
|
+
h2.find(to<std::string>(i * i * i))->first, to<std::string>(i * i * i));
|
|
373
|
+
EXPECT_TRUE(h2.find(to<std::string>(i * i * i + 2)) == h2.end());
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
T h4{h2};
|
|
377
|
+
EXPECT_EQ(h2.size(), 1000);
|
|
378
|
+
EXPECT_EQ(h4.size(), 1000);
|
|
379
|
+
|
|
380
|
+
T h5{std::move(h2)};
|
|
381
|
+
T h6;
|
|
382
|
+
h6 = h4;
|
|
383
|
+
T h7 = h4;
|
|
384
|
+
T h8({{s("abc"), s("ABC")}, {s("def"), s("DEF")}});
|
|
385
|
+
T h9({{s("abc"), s("ABD")}, {s("def"), s("DEF")}});
|
|
386
|
+
EXPECT_EQ(h8.size(), 2);
|
|
387
|
+
EXPECT_EQ(h8.count(s("abc")), 1);
|
|
388
|
+
EXPECT_EQ(h8.count(s("xyz")), 0);
|
|
389
|
+
EXPECT_TRUE(h8.contains(s("abc")));
|
|
390
|
+
EXPECT_FALSE(h8.contains(s("xyz")));
|
|
391
|
+
|
|
392
|
+
EXPECT_TRUE(h7 != h8);
|
|
393
|
+
EXPECT_TRUE(h8 != h9);
|
|
394
|
+
|
|
395
|
+
h8 = std::move(h7);
|
|
396
|
+
// h2 and h7 are moved from, h4, h5, h6, and h8 should be identical
|
|
397
|
+
|
|
398
|
+
EXPECT_TRUE(h4 == h8);
|
|
399
|
+
|
|
400
|
+
EXPECT_TRUE(h2.empty());
|
|
401
|
+
EXPECT_TRUE(h7.empty());
|
|
402
|
+
for (uint64_t i = 0; i < 1000; ++i) {
|
|
403
|
+
auto k = to<std::string>(i * i * i);
|
|
404
|
+
EXPECT_EQ(h4.count(k), 1);
|
|
405
|
+
EXPECT_EQ(h5.count(k), 1);
|
|
406
|
+
EXPECT_EQ(h6.count(k), 1);
|
|
407
|
+
EXPECT_EQ(h8.count(k), 1);
|
|
408
|
+
EXPECT_TRUE(h4.contains(k));
|
|
409
|
+
EXPECT_TRUE(h5.contains(k));
|
|
410
|
+
EXPECT_TRUE(h6.contains(k));
|
|
411
|
+
EXPECT_TRUE(h8.contains(k));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
EXPECT_TRUE(h2 == h7);
|
|
415
|
+
EXPECT_TRUE(h4 != h7);
|
|
416
|
+
|
|
417
|
+
EXPECT_EQ(h3.at(s("ghi")), s("GHI"));
|
|
418
|
+
EXPECT_THROW(h3.at(s("abc")), std::out_of_range);
|
|
419
|
+
|
|
420
|
+
h8.clear();
|
|
421
|
+
h8.emplace(s("abc"), s("ABC"));
|
|
422
|
+
EXPECT_GE(h8.bucket_count(), 1);
|
|
423
|
+
h8 = {};
|
|
424
|
+
EXPECT_GE(h8.bucket_count(), 1);
|
|
425
|
+
h9 = {{s("abc"), s("ABD")}, {s("def"), s("DEF")}};
|
|
426
|
+
EXPECT_TRUE(h8.empty());
|
|
427
|
+
EXPECT_EQ(h9.size(), 2);
|
|
428
|
+
|
|
429
|
+
auto expectH8 = [&h8](T& ref) { EXPECT_EQ(&ref, &h8); };
|
|
430
|
+
expectH8((h8 = h2));
|
|
431
|
+
expectH8((h8 = std::move(h2)));
|
|
432
|
+
expectH8((h8 = {}));
|
|
433
|
+
|
|
434
|
+
runSanityChecks(h);
|
|
435
|
+
runSanityChecks(h2);
|
|
436
|
+
runSanityChecks(h3);
|
|
437
|
+
runSanityChecks(h4);
|
|
438
|
+
runSanityChecks(h5);
|
|
439
|
+
runSanityChecks(h6);
|
|
440
|
+
runSanityChecks(h7);
|
|
441
|
+
runSanityChecks(h8);
|
|
442
|
+
runSanityChecks(h9);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
template <typename T>
|
|
446
|
+
void runEraseWhileIterating() {
|
|
447
|
+
constexpr int kNumElements = 1000;
|
|
448
|
+
|
|
449
|
+
// mul and kNumElements should be relatively prime
|
|
450
|
+
for (int mul : {1, 3, 17, 137, kNumElements - 1}) {
|
|
451
|
+
for (int interval : {1, 3, 5, kNumElements / 2}) {
|
|
452
|
+
T h;
|
|
453
|
+
for (auto i = 0; i < kNumElements; ++i) {
|
|
454
|
+
EXPECT_TRUE(h.emplace((i * mul) % kNumElements, i).second);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
int sum = 0;
|
|
458
|
+
for (auto it = h.begin(); it != h.end();) {
|
|
459
|
+
sum += it->second;
|
|
460
|
+
if (it->first % interval == 0) {
|
|
461
|
+
it = h.erase(it);
|
|
462
|
+
} else {
|
|
463
|
+
++it;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
EXPECT_EQ(kNumElements * (kNumElements - 1) / 2, sum);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
template <typename T>
|
|
472
|
+
void runRehash() {
|
|
473
|
+
unsigned n = 10000;
|
|
474
|
+
T h;
|
|
475
|
+
auto b = h.bucket_count();
|
|
476
|
+
for (unsigned i = 0; i < n; ++i) {
|
|
477
|
+
h.insert(std::make_pair(to<std::string>(i), s("")));
|
|
478
|
+
if (b != h.bucket_count()) {
|
|
479
|
+
runSanityChecks(h);
|
|
480
|
+
b = h.bucket_count();
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
EXPECT_EQ(h.size(), n);
|
|
484
|
+
runSanityChecks(h);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// T should be a map from uint64_t to Tracked<1> that uses SwapTrackingAlloc
|
|
488
|
+
template <typename T>
|
|
489
|
+
void runRandom() {
|
|
490
|
+
using R = std::unordered_map<uint64_t, Tracked<2>>;
|
|
491
|
+
|
|
492
|
+
resetTracking();
|
|
493
|
+
|
|
494
|
+
std::mt19937_64 gen(0);
|
|
495
|
+
std::uniform_int_distribution<> pctDist(0, 100);
|
|
496
|
+
std::uniform_int_distribution<uint64_t> bitsBitsDist(1, 6);
|
|
497
|
+
{
|
|
498
|
+
T t0;
|
|
499
|
+
T t1;
|
|
500
|
+
R r0;
|
|
501
|
+
R r1;
|
|
502
|
+
std::size_t rollbacks = 0;
|
|
503
|
+
std::size_t resizingSmallRollbacks = 0;
|
|
504
|
+
std::size_t resizingLargeRollbacks = 0;
|
|
505
|
+
|
|
506
|
+
for (std::size_t reps = 0; reps < 100000 ||
|
|
507
|
+
(!kFallback &&
|
|
508
|
+
(rollbacks < 10 || resizingSmallRollbacks < 1 ||
|
|
509
|
+
resizingLargeRollbacks < 1));
|
|
510
|
+
++reps) {
|
|
511
|
+
if (!kFallback && pctDist(gen) < 20) {
|
|
512
|
+
// 10% chance allocator will fail after 0 to 3 more allocations.
|
|
513
|
+
// Skip rollback tests for fallback impl because gcc 4.9's
|
|
514
|
+
// libstdc++ doesn't pass them.
|
|
515
|
+
limitTestAllocations(gen() & 3);
|
|
516
|
+
} else {
|
|
517
|
+
unlimitTestAllocations();
|
|
518
|
+
}
|
|
519
|
+
bool leakCheckOnly = false;
|
|
520
|
+
|
|
521
|
+
// discardBits will be from 0 to 62
|
|
522
|
+
auto discardBits = (uint64_t{1} << bitsBitsDist(gen)) - 2;
|
|
523
|
+
auto k = gen() >> discardBits;
|
|
524
|
+
auto v = gen();
|
|
525
|
+
auto pct = pctDist(gen);
|
|
526
|
+
|
|
527
|
+
try {
|
|
528
|
+
EXPECT_EQ(t0.empty(), r0.empty());
|
|
529
|
+
EXPECT_EQ(t0.size(), r0.size());
|
|
530
|
+
EXPECT_EQ(2, Tracked<0>::counts().liveCount());
|
|
531
|
+
EXPECT_EQ(t0.size() + t1.size(), Tracked<1>::counts().liveCount());
|
|
532
|
+
EXPECT_EQ(r0.size() + r1.size(), Tracked<2>::counts().liveCount());
|
|
533
|
+
if (pct < 15) {
|
|
534
|
+
// insert
|
|
535
|
+
auto t = t0.insert(std::make_pair(k, v));
|
|
536
|
+
auto r = r0.insert(std::make_pair(k, v));
|
|
537
|
+
EXPECT_EQ(t.first->first, r.first->first);
|
|
538
|
+
EXPECT_EQ(t.first->second.val_, r.first->second.val_);
|
|
539
|
+
EXPECT_EQ(t.second, r.second);
|
|
540
|
+
} else if (pct < 25) {
|
|
541
|
+
// emplace
|
|
542
|
+
auto t = t0.emplace(k, v);
|
|
543
|
+
auto r = r0.emplace(k, v);
|
|
544
|
+
EXPECT_EQ(t.first->first, r.first->first);
|
|
545
|
+
EXPECT_EQ(t.first->second.val_, r.first->second.val_);
|
|
546
|
+
EXPECT_EQ(t.second, r.second);
|
|
547
|
+
} else if (pct < 30) {
|
|
548
|
+
// bulk insert
|
|
549
|
+
leakCheckOnly = true;
|
|
550
|
+
t0.insert(t1.begin(), t1.end());
|
|
551
|
+
r0.insert(r1.begin(), r1.end());
|
|
552
|
+
} else if (pct < 40) {
|
|
553
|
+
// erase by key
|
|
554
|
+
auto t = t0.erase(k);
|
|
555
|
+
auto r = r0.erase(k);
|
|
556
|
+
EXPECT_EQ(t, r);
|
|
557
|
+
} else if (pct < 47) {
|
|
558
|
+
// erase by iterator
|
|
559
|
+
if (t0.size() > 0) {
|
|
560
|
+
auto r = r0.find(k);
|
|
561
|
+
if (r == r0.end()) {
|
|
562
|
+
r = r0.begin();
|
|
563
|
+
}
|
|
564
|
+
k = r->first;
|
|
565
|
+
auto t = t0.find(k);
|
|
566
|
+
t = t0.erase(t);
|
|
567
|
+
if (t != t0.end()) {
|
|
568
|
+
EXPECT_NE(t->first, k);
|
|
569
|
+
}
|
|
570
|
+
r = r0.erase(r);
|
|
571
|
+
if (r != r0.end()) {
|
|
572
|
+
EXPECT_NE(r->first, k);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
} else if (pct < 50) {
|
|
576
|
+
// bulk erase
|
|
577
|
+
if (t0.size() > 0) {
|
|
578
|
+
auto r = r0.find(k);
|
|
579
|
+
if (r == r0.end()) {
|
|
580
|
+
r = r0.begin();
|
|
581
|
+
}
|
|
582
|
+
k = r->first;
|
|
583
|
+
auto t = t0.find(k);
|
|
584
|
+
auto firstt = t;
|
|
585
|
+
auto lastt = ++t;
|
|
586
|
+
t = t0.erase(firstt, lastt);
|
|
587
|
+
if (t != t0.end()) {
|
|
588
|
+
EXPECT_NE(t->first, k);
|
|
589
|
+
}
|
|
590
|
+
auto firstr = r;
|
|
591
|
+
auto lastr = ++r;
|
|
592
|
+
r = r0.erase(firstr, lastr);
|
|
593
|
+
if (r != r0.end()) {
|
|
594
|
+
EXPECT_NE(r->first, k);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
} else if (pct < 58) {
|
|
598
|
+
// find
|
|
599
|
+
auto t = t0.find(k);
|
|
600
|
+
auto r = r0.find(k);
|
|
601
|
+
EXPECT_EQ((t == t0.end()), (r == r0.end()));
|
|
602
|
+
if (t != t0.end() && r != r0.end()) {
|
|
603
|
+
EXPECT_EQ(t->first, r->first);
|
|
604
|
+
EXPECT_EQ(t->second.val_, r->second.val_);
|
|
605
|
+
}
|
|
606
|
+
EXPECT_EQ(t0.count(k), r0.count(k));
|
|
607
|
+
// TODO: When std::unordered_map supports c++20:
|
|
608
|
+
// EXPECT_EQ(t0.contains(k), r0.contains(k));
|
|
609
|
+
} else if (pct < 60) {
|
|
610
|
+
// equal_range
|
|
611
|
+
auto t = t0.equal_range(k);
|
|
612
|
+
auto r = r0.equal_range(k);
|
|
613
|
+
EXPECT_EQ((t.first == t.second), (r.first == r.second));
|
|
614
|
+
if (t.first != t.second && r.first != r.second) {
|
|
615
|
+
EXPECT_EQ(t.first->first, r.first->first);
|
|
616
|
+
EXPECT_EQ(t.first->second.val_, r.first->second.val_);
|
|
617
|
+
t.first++;
|
|
618
|
+
r.first++;
|
|
619
|
+
EXPECT_TRUE(t.first == t.second);
|
|
620
|
+
EXPECT_TRUE(r.first == r.second);
|
|
621
|
+
}
|
|
622
|
+
} else if (pct < 65) {
|
|
623
|
+
// iterate
|
|
624
|
+
uint64_t t = 0;
|
|
625
|
+
for (auto& e : t0) {
|
|
626
|
+
t += e.first * 37 + e.second.val_ + 1000;
|
|
627
|
+
}
|
|
628
|
+
uint64_t r = 0;
|
|
629
|
+
for (auto& e : r0) {
|
|
630
|
+
r += e.first * 37 + e.second.val_ + 1000;
|
|
631
|
+
}
|
|
632
|
+
EXPECT_EQ(t, r);
|
|
633
|
+
} else if (pct < 69) {
|
|
634
|
+
// swap
|
|
635
|
+
using std::swap;
|
|
636
|
+
swap(t0, t1);
|
|
637
|
+
swap(r0, r1);
|
|
638
|
+
} else if (pct < 70) {
|
|
639
|
+
// swap
|
|
640
|
+
t0.swap(t1);
|
|
641
|
+
r0.swap(r1);
|
|
642
|
+
} else if (pct < 72) {
|
|
643
|
+
// default construct
|
|
644
|
+
t0.~T();
|
|
645
|
+
new (&t0) T();
|
|
646
|
+
r0.~R();
|
|
647
|
+
new (&r0) R();
|
|
648
|
+
} else if (pct < 74) {
|
|
649
|
+
// default construct with capacity
|
|
650
|
+
std::size_t capacity = k & 0xffff;
|
|
651
|
+
T t(capacity);
|
|
652
|
+
t0 = std::move(t);
|
|
653
|
+
R r(capacity);
|
|
654
|
+
r0 = std::move(r);
|
|
655
|
+
} else if (pct < 80) {
|
|
656
|
+
// bulk iterator construct
|
|
657
|
+
t0 = T{t1.begin(), t1.end()};
|
|
658
|
+
r0 = R{r1.begin(), r1.end()};
|
|
659
|
+
} else if (pct < 82) {
|
|
660
|
+
// initializer list construct
|
|
661
|
+
auto k2 = gen() >> discardBits;
|
|
662
|
+
auto v2 = gen();
|
|
663
|
+
T t({{k, v}, {k2, v}, {k2, v2}});
|
|
664
|
+
t0 = std::move(t);
|
|
665
|
+
R r({{k, v}, {k2, v}, {k2, v2}});
|
|
666
|
+
r0 = std::move(r);
|
|
667
|
+
} else if (pct < 85) {
|
|
668
|
+
// copy construct
|
|
669
|
+
T t(t1);
|
|
670
|
+
t0 = std::move(t);
|
|
671
|
+
R r(r1);
|
|
672
|
+
r0 = std::move(r);
|
|
673
|
+
} else if (pct < 88) {
|
|
674
|
+
// copy construct
|
|
675
|
+
T t(t1, t1.get_allocator());
|
|
676
|
+
t0 = std::move(t);
|
|
677
|
+
R r(r1, r1.get_allocator());
|
|
678
|
+
r0 = std::move(r);
|
|
679
|
+
} else if (pct < 89) {
|
|
680
|
+
// move construct
|
|
681
|
+
t0.~T();
|
|
682
|
+
new (&t0) T(std::move(t1));
|
|
683
|
+
r0.~R();
|
|
684
|
+
new (&r0) R(std::move(r1));
|
|
685
|
+
} else if (pct < 90) {
|
|
686
|
+
// move construct
|
|
687
|
+
t0.~T();
|
|
688
|
+
auto ta = t1.get_allocator();
|
|
689
|
+
new (&t0) T(std::move(t1), ta);
|
|
690
|
+
r0.~R();
|
|
691
|
+
auto ra = r1.get_allocator();
|
|
692
|
+
new (&r0) R(std::move(r1), ra);
|
|
693
|
+
} else if (pct < 94) {
|
|
694
|
+
// copy assign
|
|
695
|
+
leakCheckOnly = true;
|
|
696
|
+
t0 = t1;
|
|
697
|
+
r0 = r1;
|
|
698
|
+
} else if (pct < 96) {
|
|
699
|
+
// move assign
|
|
700
|
+
t0 = std::move(t1);
|
|
701
|
+
r0 = std::move(r1);
|
|
702
|
+
} else if (pct < 98) {
|
|
703
|
+
// operator==
|
|
704
|
+
EXPECT_EQ((t0 == t1), (r0 == r1));
|
|
705
|
+
} else if (pct < 99) {
|
|
706
|
+
// clear
|
|
707
|
+
runSanityChecks(t0);
|
|
708
|
+
t0.clear();
|
|
709
|
+
r0.clear();
|
|
710
|
+
} else if (pct < 100) {
|
|
711
|
+
// reserve
|
|
712
|
+
auto scale = std::uniform_int_distribution<>(0, 8)(gen);
|
|
713
|
+
auto delta = std::uniform_int_distribution<>(-2, 2)(gen);
|
|
714
|
+
std::ptrdiff_t target = (t0.size() * scale) / 4 + delta;
|
|
715
|
+
if (target >= 0) {
|
|
716
|
+
t0.reserve(static_cast<std::size_t>(target));
|
|
717
|
+
r0.reserve(static_cast<std::size_t>(target));
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
} catch (std::bad_alloc const&) {
|
|
721
|
+
++rollbacks;
|
|
722
|
+
|
|
723
|
+
runSanityChecks(t0);
|
|
724
|
+
|
|
725
|
+
if (leakCheckOnly) {
|
|
726
|
+
unlimitTestAllocations();
|
|
727
|
+
t0.clear();
|
|
728
|
+
for (auto&& kv : r0) {
|
|
729
|
+
t0[kv.first] = kv.second.val_;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (t0.bucket_count() == t0.size() && t0.size() > 0) {
|
|
734
|
+
if (t0.size() < 10) {
|
|
735
|
+
++resizingSmallRollbacks;
|
|
736
|
+
} else {
|
|
737
|
+
++resizingLargeRollbacks;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
assert(t0.size() == r0.size());
|
|
742
|
+
for (auto&& kv : r0) {
|
|
743
|
+
auto t = t0.find(kv.first);
|
|
744
|
+
EXPECT_TRUE(
|
|
745
|
+
t != t0.end() && t->first == kv.first &&
|
|
746
|
+
t->second.val_ == kv.second.val_);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
EXPECT_EQ(testAllocatedMemorySize(), 0);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
TEST(F14ValueMap, simple) {
|
|
756
|
+
runSimple<F14ValueMap<std::string, std::string>>();
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
TEST(F14NodeMap, simple) {
|
|
760
|
+
runSimple<F14NodeMap<std::string, std::string>>();
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
TEST(F14VectorMap, simple) {
|
|
764
|
+
runSimple<F14VectorMap<std::string, std::string>>();
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
TEST(F14FastMap, simple) {
|
|
768
|
+
runSimple<F14FastMap<std::string, std::string>>();
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
#if FOLLY_HAS_MEMORY_RESOURCE
|
|
772
|
+
TEST(F14ValueMap, pmrSimple) {
|
|
773
|
+
runSimple<pmr::F14ValueMap<std::string, std::string>>();
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
TEST(F14NodeMap, pmrSimple) {
|
|
777
|
+
runSimple<pmr::F14NodeMap<std::string, std::string>>();
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
TEST(F14VectorMap, pmrSimple) {
|
|
781
|
+
runSimple<pmr::F14VectorMap<std::string, std::string>>();
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
TEST(F14FastMap, pmrSimple) {
|
|
785
|
+
runSimple<pmr::F14FastMap<std::string, std::string>>();
|
|
786
|
+
}
|
|
787
|
+
#endif
|
|
788
|
+
|
|
789
|
+
#if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE
|
|
790
|
+
TEST(F14VectorMap, reverseIterator) {
|
|
791
|
+
using TMap = F14VectorMap<uint64_t, uint64_t>;
|
|
792
|
+
auto populate = [](TMap& h, uint64_t lo, uint64_t hi) {
|
|
793
|
+
for (auto i = lo; i < hi; ++i) {
|
|
794
|
+
h.emplace(i, i);
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
auto verify = [](TMap const& h, uint64_t lo, uint64_t hi) {
|
|
798
|
+
auto loIt = h.find(lo);
|
|
799
|
+
EXPECT_NE(h.end(), loIt);
|
|
800
|
+
uint64_t val = lo;
|
|
801
|
+
for (auto rit = h.riter(loIt); rit != h.rend(); ++rit) {
|
|
802
|
+
EXPECT_EQ(val, rit->first);
|
|
803
|
+
EXPECT_EQ(val, rit->second);
|
|
804
|
+
TMap::const_iterator it = h.iter(rit);
|
|
805
|
+
EXPECT_EQ(val, it->first);
|
|
806
|
+
EXPECT_EQ(val, it->second);
|
|
807
|
+
val++;
|
|
808
|
+
}
|
|
809
|
+
EXPECT_EQ(hi, val);
|
|
810
|
+
};
|
|
811
|
+
TMap h;
|
|
812
|
+
size_t prevSize = 0;
|
|
813
|
+
size_t newSize = 1;
|
|
814
|
+
// verify iteration order across rehashes, copies, and moves
|
|
815
|
+
while (newSize < 10'000) {
|
|
816
|
+
populate(h, prevSize, newSize);
|
|
817
|
+
verify(h, 0, newSize);
|
|
818
|
+
verify(h, newSize / 2, newSize);
|
|
819
|
+
|
|
820
|
+
TMap h2{h};
|
|
821
|
+
verify(h2, 0, newSize);
|
|
822
|
+
|
|
823
|
+
h = std::move(h2);
|
|
824
|
+
verify(h, 0, newSize);
|
|
825
|
+
prevSize = newSize;
|
|
826
|
+
newSize *= 10;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
TEST(F14VectorMap, OrderPreservingReinsertionView) {
|
|
831
|
+
F14VectorMap<int, int> m1;
|
|
832
|
+
for (size_t i = 0; i < 5; ++i) {
|
|
833
|
+
m1.emplace(i, i);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
F14VectorMap<int, int> m2;
|
|
837
|
+
for (const auto& kv : order_preserving_reinsertion_view(m1)) {
|
|
838
|
+
m2.insert(kv);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
EXPECT_EQ(asVector(m1), asVector(m2));
|
|
842
|
+
}
|
|
843
|
+
#endif
|
|
844
|
+
|
|
845
|
+
TEST(F14ValueMap, eraseWhileIterating) {
|
|
846
|
+
runEraseWhileIterating<F14ValueMap<int, int>>();
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
TEST(F14NodeMap, eraseWhileIterating) {
|
|
850
|
+
runEraseWhileIterating<F14NodeMap<int, int>>();
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
TEST(F14VectorMap, eraseWhileIterating) {
|
|
854
|
+
runEraseWhileIterating<F14VectorMap<int, int>>();
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
TEST(F14FastMap, eraseWhileIterating) {
|
|
858
|
+
runEraseWhileIterating<F14FastMap<int, int>>();
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
TEST(F14ValueMap, rehash) {
|
|
862
|
+
runRehash<F14ValueMap<std::string, std::string>>();
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
TEST(F14NodeMap, rehash) {
|
|
866
|
+
runRehash<F14NodeMap<std::string, std::string>>();
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
TEST(F14VectorMap, rehash) {
|
|
870
|
+
runRehash<F14VectorMap<std::string, std::string>>();
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
TEST(F14FastMap, rehash) {
|
|
874
|
+
runRehash<F14VectorMap<std::string, std::string>>();
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
template <typename T>
|
|
878
|
+
void runPrehash() {
|
|
879
|
+
T h;
|
|
880
|
+
|
|
881
|
+
EXPECT_EQ(h.size(), 0);
|
|
882
|
+
|
|
883
|
+
h.insert(std::make_pair(s("abc"), s("ABC")));
|
|
884
|
+
EXPECT_TRUE(h.find(s("def")) == h.end());
|
|
885
|
+
EXPECT_FALSE(h.find(s("abc")) == h.end());
|
|
886
|
+
|
|
887
|
+
auto t1 = h.prehash(s("def"));
|
|
888
|
+
F14HashToken t2;
|
|
889
|
+
t2 = h.prehash(s("abc"));
|
|
890
|
+
h.prefetch(t2);
|
|
891
|
+
EXPECT_TRUE(h.find(t1, s("def")) == h.end());
|
|
892
|
+
EXPECT_FALSE(h.find(t2, s("abc")) == h.end());
|
|
893
|
+
h.prefetch(t1);
|
|
894
|
+
|
|
895
|
+
{
|
|
896
|
+
auto const key3 = s("def");
|
|
897
|
+
auto hv3 = h.hash_function()(key3);
|
|
898
|
+
auto t3 = h.prehash(key3, hv3);
|
|
899
|
+
EXPECT_EQ(t3, h.prehash(key3));
|
|
900
|
+
EXPECT_TRUE(h.find(t3, key3) == h.end());
|
|
901
|
+
}
|
|
902
|
+
{
|
|
903
|
+
auto const key3 = s("abc");
|
|
904
|
+
auto hv3 = h.hash_function()(key3);
|
|
905
|
+
auto t3 = h.prehash(key3, hv3);
|
|
906
|
+
EXPECT_EQ(t3, h.prehash(key3));
|
|
907
|
+
EXPECT_FALSE(h.find(t3, key3) == h.end());
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
TEST(F14ValueMap, prehash) {
|
|
911
|
+
runPrehash<F14ValueMap<std::string, std::string>>();
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
TEST(F14NodeMap, prehash) {
|
|
915
|
+
runPrehash<F14NodeMap<std::string, std::string>>();
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
TEST(F14VectorMap, prehash) {
|
|
919
|
+
runPrehash<F14VectorMap<std::string, std::string>>();
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
TEST(F14FastMap, prehash) {
|
|
923
|
+
runPrehash<F14FastMap<std::string, std::string>>();
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
TEST(F14ValueMap, random) {
|
|
927
|
+
runRandom<F14ValueMap<
|
|
928
|
+
uint64_t,
|
|
929
|
+
Tracked<1>,
|
|
930
|
+
std::hash<uint64_t>,
|
|
931
|
+
std::equal_to<uint64_t>,
|
|
932
|
+
SwapTrackingAlloc<std::pair<uint64_t const, Tracked<1>>>>>();
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
TEST(F14NodeMap, random) {
|
|
936
|
+
runRandom<F14NodeMap<
|
|
937
|
+
uint64_t,
|
|
938
|
+
Tracked<1>,
|
|
939
|
+
std::hash<uint64_t>,
|
|
940
|
+
std::equal_to<uint64_t>,
|
|
941
|
+
SwapTrackingAlloc<std::pair<uint64_t const, Tracked<1>>>>>();
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
TEST(F14VectorMap, random) {
|
|
945
|
+
runRandom<F14VectorMap<
|
|
946
|
+
uint64_t,
|
|
947
|
+
Tracked<1>,
|
|
948
|
+
std::hash<uint64_t>,
|
|
949
|
+
std::equal_to<uint64_t>,
|
|
950
|
+
SwapTrackingAlloc<std::pair<uint64_t const, Tracked<1>>>>>();
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
TEST(F14FastMap, random) {
|
|
954
|
+
runRandom<F14FastMap<
|
|
955
|
+
uint64_t,
|
|
956
|
+
Tracked<1>,
|
|
957
|
+
std::hash<uint64_t>,
|
|
958
|
+
std::equal_to<uint64_t>,
|
|
959
|
+
SwapTrackingAlloc<std::pair<uint64_t const, Tracked<1>>>>>();
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
TEST(F14ValueMap, growStats) {
|
|
963
|
+
F14ValueMap<uint64_t, uint64_t> h;
|
|
964
|
+
for (unsigned i = 1; i <= 3072; ++i) {
|
|
965
|
+
h[i]++;
|
|
966
|
+
}
|
|
967
|
+
// F14ValueMap just before rehash
|
|
968
|
+
runSanityChecks(h);
|
|
969
|
+
h[0]++;
|
|
970
|
+
// F14ValueMap just after rehash
|
|
971
|
+
runSanityChecks(h);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
TEST(F14ValueMap, steadyStateStats) {
|
|
975
|
+
// 10k keys, 14% probability of insert, 90% chance of erase, so the
|
|
976
|
+
// table should converge to 1400 size without triggering the rehash
|
|
977
|
+
// that would occur at 1536.
|
|
978
|
+
F14ValueMap<uint64_t, uint64_t> h;
|
|
979
|
+
std::mt19937_64 gen(0);
|
|
980
|
+
std::uniform_int_distribution<> dist(0, 10000);
|
|
981
|
+
for (std::size_t i = 0; i < 100000; ++i) {
|
|
982
|
+
auto key = dist(gen);
|
|
983
|
+
if (dist(gen) < 1400) {
|
|
984
|
+
h.insert_or_assign(key, i);
|
|
985
|
+
} else {
|
|
986
|
+
h.erase(key);
|
|
987
|
+
}
|
|
988
|
+
if (((i + 1) % 10000) == 0) {
|
|
989
|
+
#if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE
|
|
990
|
+
auto stats = F14TableStats::compute(h);
|
|
991
|
+
// Verify that average miss probe length is bounded despite continued
|
|
992
|
+
// erase + reuse. p99 of the average across 10M random steps is 4.69,
|
|
993
|
+
// average is 2.96.
|
|
994
|
+
EXPECT_LT(f14::expectedProbe(stats.missProbeLengthHisto), 10.0);
|
|
995
|
+
#endif
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
// F14ValueMap at steady state
|
|
999
|
+
runSanityChecks(h);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
TEST(F14VectorMap, steadyStateStats) {
|
|
1003
|
+
// 10k keys, 14% probability of insert, 90% chance of erase, so the
|
|
1004
|
+
// table should converge to 1400 size without triggering the rehash
|
|
1005
|
+
// that would occur at 1536.
|
|
1006
|
+
F14VectorMap<std::string, uint64_t> h;
|
|
1007
|
+
std::mt19937_64 gen(0);
|
|
1008
|
+
std::uniform_int_distribution<> dist(0, 10000);
|
|
1009
|
+
for (std::size_t i = 0; i < 100000; ++i) {
|
|
1010
|
+
auto key = "0123456789ABCDEFGHIJKLMNOPQ" + to<std::string>(dist(gen));
|
|
1011
|
+
if (dist(gen) < 1400) {
|
|
1012
|
+
h.insert_or_assign(key, i);
|
|
1013
|
+
} else {
|
|
1014
|
+
h.erase(key);
|
|
1015
|
+
}
|
|
1016
|
+
if (((i + 1) % 10000) == 0) {
|
|
1017
|
+
#if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE
|
|
1018
|
+
auto stats = F14TableStats::compute(h);
|
|
1019
|
+
// Verify that average miss probe length is bounded despite continued
|
|
1020
|
+
// erase + reuse. p99 of the average across 10M random steps is 4.69,
|
|
1021
|
+
// average is 2.96.
|
|
1022
|
+
EXPECT_LT(f14::expectedProbe(stats.missProbeLengthHisto), 10.0);
|
|
1023
|
+
#endif
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
// F14ValueMap at steady state
|
|
1027
|
+
runSanityChecks(h);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
TEST(Tracked, baseline) {
|
|
1031
|
+
Tracked<0> a0;
|
|
1032
|
+
|
|
1033
|
+
{
|
|
1034
|
+
resetTracking();
|
|
1035
|
+
Tracked<0> b0{a0};
|
|
1036
|
+
EXPECT_EQ(a0.val_, b0.val_);
|
|
1037
|
+
EXPECT_EQ(sumCounts(), (Counts{1, 0, 0, 0}));
|
|
1038
|
+
EXPECT_EQ(Tracked<0>::counts(), (Counts{1, 0, 0, 0}));
|
|
1039
|
+
}
|
|
1040
|
+
{
|
|
1041
|
+
resetTracking();
|
|
1042
|
+
Tracked<0> b0{std::move(a0)};
|
|
1043
|
+
EXPECT_EQ(a0.val_, b0.val_);
|
|
1044
|
+
EXPECT_EQ(sumCounts(), (Counts{0, 1, 0, 0}));
|
|
1045
|
+
EXPECT_EQ(Tracked<0>::counts(), (Counts{0, 1, 0, 0}));
|
|
1046
|
+
}
|
|
1047
|
+
{
|
|
1048
|
+
resetTracking();
|
|
1049
|
+
Tracked<1> b1{a0};
|
|
1050
|
+
EXPECT_EQ(a0.val_, b1.val_);
|
|
1051
|
+
EXPECT_EQ(sumCounts(), (Counts{0, 0, 1, 0}));
|
|
1052
|
+
EXPECT_EQ(Tracked<1>::counts(), (Counts{0, 0, 1, 0}));
|
|
1053
|
+
}
|
|
1054
|
+
{
|
|
1055
|
+
resetTracking();
|
|
1056
|
+
Tracked<1> b1{std::move(a0)};
|
|
1057
|
+
EXPECT_EQ(a0.val_, b1.val_);
|
|
1058
|
+
EXPECT_EQ(sumCounts(), (Counts{0, 0, 0, 1}));
|
|
1059
|
+
EXPECT_EQ(Tracked<1>::counts(), (Counts{0, 0, 0, 1}));
|
|
1060
|
+
}
|
|
1061
|
+
{
|
|
1062
|
+
Tracked<0> b0;
|
|
1063
|
+
resetTracking();
|
|
1064
|
+
b0 = a0;
|
|
1065
|
+
EXPECT_EQ(a0.val_, b0.val_);
|
|
1066
|
+
EXPECT_EQ(sumCounts(), (Counts{0, 0, 0, 0, 1, 0}));
|
|
1067
|
+
EXPECT_EQ(Tracked<0>::counts(), (Counts{0, 0, 0, 0, 1, 0}));
|
|
1068
|
+
}
|
|
1069
|
+
{
|
|
1070
|
+
Tracked<0> b0;
|
|
1071
|
+
resetTracking();
|
|
1072
|
+
b0 = std::move(a0);
|
|
1073
|
+
EXPECT_EQ(a0.val_, b0.val_);
|
|
1074
|
+
EXPECT_EQ(sumCounts(), (Counts{0, 0, 0, 0, 0, 1}));
|
|
1075
|
+
EXPECT_EQ(Tracked<0>::counts(), (Counts{0, 0, 0, 0, 0, 1}));
|
|
1076
|
+
}
|
|
1077
|
+
{
|
|
1078
|
+
Tracked<1> b1;
|
|
1079
|
+
resetTracking();
|
|
1080
|
+
b1 = a0;
|
|
1081
|
+
EXPECT_EQ(a0.val_, b1.val_);
|
|
1082
|
+
EXPECT_EQ(sumCounts(), (Counts{0, 0, 1, 0, 0, 1, 0, 1}));
|
|
1083
|
+
EXPECT_EQ(Tracked<1>::counts(), (Counts{0, 0, 1, 0, 0, 1, 0, 1}));
|
|
1084
|
+
}
|
|
1085
|
+
{
|
|
1086
|
+
Tracked<1> b1;
|
|
1087
|
+
resetTracking();
|
|
1088
|
+
b1 = std::move(a0);
|
|
1089
|
+
EXPECT_EQ(a0.val_, b1.val_);
|
|
1090
|
+
EXPECT_EQ(sumCounts(), (Counts{0, 0, 0, 1, 0, 1, 0, 1}));
|
|
1091
|
+
EXPECT_EQ(Tracked<1>::counts(), (Counts{0, 0, 0, 1, 0, 1, 0, 1}));
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// M should be a map from Tracked<0> to Tracked<1>. F should take a map
|
|
1096
|
+
// and a pair const& or pair&& and cause it to be inserted
|
|
1097
|
+
template <typename M, typename F>
|
|
1098
|
+
void runInsertCases(
|
|
1099
|
+
std::string const& name, F const& insertFunc, uint64_t expectedDist = 0) {
|
|
1100
|
+
static_assert(std::is_same<typename M::key_type, Tracked<0>>::value, "");
|
|
1101
|
+
static_assert(std::is_same<typename M::mapped_type, Tracked<1>>::value, "");
|
|
1102
|
+
{
|
|
1103
|
+
typename M::value_type p{0, 0};
|
|
1104
|
+
M m;
|
|
1105
|
+
resetTracking();
|
|
1106
|
+
insertFunc(m, p);
|
|
1107
|
+
// fresh key, value_type const& ->
|
|
1108
|
+
// copy is expected
|
|
1109
|
+
EXPECT_EQ(
|
|
1110
|
+
Tracked<0>::counts().dist(Counts{1, 0, 0, 0}) +
|
|
1111
|
+
Tracked<1>::counts().dist(Counts{1, 0, 0, 0}),
|
|
1112
|
+
expectedDist)
|
|
1113
|
+
<< name << "\n0 -> " << Tracked<0>::counts() << "\n1 -> "
|
|
1114
|
+
<< Tracked<1>::counts();
|
|
1115
|
+
}
|
|
1116
|
+
{
|
|
1117
|
+
typename M::value_type p{0, 0};
|
|
1118
|
+
M m;
|
|
1119
|
+
resetTracking();
|
|
1120
|
+
insertFunc(m, std::move(p));
|
|
1121
|
+
// fresh key, value_type&& ->
|
|
1122
|
+
// key copy is unfortunate but required
|
|
1123
|
+
EXPECT_EQ(
|
|
1124
|
+
Tracked<0>::counts().dist(Counts{1, 0, 0, 0}) +
|
|
1125
|
+
Tracked<1>::counts().dist(Counts{0, 1, 0, 0}),
|
|
1126
|
+
expectedDist)
|
|
1127
|
+
<< name << "\n0 -> " << Tracked<0>::counts() << "\n1 -> "
|
|
1128
|
+
<< Tracked<1>::counts();
|
|
1129
|
+
}
|
|
1130
|
+
{
|
|
1131
|
+
std::pair<Tracked<0>, Tracked<1>> p{0, 0};
|
|
1132
|
+
M m;
|
|
1133
|
+
resetTracking();
|
|
1134
|
+
insertFunc(m, p);
|
|
1135
|
+
// fresh key, pair<key_type,mapped_type> const& ->
|
|
1136
|
+
// 1 copy is required
|
|
1137
|
+
EXPECT_EQ(
|
|
1138
|
+
Tracked<0>::counts().dist(Counts{1, 0, 0, 0}) +
|
|
1139
|
+
Tracked<1>::counts().dist(Counts{1, 0, 0, 0}),
|
|
1140
|
+
expectedDist)
|
|
1141
|
+
<< name << "\n0 -> " << Tracked<0>::counts() << "\n1 -> "
|
|
1142
|
+
<< Tracked<1>::counts();
|
|
1143
|
+
}
|
|
1144
|
+
{
|
|
1145
|
+
std::pair<Tracked<0>, Tracked<1>> p{0, 0};
|
|
1146
|
+
M m;
|
|
1147
|
+
resetTracking();
|
|
1148
|
+
insertFunc(m, std::move(p));
|
|
1149
|
+
// fresh key, pair<key_type,mapped_type>&& ->
|
|
1150
|
+
// this is the happy path for insert(make_pair(.., ..))
|
|
1151
|
+
EXPECT_EQ(
|
|
1152
|
+
Tracked<0>::counts().dist(Counts{0, 1, 0, 0}) +
|
|
1153
|
+
Tracked<1>::counts().dist(Counts{0, 1, 0, 0}),
|
|
1154
|
+
expectedDist)
|
|
1155
|
+
<< name << "\n0 -> " << Tracked<0>::counts() << "\n1 -> "
|
|
1156
|
+
<< Tracked<1>::counts();
|
|
1157
|
+
}
|
|
1158
|
+
{
|
|
1159
|
+
std::pair<Tracked<2>, Tracked<3>> p{0, 0};
|
|
1160
|
+
M m;
|
|
1161
|
+
resetTracking();
|
|
1162
|
+
insertFunc(m, p);
|
|
1163
|
+
// fresh key, convertible const& ->
|
|
1164
|
+
// key_type ops: Tracked<0>::counts
|
|
1165
|
+
// mapped_type ops: Tracked<1>::counts
|
|
1166
|
+
// key_src ops: Tracked<2>::counts
|
|
1167
|
+
// mapped_src ops: Tracked<3>::counts;
|
|
1168
|
+
|
|
1169
|
+
// There are three strategies that could be optimal for particular
|
|
1170
|
+
// ratios of cost:
|
|
1171
|
+
//
|
|
1172
|
+
// - convert key and value in place to final position, destroy if
|
|
1173
|
+
// insert fails. This is the strategy used by std::unordered_map
|
|
1174
|
+
// and FBHashMap
|
|
1175
|
+
//
|
|
1176
|
+
// - convert key and default value in place to final position,
|
|
1177
|
+
// convert value only if insert succeeds. Nobody uses this strategy
|
|
1178
|
+
//
|
|
1179
|
+
// - convert key to a temporary, move key and convert value if
|
|
1180
|
+
// insert succeeds. This is the strategy used by F14 and what is
|
|
1181
|
+
// EXPECT_EQ here.
|
|
1182
|
+
|
|
1183
|
+
// The expectedDist * 3 is just a hack for the emplace-pieces-by-value
|
|
1184
|
+
// test, whose test harness copies the original pair and then uses
|
|
1185
|
+
// move conversion instead of copy conversion.
|
|
1186
|
+
EXPECT_EQ(
|
|
1187
|
+
Tracked<0>::counts().dist(Counts{0, 1, 1, 0}) +
|
|
1188
|
+
Tracked<1>::counts().dist(Counts{0, 0, 1, 0}) +
|
|
1189
|
+
Tracked<2>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1190
|
+
Tracked<3>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1191
|
+
expectedDist * 3);
|
|
1192
|
+
}
|
|
1193
|
+
{
|
|
1194
|
+
std::pair<Tracked<2>, Tracked<3>> p{0, 0};
|
|
1195
|
+
M m;
|
|
1196
|
+
resetTracking();
|
|
1197
|
+
insertFunc(m, std::move(p));
|
|
1198
|
+
// fresh key, convertible&& ->
|
|
1199
|
+
// key_type ops: Tracked<0>::counts
|
|
1200
|
+
// mapped_type ops: Tracked<1>::counts
|
|
1201
|
+
// key_src ops: Tracked<2>::counts
|
|
1202
|
+
// mapped_src ops: Tracked<3>::counts;
|
|
1203
|
+
EXPECT_EQ(
|
|
1204
|
+
Tracked<0>::counts().dist(Counts{0, 1, 0, 1}) +
|
|
1205
|
+
Tracked<1>::counts().dist(Counts{0, 0, 0, 1}) +
|
|
1206
|
+
Tracked<2>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1207
|
+
Tracked<3>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1208
|
+
expectedDist);
|
|
1209
|
+
}
|
|
1210
|
+
if (!kFallback) {
|
|
1211
|
+
typename M::value_type p{0, 0};
|
|
1212
|
+
M m;
|
|
1213
|
+
m[0] = 0;
|
|
1214
|
+
resetTracking();
|
|
1215
|
+
insertFunc(m, p);
|
|
1216
|
+
// duplicate key, value_type const&
|
|
1217
|
+
EXPECT_EQ(
|
|
1218
|
+
Tracked<0>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1219
|
+
Tracked<1>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1220
|
+
expectedDist);
|
|
1221
|
+
}
|
|
1222
|
+
if (!kFallback) {
|
|
1223
|
+
typename M::value_type p{0, 0};
|
|
1224
|
+
M m;
|
|
1225
|
+
m[0] = 0;
|
|
1226
|
+
resetTracking();
|
|
1227
|
+
insertFunc(m, std::move(p));
|
|
1228
|
+
// duplicate key, value_type&&
|
|
1229
|
+
EXPECT_EQ(
|
|
1230
|
+
Tracked<0>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1231
|
+
Tracked<1>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1232
|
+
expectedDist);
|
|
1233
|
+
}
|
|
1234
|
+
if (!kFallback) {
|
|
1235
|
+
std::pair<Tracked<0>, Tracked<1>> p{0, 0};
|
|
1236
|
+
M m;
|
|
1237
|
+
m[0] = 0;
|
|
1238
|
+
resetTracking();
|
|
1239
|
+
insertFunc(m, p);
|
|
1240
|
+
// duplicate key, pair<key_type,mapped_type> const&
|
|
1241
|
+
EXPECT_EQ(
|
|
1242
|
+
Tracked<0>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1243
|
+
Tracked<1>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1244
|
+
expectedDist);
|
|
1245
|
+
}
|
|
1246
|
+
if (!kFallback) {
|
|
1247
|
+
std::pair<Tracked<0>, Tracked<1>> p{0, 0};
|
|
1248
|
+
M m;
|
|
1249
|
+
m[0] = 0;
|
|
1250
|
+
resetTracking();
|
|
1251
|
+
insertFunc(m, std::move(p));
|
|
1252
|
+
// duplicate key, pair<key_type,mapped_type>&&
|
|
1253
|
+
EXPECT_EQ(
|
|
1254
|
+
Tracked<0>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1255
|
+
Tracked<1>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1256
|
+
expectedDist);
|
|
1257
|
+
}
|
|
1258
|
+
if (!kFallback) {
|
|
1259
|
+
std::pair<Tracked<2>, Tracked<3>> p{0, 0};
|
|
1260
|
+
M m;
|
|
1261
|
+
m[0] = 0;
|
|
1262
|
+
resetTracking();
|
|
1263
|
+
insertFunc(m, p);
|
|
1264
|
+
// duplicate key, convertible const& ->
|
|
1265
|
+
// key_type ops: Tracked<0>::counts
|
|
1266
|
+
// mapped_type ops: Tracked<1>::counts
|
|
1267
|
+
// key_src ops: Tracked<2>::counts
|
|
1268
|
+
// mapped_src ops: Tracked<3>::counts;
|
|
1269
|
+
EXPECT_EQ(
|
|
1270
|
+
Tracked<0>::counts().dist(Counts{0, 0, 1, 0}) +
|
|
1271
|
+
Tracked<1>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1272
|
+
Tracked<2>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1273
|
+
Tracked<3>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1274
|
+
expectedDist * 2);
|
|
1275
|
+
}
|
|
1276
|
+
if (!kFallback) {
|
|
1277
|
+
std::pair<Tracked<2>, Tracked<3>> p{0, 0};
|
|
1278
|
+
M m;
|
|
1279
|
+
m[0] = 0;
|
|
1280
|
+
resetTracking();
|
|
1281
|
+
insertFunc(m, std::move(p));
|
|
1282
|
+
// duplicate key, convertible&& ->
|
|
1283
|
+
// key_type ops: Tracked<0>::counts
|
|
1284
|
+
// mapped_type ops: Tracked<1>::counts
|
|
1285
|
+
// key_src ops: Tracked<2>::counts
|
|
1286
|
+
// mapped_src ops: Tracked<3>::counts;
|
|
1287
|
+
EXPECT_EQ(
|
|
1288
|
+
Tracked<0>::counts().dist(Counts{0, 0, 0, 1}) +
|
|
1289
|
+
Tracked<1>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1290
|
+
Tracked<2>::counts().dist(Counts{0, 0, 0, 0}) +
|
|
1291
|
+
Tracked<3>::counts().dist(Counts{0, 0, 0, 0}),
|
|
1292
|
+
expectedDist);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
struct DoInsert {
|
|
1297
|
+
template <typename M, typename P>
|
|
1298
|
+
void operator()(M& m, P&& p) const {
|
|
1299
|
+
m.insert(std::forward<P>(p));
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
struct DoEmplace1 {
|
|
1304
|
+
template <typename M, typename P>
|
|
1305
|
+
void operator()(M& m, P&& p) const {
|
|
1306
|
+
m.emplace(std::forward<P>(p));
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
struct DoEmplace2 {
|
|
1311
|
+
template <typename M, typename U1, typename U2>
|
|
1312
|
+
void operator()(M& m, std::pair<U1, U2> const& p) const {
|
|
1313
|
+
m.emplace(p.first, p.second);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
template <typename M, typename U1, typename U2>
|
|
1317
|
+
void operator()(M& m, std::pair<U1, U2>&& p) const {
|
|
1318
|
+
m.emplace(std::move(p.first), std::move(p.second));
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
struct DoEmplace3 {
|
|
1323
|
+
template <typename M, typename U1, typename U2>
|
|
1324
|
+
void operator()(M& m, std::pair<U1, U2> const& p) const {
|
|
1325
|
+
m.emplace(
|
|
1326
|
+
std::piecewise_construct,
|
|
1327
|
+
std::forward_as_tuple(p.first),
|
|
1328
|
+
std::forward_as_tuple(p.second));
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
template <typename M, typename U1, typename U2>
|
|
1332
|
+
void operator()(M& m, std::pair<U1, U2>&& p) const {
|
|
1333
|
+
m.emplace(
|
|
1334
|
+
std::piecewise_construct,
|
|
1335
|
+
std::forward_as_tuple(std::move(p.first)),
|
|
1336
|
+
std::forward_as_tuple(std::move(p.second)));
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
// Simulates use of piecewise_construct without proper use of
|
|
1341
|
+
// forward_as_tuple. This code doesn't yield the normal pattern, but
|
|
1342
|
+
// it should have exactly 1 additional move or copy of the key and 1
|
|
1343
|
+
// additional move or copy of the mapped value.
|
|
1344
|
+
struct DoEmplace3Value {
|
|
1345
|
+
template <typename M, typename U1, typename U2>
|
|
1346
|
+
void operator()(M& m, std::pair<U1, U2> const& p) const {
|
|
1347
|
+
m.emplace(
|
|
1348
|
+
std::piecewise_construct,
|
|
1349
|
+
std::tuple<U1>{p.first},
|
|
1350
|
+
std::tuple<U2>{p.second});
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
template <typename M, typename U1, typename U2>
|
|
1354
|
+
void operator()(M& m, std::pair<U1, U2>&& p) const {
|
|
1355
|
+
m.emplace(
|
|
1356
|
+
std::piecewise_construct,
|
|
1357
|
+
std::tuple<U1>{std::move(p.first)},
|
|
1358
|
+
std::tuple<U2>{std::move(p.second)});
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
template <typename M>
|
|
1363
|
+
void runInsertAndEmplace(std::string const& name) {
|
|
1364
|
+
runInsertCases<M>(name + " insert", DoInsert{});
|
|
1365
|
+
runInsertCases<M>(name + " emplace pair", DoEmplace1{});
|
|
1366
|
+
runInsertCases<M>(name + " emplace k,v", DoEmplace2{});
|
|
1367
|
+
runInsertCases<M>(name + " emplace pieces", DoEmplace3{});
|
|
1368
|
+
runInsertCases<M>(name + " emplace pieces by value", DoEmplace3Value{}, 2);
|
|
1369
|
+
|
|
1370
|
+
// Calling the default pair constructor via emplace is valid, but not
|
|
1371
|
+
// very useful in real life. Verify that it works.
|
|
1372
|
+
M m;
|
|
1373
|
+
typename M::key_type k;
|
|
1374
|
+
EXPECT_EQ(m.count(k), 0);
|
|
1375
|
+
EXPECT_FALSE(m.contains(k));
|
|
1376
|
+
m.emplace();
|
|
1377
|
+
EXPECT_EQ(m.count(k), 1);
|
|
1378
|
+
EXPECT_TRUE(m.contains(k));
|
|
1379
|
+
m.emplace();
|
|
1380
|
+
EXPECT_EQ(m.count(k), 1);
|
|
1381
|
+
EXPECT_TRUE(m.contains(k));
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
TEST(F14ValueMap, destructuring) {
|
|
1385
|
+
runInsertAndEmplace<F14ValueMap<Tracked<0>, Tracked<1>>>("f14value");
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
TEST(F14NodeMap, destructuring) {
|
|
1389
|
+
runInsertAndEmplace<F14NodeMap<Tracked<0>, Tracked<1>>>("f14node");
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
TEST(F14VectorMap, destructuring) {
|
|
1393
|
+
runInsertAndEmplace<F14VectorMap<Tracked<0>, Tracked<1>>>("f14vector");
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
TEST(F14VectorMap, destructuringErase) {
|
|
1397
|
+
SKIP_IF(kFallback);
|
|
1398
|
+
|
|
1399
|
+
using M = F14VectorMap<Tracked<0>, Tracked<1>>;
|
|
1400
|
+
typename M::value_type p1{0, 0};
|
|
1401
|
+
typename M::value_type p2{2, 2};
|
|
1402
|
+
M m;
|
|
1403
|
+
m.insert(p1);
|
|
1404
|
+
m.insert(p2);
|
|
1405
|
+
|
|
1406
|
+
resetTracking();
|
|
1407
|
+
m.erase(p1.first);
|
|
1408
|
+
LOG(INFO) << "erase -> " << "key_type ops " << Tracked<0>::counts()
|
|
1409
|
+
<< ", mapped_type ops " << Tracked<1>::counts();
|
|
1410
|
+
// deleting p1 will cause p2 to be moved to the front of the values array
|
|
1411
|
+
EXPECT_EQ(
|
|
1412
|
+
Tracked<0>::counts().dist(Counts{0, 1, 0, 0}) +
|
|
1413
|
+
Tracked<1>::counts().dist(Counts{0, 1, 0, 0}),
|
|
1414
|
+
0);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
#if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE
|
|
1418
|
+
TEST(F14ValueMap, maxSize) {
|
|
1419
|
+
F14ValueMap<int, int> m;
|
|
1420
|
+
EXPECT_EQ(
|
|
1421
|
+
m.max_size(),
|
|
1422
|
+
std::min(
|
|
1423
|
+
folly::f14::detail::SizeAndChunkShift::kMaxSize,
|
|
1424
|
+
std::allocator_traits<decltype(m)::allocator_type>::max_size(
|
|
1425
|
+
m.get_allocator())));
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
TEST(F14NodeMap, maxSize) {
|
|
1429
|
+
F14NodeMap<int, int> m;
|
|
1430
|
+
EXPECT_EQ(
|
|
1431
|
+
m.max_size(),
|
|
1432
|
+
std::min(
|
|
1433
|
+
folly::f14::detail::SizeAndChunkShift::kMaxSize,
|
|
1434
|
+
std::allocator_traits<decltype(m)::allocator_type>::max_size(
|
|
1435
|
+
m.get_allocator())));
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
TEST(F14VectorMap, vectorMaxSize) {
|
|
1439
|
+
F14VectorMap<int, int> m;
|
|
1440
|
+
EXPECT_EQ(
|
|
1441
|
+
m.max_size(),
|
|
1442
|
+
std::min(
|
|
1443
|
+
{folly::f14::detail::SizeAndChunkShift::kMaxSize,
|
|
1444
|
+
std::size_t{std::numeric_limits<uint32_t>::max()},
|
|
1445
|
+
std::allocator_traits<decltype(m)::allocator_type>::max_size(
|
|
1446
|
+
m.get_allocator())}));
|
|
1447
|
+
}
|
|
1448
|
+
#endif
|
|
1449
|
+
|
|
1450
|
+
template <typename M>
|
|
1451
|
+
void runMoveOnlyTest() {
|
|
1452
|
+
M t0;
|
|
1453
|
+
t0[10] = 20;
|
|
1454
|
+
t0.emplace(30, 40);
|
|
1455
|
+
t0.insert(std::make_pair(50, 60));
|
|
1456
|
+
M t1{std::move(t0)};
|
|
1457
|
+
EXPECT_TRUE(t0.empty());
|
|
1458
|
+
M t2;
|
|
1459
|
+
EXPECT_TRUE(t2.empty());
|
|
1460
|
+
t2 = std::move(t1);
|
|
1461
|
+
EXPECT_EQ(t2.size(), 3);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
TEST(F14ValueMap, moveOnly) {
|
|
1465
|
+
runMoveOnlyTest<F14ValueMap<MoveOnlyTestInt, int>>();
|
|
1466
|
+
runMoveOnlyTest<F14ValueMap<int, MoveOnlyTestInt>>();
|
|
1467
|
+
runMoveOnlyTest<F14ValueMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
TEST(F14NodeMap, moveOnly) {
|
|
1471
|
+
runMoveOnlyTest<F14NodeMap<MoveOnlyTestInt, int>>();
|
|
1472
|
+
runMoveOnlyTest<F14NodeMap<int, MoveOnlyTestInt>>();
|
|
1473
|
+
runMoveOnlyTest<F14NodeMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
TEST(F14VectorMap, moveOnly) {
|
|
1477
|
+
runMoveOnlyTest<F14VectorMap<MoveOnlyTestInt, int>>();
|
|
1478
|
+
runMoveOnlyTest<F14VectorMap<int, MoveOnlyTestInt>>();
|
|
1479
|
+
runMoveOnlyTest<F14VectorMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
TEST(F14FastMap, moveOnly) {
|
|
1483
|
+
runMoveOnlyTest<F14FastMap<MoveOnlyTestInt, int>>();
|
|
1484
|
+
runMoveOnlyTest<F14FastMap<int, MoveOnlyTestInt>>();
|
|
1485
|
+
runMoveOnlyTest<F14FastMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
template <typename M>
|
|
1489
|
+
void runEraseIntoTest() {
|
|
1490
|
+
M t0;
|
|
1491
|
+
M t1;
|
|
1492
|
+
|
|
1493
|
+
auto emplaceIntoT0 = [&t0](auto&& key, auto&& value) {
|
|
1494
|
+
EXPECT_FALSE(key.destroyed);
|
|
1495
|
+
t0.emplace(std::move(key), std::move(value));
|
|
1496
|
+
};
|
|
1497
|
+
auto emplaceIntoT0Mut = [&](typename M::key_type&& key,
|
|
1498
|
+
typename M::mapped_type&& value) mutable {
|
|
1499
|
+
emplaceIntoT0(std::move(key), std::move(value));
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
t0.emplace(10, 0);
|
|
1503
|
+
t1.emplace(20, 0);
|
|
1504
|
+
t1.eraseInto(t1.begin(), emplaceIntoT0);
|
|
1505
|
+
EXPECT_TRUE(t1.empty());
|
|
1506
|
+
EXPECT_EQ(t0.size(), 2);
|
|
1507
|
+
EXPECT_TRUE(t0.find(10) != t0.end());
|
|
1508
|
+
EXPECT_TRUE(t0.find(20) != t0.end());
|
|
1509
|
+
|
|
1510
|
+
t1.emplace(20, 0);
|
|
1511
|
+
t1.emplace(30, 0);
|
|
1512
|
+
t1.emplace(40, 0);
|
|
1513
|
+
t1.eraseInto(t1.begin(), t1.end(), emplaceIntoT0Mut);
|
|
1514
|
+
EXPECT_TRUE(t1.empty());
|
|
1515
|
+
EXPECT_EQ(t0.size(), 4);
|
|
1516
|
+
EXPECT_TRUE(t0.find(30) != t0.end());
|
|
1517
|
+
EXPECT_TRUE(t0.find(40) != t0.end());
|
|
1518
|
+
|
|
1519
|
+
t1.emplace(50, 0);
|
|
1520
|
+
size_t erased = t1.eraseInto(t1.find(50)->first, emplaceIntoT0);
|
|
1521
|
+
EXPECT_EQ(erased, 1);
|
|
1522
|
+
EXPECT_TRUE(t1.empty());
|
|
1523
|
+
EXPECT_EQ(t0.size(), 5);
|
|
1524
|
+
EXPECT_TRUE(t0.find(50) != t0.end());
|
|
1525
|
+
|
|
1526
|
+
typename M::key_type key{60};
|
|
1527
|
+
erased = t1.eraseInto(key, emplaceIntoT0Mut);
|
|
1528
|
+
EXPECT_EQ(erased, 0);
|
|
1529
|
+
EXPECT_EQ(t0.size(), 5);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
TEST(F14ValueMap, eraseInto) {
|
|
1533
|
+
runEraseIntoTest<F14ValueMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
TEST(F14NodeMap, eraseInto) {
|
|
1537
|
+
runEraseIntoTest<F14NodeMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
TEST(F14VectorMap, eraseInto) {
|
|
1541
|
+
runEraseIntoTest<F14VectorMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
TEST(F14FastMap, eraseInto) {
|
|
1545
|
+
runEraseIntoTest<F14FastMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
template <typename M>
|
|
1549
|
+
void runEraseIntoEmptyFromEraseTest() {
|
|
1550
|
+
M m;
|
|
1551
|
+
m.emplace(0, 0);
|
|
1552
|
+
m.erase(0);
|
|
1553
|
+
|
|
1554
|
+
EXPECT_GT(m.bucket_count(), 0);
|
|
1555
|
+
EXPECT_TRUE(m.empty());
|
|
1556
|
+
|
|
1557
|
+
m.eraseInto(m.begin(), m.end(), [](auto&&, auto&&) {});
|
|
1558
|
+
|
|
1559
|
+
EXPECT_GT(m.bucket_count(), 0);
|
|
1560
|
+
EXPECT_TRUE(m.empty());
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
TEST(F14ValueMap, eraseIntoEmptyFromErase) {
|
|
1564
|
+
runEraseIntoEmptyFromEraseTest<
|
|
1565
|
+
F14ValueMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
TEST(F14NodeMap, eraseIntoEmptyFromErase) {
|
|
1569
|
+
runEraseIntoEmptyFromEraseTest<
|
|
1570
|
+
F14NodeMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
TEST(F14VectorMap, eraseIntoEmptyFromErase) {
|
|
1574
|
+
runEraseIntoEmptyFromEraseTest<
|
|
1575
|
+
F14VectorMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
TEST(F14FastMap, eraseIntoEmptyFromErase) {
|
|
1579
|
+
runEraseIntoEmptyFromEraseTest<
|
|
1580
|
+
F14FastMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
template <typename M>
|
|
1584
|
+
void runEraseIntoEmptyFromReserveTest() {
|
|
1585
|
+
M m;
|
|
1586
|
+
m.reserve(1);
|
|
1587
|
+
|
|
1588
|
+
EXPECT_GT(m.bucket_count(), 0);
|
|
1589
|
+
EXPECT_TRUE(m.empty());
|
|
1590
|
+
|
|
1591
|
+
m.eraseInto(m.begin(), m.end(), [](auto&&, auto&&) {});
|
|
1592
|
+
|
|
1593
|
+
EXPECT_GT(m.bucket_count(), 0);
|
|
1594
|
+
EXPECT_TRUE(m.empty());
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
TEST(F14ValueMap, eraseIntoEmptyFromReserve) {
|
|
1598
|
+
runEraseIntoEmptyFromReserveTest<
|
|
1599
|
+
F14ValueMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
TEST(F14NodeMap, eraseIntoEmptyFromReserve) {
|
|
1603
|
+
runEraseIntoEmptyFromReserveTest<
|
|
1604
|
+
F14NodeMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
TEST(F14VectorMap, eraseIntoEmptyFromReserve) {
|
|
1608
|
+
runEraseIntoEmptyFromReserveTest<
|
|
1609
|
+
F14VectorMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
TEST(F14FastMap, eraseIntoEmptyFromReserve) {
|
|
1613
|
+
runEraseIntoEmptyFromReserveTest<
|
|
1614
|
+
F14FastMap<MoveOnlyTestInt, MoveOnlyTestInt>>();
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
template <typename M>
|
|
1618
|
+
void runPermissiveConstructorTest() {
|
|
1619
|
+
M t;
|
|
1620
|
+
M const& ct{t};
|
|
1621
|
+
|
|
1622
|
+
for (int i = 10; i <= 100; i += 10) {
|
|
1623
|
+
t[i] = i;
|
|
1624
|
+
}
|
|
1625
|
+
t.erase(10);
|
|
1626
|
+
EXPECT_EQ(t.size(), 9);
|
|
1627
|
+
t.erase(t.find(20));
|
|
1628
|
+
EXPECT_EQ(t.size(), 8);
|
|
1629
|
+
t.erase(ct.find(30));
|
|
1630
|
+
EXPECT_EQ(t.size(), 7);
|
|
1631
|
+
t.eraseInto(40, [](auto&&, auto&&) {});
|
|
1632
|
+
EXPECT_EQ(t.size(), 6);
|
|
1633
|
+
t.eraseInto(t.find(50), [](auto&&, auto&&) {});
|
|
1634
|
+
EXPECT_EQ(t.size(), 5);
|
|
1635
|
+
t.eraseInto(ct.find(60), [](auto&&, auto&&) {});
|
|
1636
|
+
EXPECT_EQ(t.size(), 4);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
TEST(F14ValueMap, permissiveConstructor) {
|
|
1640
|
+
runPermissiveConstructorTest<F14ValueMap<
|
|
1641
|
+
PermissiveConstructorTestInt,
|
|
1642
|
+
PermissiveConstructorTestInt>>();
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
TEST(F14NodeMap, permissiveConstructor) {
|
|
1646
|
+
runPermissiveConstructorTest<
|
|
1647
|
+
F14NodeMap<PermissiveConstructorTestInt, PermissiveConstructorTestInt>>();
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
TEST(F14VectorMap, permissiveConstructor) {
|
|
1651
|
+
runPermissiveConstructorTest<F14VectorMap<
|
|
1652
|
+
PermissiveConstructorTestInt,
|
|
1653
|
+
PermissiveConstructorTestInt>>();
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
TEST(F14FastMap, permissiveConstructor) {
|
|
1657
|
+
runPermissiveConstructorTest<
|
|
1658
|
+
F14FastMap<PermissiveConstructorTestInt, PermissiveConstructorTestInt>>();
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
TEST(F14ValueMap, heterogeneousLookup) {
|
|
1662
|
+
using Hasher = folly::transparent<folly::hasher<folly::StringPiece>>;
|
|
1663
|
+
using KeyEqual = folly::transparent<std::equal_to<folly::StringPiece>>;
|
|
1664
|
+
|
|
1665
|
+
constexpr auto hello = "hello"_sp;
|
|
1666
|
+
constexpr auto buddy = "buddy"_sp;
|
|
1667
|
+
constexpr auto world = "world"_sp;
|
|
1668
|
+
|
|
1669
|
+
F14ValueMap<std::string, bool, Hasher, KeyEqual> map;
|
|
1670
|
+
map.emplace(hello, true);
|
|
1671
|
+
map.emplace(world, false);
|
|
1672
|
+
|
|
1673
|
+
auto checks = [hello, buddy](auto& ref) {
|
|
1674
|
+
// count
|
|
1675
|
+
EXPECT_EQ(0, ref.count(buddy));
|
|
1676
|
+
EXPECT_EQ(1, ref.count(hello));
|
|
1677
|
+
|
|
1678
|
+
// find
|
|
1679
|
+
EXPECT_TRUE(ref.end() == ref.find(buddy));
|
|
1680
|
+
EXPECT_EQ(hello, ref.find(hello)->first);
|
|
1681
|
+
|
|
1682
|
+
const auto buddyHashToken = ref.prehash(buddy);
|
|
1683
|
+
const auto helloHashToken = ref.prehash(hello);
|
|
1684
|
+
|
|
1685
|
+
EXPECT_TRUE(
|
|
1686
|
+
buddyHashToken == ref.prehash(buddy, ref.hash_function()(buddy)));
|
|
1687
|
+
EXPECT_TRUE(
|
|
1688
|
+
helloHashToken == ref.prehash(hello, ref.hash_function()(hello)));
|
|
1689
|
+
#if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE
|
|
1690
|
+
EXPECT_FALSE(
|
|
1691
|
+
buddyHashToken == ref.prehash(hello, ref.hash_function()(hello)));
|
|
1692
|
+
#endif
|
|
1693
|
+
|
|
1694
|
+
// prehash + find
|
|
1695
|
+
EXPECT_TRUE(ref.end() == ref.find(buddyHashToken, buddy));
|
|
1696
|
+
EXPECT_EQ(hello, ref.find(helloHashToken, hello)->first);
|
|
1697
|
+
|
|
1698
|
+
// contains
|
|
1699
|
+
EXPECT_FALSE(ref.contains(buddy));
|
|
1700
|
+
EXPECT_TRUE(ref.contains(hello));
|
|
1701
|
+
|
|
1702
|
+
// contains with prehash
|
|
1703
|
+
EXPECT_FALSE(ref.contains(buddyHashToken, buddy));
|
|
1704
|
+
EXPECT_TRUE(ref.contains(helloHashToken, hello));
|
|
1705
|
+
|
|
1706
|
+
// equal_range
|
|
1707
|
+
EXPECT_TRUE(std::make_pair(ref.end(), ref.end()) == ref.equal_range(buddy));
|
|
1708
|
+
EXPECT_TRUE(
|
|
1709
|
+
std::make_pair(ref.find(hello), ++ref.find(hello)) ==
|
|
1710
|
+
ref.equal_range(hello));
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
checks(map);
|
|
1714
|
+
checks(std::as_const(map));
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
template <typename M>
|
|
1718
|
+
void runStatefulFunctorTest() {
|
|
1719
|
+
bool ranHasher = false;
|
|
1720
|
+
bool ranEqual = false;
|
|
1721
|
+
bool ranAlloc = false;
|
|
1722
|
+
bool ranDealloc = false;
|
|
1723
|
+
|
|
1724
|
+
auto hasher = [&](int x) {
|
|
1725
|
+
ranHasher = true;
|
|
1726
|
+
return x;
|
|
1727
|
+
};
|
|
1728
|
+
auto equal = [&](int x, int y) {
|
|
1729
|
+
ranEqual = true;
|
|
1730
|
+
return x == y;
|
|
1731
|
+
};
|
|
1732
|
+
auto alloc = [&](std::size_t n) {
|
|
1733
|
+
ranAlloc = true;
|
|
1734
|
+
return std::malloc(n);
|
|
1735
|
+
};
|
|
1736
|
+
auto dealloc = [&](void* p, std::size_t) {
|
|
1737
|
+
ranDealloc = true;
|
|
1738
|
+
std::free(p);
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
{
|
|
1742
|
+
M map(0, hasher, equal, {alloc, dealloc});
|
|
1743
|
+
map[10]++;
|
|
1744
|
+
map[10]++;
|
|
1745
|
+
EXPECT_EQ(map[10], 2);
|
|
1746
|
+
|
|
1747
|
+
M map2(map);
|
|
1748
|
+
M map3(std::move(map));
|
|
1749
|
+
map = map2;
|
|
1750
|
+
map2.clear();
|
|
1751
|
+
map2 = std::move(map3);
|
|
1752
|
+
}
|
|
1753
|
+
EXPECT_TRUE(ranHasher);
|
|
1754
|
+
EXPECT_TRUE(ranEqual);
|
|
1755
|
+
EXPECT_TRUE(ranAlloc);
|
|
1756
|
+
EXPECT_TRUE(ranDealloc);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
TEST(F14ValueMap, statefulFunctors) {
|
|
1760
|
+
runStatefulFunctorTest<F14ValueMap<
|
|
1761
|
+
int,
|
|
1762
|
+
int,
|
|
1763
|
+
GenericHasher<int>,
|
|
1764
|
+
GenericEqual<int>,
|
|
1765
|
+
GenericAlloc<std::pair<int const, int>>>>();
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
TEST(F14NodeMap, statefulFunctors) {
|
|
1769
|
+
runStatefulFunctorTest<F14NodeMap<
|
|
1770
|
+
int,
|
|
1771
|
+
int,
|
|
1772
|
+
GenericHasher<int>,
|
|
1773
|
+
GenericEqual<int>,
|
|
1774
|
+
GenericAlloc<std::pair<int const, int>>>>();
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
TEST(F14VectorMap, statefulFunctors) {
|
|
1778
|
+
runStatefulFunctorTest<F14VectorMap<
|
|
1779
|
+
int,
|
|
1780
|
+
int,
|
|
1781
|
+
GenericHasher<int>,
|
|
1782
|
+
GenericEqual<int>,
|
|
1783
|
+
GenericAlloc<std::pair<int const, int>>>>();
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
TEST(F14FastMap, statefulFunctors) {
|
|
1787
|
+
runStatefulFunctorTest<F14FastMap<
|
|
1788
|
+
int,
|
|
1789
|
+
int,
|
|
1790
|
+
GenericHasher<int>,
|
|
1791
|
+
GenericEqual<int>,
|
|
1792
|
+
GenericAlloc<std::pair<int const, int>>>>();
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
template <typename M>
|
|
1796
|
+
void runHeterogeneousInsertTest() {
|
|
1797
|
+
M map;
|
|
1798
|
+
|
|
1799
|
+
resetTracking();
|
|
1800
|
+
EXPECT_EQ(map.count(10), 0);
|
|
1801
|
+
EXPECT_FALSE(map.contains(10));
|
|
1802
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 0}), 0)
|
|
1803
|
+
<< Tracked<1>::counts();
|
|
1804
|
+
|
|
1805
|
+
resetTracking();
|
|
1806
|
+
map[10] = 20;
|
|
1807
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 1}), 0)
|
|
1808
|
+
<< Tracked<1>::counts();
|
|
1809
|
+
|
|
1810
|
+
resetTracking();
|
|
1811
|
+
std::pair<int, int> p(10, 30);
|
|
1812
|
+
std::vector<std::pair<int, int>> v({p});
|
|
1813
|
+
map[10] = 30;
|
|
1814
|
+
map.insert(std::pair<int, int>(10, 30));
|
|
1815
|
+
map.insert(std::pair<int const, int>(10, 30));
|
|
1816
|
+
map.insert(p);
|
|
1817
|
+
map.insert(v.begin(), v.end());
|
|
1818
|
+
map.insert(
|
|
1819
|
+
std::make_move_iterator(v.begin()), std::make_move_iterator(v.end()));
|
|
1820
|
+
map.insert_or_assign(10, 40);
|
|
1821
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 0}), 0)
|
|
1822
|
+
<< Tracked<1>::counts();
|
|
1823
|
+
|
|
1824
|
+
resetTracking();
|
|
1825
|
+
map.emplace(10, 30);
|
|
1826
|
+
map.emplace(
|
|
1827
|
+
std::piecewise_construct,
|
|
1828
|
+
std::forward_as_tuple(10),
|
|
1829
|
+
std::forward_as_tuple(30));
|
|
1830
|
+
map.emplace(p);
|
|
1831
|
+
map.try_emplace(10, 30);
|
|
1832
|
+
map.try_emplace(10);
|
|
1833
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 0}), 0)
|
|
1834
|
+
<< Tracked<1>::counts();
|
|
1835
|
+
|
|
1836
|
+
resetTracking();
|
|
1837
|
+
map.erase(10);
|
|
1838
|
+
EXPECT_EQ(map.size(), 0);
|
|
1839
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 0}), 0)
|
|
1840
|
+
<< Tracked<1>::counts();
|
|
1841
|
+
|
|
1842
|
+
map.emplace(10, 40);
|
|
1843
|
+
resetTracking();
|
|
1844
|
+
map.erase(map.find(10));
|
|
1845
|
+
EXPECT_EQ(map.size(), 0);
|
|
1846
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 0}), 0)
|
|
1847
|
+
<< Tracked<1>::counts();
|
|
1848
|
+
|
|
1849
|
+
map.emplace(10, 40);
|
|
1850
|
+
resetTracking();
|
|
1851
|
+
map.eraseInto(10, [](auto&&, auto&&) {});
|
|
1852
|
+
EXPECT_EQ(map.size(), 0);
|
|
1853
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 0}), 0)
|
|
1854
|
+
<< Tracked<1>::counts();
|
|
1855
|
+
|
|
1856
|
+
const auto t = map.prehash(10);
|
|
1857
|
+
resetTracking();
|
|
1858
|
+
map.try_emplace_token(t, 10, 40);
|
|
1859
|
+
EXPECT_TRUE(map.contains(t, 10));
|
|
1860
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 1}), 0)
|
|
1861
|
+
<< Tracked<1>::counts();
|
|
1862
|
+
resetTracking();
|
|
1863
|
+
map.erase(map.find(t, 10));
|
|
1864
|
+
EXPECT_EQ(map.size(), 0);
|
|
1865
|
+
EXPECT_EQ(Tracked<1>::counts().dist(Counts{0, 0, 0, 0}), 0)
|
|
1866
|
+
<< Tracked<1>::counts();
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
template <typename M>
|
|
1870
|
+
void runHeterogeneousInsertStringTest() {
|
|
1871
|
+
using P = std::pair<StringPiece, std::string>;
|
|
1872
|
+
using CP = std::pair<const StringPiece, std::string>;
|
|
1873
|
+
|
|
1874
|
+
M map;
|
|
1875
|
+
P p{"foo", "hello"};
|
|
1876
|
+
std::vector<P> v{p};
|
|
1877
|
+
StringPiece foo{"foo"};
|
|
1878
|
+
|
|
1879
|
+
map.insert(P("foo", "hello"));
|
|
1880
|
+
// TODO(T31574848): the list-initialization below does not work on libstdc++
|
|
1881
|
+
// versions (e.g., GCC < 6) with no implementation of N4387 ("perfect
|
|
1882
|
+
// initialization" for pairs and tuples).
|
|
1883
|
+
// StringPiece sp{"foo"};
|
|
1884
|
+
// map.insert({sp, "hello"});
|
|
1885
|
+
map.insert({"foo", "hello"});
|
|
1886
|
+
map.insert(CP("foo", "hello"));
|
|
1887
|
+
map.insert(p);
|
|
1888
|
+
map.insert(v.begin(), v.end());
|
|
1889
|
+
map.insert(
|
|
1890
|
+
std::make_move_iterator(v.begin()), std::make_move_iterator(v.end()));
|
|
1891
|
+
map.insert_or_assign("foo", "hello");
|
|
1892
|
+
map.insert_or_assign(StringPiece{"foo"}, "hello");
|
|
1893
|
+
EXPECT_EQ(map["foo"], "hello");
|
|
1894
|
+
|
|
1895
|
+
map.emplace(StringPiece{"foo"}, "hello");
|
|
1896
|
+
map.emplace("foo", "hello");
|
|
1897
|
+
map.emplace(p);
|
|
1898
|
+
map.emplace();
|
|
1899
|
+
map.emplace(
|
|
1900
|
+
std::piecewise_construct,
|
|
1901
|
+
std::forward_as_tuple(StringPiece{"foo"}),
|
|
1902
|
+
std::forward_as_tuple(/* count */ 20, 'x'));
|
|
1903
|
+
map.try_emplace(StringPiece{"foo"}, "hello");
|
|
1904
|
+
map.try_emplace(foo, "hello");
|
|
1905
|
+
map.try_emplace(foo);
|
|
1906
|
+
map.try_emplace("foo");
|
|
1907
|
+
map.try_emplace("foo", "hello");
|
|
1908
|
+
map.try_emplace("foo", /* count */ 20, 'x');
|
|
1909
|
+
|
|
1910
|
+
map.erase(StringPiece{"foo"});
|
|
1911
|
+
map.erase(foo);
|
|
1912
|
+
map.erase("");
|
|
1913
|
+
EXPECT_TRUE(map.empty());
|
|
1914
|
+
|
|
1915
|
+
map.try_emplace(foo);
|
|
1916
|
+
map.erase(map.find(foo));
|
|
1917
|
+
map.try_emplace(foo);
|
|
1918
|
+
typename M::const_iterator it = map.find(foo);
|
|
1919
|
+
map.erase(it);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
TEST(F14ValueMap, heterogeneousInsert) {
|
|
1923
|
+
runHeterogeneousInsertTest<F14ValueMap<
|
|
1924
|
+
Tracked<1>,
|
|
1925
|
+
int,
|
|
1926
|
+
TransparentTrackedHash<1>,
|
|
1927
|
+
TransparentTrackedEqual<1>>>();
|
|
1928
|
+
runHeterogeneousInsertStringTest<F14ValueMap<
|
|
1929
|
+
std::string,
|
|
1930
|
+
std::string,
|
|
1931
|
+
transparent<hasher<StringPiece>>,
|
|
1932
|
+
transparent<DefaultKeyEqual<StringPiece>>>>();
|
|
1933
|
+
runHeterogeneousInsertStringTest<F14ValueMap<std::string, std::string>>();
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
TEST(F14NodeMap, heterogeneousInsert) {
|
|
1937
|
+
runHeterogeneousInsertTest<F14NodeMap<
|
|
1938
|
+
Tracked<1>,
|
|
1939
|
+
int,
|
|
1940
|
+
TransparentTrackedHash<1>,
|
|
1941
|
+
TransparentTrackedEqual<1>>>();
|
|
1942
|
+
runHeterogeneousInsertStringTest<F14NodeMap<
|
|
1943
|
+
std::string,
|
|
1944
|
+
std::string,
|
|
1945
|
+
transparent<hasher<StringPiece>>,
|
|
1946
|
+
transparent<DefaultKeyEqual<StringPiece>>>>();
|
|
1947
|
+
runHeterogeneousInsertStringTest<F14NodeMap<std::string, std::string>>();
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
TEST(F14VectorMap, heterogeneousInsert) {
|
|
1951
|
+
runHeterogeneousInsertTest<F14VectorMap<
|
|
1952
|
+
Tracked<1>,
|
|
1953
|
+
int,
|
|
1954
|
+
TransparentTrackedHash<1>,
|
|
1955
|
+
TransparentTrackedEqual<1>>>();
|
|
1956
|
+
runHeterogeneousInsertStringTest<F14VectorMap<
|
|
1957
|
+
std::string,
|
|
1958
|
+
std::string,
|
|
1959
|
+
transparent<hasher<StringPiece>>,
|
|
1960
|
+
transparent<DefaultKeyEqual<StringPiece>>>>();
|
|
1961
|
+
runHeterogeneousInsertStringTest<F14VectorMap<std::string, std::string>>();
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
TEST(F14FastMap, heterogeneousInsert) {
|
|
1965
|
+
runHeterogeneousInsertTest<F14FastMap<
|
|
1966
|
+
Tracked<1>,
|
|
1967
|
+
int,
|
|
1968
|
+
TransparentTrackedHash<1>,
|
|
1969
|
+
TransparentTrackedEqual<1>>>();
|
|
1970
|
+
runHeterogeneousInsertStringTest<F14FastMap<
|
|
1971
|
+
std::string,
|
|
1972
|
+
std::string,
|
|
1973
|
+
transparent<hasher<StringPiece>>,
|
|
1974
|
+
transparent<DefaultKeyEqual<StringPiece>>>>();
|
|
1975
|
+
runHeterogeneousInsertStringTest<F14FastMap<std::string, std::string>>();
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
namespace {
|
|
1979
|
+
|
|
1980
|
+
// std::is_convertible is not transitive :( Problem scenario: B<T> is
|
|
1981
|
+
// implicitly convertible to A, so hasher that takes A can be used as a
|
|
1982
|
+
// transparent hasher for a map with key of type B<T>. C is implicitly
|
|
1983
|
+
// convertible to any B<T>, but we have to disable heterogeneous find
|
|
1984
|
+
// for C. There is no way to infer the T of the intermediate type so C
|
|
1985
|
+
// can't be used to explicitly construct A.
|
|
1986
|
+
|
|
1987
|
+
struct A {
|
|
1988
|
+
int value;
|
|
1989
|
+
|
|
1990
|
+
bool operator==(A const& rhs) const { return value == rhs.value; }
|
|
1991
|
+
bool operator!=(A const& rhs) const { return !(*this == rhs); }
|
|
1992
|
+
};
|
|
1993
|
+
|
|
1994
|
+
struct AHasher {
|
|
1995
|
+
std::size_t operator()(A const& v) const { return v.value; }
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1998
|
+
template <typename T>
|
|
1999
|
+
struct B {
|
|
2000
|
+
int value;
|
|
2001
|
+
|
|
2002
|
+
explicit B(int v) : value(v) {}
|
|
2003
|
+
|
|
2004
|
+
/* implicit */ B(A const& v) : value(v.value) {}
|
|
2005
|
+
|
|
2006
|
+
/* implicit */ operator A() const { return A{value}; }
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
struct C {
|
|
2010
|
+
int value;
|
|
2011
|
+
|
|
2012
|
+
template <typename T>
|
|
2013
|
+
/* implicit */ operator B<T>() const {
|
|
2014
|
+
return B<T>{value};
|
|
2015
|
+
}
|
|
2016
|
+
};
|
|
2017
|
+
} // namespace
|
|
2018
|
+
|
|
2019
|
+
TEST(F14FastMap, disabledDoubleTransparent) {
|
|
2020
|
+
static_assert(std::is_convertible<B<char>, A>::value, "");
|
|
2021
|
+
static_assert(std::is_convertible<C, B<char>>::value, "");
|
|
2022
|
+
static_assert(!std::is_convertible<C, A>::value, "");
|
|
2023
|
+
|
|
2024
|
+
F14FastMap<
|
|
2025
|
+
B<char>,
|
|
2026
|
+
int,
|
|
2027
|
+
folly::transparent<AHasher>,
|
|
2028
|
+
folly::transparent<std::equal_to<A>>>
|
|
2029
|
+
map;
|
|
2030
|
+
map[A{10}] = 10;
|
|
2031
|
+
|
|
2032
|
+
EXPECT_TRUE(map.find(C{10}) != map.end());
|
|
2033
|
+
EXPECT_TRUE(map.find(C{20}) == map.end());
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
template <typename M>
|
|
2037
|
+
void runRandomInsertOrderTest() {
|
|
2038
|
+
if (FOLLY_F14_PERTURB_INSERTION_ORDER) {
|
|
2039
|
+
std::string prev;
|
|
2040
|
+
bool diffFound = false;
|
|
2041
|
+
for (int tries = 0; tries < 100; ++tries) {
|
|
2042
|
+
M m;
|
|
2043
|
+
for (char x = '0'; x <= '7'; ++x) {
|
|
2044
|
+
m.try_emplace(x);
|
|
2045
|
+
}
|
|
2046
|
+
m.reserve(10);
|
|
2047
|
+
auto it = m.try_emplace('8').first;
|
|
2048
|
+
auto addr = &*it;
|
|
2049
|
+
m.try_emplace('9');
|
|
2050
|
+
EXPECT_TRUE(it == m.find('8'));
|
|
2051
|
+
EXPECT_TRUE(addr = &*m.find('8'));
|
|
2052
|
+
std::string s;
|
|
2053
|
+
for (auto&& e : m) {
|
|
2054
|
+
s.push_back(e.first);
|
|
2055
|
+
}
|
|
2056
|
+
LOG(INFO) << s << "\n";
|
|
2057
|
+
if (prev.empty()) {
|
|
2058
|
+
prev = s;
|
|
2059
|
+
continue;
|
|
2060
|
+
}
|
|
2061
|
+
if (prev != s) {
|
|
2062
|
+
diffFound = true;
|
|
2063
|
+
break;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
EXPECT_TRUE(diffFound) << "no randomness found in insert order";
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
TEST(F14Map, randomInsertOrder) {
|
|
2071
|
+
runRandomInsertOrderTest<F14ValueMap<char, char>>();
|
|
2072
|
+
runRandomInsertOrderTest<F14FastMap<char, char>>();
|
|
2073
|
+
runRandomInsertOrderTest<F14FastMap<char, std::string>>();
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
template <typename M>
|
|
2077
|
+
void runContinuousCapacityTest(std::size_t minSize, std::size_t maxSize) {
|
|
2078
|
+
SKIP_IF(kFallback);
|
|
2079
|
+
|
|
2080
|
+
using K = typename M::key_type;
|
|
2081
|
+
for (std::size_t n = minSize; n <= maxSize; ++n) {
|
|
2082
|
+
M m1;
|
|
2083
|
+
m1.reserve(n);
|
|
2084
|
+
auto cap = m1.bucket_count();
|
|
2085
|
+
double ratio = cap * 1.0 / n;
|
|
2086
|
+
// worst case scenario is that rehash just occurred and capacityScale
|
|
2087
|
+
// is 5*2^12
|
|
2088
|
+
EXPECT_TRUE(ratio < 1 + 1.0 / (5 << 12))
|
|
2089
|
+
<< ratio << ", " << cap << ", " << n;
|
|
2090
|
+
m1[0];
|
|
2091
|
+
M m2;
|
|
2092
|
+
m2 = m1;
|
|
2093
|
+
EXPECT_LE(m2.bucket_count(), 2);
|
|
2094
|
+
for (K i = 1; i < n; ++i) {
|
|
2095
|
+
folly::makeUnpredictable(i);
|
|
2096
|
+
m1[i];
|
|
2097
|
+
}
|
|
2098
|
+
EXPECT_EQ(m1.bucket_count(), cap);
|
|
2099
|
+
M m3 = m1;
|
|
2100
|
+
EXPECT_EQ(m3.bucket_count(), cap);
|
|
2101
|
+
for (K i = n; i <= cap; ++i) {
|
|
2102
|
+
folly::makeUnpredictable(i);
|
|
2103
|
+
m1[i];
|
|
2104
|
+
}
|
|
2105
|
+
EXPECT_GT(m1.bucket_count(), cap);
|
|
2106
|
+
EXPECT_LE(m1.bucket_count(), 3 * cap);
|
|
2107
|
+
|
|
2108
|
+
M m4;
|
|
2109
|
+
for (K i = 0; i < n; ++i) {
|
|
2110
|
+
folly::makeUnpredictable(i);
|
|
2111
|
+
m4[i];
|
|
2112
|
+
}
|
|
2113
|
+
// reserve(0) works like shrink_to_fit. Note that tight fit (1/8
|
|
2114
|
+
// waste bound) only applies for vector policy or single-chunk, which
|
|
2115
|
+
// might not apply to m1. m3 should already have been optimally sized.
|
|
2116
|
+
m1.reserve(0);
|
|
2117
|
+
m3.reserve(0);
|
|
2118
|
+
m4.reserve(0);
|
|
2119
|
+
EXPECT_GT(m1.load_factor(), 0.5);
|
|
2120
|
+
EXPECT_GE(m3.load_factor(), 0.875);
|
|
2121
|
+
EXPECT_EQ(m3.bucket_count(), cap);
|
|
2122
|
+
EXPECT_GE(m4.load_factor(), 0.875);
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
TEST(F14Map, continuousCapacitySmall0) {
|
|
2127
|
+
runContinuousCapacityTest<F14NodeMap<std::size_t, std::string>>(1, 14);
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
TEST(F14Map, continuousCapacitySmall1) {
|
|
2131
|
+
runContinuousCapacityTest<F14ValueMap<std::size_t, std::string>>(1, 14);
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
TEST(F14Map, continuousCapacitySmall2) {
|
|
2135
|
+
runContinuousCapacityTest<F14VectorMap<std::size_t, std::string>>(1, 100);
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
TEST(F14Map, continuousCapacitySmall3) {
|
|
2139
|
+
runContinuousCapacityTest<F14FastMap<std::size_t, std::string>>(1, 14);
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
TEST(F14Map, continuousCapacityBig0) {
|
|
2143
|
+
runContinuousCapacityTest<F14VectorMap<std::size_t, std::string>>(
|
|
2144
|
+
1000000 - 1, 1000000 - 1);
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
TEST(F14Map, continuousCapacityBig1) {
|
|
2148
|
+
runContinuousCapacityTest<F14VectorMap<std::size_t, std::string>>(
|
|
2149
|
+
1000000, 1000000);
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
TEST(F14Map, continuousCapacityBig2) {
|
|
2153
|
+
runContinuousCapacityTest<F14VectorMap<std::size_t, std::string>>(
|
|
2154
|
+
1000000 + 1, 1000000 + 1);
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
TEST(F14Map, continuousCapacityBig3) {
|
|
2158
|
+
runContinuousCapacityTest<F14VectorMap<std::size_t, std::string>>(
|
|
2159
|
+
1000000 + 2, 1000000 + 2);
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
TEST(F14Map, continuousCapacityF12) {
|
|
2163
|
+
runContinuousCapacityTest<F14VectorMap<uint16_t, uint16_t>>(0xfff0, 0xfffe);
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
template <template <class...> class TMap>
|
|
2167
|
+
void testContainsWithPrecomputedHash() {
|
|
2168
|
+
TMap<int, int> m{};
|
|
2169
|
+
const auto key{1};
|
|
2170
|
+
m.insert({key, 1});
|
|
2171
|
+
const auto hashToken = m.prehash(key);
|
|
2172
|
+
EXPECT_TRUE(m.contains(hashToken, key));
|
|
2173
|
+
const auto otherKey{2};
|
|
2174
|
+
const auto hashTokenNotFound = m.prehash(otherKey);
|
|
2175
|
+
EXPECT_FALSE(m.contains(hashTokenNotFound, otherKey));
|
|
2176
|
+
|
|
2177
|
+
m.prefetch(hashToken);
|
|
2178
|
+
m.prefetch(hashTokenNotFound);
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
TEST(F14Map, containsWithPrecomputedHash) {
|
|
2182
|
+
testContainsWithPrecomputedHash<F14ValueMap>();
|
|
2183
|
+
testContainsWithPrecomputedHash<F14VectorMap>();
|
|
2184
|
+
testContainsWithPrecomputedHash<F14NodeMap>();
|
|
2185
|
+
testContainsWithPrecomputedHash<F14FastMap>();
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
#if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE
|
|
2189
|
+
template <template <class...> class TMap>
|
|
2190
|
+
void testContainsWithPrecomputedHashKeyWrapper() {
|
|
2191
|
+
TMap<int, int> m{};
|
|
2192
|
+
const auto key{1};
|
|
2193
|
+
m.insert({key, 1});
|
|
2194
|
+
const F14HashedKey<int> hashedKey{key};
|
|
2195
|
+
EXPECT_TRUE(m.contains(hashedKey));
|
|
2196
|
+
const auto otherKey{2};
|
|
2197
|
+
const F14HashedKey<int> hashedKeyNotFound{otherKey};
|
|
2198
|
+
EXPECT_FALSE(m.contains(hashedKeyNotFound));
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
TEST(F14Map, containsWithPrecomputedHashKeyWrapper) {
|
|
2202
|
+
testContainsWithPrecomputedHashKeyWrapper<F14ValueMap>();
|
|
2203
|
+
testContainsWithPrecomputedHashKeyWrapper<F14VectorMap>();
|
|
2204
|
+
testContainsWithPrecomputedHashKeyWrapper<F14NodeMap>();
|
|
2205
|
+
testContainsWithPrecomputedHashKeyWrapper<F14FastMap>();
|
|
2206
|
+
}
|
|
2207
|
+
#endif
|
|
2208
|
+
|
|
2209
|
+
template <template <class...> class TMap>
|
|
2210
|
+
void testEraseIf() {
|
|
2211
|
+
TMap<int, int> m{{1, 1}, {2, 2}, {3, 3}, {4, 4}};
|
|
2212
|
+
const auto isEvenKey = [](const auto& p) { return p.first % 2 == 0; };
|
|
2213
|
+
EXPECT_EQ(2u, erase_if(m, isEvenKey));
|
|
2214
|
+
ASSERT_EQ(2u, m.size());
|
|
2215
|
+
EXPECT_TRUE(m.contains(1));
|
|
2216
|
+
EXPECT_TRUE(m.contains(3));
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
TEST(F14Map, eraseIf) {
|
|
2220
|
+
testEraseIf<F14ValueMap>();
|
|
2221
|
+
testEraseIf<F14VectorMap>();
|
|
2222
|
+
testEraseIf<F14NodeMap>();
|
|
2223
|
+
testEraseIf<F14FastMap>();
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
namespace {
|
|
2227
|
+
template <std::size_t N>
|
|
2228
|
+
struct DivideBy {
|
|
2229
|
+
// this is a lie for testing purposes
|
|
2230
|
+
using folly_is_avalanching = std::true_type;
|
|
2231
|
+
|
|
2232
|
+
std::size_t operator()(std::size_t v) const { return v / N; }
|
|
2233
|
+
};
|
|
2234
|
+
} // namespace
|
|
2235
|
+
|
|
2236
|
+
template <template <class...> class TMap>
|
|
2237
|
+
void testCopyAfterRemovedCollisions() {
|
|
2238
|
+
// Insert 11 things into chunks 0, 1, and 2, 15 into chunk 3, then
|
|
2239
|
+
// remove all but the last one from chunk 1 and see if we can find that
|
|
2240
|
+
// one in a copy of the map.
|
|
2241
|
+
TMap<std::size_t, bool, DivideBy<16>> map;
|
|
2242
|
+
map.reserve(48);
|
|
2243
|
+
for (std::size_t k = 0; k < 11; ++k) {
|
|
2244
|
+
map[k] = true;
|
|
2245
|
+
map[k + 16] = true;
|
|
2246
|
+
map[k + 32] = true;
|
|
2247
|
+
}
|
|
2248
|
+
for (std::size_t k = 0; k < 14; ++k) {
|
|
2249
|
+
map[k + 48] = true;
|
|
2250
|
+
}
|
|
2251
|
+
map[14 + 48] = true;
|
|
2252
|
+
for (std::size_t k = 0; k < 14; ++k) {
|
|
2253
|
+
map.erase(k + 48);
|
|
2254
|
+
}
|
|
2255
|
+
auto copy = map;
|
|
2256
|
+
EXPECT_EQ(copy.count(14 + 48), 1);
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
TEST(F14Map, copyAfterRemovedCollisions) {
|
|
2260
|
+
testCopyAfterRemovedCollisions<F14ValueMap>();
|
|
2261
|
+
testCopyAfterRemovedCollisions<F14VectorMap>();
|
|
2262
|
+
testCopyAfterRemovedCollisions<F14NodeMap>();
|
|
2263
|
+
testCopyAfterRemovedCollisions<F14FastMap>();
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
template <template <class...> class TMap>
|
|
2267
|
+
void testIterDeductionGuide() {
|
|
2268
|
+
TMap<int, double> source({{1, 2.0}, {3, 4.0}});
|
|
2269
|
+
|
|
2270
|
+
TMap dest1(source.begin(), source.end());
|
|
2271
|
+
static_assert(std::is_same_v<decltype(dest1), decltype(source)>);
|
|
2272
|
+
EXPECT_EQ(dest1, source);
|
|
2273
|
+
|
|
2274
|
+
TMap dest2(source.begin(), source.end(), 2);
|
|
2275
|
+
static_assert(std::is_same_v<decltype(dest2), decltype(source)>);
|
|
2276
|
+
EXPECT_EQ(dest2, source);
|
|
2277
|
+
|
|
2278
|
+
TMap dest3(source.begin(), source.end(), 2, f14::DefaultHasher<int>{});
|
|
2279
|
+
static_assert(std::is_same_v<decltype(dest3), decltype(source)>);
|
|
2280
|
+
EXPECT_EQ(dest3, source);
|
|
2281
|
+
|
|
2282
|
+
TMap dest4(
|
|
2283
|
+
source.begin(),
|
|
2284
|
+
source.end(),
|
|
2285
|
+
2,
|
|
2286
|
+
f14::DefaultHasher<int>{},
|
|
2287
|
+
f14::DefaultKeyEqual<int>{});
|
|
2288
|
+
static_assert(std::is_same_v<decltype(dest4), decltype(source)>);
|
|
2289
|
+
EXPECT_EQ(dest4, source);
|
|
2290
|
+
|
|
2291
|
+
TMap dest5(
|
|
2292
|
+
source.begin(),
|
|
2293
|
+
source.end(),
|
|
2294
|
+
2,
|
|
2295
|
+
f14::DefaultHasher<int>{},
|
|
2296
|
+
f14::DefaultKeyEqual<int>{},
|
|
2297
|
+
f14::DefaultAlloc<std::pair<const int, double>>{});
|
|
2298
|
+
static_assert(std::is_same_v<decltype(dest5), decltype(source)>);
|
|
2299
|
+
EXPECT_EQ(dest5, source);
|
|
2300
|
+
|
|
2301
|
+
TMap dest6(
|
|
2302
|
+
source.begin(),
|
|
2303
|
+
source.end(),
|
|
2304
|
+
2,
|
|
2305
|
+
f14::DefaultAlloc<std::pair<const int, double>>{});
|
|
2306
|
+
static_assert(std::is_same_v<decltype(dest6), decltype(source)>);
|
|
2307
|
+
EXPECT_EQ(dest6, source);
|
|
2308
|
+
|
|
2309
|
+
TMap dest7(
|
|
2310
|
+
source.begin(),
|
|
2311
|
+
source.end(),
|
|
2312
|
+
2,
|
|
2313
|
+
f14::DefaultHasher<int>{},
|
|
2314
|
+
f14::DefaultAlloc<std::pair<const int, double>>{});
|
|
2315
|
+
static_assert(std::is_same_v<decltype(dest7), decltype(source)>);
|
|
2316
|
+
EXPECT_EQ(dest7, source);
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
TEST(F14Map, iterDeductionGuide) {
|
|
2320
|
+
testIterDeductionGuide<F14ValueMap>();
|
|
2321
|
+
testIterDeductionGuide<F14NodeMap>();
|
|
2322
|
+
testIterDeductionGuide<F14VectorMap>();
|
|
2323
|
+
testIterDeductionGuide<F14FastMap>();
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
template <template <class...> class TMap>
|
|
2327
|
+
void testInitializerListDeductionGuide() {
|
|
2328
|
+
TMap<int, double> source({{1, 2.0}, {3, 4.0}});
|
|
2329
|
+
|
|
2330
|
+
#if !defined(__GNUC__) || __GNUC__ > 12 || defined(__clang__)
|
|
2331
|
+
// some versions of gcc, including until at least gcc v12, fail here
|
|
2332
|
+
TMap dest1{std::pair{1, 2.0}, {3, 4.0}};
|
|
2333
|
+
static_assert(std::is_same_v<decltype(dest1), decltype(source)>);
|
|
2334
|
+
EXPECT_EQ(dest1, source);
|
|
2335
|
+
#endif
|
|
2336
|
+
|
|
2337
|
+
TMap dest2({std::pair{1, 2.0}, {3, 4.0}});
|
|
2338
|
+
static_assert(std::is_same_v<decltype(dest2), decltype(source)>);
|
|
2339
|
+
EXPECT_EQ(dest2, source);
|
|
2340
|
+
|
|
2341
|
+
TMap dest3({std::pair{1, 2.0}, {3, 4.0}}, 2);
|
|
2342
|
+
static_assert(std::is_same_v<decltype(dest3), decltype(source)>);
|
|
2343
|
+
EXPECT_EQ(dest3, source);
|
|
2344
|
+
|
|
2345
|
+
TMap dest4({std::pair{1, 2.0}, {3, 4.0}}, 2, f14::DefaultHasher<int>{});
|
|
2346
|
+
static_assert(std::is_same_v<decltype(dest4), decltype(source)>);
|
|
2347
|
+
EXPECT_EQ(dest4, source);
|
|
2348
|
+
|
|
2349
|
+
TMap dest5(
|
|
2350
|
+
{std::pair{1, 2.0}, {3, 4.0}},
|
|
2351
|
+
2,
|
|
2352
|
+
f14::DefaultHasher<int>{},
|
|
2353
|
+
f14::DefaultKeyEqual<int>{});
|
|
2354
|
+
static_assert(std::is_same_v<decltype(dest5), decltype(source)>);
|
|
2355
|
+
EXPECT_EQ(dest5, source);
|
|
2356
|
+
|
|
2357
|
+
TMap dest6(
|
|
2358
|
+
{std::pair{1, 2.0}, {3, 4.0}},
|
|
2359
|
+
2,
|
|
2360
|
+
f14::DefaultHasher<int>{},
|
|
2361
|
+
f14::DefaultKeyEqual<int>{},
|
|
2362
|
+
f14::DefaultAlloc<std::pair<const int, double>>{});
|
|
2363
|
+
static_assert(std::is_same_v<decltype(dest6), decltype(source)>);
|
|
2364
|
+
EXPECT_EQ(dest6, source);
|
|
2365
|
+
|
|
2366
|
+
TMap dest7(
|
|
2367
|
+
{std::pair{1, 2.0}, {3, 4.0}},
|
|
2368
|
+
2,
|
|
2369
|
+
f14::DefaultAlloc<std::pair<const int, double>>{});
|
|
2370
|
+
static_assert(std::is_same_v<decltype(dest7), decltype(source)>);
|
|
2371
|
+
EXPECT_EQ(dest7, source);
|
|
2372
|
+
|
|
2373
|
+
TMap dest8(
|
|
2374
|
+
{std::pair{1, 2.0}, {3, 4.0}},
|
|
2375
|
+
2,
|
|
2376
|
+
f14::DefaultHasher<int>{},
|
|
2377
|
+
f14::DefaultAlloc<std::pair<const int, double>>{});
|
|
2378
|
+
static_assert(std::is_same_v<decltype(dest8), decltype(source)>);
|
|
2379
|
+
EXPECT_EQ(dest8, source);
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
TEST(F14Map, initializerListDeductionGuide) {
|
|
2383
|
+
testInitializerListDeductionGuide<F14ValueMap>();
|
|
2384
|
+
testInitializerListDeductionGuide<F14NodeMap>();
|
|
2385
|
+
testInitializerListDeductionGuide<F14VectorMap>();
|
|
2386
|
+
testInitializerListDeductionGuide<F14FastMap>();
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
namespace {
|
|
2390
|
+
|
|
2391
|
+
struct TracedMovable {
|
|
2392
|
+
public:
|
|
2393
|
+
TracedMovable() = default;
|
|
2394
|
+
|
|
2395
|
+
TracedMovable& operator=(TracedMovable&& other) noexcept {
|
|
2396
|
+
if (this != &other) {
|
|
2397
|
+
n = std::exchange(other.n, 0);
|
|
2398
|
+
}
|
|
2399
|
+
return *this;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
TracedMovable(TracedMovable&& other) noexcept {
|
|
2403
|
+
n = std::exchange(other.n, 0);
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
int32_t n{10};
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2409
|
+
} // namespace
|
|
2410
|
+
|
|
2411
|
+
template <template <class...> class TMap>
|
|
2412
|
+
void testInsertOrAssignUnchangedIfNoInsert() {
|
|
2413
|
+
TMap<int32_t, TracedMovable> m;
|
|
2414
|
+
|
|
2415
|
+
m[0] = TracedMovable{};
|
|
2416
|
+
EXPECT_EQ(m[0].n, 10);
|
|
2417
|
+
|
|
2418
|
+
m.insert_or_assign(0, TracedMovable{});
|
|
2419
|
+
EXPECT_EQ(m[0].n, 10);
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
TEST(F14Map, insertOrAssignUnchangedIfNoInsert) {
|
|
2423
|
+
testInsertOrAssignUnchangedIfNoInsert<F14ValueMap>();
|
|
2424
|
+
testInsertOrAssignUnchangedIfNoInsert<F14NodeMap>();
|
|
2425
|
+
testInsertOrAssignUnchangedIfNoInsert<F14VectorMap>();
|
|
2426
|
+
testInsertOrAssignUnchangedIfNoInsert<F14FastMap>();
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
template <typename M>
|
|
2430
|
+
void runSimpleShrinkToFitTest(float expectedLoadFactor) {
|
|
2431
|
+
using K = typename M::key_type;
|
|
2432
|
+
for (int n = 1; n <= 1000; ++n) {
|
|
2433
|
+
M m;
|
|
2434
|
+
for (K k = 0; k < n; ++k) {
|
|
2435
|
+
m[k];
|
|
2436
|
+
}
|
|
2437
|
+
m.reserve(0); // reserve(0) works like shrink_to_fit
|
|
2438
|
+
EXPECT_GE(m.load_factor(), expectedLoadFactor);
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
TEST(F14Map, shrinkToFit) {
|
|
2443
|
+
SKIP_IF(kFallback);
|
|
2444
|
+
runSimpleShrinkToFitTest<F14NodeMap<int, int>>(0.5);
|
|
2445
|
+
runSimpleShrinkToFitTest<F14ValueMap<int, int>>(0.5);
|
|
2446
|
+
runSimpleShrinkToFitTest<F14VectorMap<int, int>>(0.875);
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
template <typename M>
|
|
2450
|
+
void runDefactoShrinkToFitTest(float expectedLoadFactor) {
|
|
2451
|
+
for (int n = 1; n <= 1000; n += (n + 9) / 10) {
|
|
2452
|
+
M m1;
|
|
2453
|
+
for (int k = 0; k < n; ++k) {
|
|
2454
|
+
m1[k];
|
|
2455
|
+
}
|
|
2456
|
+
for (int j = 0; j <= n; ++j) {
|
|
2457
|
+
auto m2 = m1;
|
|
2458
|
+
// any argument < size is a "defacto" shrink_to_fit
|
|
2459
|
+
m2.reserve(m2.size() - j);
|
|
2460
|
+
EXPECT_GE(m2.load_factor(), expectedLoadFactor);
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
TEST(F14Map, defactoShrinkToFit) {
|
|
2466
|
+
SKIP_IF(kFallback);
|
|
2467
|
+
runDefactoShrinkToFitTest<F14NodeMap<int, int>>(0.5);
|
|
2468
|
+
runDefactoShrinkToFitTest<F14ValueMap<int, int>>(0.5);
|
|
2469
|
+
runDefactoShrinkToFitTest<F14VectorMap<int, int>>(0.875);
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
template <typename M>
|
|
2473
|
+
void runInitialReserveTest(float expectedLoadFactor) {
|
|
2474
|
+
auto initBucketsCtor = [](int initBuckets) { return M(initBuckets); };
|
|
2475
|
+
auto defaultCtorAndReserve = [](int initBuckets) {
|
|
2476
|
+
M m;
|
|
2477
|
+
m.reserve(initBuckets);
|
|
2478
|
+
return m;
|
|
2479
|
+
};
|
|
2480
|
+
|
|
2481
|
+
auto fill = [](M& m, int n) {
|
|
2482
|
+
using K = typename M::key_type;
|
|
2483
|
+
auto initBuckets = m.bucket_count();
|
|
2484
|
+
for (K k = 0; k < n; ++k) {
|
|
2485
|
+
m[k];
|
|
2486
|
+
EXPECT_EQ(m.bucket_count(), initBuckets);
|
|
2487
|
+
}
|
|
2488
|
+
};
|
|
2489
|
+
|
|
2490
|
+
using MakeFuncs = std::initializer_list<std::function<M(int)>>;
|
|
2491
|
+
for (const auto& make : MakeFuncs{initBucketsCtor, defaultCtorAndReserve}) {
|
|
2492
|
+
for (int n = 1; n <= 1000; ++n) {
|
|
2493
|
+
auto m = make(n);
|
|
2494
|
+
fill(m, n);
|
|
2495
|
+
EXPECT_GE(m.load_factor(), expectedLoadFactor);
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
TEST(F14Map, initialReserve) {
|
|
2501
|
+
SKIP_IF(kFallback);
|
|
2502
|
+
runInitialReserveTest<F14NodeMap<int, int>>(0.5);
|
|
2503
|
+
runInitialReserveTest<F14ValueMap<int, int>>(0.5);
|
|
2504
|
+
runInitialReserveTest<F14VectorMap<int, int>>(0.875);
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
template <typename M>
|
|
2508
|
+
void runReserveMoreTest(int n) {
|
|
2509
|
+
constexpr int kIters = 1000;
|
|
2510
|
+
M m;
|
|
2511
|
+
int k = 0;
|
|
2512
|
+
for (int i = 0; i < kIters; ++i) {
|
|
2513
|
+
auto bc = m.bucket_count();
|
|
2514
|
+
m.reserve(m.size() + n);
|
|
2515
|
+
EXPECT_GE(m.bucket_count(), bc); // should never shrink
|
|
2516
|
+
for (int j = 0; j < n; ++j) {
|
|
2517
|
+
bc = m.bucket_count();
|
|
2518
|
+
m[k++];
|
|
2519
|
+
EXPECT_EQ(m.bucket_count(), bc);
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
TEST(F14Map, reserveMoreNeverShrinks) {
|
|
2525
|
+
SKIP_IF(kFallback);
|
|
2526
|
+
runReserveMoreTest<F14NodeMap<int, int>>(1);
|
|
2527
|
+
runReserveMoreTest<F14ValueMap<int, int>>(1);
|
|
2528
|
+
runReserveMoreTest<F14VectorMap<int, int>>(1);
|
|
2529
|
+
runReserveMoreTest<F14NodeMap<int, int>>(10);
|
|
2530
|
+
runReserveMoreTest<F14ValueMap<int, int>>(10);
|
|
2531
|
+
runReserveMoreTest<F14VectorMap<int, int>>(10);
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
TEST(F14Map, reserveBadAlloc) {
|
|
2535
|
+
SKIP_IF(kFallback);
|
|
2536
|
+
SKIP_IF(
|
|
2537
|
+
std::numeric_limits<size_t>::max() <=
|
|
2538
|
+
std::numeric_limits<uint32_t>::max());
|
|
2539
|
+
EXPECT_THROW(
|
|
2540
|
+
(F14VectorMap<int, int>().reserve(
|
|
2541
|
+
std::size_t{std::numeric_limits<uint32_t>::max()} + 1)),
|
|
2542
|
+
std::bad_alloc);
|
|
2543
|
+
}
|