From 6dea711745d64193c9db8ae0da3a39a72e2c5964 Mon Sep 17 00:00:00 2001 From: Chris Kennelly Date: Mon, 8 Dec 2025 12:03:51 -0800 Subject: [PATCH] Allow tables to be in read-only sections. PiperOrigin-RevId: 841862343 --- .../protobuf/generated_message_tctable_decl.h | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/google/protobuf/generated_message_tctable_decl.h b/src/google/protobuf/generated_message_tctable_decl.h index a71cb1cbfbd4a..27c52dca9535a 100644 --- a/src/google/protobuf/generated_message_tctable_decl.h +++ b/src/google/protobuf/generated_message_tctable_decl.h @@ -334,7 +334,7 @@ struct alignas(uint64_t) TcParseTableBase { // Table entry for fast-path tailcall dispatch handling. struct FastFieldEntry { // Target function for dispatch: - mutable std::atomic target_atomic; + TailCallParseFunc target_function; // Field data used during parse: TcFieldData bits; @@ -344,25 +344,14 @@ struct alignas(uint64_t) TcParseTableBase { // Constant initializes this instance constexpr FastFieldEntry(TailCallParseFunc func, TcFieldData bits) - : target_atomic(func), bits(bits) {} + : target_function(func), bits(bits) {} // FastFieldEntry is copy-able and assignable, which is intended // mainly for testing and debugging purposes. - FastFieldEntry(const FastFieldEntry& rhs) noexcept - : FastFieldEntry(rhs.target(), rhs.bits) {} - FastFieldEntry& operator=(const FastFieldEntry& rhs) noexcept { - SetTarget(rhs.target()); - bits = rhs.bits; - return *this; - } + FastFieldEntry(const FastFieldEntry& rhs) noexcept = default; + FastFieldEntry& operator=(const FastFieldEntry& rhs) noexcept = default; - // Protocol buffer code should use these relaxed accessors. - TailCallParseFunc target() const { - return target_atomic.load(std::memory_order_relaxed); - } - void SetTarget(TailCallParseFunc func) const { - return target_atomic.store(func, std::memory_order_relaxed); - } + TailCallParseFunc target() const { return target_function; } }; // There is always at least one table entry. const FastFieldEntry* fast_entry(size_t idx) const {