Skip to content

Commit 6dea711

Browse files
ckennellycopybara-github
authored andcommitted
Allow tables to be in read-only sections.
PiperOrigin-RevId: 841862343
1 parent 448b53f commit 6dea711

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/google/protobuf/generated_message_tctable_decl.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ struct alignas(uint64_t) TcParseTableBase {
334334
// Table entry for fast-path tailcall dispatch handling.
335335
struct FastFieldEntry {
336336
// Target function for dispatch:
337-
mutable std::atomic<TailCallParseFunc> target_atomic;
337+
TailCallParseFunc target_function;
338338

339339
// Field data used during parse:
340340
TcFieldData bits;
@@ -344,25 +344,14 @@ struct alignas(uint64_t) TcParseTableBase {
344344

345345
// Constant initializes this instance
346346
constexpr FastFieldEntry(TailCallParseFunc func, TcFieldData bits)
347-
: target_atomic(func), bits(bits) {}
347+
: target_function(func), bits(bits) {}
348348

349349
// FastFieldEntry is copy-able and assignable, which is intended
350350
// mainly for testing and debugging purposes.
351-
FastFieldEntry(const FastFieldEntry& rhs) noexcept
352-
: FastFieldEntry(rhs.target(), rhs.bits) {}
353-
FastFieldEntry& operator=(const FastFieldEntry& rhs) noexcept {
354-
SetTarget(rhs.target());
355-
bits = rhs.bits;
356-
return *this;
357-
}
351+
FastFieldEntry(const FastFieldEntry& rhs) noexcept = default;
352+
FastFieldEntry& operator=(const FastFieldEntry& rhs) noexcept = default;
358353

359-
// Protocol buffer code should use these relaxed accessors.
360-
TailCallParseFunc target() const {
361-
return target_atomic.load(std::memory_order_relaxed);
362-
}
363-
void SetTarget(TailCallParseFunc func) const {
364-
return target_atomic.store(func, std::memory_order_relaxed);
365-
}
354+
TailCallParseFunc target() const { return target_function; }
366355
};
367356
// There is always at least one table entry.
368357
const FastFieldEntry* fast_entry(size_t idx) const {

0 commit comments

Comments
 (0)