Move the minimal set of function from `unknown_field_set.cc` to `unknown_field_set_lite.cc`
Change the parser fallback function to separate the extensions case from the unknown field case. This makes both cases faster.
PiperOrigin-RevId: 940598545
Refactor many operations to move the split section handing into an out-of-line function. This makes the main function leaner. It includes destruction, merging, clearing, and byte size calculation.
Change serialization to skip split fields by checking first on the default
check. It can skip sequential fields in a single check.
Change merging algorithm to only "prepare" the split section if we need to write to it. Previously it was preparing it if the source had a split section. This is suboptimal because the source might have allocated a split section but not using it anymore (for example, after a `Clear()`).
Changed copy constructor to invoke the out-of-line merger logic for split fields.
PiperOrigin-RevId: 933816045
Putting message globals on .data.rel.ro section has two benefits:
(1) makes it truly read only and forces seg faults rather than subtle bug when
users unintentionally mutate the default instance.
(2) collocates it on the same section where the type's other const data (vtbl).
PiperOrigin-RevId: 895408151
'_' followed by a capital letter is not allowed and UB. Also, AI review pointed
out that '__' in split default is also UB. Let's fix that as well.
Specifically, this CL renames _MessageName_globals_ &
_MessageName__Impl_Split_default_instance_ to avoid UB.
PiperOrigin-RevId: 894162111
To flush out cases that assume globals == default_instance, add a dummy
pointer #ifdef PROTOBUF_MESSAGE_GLOBALS. Fix those assumptions by explicitly
getting default_instance from globals. This includes how parsers may store
globals.
This CL is no-op #ifndef PROTOBUF_MESSAGE_GLOBALS.
PiperOrigin-RevId: 883399940
With globals == default_instance, this CL is no-op but enables future CLs
that actually break that assumption. This allows collocating default instances,
class data, and parse tables.
PiperOrigin-RevId: 882671564
In the future this option will be used by the field generators to decide which interface to generate for each repeated field, either proxy or legacy.
PiperOrigin-RevId: 879936002
Using `MessageGlobalsBase::default_instance(const void*)` allows transparent
handling of returning default instance at an arbitrary (but constant) offset
from "message globals".
PiperOrigin-RevId: 868373777
ClassDataFull currently contains mutable fields for lazy descriptor init.
Mutable fields prevent message globals placed on read only section and
those fields are not hot either. Moving those fields to a separate data
structure (ReflectionData) improves data locality and enables write-protection.
PiperOrigin-RevId: 866532011
This CL prepares upcoming changes to collocate message-globals under a single
wrapper (go/proto-msg-globals). The plan is to keep dual state guarded by
PROTOBUF_MESSAGE_GLOBALS, which allows smaller CLs and potential A/B experiments.
Exising code exposes a raw default instance to messages that contain the type
to support constinit or constexpr. Using `T::default_instance()` would encapsulate
#ifdef'ing but I didn't find a way to achieve that. (Also, constexpr doesn't allow
reinterpret_cast.)
This CL renames existing raw default instances so that both branches (#ifdef & #ifndef)
can refer to the same name.
```
// Before:
struct FooDefaultTypeInternal;
extern FooDefaultTypeInternal _Foo_default_instance_;
DoSomething(_Foo_default_instance_._instance);
// After
struct FooGlobalsTypeInternal;
extern FooGlobalsTypeInternal _Foo_globals_;
DoSomething(_Foo_globals_._default);
```
Note that this is meant to be name changes only.
PiperOrigin-RevId: 864580684
#test-continuous
This was a legacy shim for C++11 and C++14 support, that's no longer needed. It also seems to be causing potential issues for unsupported compilers, when we disable it.
PiperOrigin-RevId: 853822318
This covers two types of failures:
* Methods that are logically const and failure to consume the result indicates a bug
(an unnecessary call, etc.)
* Methods that return significant errors (failure to parse, etc.) that should not be
unintentionally ignored.
PiperOrigin-RevId: 852406706
Instead of a separate HasBits object with one bit per field we track donation in one arbitrary bit in the capacity.
When the string IsLong that bit in the capacity determines if it is donated.
We also remove all the plumbing for these donation bits, on demand arena destructor, etc.
PiperOrigin-RevId: 843790247
This covers two types of failures:
* Methods that are logically const and failure to consume the result indicates a bug
(an unnecessary call, etc.)
* Methods that return significant errors (failure to parse, etc.) that should not be
unintentionally ignored.
PiperOrigin-RevId: 842042770
All changes to generated code are protected by `PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD`.
With this change, code will now compile with `PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS_REPEATED_PTR_FIELD` enabled.
This change is a no-op and does not enable the change. All generated code is annotated with both the current behavior and the new behavior, and defining PROTOBUF_INTERNAL_REMOVE_ARENA_PTRS will turn the feature on (with no change to codegen needed).
PiperOrigin-RevId: 817848228
Check makes clearer that this method crashes on failure. In a future cl, Verify* will return a status, which is more ergonomic for testing.
PiperOrigin-RevId: 790860983
Fixes the readability-uppercase-literal-suffix clang-tidy warning in the c++ sources produces by protoc as discussed in #21029 with @zhangskz
Closes#21066
PiperOrigin-RevId: 752486171
This results in roughly a 2x speedup and memory reduction, which recovers a big chunk of the 4x regression observed in Chromium after some of our refactorings over the last few years.
PiperOrigin-RevId: 746158016
Store int32_t instead of 16-bits, as that won't increase the size of the aux
entry and will serve for more enums.
Store a closed range instead of start+length. Makes it easier to use.
PiperOrigin-RevId: 740906393