Skip to content

Commit

Permalink
Roll abseil_revision 143e983739..7676c565ee
Browse files Browse the repository at this point in the history
Change Log:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+log/143e983739..7676c565ee
Full diff:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+/143e983739..7676c565ee

Bug: None
Change-Id: I5d752e1f3bc11191726f85d679da0304a898c260
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4952590
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
Auto-Submit: Mirko Bonadei <mbonadei@chromium.org>
Reviewed-by: Danil Chapovalov <danilchap@chromium.org>
Commit-Queue: Danil Chapovalov <danilchap@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1211485}
  • Loading branch information
Mirko Bonadei authored and Chromium LUCI CQ committed Oct 18, 2023
1 parent 24f9de2 commit 3fe2752
Show file tree
Hide file tree
Showing 51 changed files with 189 additions and 101 deletions.
1 change: 0 additions & 1 deletion third_party/abseil-cpp/CMake/AbseilDll.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ set(ABSL_INTERNAL_DLL_FILES
"strings/internal/string_constant.h"
"strings/internal/stringify_sink.h"
"strings/internal/stringify_sink.cc"
"strings/internal/has_absl_stringify.h"
"strings/has_absl_stringify.h"
"strings/match.cc"
"strings/match.h"
Expand Down
5 changes: 5 additions & 0 deletions third_party/abseil-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)

# Honor the GTest_ROOT variable if specified
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif (POLICY CMP0074)

# option() honor variables
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
Expand Down
2 changes: 1 addition & 1 deletion third_party/abseil-cpp/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ URL: https://github.com/abseil/abseil-cpp
License: Apache 2.0
License File: LICENSE
Version: 0
Revision: 143e983739333ce4b30320d26bce8594bd24b5f3
Revision: 7676c565eedd2581b66839c239f3825d8e381119
Security Critical: yes
Shipped: yes

Expand Down
11 changes: 6 additions & 5 deletions third_party/abseil-cpp/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# GoogleTest/GoogleMock framework. Used by most unit-tests.
http_archive(
name = "com_google_googletest", # 2023-08-02T16:45:10Z
sha256 = "c4f675500e09da97fd5a2b9c3fdadf48de858a036db565d52e6835c96eeea147",
strip_prefix = "googletest-843976e4f582ccb76cf87e0f128585324335779b",
# Keep this URL in sync with ABSL_GOOGLETEST_COMMIT in ci/cmake_common.sh.
urls = ["https://github.com/google/googletest/archive/843976e4f582ccb76cf87e0f128585324335779b.zip"],
name = "com_google_googletest", # 2023-10-05T21:13:04Z
sha256 = "ba96972e0aa8a1428596570ac573958c1c879483bd148a2b72994453f9dfa7c2",
strip_prefix = "googletest-2dd1c131950043a8ad5ab0d2dda0e0970596586a",
# Keep this URL in sync with ABSL_GOOGLETEST_COMMIT in ci/cmake_common.sh and
# ci/windows_msvc_cmake.bat.
urls = ["https://github.com/google/googletest/archive/2dd1c131950043a8ad5ab0d2dda0e0970596586a.zip"],
)

