Bug 1350262 - implement prime rehash policy compat for unordered_map and unordered_set in libstdc++. r=glandium
authorLee Salzman <lsalzman@mozilla.com>
Tue, 09 May 2017 22:15:18 -0400
changeset 407936 3d157ccbc5a793ab96cc6a2c2b8aca2bd57f5056
parent 407935 c40129d19820fbf3cef1a70cb0c1a3ef1b8a69c5
child 407937 af6f19870b2a00759ac1d83dedc3db57213abfee
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1350262
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1350262 - implement prime rehash policy compat for unordered_map and unordered_set in libstdc++. r=glandium MozReview-Commit-ID: 1zlGjRMKcBM
build/unix/stdc++compat/stdc++compat.cpp
config/stl-headers
--- a/build/unix/stdc++compat/stdc++compat.cpp
+++ b/build/unix/stdc++compat/stdc++compat.cpp
@@ -27,16 +27,46 @@
 This file adds the necessary compatibility tricks to avoid symbols with
 version GLIBCXX_3.4.16 and bigger, keeping binary compatibility with
 libstdc++ 4.6.1.
 
 */
 
 #define GLIBCXX_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c))
 
+#if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 18)
+// Implementation of utility functions for the prime rehash policy used in
+// unordered_map and unordered_set.
+#include <unordered_map>
+#include <tr1/unordered_map>
+namespace std
+{
+  size_t
+  __detail::_Prime_rehash_policy::_M_next_bkt(size_t __n) const
+  {
+    tr1::__detail::_Prime_rehash_policy policy(_M_max_load_factor);
+    size_t ret = policy._M_next_bkt(__n);
+    _M_next_resize = policy._M_next_resize;
+    return ret;
+  }
+
+  pair<bool, size_t>
+  __detail::_Prime_rehash_policy::_M_need_rehash(size_t __n_bkt,
+                                                 size_t __n_elt,
+                                                 size_t __n_ins) const
+  {
+    tr1::__detail::_Prime_rehash_policy policy(_M_max_load_factor);
+    policy._M_next_resize = _M_next_resize;
+    pair<bool, size_t> ret = policy._M_need_rehash(__n_bkt, __n_elt, __n_ins);
+    _M_next_resize = policy._M_next_resize;
+    return ret;
+  }
+}
+#endif
+
 #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 20)
 namespace std {
 
     /* We shouldn't be throwing exceptions at all, but it sadly turns out
        we call STL (inline) functions that do. */
     void __throw_out_of_range_fmt(char const* fmt, ...)
     {
         va_list ap;
--- a/config/stl-headers
+++ b/config/stl-headers
@@ -31,16 +31,18 @@ list
 map
 memory
 ostream
 set
 stack
 string
 thread
 type_traits
+unordered_map
+unordered_set
 utility
 vector
 cassert
 climits
 cmath
 cstdarg
 cstdio
 cstdlib