summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-02-03 08:46:25 -0800
committerGravatar Derek Mauro <dmauro@google.com>2022-02-03 19:17:29 +0000
commit36db0e4b695756c948dbb45568b43a62ba5883ec (patch)
treef19029c6f2e6b7da0ad196d5c98dbaed8292dc5a /absl
parent5202173ca7671ebe241cb4d9447dc4b1f2d3ec10 (diff)
Export of internal Abseil changes
-- 4409b08e103d6e7041d18a4d431290cafe3650cf by Derek Mauro <dmauro@google.com>: Workaround NVCC compile error in StringConstant Based on a patch in TensorFlow: https://github.com/tensorflow/tensorflow/blob/da83132aba8d2b6a3c3a9b2e662868eb24f4dd1e/third_party/absl/com_google_absl_fix_mac_and_nvcc_build.patch#L262-L282 Fixes #1105 PiperOrigin-RevId: 426156316 -- 25db16567ffc5400dfaa30b567398ede84729687 by Abseil Team <absl-team@google.com>: Only look for Elf64_Auxinfo on 64-bit FreeBSD. PiperOrigin-RevId: 426132251 -- 2e73c3d9df59b2b769d2b8dca97f0ca5c512c72a by Abseil Team <absl-team@google.com>: Add a problem hint to the error message when dereferencing the end() iterator. PiperOrigin-RevId: 426120394 -- 6befbf89c47963656b9e8151166ab4c8446d4785 by Martijn Vels <mvels@google.com>: Make Cord Btree the default and remove opt out machinery This change makes btree the default Cord format and removes the machinery to opt out. Subsequent changes will remove the 'true' constant evaluation and effectively cleanup all old code and references to CONCAT. PiperOrigin-RevId: 426119728 -- f6a0a664029d61811d90bd484f4eefa0400b5dd4 by Abseil Team <absl-team@google.com>: Mark Notification::HasBeenNotified as ABSL_MUST_USE_RESULT PiperOrigin-RevId: 425927033 GitOrigin-RevId: 4409b08e103d6e7041d18a4d431290cafe3650cf Change-Id: I86f1052c63c13c6486baf4108de2554f162f9c40
Diffstat (limited to 'absl')
-rw-r--r--absl/container/internal/raw_hash_set.h16
-rw-r--r--absl/debugging/internal/vdso_support.cc2
-rw-r--r--absl/strings/cord.cc5
-rw-r--r--absl/strings/cord_test.cc73
-rw-r--r--absl/strings/internal/cord_internal.cc1
-rw-r--r--absl/strings/internal/cord_internal.h6
-rw-r--r--absl/strings/internal/string_constant.h8
-rw-r--r--absl/synchronization/notification.h3
8 files changed, 24 insertions, 90 deletions
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index 93a3fa85..7409d5ec 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -535,15 +535,19 @@ size_t SelectBucketCountForIterRange(InputIter first, InputIter last,
}
inline void AssertIsFull(ctrl_t* ctrl) {
- ABSL_HARDENING_ASSERT((ctrl != nullptr && IsFull(*ctrl)) &&
- "Invalid operation on iterator. The element might have "
- "been erased, or the table might have rehashed.");
+ ABSL_HARDENING_ASSERT(
+ (ctrl != nullptr && IsFull(*ctrl)) &&
+ "Invalid operation on iterator. The element might have "
+ "been erased, the table might have rehashed, or this may "
+ "be an end() iterator.");
}
inline void AssertIsValid(ctrl_t* ctrl) {
- ABSL_HARDENING_ASSERT((ctrl == nullptr || IsFull(*ctrl)) &&
- "Invalid operation on iterator. The element might have "
- "been erased, or the table might have rehashed.");
+ ABSL_HARDENING_ASSERT(
+ (ctrl == nullptr || IsFull(*ctrl)) &&
+ "Invalid operation on iterator. The element might have "
+ "been erased, the table might have rehashed, or this may "
+ "be an end() iterator.");
}
struct FindInfo {
diff --git a/absl/debugging/internal/vdso_support.cc b/absl/debugging/internal/vdso_support.cc
index 977a9f6b..8a015d55 100644
--- a/absl/debugging/internal/vdso_support.cc
+++ b/absl/debugging/internal/vdso_support.cc
@@ -51,7 +51,9 @@
#endif
#if defined(__FreeBSD__)
+#if defined(__ELF_WORD_SIZE) && __ELF_WORD_SIZE == 64
using Elf64_auxv_t = Elf64_Auxinfo;
+#endif
using Elf32_auxv_t = Elf32_Auxinfo;
#endif
diff --git a/absl/strings/cord.cc b/absl/strings/cord.cc
index ddd14ef4..59722107 100644
--- a/absl/strings/cord.cc
+++ b/absl/strings/cord.cc
@@ -96,10 +96,7 @@ static constexpr uint64_t min_length[] = {
static const int kMinLengthSize = ABSL_ARRAYSIZE(min_length);
-static inline bool btree_enabled() {
- return cord_internal::cord_btree_enabled.load(
- std::memory_order_relaxed);
-}
+static inline constexpr bool btree_enabled() { return true; }
static inline bool IsRootBalanced(CordRep* node) {
if (!node->IsConcat()) {
diff --git a/absl/strings/cord_test.cc b/absl/strings/cord_test.cc
index e499b55f..c26e506d 100644
--- a/absl/strings/cord_test.cc
+++ b/absl/strings/cord_test.cc
@@ -231,15 +231,7 @@ ABSL_NAMESPACE_END
// and with our without expected CRCs being set on the subject Cords.
class CordTest : public testing::TestWithParam<int> {
public:
- CordTest() : was_btree_(absl::cord_internal::cord_btree_enabled.load()) {
- absl::cord_internal::cord_btree_enabled.store(UseBtree());
- }
- ~CordTest() override {
- absl::cord_internal::cord_btree_enabled.store(was_btree_);
- }
-
// Returns true if test is running with btree enabled.
- bool UseBtree() const { return GetParam() == 1 || GetParam() == 3; }
bool UseCrc() const { return GetParam() == 2 || GetParam() == 3; }
void MaybeHarden(absl::Cord& c) {
if (UseCrc()) {
@@ -255,27 +247,19 @@ class CordTest : public testing::TestWithParam<int> {
static std::string ToString(testing::TestParamInfo<int> param) {
switch (param.param) {
case 0:
- return "Concat";
- case 1:
return "Btree";
- case 2:
- return "ConcatHardened";
- case 3:
+ case 1:
return "BtreeHardened";
default:
assert(false);
return "???";
}
}
-
- private:
- const bool was_btree_;
};
-INSTANTIATE_TEST_SUITE_P(WithParam, CordTest, testing::Values(0, 1, 2, 3),
+INSTANTIATE_TEST_SUITE_P(WithParam, CordTest, testing::Values(0, 1),
CordTest::ToString);
-
TEST(CordRepFlat, AllFlatCapacities) {
// Explicitly and redundantly assert built-in min/max limits
static_assert(absl::cord_internal::kFlatOverhead < 32, "");
@@ -1561,8 +1545,6 @@ TEST(CordTest, CordMemoryUsageFlatHardenedAndShared) {
}
TEST(CordTest, CordMemoryUsageBTree) {
- absl::cord_internal::enable_cord_btree(true);
-
absl::Cord cord1;
size_t flats1_size = 0;
absl::Cord flats1[4] = {MakeCord(1000, 'a'), MakeCord(1100, 'a'),
@@ -1611,57 +1593,6 @@ TEST(CordTest, CordMemoryUsageBTree) {
rep2_size);
}
-TEST(CordTest, CordMemoryUsageConcat) {
- absl::cord_internal::enable_cord_btree(false);
-
- absl::Cord cord1;
- size_t flats1_size = 0;
- absl::Cord flats1[4] = {MakeCord(1000, 'a'), MakeCord(1100, 'a'),
- MakeCord(1200, 'a'), MakeCord(1300, 'a')};
- for (absl::Cord flat : flats1) {
- flats1_size += absl::CordTestPeer::Tree(flat)->flat()->AllocatedSize();
- cord1.Append(std::move(flat));
- }
-
- // Make sure the created cord is a CONCAT tree. Under some builds such as
- // windows DLL, we may have ODR like effects on the flag, meaning the DLL
- // code will run with the picked up default.
- if (!absl::CordTestPeer::Tree(cord1)->IsConcat()) {
- ABSL_RAW_LOG(WARNING, "Cord library code not respecting btree flag");
- return;
- }
-
- size_t rep1_size = sizeof(CordRepConcat) * 3 + flats1_size;
- size_t rep1_shared_size = sizeof(CordRepConcat) * 3 + flats1_size / 2;
-
- EXPECT_EQ(cord1.EstimatedMemoryUsage(), sizeof(absl::Cord) + rep1_size);
- EXPECT_EQ(cord1.EstimatedMemoryUsage(kFairShare),
- sizeof(absl::Cord) + rep1_shared_size);
-
- absl::Cord cord2;
- size_t flats2_size = 0;
- absl::Cord flats2[4] = {MakeCord(600, 'a'), MakeCord(700, 'a'),
- MakeCord(800, 'a'), MakeCord(900, 'a')};
- for (absl::Cord& flat : flats2) {
- flats2_size += absl::CordTestPeer::Tree(flat)->flat()->AllocatedSize();
- cord2.Append(std::move(flat));
- }
-
- size_t rep2_size = sizeof(CordRepConcat) * 3 + flats2_size;
-
- EXPECT_EQ(cord2.EstimatedMemoryUsage(), sizeof(absl::Cord) + rep2_size);
- EXPECT_EQ(cord2.EstimatedMemoryUsage(kFairShare),
- sizeof(absl::Cord) + rep2_size);
-
- absl::Cord cord(cord1);
- cord.Append(std::move(cord2));
- EXPECT_EQ(cord.EstimatedMemoryUsage(),
- sizeof(absl::Cord) + sizeof(CordRepConcat) + rep1_size + rep2_size);
- EXPECT_EQ(cord.EstimatedMemoryUsage(kFairShare),
- sizeof(absl::Cord) + sizeof(CordRepConcat) + rep1_shared_size / 2 +
- rep2_size);
-}
-
// Regtest for a change that had to be rolled back because it expanded out
// of the InlineRep too soon, which was observable through MemoryUsage().
TEST_P(CordTest, CordMemoryUsageInlineRep) {
diff --git a/absl/strings/internal/cord_internal.cc b/absl/strings/internal/cord_internal.cc
index c9ceac90..feb3bec1 100644
--- a/absl/strings/internal/cord_internal.cc
+++ b/absl/strings/internal/cord_internal.cc
@@ -27,7 +27,6 @@ namespace absl {
ABSL_NAMESPACE_BEGIN
namespace cord_internal {
-ABSL_CONST_INIT std::atomic<bool> cord_btree_enabled(kCordEnableBtreeDefault);
ABSL_CONST_INIT std::atomic<bool> cord_ring_buffer_enabled(
kCordEnableRingBufferDefault);
ABSL_CONST_INIT std::atomic<bool> shallow_subcords_enabled(
diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h
index 776d1c40..b9ecbba6 100644
--- a/absl/strings/internal/cord_internal.h
+++ b/absl/strings/internal/cord_internal.h
@@ -37,12 +37,10 @@ class CordzInfo;
// Default feature enable states for cord ring buffers
enum CordFeatureDefaults {
- kCordEnableBtreeDefault = true,
kCordEnableRingBufferDefault = false,
kCordShallowSubcordsDefault = false
};
-extern std::atomic<bool> cord_btree_enabled;
extern std::atomic<bool> cord_ring_buffer_enabled;
extern std::atomic<bool> shallow_subcords_enabled;
@@ -52,10 +50,6 @@ extern std::atomic<bool> shallow_subcords_enabled;
// O(n^2) complexity as recursive / full tree validation is O(n).
extern std::atomic<bool> cord_btree_exhaustive_validation;
-inline void enable_cord_btree(bool enable) {
- cord_btree_enabled.store(enable, std::memory_order_relaxed);
-}
-
inline void enable_cord_ring_buffer(bool enable) {
cord_ring_buffer_enabled.store(enable, std::memory_order_relaxed);
}
diff --git a/absl/strings/internal/string_constant.h b/absl/strings/internal/string_constant.h
index a11336b7..b358efdd 100644
--- a/absl/strings/internal/string_constant.h
+++ b/absl/strings/internal/string_constant.h
@@ -35,12 +35,18 @@ namespace strings_internal {
// below.
template <typename T>
struct StringConstant {
+ private:
+ static constexpr bool TryConstexprEval(absl::string_view view) {
+ return view.empty() || 2 * view[0] != 1;
+ }
+
+ public:
static constexpr absl::string_view value = T{}();
constexpr absl::string_view operator()() const { return value; }
// Check to be sure `view` points to constant data.
// Otherwise, it can't be constant evaluated.
- static_assert(value.empty() || 2 * value[0] != 1,
+ static_assert(TryConstexprEval(value),
"The input string_view must point to constant data.");
};
diff --git a/absl/synchronization/notification.h b/absl/synchronization/notification.h
index 429968da..4bec2689 100644
--- a/absl/synchronization/notification.h
+++ b/absl/synchronization/notification.h
@@ -52,6 +52,7 @@
#include <atomic>
+#include "absl/base/attributes.h"
#include "absl/base/macros.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/time.h"
@@ -74,7 +75,7 @@ class Notification {
// Notification::HasBeenNotified()
//
// Returns the value of the notification's internal "notified" state.
- bool HasBeenNotified() const {
+ ABSL_MUST_USE_RESULT bool HasBeenNotified() const {
return HasBeenNotifiedInternal(&this->notified_yet_);
}