# RE2 (the regular expression library used by GoogleTest)
Expand Down
1 change: 1 addition & 0 deletions third_party/abseil-cpp/absl/algorithm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ load(
package(
default_visibility = ["//visibility:public"],
features = [
"header_modules",
"layering_check",
"parse_headers",
],
Expand Down
1 change: 1 addition & 0 deletions third_party/abseil-cpp/absl/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ load(
package(
default_visibility = ["//visibility:public"],
features = [
"header_modules",
"layering_check",
"parse_headers",
],
Expand Down
1 change: 1 addition & 0 deletions third_party/abseil-cpp/absl/cleanup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ load(
package(
default_visibility = ["//visibility:public"],
features = [
"header_modules",
"layering_check",
"parse_headers",
],
Expand Down
3 changes: 3 additions & 0 deletions third_party/abseil-cpp/absl/container/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ load(
package(
default_visibility = ["//visibility:public"],
features = [
"header_modules",
"layering_check",
"parse_headers",
],
Expand Down Expand Up @@ -618,6 +619,8 @@ cc_library(
deps = [
":container_memory",
":raw_hash_set",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/base:throw_delegate",
],
)
Expand Down
2 changes: 2 additions & 0 deletions third_party/abseil-cpp/absl/container/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ absl_source_set("raw_hash_map") {
deps = [
":container_memory",
":raw_hash_set",
"//third_party/abseil-cpp/absl/base:config",
"//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/base:throw_delegate",
]
}
Expand Down
2 changes: 2 additions & 0 deletions third_party/abseil-cpp/absl/container/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@ absl_cc_library(
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::container_memory
absl::core_headers
absl::raw_hash_set
absl::throw_delegate
PUBLIC
Expand Down
2 changes: 2 additions & 0 deletions third_party/abseil-cpp/absl/container/internal/raw_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <type_traits>
#include <utility>

#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/throw_delegate.h"
#include "absl/container/internal/container_memory.h"
#include "absl/container/internal/raw_hash_set.h" // IWYU pragma: export
Expand Down
48 changes: 31 additions & 17 deletions third_party/abseil-cpp/absl/container/internal/raw_hash_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ class NonIterableBitMask {
uint32_t LeadingZeros() const {
constexpr int total_significant_bits = SignificantBits << Shift;
constexpr int extra_bits = sizeof(T) * 8 - total_significant_bits;
return static_cast<uint32_t>(countl_zero(mask_ << extra_bits)) >> Shift;
return static_cast<uint32_t>(
countl_zero(static_cast<T>(mask_ << extra_bits))) >>
Shift;
}

T mask_;
Expand Down Expand Up @@ -614,29 +616,31 @@ struct GroupSse2Impl {
}

// Returns a bitmask representing the positions of slots that match hash.
BitMask<uint32_t, kWidth> Match(h2_t hash) const {
BitMask<uint16_t, kWidth> Match(h2_t hash) const {
auto match = _mm_set1_epi8(static_cast<char>(hash));
return BitMask<uint32_t, kWidth>(
static_cast<uint32_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl))));
BitMask<uint16_t, kWidth> result = BitMask<uint16_t, kWidth>(0);
result = BitMask<uint16_t, kWidth>(
static_cast<uint16_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl))));
return result;
}

// Returns a bitmask representing the positions of empty slots.
NonIterableBitMask<uint32_t, kWidth> MaskEmpty() const {
NonIterableBitMask<uint16_t, kWidth> MaskEmpty() const {
#ifdef ABSL_INTERNAL_HAVE_SSSE3
// This only works because ctrl_t::kEmpty is -128.
return NonIterableBitMask<uint32_t, kWidth>(
static_cast<uint32_t>(_mm_movemask_epi8(_mm_sign_epi8(ctrl, ctrl))));
return NonIterableBitMask<uint16_t, kWidth>(
static_cast<uint16_t>(_mm_movemask_epi8(_mm_sign_epi8(ctrl, ctrl))));
#else
auto match = _mm_set1_epi8(static_cast<char>(ctrl_t::kEmpty));
return NonIterableBitMask<uint32_t, kWidth>(
static_cast<uint32_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl))));
return NonIterableBitMask<uint16_t, kWidth>(
static_cast<uint16_t>(_mm_movemask_epi8(_mm_cmpeq_epi8(match, ctrl))));
#endif
}

// Returns a bitmask representing the positions of empty or deleted slots.
NonIterableBitMask<uint32_t, kWidth> MaskEmptyOrDeleted() const {
NonIterableBitMask<uint16_t, kWidth> MaskEmptyOrDeleted() const {
auto special = _mm_set1_epi8(static_cast<char>(ctrl_t::kSentinel));
return NonIterableBitMask<uint32_t, kWidth>(static_cast<uint32_t>(
return NonIterableBitMask<uint16_t, kWidth>(static_cast<uint16_t>(
_mm_movemask_epi8(_mm_cmpgt_epi8_fixed(special, ctrl))));
}

Expand Down Expand Up @@ -842,9 +846,10 @@ class CommonFieldsGenerationInfoEnabled {
if (reserved_growth_ > 0) {
if (--reserved_growth_ == 0) reserved_growth_ = kReservedGrowthJustRanOut;
} else {
*generation_ = NextGeneration(*generation_);
increment_generation();
}
}
void increment_generation() { *generation_ = NextGeneration(*generation_); }
void reset_reserved_growth(size_t reservation, size_t size) {
reserved_growth_ = reservation - size;
}
Expand Down Expand Up @@ -891,6 +896,7 @@ class CommonFieldsGenerationInfoDisabled {
return false;
}
void maybe_increment_generation_on_insert() {}
void increment_generation() {}
void reset_reserved_growth(size_t, size_t) {}
size_t reserved_growth() const { return 0; }
void set_reserved_growth(size_t) {}
Expand Down Expand Up @@ -1062,6 +1068,10 @@ class CommonFields : public CommonFieldsGenerationInfo {
return CommonFieldsGenerationInfo::
should_rehash_for_bug_detection_on_insert(control(), capacity());
}
void maybe_increment_generation_on_move() {
if (capacity() == 0) return;
increment_generation();
}
void reset_reserved_growth(size_t reservation) {
CommonFieldsGenerationInfo::reset_reserved_growth(reservation, size());
}
Expand Down Expand Up @@ -1215,7 +1225,7 @@ inline void AssertIsFull(const ctrl_t* ctrl, GenerationType generation,
if (ABSL_PREDICT_FALSE(generation != *generation_ptr)) {
ABSL_RAW_LOG(FATAL,
"%s called on invalid iterator. The table could have "
"rehashed since this iterator was initialized.",
"rehashed or moved since this iterator was initialized.",
operation);
}
if (ABSL_PREDICT_FALSE(!IsFull(*ctrl))) {
Expand Down Expand Up @@ -1246,8 +1256,8 @@ inline void AssertIsValidForComparison(const ctrl_t* ctrl,
if (SwisstableGenerationsEnabled()) {
if (ABSL_PREDICT_FALSE(generation != *generation_ptr)) {
ABSL_RAW_LOG(FATAL,
"Invalid iterator comparison. The table could have "
"rehashed since this iterator was initialized.");
"Invalid iterator comparison. The table could have rehashed "
"or moved since this iterator was initialized.");
}
if (ABSL_PREDICT_FALSE(!ctrl_is_valid_for_comparison)) {
ABSL_RAW_LOG(
Expand Down Expand Up @@ -1334,8 +1344,8 @@ inline void AssertSameContainer(const ctrl_t* ctrl_a, const ctrl_t* ctrl_b,
ABSL_HARDENING_ASSERT(
AreItersFromSameContainer(ctrl_a, ctrl_b, slot_a, slot_b) &&
"Invalid iterator comparison. The iterators may be from different "
"containers or the container might have rehashed. Consider running "
"with --config=asan to diagnose rehashing issues.");
"containers or the container might have rehashed or moved. Consider "
"running with --config=asan to diagnose issues.");
}
}

Expand Down Expand Up @@ -1922,6 +1932,7 @@ class raw_hash_set {
settings_(std::move(that.common()), that.hash_ref(), that.eq_ref(),
that.alloc_ref()) {
that.common() = CommonFields{};
common().maybe_increment_generation_on_move();
}

raw_hash_set(raw_hash_set&& that, const allocator_type& a)
Expand All @@ -1931,6 +1942,7 @@ class raw_hash_set {
} else {
move_elements_allocs_unequal(std::move(that));
}
common().maybe_increment_generation_on_move();
}

raw_hash_set& operator=(const raw_hash_set& that) {
Expand Down Expand Up @@ -2703,6 +2715,7 @@ class raw_hash_set {
CopyAlloc(alloc_ref(), that.alloc_ref(),
std::integral_constant<bool, propagate_alloc>());
that.common() = CommonFields{};
common().maybe_increment_generation_on_move();
return *this;
}

Expand Down Expand Up @@ -2737,6 +2750,7 @@ class raw_hash_set {
// TODO(b/296061262): move instead of copying hash/eq.
hash_ref() = that.hash_ref();
eq_ref() = that.eq_ref();
common().maybe_increment_generation_on_move();
return move_elements_allocs_unequal(std::move(that));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,32 +284,36 @@ TEST_F(NoPropagateOnCopy, CopyConstructorWithDifferentAlloc) {
}

TEST_F(PropagateOnAll, MoveConstructor) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(std::move(t1));
auto it = u.begin();
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(0, it->num_moves());
EXPECT_EQ(0, it->num_copies());
}

TEST_F(NoPropagateOnMove, MoveConstructor) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(std::move(t1));
auto it = u.begin();
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(0, it->num_moves());
EXPECT_EQ(0, it->num_copies());
}

TEST_F(PropagateOnAll, MoveConstructorWithSameAlloc) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(std::move(t1), a1);
auto it = u.begin();
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(0, it->num_moves());
EXPECT_EQ(0, it->num_copies());
}

TEST_F(NoPropagateOnMove, MoveConstructorWithSameAlloc) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(std::move(t1), a1);
auto it = u.begin();
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(0, it->num_moves());
EXPECT_EQ(0, it->num_copies());
Expand Down Expand Up @@ -378,29 +382,32 @@ TEST_F(NoPropagateOnCopy, CopyAssignmentWithDifferentAlloc) {
}

TEST_F(PropagateOnAll, MoveAssignmentWithSameAlloc) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(0, a1);
u = std::move(t1);
auto it = u.begin();
EXPECT_EQ(a1, u.get_allocator());
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(0, it->num_moves());
EXPECT_EQ(0, it->num_copies());
}

TEST_F(NoPropagateOnMove, MoveAssignmentWithSameAlloc) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(0, a1);
u = std::move(t1);
auto it = u.begin();
EXPECT_EQ(a1, u.get_allocator());
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(0, it->num_moves());
EXPECT_EQ(0, it->num_copies());
}

TEST_F(PropagateOnAll, MoveAssignmentWithDifferentAlloc) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(0, a2);
u = std::move(t1);
auto it = u.begin();
EXPECT_EQ(a1, u.get_allocator());
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(0, a2.num_allocs());
Expand All @@ -409,10 +416,10 @@ TEST_F(PropagateOnAll, MoveAssignmentWithDifferentAlloc) {
}

TEST_F(NoPropagateOnMove, MoveAssignmentWithDifferentAlloc) {
auto it = t1.insert(0).first;
t1.insert(0);
Table u(0, a2);
u = std::move(t1);
it = u.find(0);
auto it = u.find(0);
EXPECT_EQ(a2, u.get_allocator());
EXPECT_EQ(1, a1.num_allocs());
EXPECT_EQ(1, a2.num_allocs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2370,6 +2370,19 @@ TEST(Iterator, InvalidUseWithReserveCrashesWithSanitizers) {
#endif
}

TEST(Iterator, InvalidUseWithMoveCrashesWithSanitizers) {
if (!SwisstableGenerationsEnabled()) GTEST_SKIP() << "Generations disabled.";
if (kMsvc) GTEST_SKIP() << "MSVC doesn't support | in regexp.";

IntTable t1, t2;
t1.insert(1);
auto it = t1.begin();
t2 = std::move(t1);
EXPECT_DEATH_IF_SUPPORTED(*it, kInvalidIteratorDeathMessage);
EXPECT_DEATH_IF_SUPPORTED(void(it == t2.begin()),
kInvalidIteratorDeathMessage);
}

TEST(Table, ReservedGrowthUpdatesWhenTableDoesntGrow) {
IntTable t;
for (int i = 0; i < 8; ++i) t.insert(i);
Expand Down
1 change: 1 addition & 0 deletions third_party/abseil-cpp/absl/crc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ load(
package(
default_visibility = ["//visibility:private"],
features = [
"header_modules",
"layering_check",
"parse_headers",
],
Expand Down
1 change: 1 addition & 0 deletions third_party/abseil-cpp/absl/flags/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ load(
package(
default_visibility = ["//visibility:public"],
features = [
"header_modules",
"layering_check",
"parse_headers",
],
Expand Down
1 change: 1 addition & 0 deletions third_party/abseil-cpp/absl/functional/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ load(
package(
default_visibility = ["//visibility:public"],
features = [
"header_modules",
"layering_check",
"parse_headers",
],
Expand Down

0 comments on commit 3fe2752

Please sign in to comment.