Introduce `MessageCreator`, which will use more efficient techniques to instantiate objects if permitted by the compiler.

We can use memset for zero initialized objects, and memcpy for ones cloned from the prototype.
This permits creating objects from the parser without calling virtual functions.

For the cases where the efficient implementation can't be used, we generate a "placement new" style function to offload the memory allocation out of the code generation. This reduces code bloat even when we can't use the more efficient implementation.

Migrate many callers of `New` and similar to the new functionality. In particular, the parsing paths will use this.

Finally, make `New` non-virtual now that `MessageLite` can handle it directly. It reduces binary size.

PiperOrigin-RevId: 665411723
pull/17841/head
Protobuf Team Bot 5 months ago committed by Copybara-Service
parent c8d0f96256
commit cd002c06b6
  1. 2
      editions/golden/compare_cpp_codegen_failure.xml
  2. 1
      src/google/protobuf/arena_unittest.cc
  3. 1
      src/google/protobuf/compiler/cpp/file.cc
  4. 7
      src/google/protobuf/compiler/cpp/file_unittest.cc
  5. 182
      src/google/protobuf/compiler/cpp/message.cc
  6. 11
      src/google/protobuf/compiler/cpp/message.h
  7. 4
      src/google/protobuf/compiler/cpp/parse_function_generator.cc
  8. 18
      src/google/protobuf/compiler/cpp/test_bad_identifiers.proto
  9. 10
      src/google/protobuf/compiler/java/java_features.pb.cc
  10. 5
      src/google/protobuf/compiler/java/java_features.pb.h
  11. 67
      src/google/protobuf/compiler/plugin.pb.cc
  12. 20
      src/google/protobuf/compiler/plugin.pb.h
  13. 10
      src/google/protobuf/cpp_features.pb.cc
  14. 5
      src/google/protobuf/cpp_features.pb.h
  15. 635
      src/google/protobuf/descriptor.pb.cc
  16. 165
      src/google/protobuf/descriptor.pb.h
  17. 45
      src/google/protobuf/dynamic_message.cc
  18. 4
      src/google/protobuf/extension_set.h
  19. 1
      src/google/protobuf/generated_message_reflection.cc
  20. 3
      src/google/protobuf/generated_message_tctable_decl.h
  21. 5
      src/google/protobuf/generated_message_tctable_gen.cc
  22. 1
      src/google/protobuf/generated_message_tctable_gen.h
  23. 5
      src/google/protobuf/generated_message_tctable_impl.h
  24. 4
      src/google/protobuf/generated_message_tctable_lite.cc
  25. 15
      src/google/protobuf/generated_message_util.h
  26. 3
      src/google/protobuf/implicit_weak_message.cc
  27. 9
      src/google/protobuf/implicit_weak_message.h
  28. 4
      src/google/protobuf/map.h
  29. 4
      src/google/protobuf/map_entry.h
  30. 10
      src/google/protobuf/map_field.h
  31. 7
      src/google/protobuf/map_field_lite.h
  32. 4
      src/google/protobuf/message.h
  33. 9
      src/google/protobuf/message_lite.cc
  34. 235
      src/google/protobuf/message_lite.h
  35. 3
      src/google/protobuf/message_unittest.cc
  36. 34
      src/google/protobuf/port.h
  37. 5
      src/google/protobuf/repeated_field.h
  38. 6
      src/google/protobuf/repeated_ptr_field.h
  39. 24
      src/google/protobuf/unittest.proto

@ -2,7 +2,7 @@
<testsuites tests="1" name="AllTests">
<testsuite name="EditionsCodegenTests">
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.cc" status="run" result="completed" classname="DiffTest">
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.cc&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;// Protobuf C++ Version: 0.20240819.0&#x0A;&#x0A;#include &quot;third_party/protobuf/editions/golden/simple_proto3.pb.h&quot;&#x0A;&#x0A;#include &lt;algorithm&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/extension_set.h&quot;&#x0A;#include &quot;third_party/protobuf/wire_format_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/io/zero_copy_stream_impl_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;, with the difference:&#x0A;@@ @@&#x0A; ::_pbi::TcParser::GetTable&lt;::protobuf_editions_test::golden::SimpleProto3&gt;(), // to_prefetch&#x0A; #endif // PROTOBUF_PREFETCH_PARSE_TABLE&#x0A; }, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {::_pbi::TcParser::FastV32S1,&#x0A; {8, 0, 0, PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},&#x0A; }}, {{&#x0A; 65535, 65535&#x0A; }}, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0,&#x0A; (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; target = ::proto2::internal::WireFormatLite::&#x0A; WriteInt32ToArrayWithField&lt;1&gt;(&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; {&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.cc&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;// Protobuf C++ Version: 0.20240819.0&#x0A;&#x0A;#include &quot;third_party/protobuf/editions/golden/simple_proto3.pb.h&quot;&#x0A;&#x0A;#include &lt;algorithm&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_impl.h&quot;&#x0A;#include &quot;third_party/protobuf/extension_set.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/wire_format_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/io/zero_copy_stream_impl_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;, with the difference:&#x0A;@@ @@&#x0A; ::_pbi::TcParser::GetTable&lt;::protobuf_editions_test::golden::SimpleProto3&gt;(), // to_prefetch&#x0A; #endif // PROTOBUF_PREFETCH_PARSE_TABLE&#x0A; }, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {::_pbi::TcParser::FastV32S1,&#x0A; {8, 0, 0, PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_)}},&#x0A; }}, {{&#x0A; 65535, 65535&#x0A; }}, {{&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; {PROTOBUF_FIELD_OFFSET(SimpleProto3, _impl_.int32_field_), _Internal::kHasBitsOffset + 0, 0,&#x0A; (0 | ::_fl::kFcOptional | ::_fl::kInt32)},&#x0A; }},&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; target = ::proto2::internal::WireFormatLite::&#x0A; WriteInt32ToArrayWithField&lt;1&gt;(&#x0A;@@ @@&#x0A; (void)cached_has_bits;&#x0A; &#x0A; {&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; cached_has_bits = this_._impl_._has_bits_[0];&#x0A; if (cached_has_bits &amp; 0x00000001u) {&#x0A; total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(" type=""></failure>
</testcase>
<testcase name="third_party/protobuf/editions/golden/simple_proto3.pb.h" status="run" result="completed" classname="DiffTest">
<failure message="Value of: third_party/protobuf/editions/golden/simple_proto3.pb.h&#x0A;Expected: &#x0A;// Generated by the protocol buffer compiler. DO NOT EDIT!&#x0A;// NO CHECKED-IN PROTOBUF GENCODE&#x0A;// source: third_party/protobuf/editions/golden/simple_proto3.proto&#x0A;// Protobuf C++ Version: 0.20240819.0&#x0A;&#x0A;#ifndef GOOGLE_PROTOBUF_INCLUDED_third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;#define GOOGLE_PROTOBUF_INCLUDED_third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;&#x0A;#include &lt;limits&gt;&#x0A;#include &lt;string&gt;&#x0A;#include &lt;type_traits&gt;&#x0A;#include &lt;utility&gt;&#x0A;&#x0A;#include &quot;third_party/protobuf/runtime_version.h&quot;&#x0A;#if PROTOBUF_VERSION != 20240819&#x0A;#error &quot;Protobuf C++ gencode is built with an incompatible version of&quot;&#x0A;#error &quot;Protobuf C++ headers/runtime. See&quot;&#x0A;#error &quot;https://protobuf.dev/support/cross-version-runtime-guarantee/#cpp&quot;&#x0A;#endif&#x0A;#include &quot;third_party/protobuf/io/coded_stream.h&quot;&#x0A;#include &quot;third_party/protobuf/arena.h&quot;&#x0A;#include &quot;third_party/protobuf/arenastring.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_tctable_decl.h&quot;&#x0A;#include &quot;third_party/protobuf/generated_message_util.h&quot;&#x0A;#include &quot;third_party/protobuf/metadata_lite.h&quot;&#x0A;#include &quot;third_party/protobuf/message_lite.h&quot;&#x0A;// @@protoc_insertion_point(includes)&#x0A;&#x0A;// Must be included last.&#x0A;&#x0A;#endif // GOOGLE_PROTOBUF_INCLUDED_third_5fparty_2fprotobuf_2feditions_2fgolden_2fsimple_5fproto3_2eproto_2epb_2eh&#x0A;, with the difference:&#x0A;@@ @@&#x0A; enum : int {&#x0A; kInt32FieldFieldNumber = 1,&#x0A; };&#x0A;- // optional int32 int32_field = 1;&#x0A;+ // int32 int32_field = 1;&#x0A; bool has_int32_field() const;&#x0A; void clear_int32_field() ;&#x0A; ::int32_t int32_field() const;&#x0A;@@ @@&#x0A; &#x0A; // SimpleProto3&#x0A; &#x0A;-// optional int32 int32_field = 1;&#x0A;+// int32 int32_field = 1;&#x0A; inline bool SimpleProto3::has_int32_field() const {&#x0A; bool value = (_impl_._has_bits_[0] &amp; 0x00000001u) != 0;&#x0A; return value;" type=""></failure>

@ -528,7 +528,6 @@ class DispatcherTestProto : public Message {
: Message(nullptr, nullptr) {
ABSL_LOG(FATAL);
}
DispatcherTestProto* New(Arena*) const PROTOBUF_FINAL { ABSL_LOG(FATAL); }
const ClassData* GetClassData() const PROTOBUF_FINAL { ABSL_LOG(FATAL); }
};
// We use a specialization to inject behavior for the test.

@ -489,6 +489,7 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* p) {
IncludeFile("third_party/protobuf/generated_message_tctable_impl.h", p);
// TODO This is to include parse_context.h, we need a better way
IncludeFile("third_party/protobuf/extension_set.h", p);
IncludeFile("third_party/protobuf/generated_message_util.h", p);
IncludeFile("third_party/protobuf/wire_format_lite.h", p);
if (ShouldVerify(file_, options_, &scc_analyzer_)) {

@ -115,6 +115,9 @@ TEST(FileTest, TopologicallyOrderedDescriptors) {
"OneBytes",
"MoreString",
"MoreBytes",
"MessageCreatorZeroInit",
"MessageCreatorMemcpy.M2Entry",
"MessageCreatorFunc",
"ManyOptionalString",
"Int64ParseTester",
"Int64Message",
@ -153,6 +156,7 @@ TEST(FileTest, TopologicallyOrderedDescriptors) {
"TestCamelCaseFieldNames",
"TestAllTypes",
"RedactedFields",
"MessageCreatorMemcpy",
"TestVerifyUint32BigFieldNumber",
"TestVerifyUint32",
"TestVerifyOneUint32",
@ -206,9 +210,6 @@ TEST(FileTest, TopologicallyOrderedDescriptors) {
EXPECT_TRUE(match) << "failed to match; expected "
<< kExpectedDescriptorOrder[i] << ", got "
<< desc->full_name();
if (!match) {
break;
}
}
}

@ -1388,12 +1388,17 @@ void MessageGenerator::GenerateMapEntryClassDefinition(io::Printer* p) {
$decl_verify_func$;
private:
friend class ::$proto_ns$::MessageLite;
friend struct ::$tablename$;
$parse_decls$;
$decl_annotate$;
const $superclass$::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::$proto_ns$::Arena* arena);
static constexpr auto InternalNewImpl_();
static const $superclass$::ClassDataFull _class_data_;
friend struct ::$tablename$;
};
)cc");
}
@ -2133,7 +2138,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
// implements Message ----------------------------------------------
$classname$* New(::$proto_ns$::Arena* arena = nullptr) const PROTOBUF_FINAL {
$classname$* New(::$proto_ns$::Arena* arena = nullptr) const {
return $superclass$::DefaultConstruct<$classname$>(arena);
}
$generated_methods$;
@ -2158,6 +2163,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
}
$arena_dtor$;
const $superclass$::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::$proto_ns$::Arena* arena);
static constexpr auto InternalNewImpl_();
static const $superclass$::$classdata_type$ _class_data_;
public:
@ -3787,12 +3795,176 @@ void MessageGenerator::GenerateSwap(io::Printer* p) {
format("}\n");
}
MessageGenerator::NewOpRequirements MessageGenerator::GetNewOp(
io::Printer* arena_emitter) const {
size_t arena_seeding_count = 0;
NewOpRequirements op;
if (IsBootstrapProto(options_, descriptor_->file())) {
// To simplify bootstrapping we always use a function for these types.
// It makes it easier to change the ABI of the `MessageCreator` class.
op.needs_to_run_constructor = true;
return op;
}
if (NeedsArenaDestructor() == ArenaDtorNeeds::kRequired) {
// We can't skip the ArenaDtor for these messages.
op.needs_to_run_constructor = true;
}
if (descriptor_->extension_range_count() > 0) {
op.needs_arena_seeding = true;
++arena_seeding_count;
if (arena_emitter) {
arena_emitter->Emit(R"cc(
PROTOBUF_FIELD_OFFSET($classname$, $extensions$) +
decltype($classname$::$extensions$)::InternalGetArenaOffset(
$superclass$::internal_visibility()),
)cc");
}
}
if (num_weak_fields_ != 0) {
op.needs_to_run_constructor = true;
}
for (const FieldDescriptor* field : FieldRange(descriptor_)) {
const auto print_arena_offset = [&](absl::string_view suffix = "") {
++arena_seeding_count;
if (arena_emitter) {
arena_emitter->Emit(
{{"field", FieldMemberName(field, false)}, {"suffix", suffix}},
R"cc(
PROTOBUF_FIELD_OFFSET($classname$, $field$) +
decltype($classname$::$field$)::
InternalGetArenaOffset$suffix$(
$superclass$::internal_visibility()),
)cc");
}
};
if (ShouldSplit(field, options_)) {
op.needs_memcpy = true;
} else if (field->real_containing_oneof() != nullptr) {
/* nothing to do */
} else if (field->is_map()) {
op.needs_arena_seeding = true;
// MapField contains an internal vtable pointer we need to copy.
op.needs_memcpy = true;
print_arena_offset();
// Non-lite maps currently have more than one arena pointer in them. Print
// both.
if (HasDescriptorMethods(descriptor_->file(), options_)) {
print_arena_offset("Alt");
}
} else if (field->is_repeated()) {
op.needs_arena_seeding = true;
print_arena_offset();
} else {
const auto& generator = field_generators_.get(field);
if (generator.has_trivial_zero_default()) {
/* nothing to do */
} else {
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_INT32:
case FieldDescriptor::CPPTYPE_INT64:
case FieldDescriptor::CPPTYPE_UINT32:
case FieldDescriptor::CPPTYPE_UINT64:
case FieldDescriptor::CPPTYPE_DOUBLE:
case FieldDescriptor::CPPTYPE_FLOAT:
case FieldDescriptor::CPPTYPE_BOOL:
case FieldDescriptor::CPPTYPE_ENUM:
op.needs_memcpy = true;
break;
case FieldDescriptor::CPPTYPE_STRING:
switch (internal::cpp::EffectiveStringCType(field)) {
case FieldOptions::STRING_PIECE:
op.needs_arena_seeding = true;
print_arena_offset();
break;
case FieldOptions::CORD:
// Cord fields are currently rejected above because of ArenaDtor
// requirements.
ABSL_CHECK(op.needs_to_run_constructor);
break;
case FieldOptions::STRING:
op.needs_memcpy = true;
break;
default:
ABSL_LOG(FATAL);
}
break;
case FieldDescriptor::CPPTYPE_MESSAGE:
ABSL_LOG(FATAL) << "Message should be zero initializable.";
break;
}
}
}
}
// If we are going to generate too many arena seeding offsets, we can skip the
// attempt because we know it will fail at compile time and fallback to
// placement new. The arena seeding code can handle up to an offset of
// `63 * sizeof(Arena*)`.
// This prevents generating huge lists that have to be run during constant
// evaluation to just fail anyway. The actual upper bound is smaller than
// this, but any reasonable value is enough to prevent long compile times for
// big messages.
if (arena_seeding_count >= 64) {
op.needs_to_run_constructor = true;
}
return op;
}
void MessageGenerator::GenerateClassData(io::Printer* p) {
const auto new_op = GetNewOp(nullptr);
// Always generate PlacementNew_ because we might need it for different
// reasons. EnableCustomNewFor<T> might be false in this compiler, or the
// object might be too large for arena seeding.
// We mark `inline` to avoid library bloat if the function is unused.
p->Emit(R"cc(
inline void* $classname$::PlacementNew_(const void*, void* mem,
::$proto_ns$::Arena* arena) {
return ::new (mem) $classname$(arena);
}
)cc");
if (new_op.needs_to_run_constructor) {
p->Emit(R"cc(
constexpr auto $classname$::InternalNewImpl_() {
return $pbi$::MessageCreator(&$classname$::PlacementNew_,
sizeof($classname$));
}
)cc");
} else if (new_op.needs_arena_seeding) {
p->Emit({{"copy_type", new_op.needs_memcpy ? "CopyInit" : "ZeroInit"},
{"arena_offsets", [&] { GetNewOp(p); }}},
R"cc(
constexpr auto $classname$::InternalNewImpl_() {
constexpr auto arena_bits = $pbi$::EncodePlacementArenaOffsets({
$arena_offsets$,
});
if (arena_bits.has_value()) {
return $pbi$::MessageCreator::$copy_type$(sizeof($classname$), *arena_bits);
} else {
return $pbi$::MessageCreator(&$classname$::PlacementNew_,
sizeof($classname$));
}
}
)cc");
} else {
p->Emit({{"copy_type", new_op.needs_memcpy ? "CopyInit" : "ZeroInit"},
{"arena_offsets", [&] { GetNewOp(p); }}},
R"cc(
constexpr auto $classname$::InternalNewImpl_() {
return $pbi$::MessageCreator::$copy_type$(sizeof($classname$));
}
)cc");
}
auto vars = p->WithVars(
{{"default_instance",
absl::StrCat("&", DefaultInstanceName(descriptor_, options_),
"._instance")}});
const auto on_demand_register_arena_dtor = [&] {
if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) {
p->Emit(R"cc(
@ -3882,9 +4054,9 @@ void MessageGenerator::GenerateClassData(io::Printer* p) {
$on_demand_register_arena_dtor$,
$is_initialized$,
&$classname$::MergeImpl,
$superclass$::GetNewImpl<$classname$>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
$superclass$::GetDeleteImpl<$classname$>(),
$superclass$::GetNewImpl<$classname$>(),
$custom_vtable_methods$,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET($classname$, $cached_size$),
@ -3920,9 +4092,9 @@ void MessageGenerator::GenerateClassData(io::Printer* p) {
$on_demand_register_arena_dtor$,
$is_initialized$,
&$classname$::MergeImpl,
$superclass$::GetNewImpl<$classname$>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
$superclass$::GetDeleteImpl<$classname$>(),
$superclass$::GetNewImpl<$classname$>(),
$custom_vtable_methods$,
#endif // PROTOBUF_CUSTOM_VTABLE
PROTOBUF_FIELD_OFFSET($classname$, $cached_size$),

@ -134,6 +134,17 @@ class MessageGenerator {
void GenerateIsInitialized(io::Printer* p);
bool NeedsIsInitialized();
struct NewOpRequirements {
// Some field is initialized to non-zero values. Eg string fields pointing
// to default string.
bool needs_memcpy = false;
// Some field has a copy of the arena.
bool needs_arena_seeding = false;
// Some field has logic that needs to run.
bool needs_to_run_constructor = false;
};
NewOpRequirements GetNewOp(io::Printer* arena_emitter) const;
// Helpers for GenerateSerializeWithCachedSizes().
//
// cached_has_bit_index maintains that:

@ -490,10 +490,6 @@ void ParseFunctionGenerator::GenerateTailCallTable(io::Printer* printer) {
)cc");
break;
}
case TailCallTableInfo::kCreateInArena:
format("{::_pbi::TcParser::CreateInArenaStorageCb<$1$>},\n",
QualifiedClassName(aux_entry.desc, options_));
break;
}
}
}

@ -69,18 +69,32 @@ message TestConflictingSymbolNames {
optional int32 controller = 14;
optional int32 already_here = 15;
// Integral types
optional uint32 uint8 = 47;
optional uint32 uint8_t = 48;
optional uint32 uint16 = 49;
optional uint32 uint16_t = 50;
optional uint32 uint32 = 16;
optional uint32 uint32_t = 41;
optional uint64 uint64 = 17;
optional uint32 uint64_t = 42;
optional string string = 18;
optional int32 memset = 19;
optional uint32 int8 = 51;
optional uint32 int8_t = 52;
optional uint32 int16 = 53;
optional uint32 int16_t = 54;
optional int32 int32 = 20;
optional int32 int32_t = 43;
optional int64 int64 = 21;
optional int64 int64_t = 44;
optional int64 size_t = 45;
optional int64 ssize_t = 55;
optional int64 intptr_t = 46;
optional int64 uintptr_t = 56;
optional string string = 18;
optional int32 memset = 19;
// Internal identifier
optional uint32 cached_size = 22;
optional uint32 extensions = 23;
optional uint32 bit = 24;

@ -10,6 +10,7 @@
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/generated_message_tctable_impl.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_reflection.h"
@ -193,6 +194,13 @@ inline void JavaFeatures::SharedDtor() {
_impl_.~Impl_();
}
inline void* JavaFeatures::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) JavaFeatures(arena);
}
constexpr auto JavaFeatures::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(JavaFeatures));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::MessageLite::ClassDataFull
@ -203,9 +211,9 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&JavaFeatures::MergeImpl,
::google::protobuf::Message::GetNewImpl<JavaFeatures>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<JavaFeatures>(),
::google::protobuf::Message::GetNewImpl<JavaFeatures>(),
::google::protobuf::Message::GetClearImpl<JavaFeatures>(), &JavaFeatures::ByteSizeLong,
&JavaFeatures::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE

@ -175,7 +175,7 @@ class PROTOC_EXPORT JavaFeatures final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
JavaFeatures* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
JavaFeatures* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<JavaFeatures>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -231,6 +231,9 @@ class PROTOC_EXPORT JavaFeatures final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:

@ -10,6 +10,7 @@
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/generated_message_tctable_impl.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_reflection.h"
@ -391,6 +392,13 @@ inline void Version::SharedDtor() {
_impl_.~Impl_();
}
inline void* Version::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) Version(arena);
}
constexpr auto Version::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(Version));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::MessageLite::ClassDataFull
@ -401,9 +409,9 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&Version::MergeImpl,
::google::protobuf::Message::GetNewImpl<Version>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<Version>(),
::google::protobuf::Message::GetNewImpl<Version>(),
::google::protobuf::Message::GetClearImpl<Version>(), &Version::ByteSizeLong,
&Version::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE
@ -725,6 +733,32 @@ inline void CodeGeneratorRequest::SharedDtor() {
_impl_.~Impl_();
}
inline void* CodeGeneratorRequest::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) CodeGeneratorRequest(arena);
}
constexpr auto CodeGeneratorRequest::InternalNewImpl_() {
constexpr auto arena_bits = ::google::protobuf::internal::EncodePlacementArenaOffsets({
PROTOBUF_FIELD_OFFSET(CodeGeneratorRequest, _impl_.file_to_generate_) +
decltype(CodeGeneratorRequest::_impl_.file_to_generate_)::
InternalGetArenaOffset(
::google::protobuf::Message::internal_visibility()),
PROTOBUF_FIELD_OFFSET(CodeGeneratorRequest, _impl_.proto_file_) +
decltype(CodeGeneratorRequest::_impl_.proto_file_)::
InternalGetArenaOffset(
::google::protobuf::Message::internal_visibility()),
PROTOBUF_FIELD_OFFSET(CodeGeneratorRequest, _impl_.source_file_descriptors_) +
decltype(CodeGeneratorRequest::_impl_.source_file_descriptors_)::
InternalGetArenaOffset(
::google::protobuf::Message::internal_visibility()),
});
if (arena_bits.has_value()) {
return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(CodeGeneratorRequest), *arena_bits);
} else {
return ::google::protobuf::internal::MessageCreator(&CodeGeneratorRequest::PlacementNew_,
sizeof(CodeGeneratorRequest));
}
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::MessageLite::ClassDataFull
@ -735,9 +769,9 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
CodeGeneratorRequest::IsInitializedImpl,
&CodeGeneratorRequest::MergeImpl,
::google::protobuf::Message::GetNewImpl<CodeGeneratorRequest>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CodeGeneratorRequest>(),
::google::protobuf::Message::GetNewImpl<CodeGeneratorRequest>(),
::google::protobuf::Message::GetClearImpl<CodeGeneratorRequest>(), &CodeGeneratorRequest::ByteSizeLong,
&CodeGeneratorRequest::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE
@ -1114,6 +1148,13 @@ inline void CodeGeneratorResponse_File::SharedDtor() {
_impl_.~Impl_();
}
inline void* CodeGeneratorResponse_File::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) CodeGeneratorResponse_File(arena);
}
constexpr auto CodeGeneratorResponse_File::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(CodeGeneratorResponse_File));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::MessageLite::ClassDataFull
@ -1124,9 +1165,9 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&CodeGeneratorResponse_File::MergeImpl,
::google::protobuf::Message::GetNewImpl<CodeGeneratorResponse_File>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CodeGeneratorResponse_File>(),
::google::protobuf::Message::GetNewImpl<CodeGeneratorResponse_File>(),
::google::protobuf::Message::GetClearImpl<CodeGeneratorResponse_File>(), &CodeGeneratorResponse_File::ByteSizeLong,
&CodeGeneratorResponse_File::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE
@ -1458,6 +1499,24 @@ inline void CodeGeneratorResponse::SharedDtor() {
_impl_.~Impl_();
}
inline void* CodeGeneratorResponse::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) CodeGeneratorResponse(arena);
}
constexpr auto CodeGeneratorResponse::InternalNewImpl_() {
constexpr auto arena_bits = ::google::protobuf::internal::EncodePlacementArenaOffsets({
PROTOBUF_FIELD_OFFSET(CodeGeneratorResponse, _impl_.file_) +
decltype(CodeGeneratorResponse::_impl_.file_)::
InternalGetArenaOffset(
::google::protobuf::Message::internal_visibility()),
});
if (arena_bits.has_value()) {
return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(CodeGeneratorResponse), *arena_bits);
} else {
return ::google::protobuf::internal::MessageCreator(&CodeGeneratorResponse::PlacementNew_,
sizeof(CodeGeneratorResponse));
}
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::MessageLite::ClassDataFull
@ -1468,9 +1527,9 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&CodeGeneratorResponse::MergeImpl,
::google::protobuf::Message::GetNewImpl<CodeGeneratorResponse>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CodeGeneratorResponse>(),
::google::protobuf::Message::GetNewImpl<CodeGeneratorResponse>(),
::google::protobuf::Message::GetClearImpl<CodeGeneratorResponse>(), &CodeGeneratorResponse::ByteSizeLong,
&CodeGeneratorResponse::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE

@ -192,7 +192,7 @@ class PROTOC_EXPORT Version final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
Version* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
Version* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<Version>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -248,6 +248,9 @@ class PROTOC_EXPORT Version final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -425,7 +428,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::google::protobuf
// implements Message ----------------------------------------------
CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<CodeGeneratorResponse_File>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -481,6 +484,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::google::protobuf
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -674,7 +680,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final : public ::google::protobuf::Mes
// implements Message ----------------------------------------------
CodeGeneratorResponse* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
CodeGeneratorResponse* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<CodeGeneratorResponse>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -730,6 +736,9 @@ class PROTOC_EXPORT CodeGeneratorResponse final : public ::google::protobuf::Mes
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -947,7 +956,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : public ::google::protobuf::Mess
// implements Message ----------------------------------------------
CodeGeneratorRequest* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
CodeGeneratorRequest* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<CodeGeneratorRequest>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -1008,6 +1017,9 @@ class PROTOC_EXPORT CodeGeneratorRequest final : public ::google::protobuf::Mess
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:

@ -10,6 +10,7 @@
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/generated_message_tctable_impl.h"
#include "google/protobuf/extension_set.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_reflection.h"
@ -193,6 +194,13 @@ inline void CppFeatures::SharedDtor() {
_impl_.~Impl_();
}
inline void* CppFeatures::PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena) {
return ::new (mem) CppFeatures(arena);
}
constexpr auto CppFeatures::InternalNewImpl_() {
return ::google::protobuf::internal::MessageCreator::ZeroInit(sizeof(CppFeatures));
}
PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
const ::google::protobuf::MessageLite::ClassDataFull
@ -203,9 +211,9 @@ const ::google::protobuf::MessageLite::ClassDataFull
nullptr, // OnDemandRegisterArenaDtor
nullptr, // IsInitialized
&CppFeatures::MergeImpl,
::google::protobuf::Message::GetNewImpl<CppFeatures>(),
#if defined(PROTOBUF_CUSTOM_VTABLE)
::google::protobuf::Message::GetDeleteImpl<CppFeatures>(),
::google::protobuf::Message::GetNewImpl<CppFeatures>(),
::google::protobuf::Message::GetClearImpl<CppFeatures>(), &CppFeatures::ByteSizeLong,
&CppFeatures::_InternalSerialize,
#endif // PROTOBUF_CUSTOM_VTABLE

@ -176,7 +176,7 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
CppFeatures* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
CppFeatures* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<CppFeatures>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -232,6 +232,9 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:

File diff suppressed because it is too large Load Diff

@ -778,7 +778,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::google::prot
// implements Message ----------------------------------------------
UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<UninterpretedOption_NamePart>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -839,6 +839,9 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::google::prot
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -990,7 +993,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::google::protobuf:
// implements Message ----------------------------------------------
SourceCodeInfo_Location* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
SourceCodeInfo_Location* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<SourceCodeInfo_Location>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -1046,6 +1049,9 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::google::protobuf:
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -1269,7 +1275,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::google::prot
// implements Message ----------------------------------------------
GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<GeneratedCodeInfo_Annotation>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -1325,6 +1331,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::google::prot
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -1543,7 +1552,7 @@ class PROTOBUF_EXPORT FieldOptions_FeatureSupport final : public ::google::proto
// implements Message ----------------------------------------------
FieldOptions_FeatureSupport* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FieldOptions_FeatureSupport* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FieldOptions_FeatureSupport>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -1599,6 +1608,9 @@ class PROTOBUF_EXPORT FieldOptions_FeatureSupport final : public ::google::proto
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -1776,7 +1788,7 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : public ::google::proto
// implements Message ----------------------------------------------
FieldOptions_EditionDefault* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FieldOptions_EditionDefault* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FieldOptions_EditionDefault>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -1832,6 +1844,9 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : public ::google::proto
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -1983,7 +1998,7 @@ class PROTOBUF_EXPORT FeatureSet final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
FeatureSet* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FeatureSet* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FeatureSet>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -2044,6 +2059,9 @@ class PROTOBUF_EXPORT FeatureSet final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -2542,7 +2560,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : public ::google:
// implements Message ----------------------------------------------
ExtensionRangeOptions_Declaration* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
ExtensionRangeOptions_Declaration* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<ExtensionRangeOptions_Declaration>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -2598,6 +2616,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : public ::google:
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -2794,7 +2815,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::goo
// implements Message ----------------------------------------------
EnumDescriptorProto_EnumReservedRange* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
EnumDescriptorProto_EnumReservedRange* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<EnumDescriptorProto_EnumReservedRange>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -2850,6 +2871,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::goo
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -2995,7 +3019,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::google::pro
// implements Message ----------------------------------------------
DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<DescriptorProto_ReservedRange>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -3051,6 +3075,9 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::google::pro
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -3196,7 +3223,7 @@ class PROTOBUF_EXPORT UninterpretedOption final : public ::google::protobuf::Mes
// implements Message ----------------------------------------------
UninterpretedOption* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
UninterpretedOption* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<UninterpretedOption>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -3257,6 +3284,9 @@ class PROTOBUF_EXPORT UninterpretedOption final : public ::google::protobuf::Mes
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -3492,7 +3522,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
SourceCodeInfo* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
SourceCodeInfo* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<SourceCodeInfo>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -3548,6 +3578,9 @@ class PROTOBUF_EXPORT SourceCodeInfo final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -3686,7 +3719,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::google::protobuf::Messa
// implements Message ----------------------------------------------
GeneratedCodeInfo* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
GeneratedCodeInfo* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<GeneratedCodeInfo>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -3742,6 +3775,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::google::protobuf::Messa
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -3880,7 +3916,7 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : public
// implements Message ----------------------------------------------
FeatureSetDefaults_FeatureSetEditionDefault* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FeatureSetDefaults_FeatureSetEditionDefault* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FeatureSetDefaults_FeatureSetEditionDefault>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -3941,6 +3977,9 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : public
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -4107,7 +4146,7 @@ class PROTOBUF_EXPORT ServiceOptions final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
ServiceOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
ServiceOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<ServiceOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -4168,6 +4207,9 @@ class PROTOBUF_EXPORT ServiceOptions final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -4516,7 +4558,7 @@ class PROTOBUF_EXPORT OneofOptions final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
OneofOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
OneofOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<OneofOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -4577,6 +4619,9 @@ class PROTOBUF_EXPORT OneofOptions final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -4912,7 +4957,7 @@ class PROTOBUF_EXPORT MethodOptions final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
MethodOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
MethodOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<MethodOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -4973,6 +5018,9 @@ class PROTOBUF_EXPORT MethodOptions final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -5354,7 +5402,7 @@ class PROTOBUF_EXPORT MessageOptions final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
MessageOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
MessageOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<MessageOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -5415,6 +5463,9 @@ class PROTOBUF_EXPORT MessageOptions final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -5815,7 +5866,7 @@ class PROTOBUF_EXPORT FileOptions final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
FileOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FileOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FileOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -5876,6 +5927,9 @@ class PROTOBUF_EXPORT FileOptions final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -6538,7 +6592,7 @@ class PROTOBUF_EXPORT FieldOptions final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
FieldOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FieldOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FieldOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -6599,6 +6653,9 @@ class PROTOBUF_EXPORT FieldOptions final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -7197,7 +7254,7 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : public ::google::protobuf::Mess
// implements Message ----------------------------------------------
FeatureSetDefaults* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FeatureSetDefaults* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FeatureSetDefaults>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -7258,6 +7315,9 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : public ::google::protobuf::Mess
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -7423,7 +7483,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::google::protobuf::M
// implements Message ----------------------------------------------
ExtensionRangeOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
ExtensionRangeOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<ExtensionRangeOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -7484,6 +7544,9 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::google::protobuf::M
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -7871,7 +7934,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : public ::google::protobuf::Messag
// implements Message ----------------------------------------------
EnumValueOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
EnumValueOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<EnumValueOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -7932,6 +7995,9 @@ class PROTOBUF_EXPORT EnumValueOptions final : public ::google::protobuf::Messag
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -8310,7 +8376,7 @@ class PROTOBUF_EXPORT EnumOptions final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
EnumOptions* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
EnumOptions* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<EnumOptions>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -8371,6 +8437,9 @@ class PROTOBUF_EXPORT EnumOptions final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -8745,7 +8814,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : public ::google::protobuf::Me
// implements Message ----------------------------------------------
OneofDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
OneofDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<OneofDescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -8806,6 +8875,9 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : public ::google::protobuf::Me
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -8961,7 +9033,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : public ::google::protobuf::M
// implements Message ----------------------------------------------
MethodDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
MethodDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<MethodDescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -9022,6 +9094,9 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : public ::google::protobuf::M
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -9241,7 +9316,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : public ::google::protobuf::Me
// implements Message ----------------------------------------------
FieldDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FieldDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FieldDescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -9302,6 +9377,9 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : public ::google::protobuf::Me
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -9653,7 +9731,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::google::protobuf
// implements Message ----------------------------------------------
EnumValueDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
EnumValueDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<EnumValueDescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -9714,6 +9792,9 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::google::protobuf
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -9882,7 +9963,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::google::pr
// implements Message ----------------------------------------------
DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<DescriptorProto_ExtensionRange>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -9943,6 +10024,9 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::google::pr
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -10105,7 +10189,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::google::protobuf::
// implements Message ----------------------------------------------
ServiceDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
ServiceDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<ServiceDescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -10166,6 +10250,9 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::google::protobuf::
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -10340,7 +10427,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : public ::google::protobuf::Mes
// implements Message ----------------------------------------------
EnumDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
EnumDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<EnumDescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -10401,6 +10488,9 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : public ::google::protobuf::Mes
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -10619,7 +10709,7 @@ class PROTOBUF_EXPORT DescriptorProto final : public ::google::protobuf::Message
// implements Message ----------------------------------------------
DescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
DescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<DescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -10680,6 +10770,9 @@ class PROTOBUF_EXPORT DescriptorProto final : public ::google::protobuf::Message
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -10994,7 +11087,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final : public ::google::protobuf::Mes
// implements Message ----------------------------------------------
FileDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FileDescriptorProto* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FileDescriptorProto>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -11055,6 +11148,9 @@ class PROTOBUF_EXPORT FileDescriptorProto final : public ::google::protobuf::Mes
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:
@ -11418,7 +11514,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final : public ::google::protobuf::Messa
// implements Message ----------------------------------------------
FileDescriptorSet* New(::google::protobuf::Arena* arena = nullptr) const PROTOBUF_FINAL {
FileDescriptorSet* New(::google::protobuf::Arena* arena = nullptr) const {
return ::google::protobuf::Message::DefaultConstruct<FileDescriptorSet>(arena);
}
using ::google::protobuf::Message::CopyFrom;
@ -11479,6 +11575,9 @@ class PROTOBUF_EXPORT FileDescriptorSet final : public ::google::protobuf::Messa
*this = ::std::move(from);
}
const ::google::protobuf::Message::ClassData* GetClassData() const PROTOBUF_FINAL;
static void* PlacementNew_(const void*, void* mem,
::google::protobuf::Arena* arena);
static constexpr auto InternalNewImpl_();
static const ::google::protobuf::Message::ClassDataFull _class_data_;
public:

@ -181,8 +181,6 @@ inline int AlignOffset(int offset) { return AlignTo(offset, kSafeAlignment); }
class DynamicMessage final : public Message {
public:
explicit DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info);
// This should only be used by GetPrototypeNoLock() to avoid dead lock.
DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, bool lock_factory);
DynamicMessage(const DynamicMessage&) = delete;
@ -202,8 +200,6 @@ class DynamicMessage final : public Message {
// implements Message ----------------------------------------------
Message* New(Arena* arena) const PROTOBUF_FINAL;
const ClassData* GetClassData() const PROTOBUF_FINAL;
#if defined(__cpp_lib_destroying_delete) && defined(__cpp_sized_deallocation)
@ -237,6 +233,7 @@ class DynamicMessage final : public Message {
return reinterpret_cast<const uint8_t*>(this) + offset;
}
static void* NewImpl(const void* prototype, void* mem, Arena* arena);
static void DeleteImpl(void* ptr, bool free_memory);
void* MutableRaw(int i);
@ -250,7 +247,6 @@ class DynamicMessage final : public Message {
};
struct DynamicMessageFactory::TypeInfo {
int size;
int has_bits_offset;
int oneof_case_offset;
int extensions_offset;
@ -272,8 +268,8 @@ struct DynamicMessageFactory::TypeInfo {
nullptr, // on_demand_register_arena_dtor
&DynamicMessage::IsInitializedImpl,
&DynamicMessage::MergeImpl,
internal::MessageCreator(), // to be filled later
&DynamicMessage::DeleteImpl,
DynamicMessage::GetNewImpl<DynamicMessage>(),
DynamicMessage::ClearImpl,
DynamicMessage::ByteSizeLongImpl,
DynamicMessage::_InternalSerializeImpl,
@ -307,13 +303,6 @@ struct DynamicMessageFactory::TypeInfo {
}
};
DynamicMessage::DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info)
: Message(type_info->class_data.base()),
type_info_(type_info),
cached_byte_size_(0) {
SharedCtor(true);
}
DynamicMessage::DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info,
Arena* arena)
: Message(arena, type_info->class_data.base()),
@ -472,7 +461,7 @@ bool DynamicMessage::is_prototype() const {
#if defined(__cpp_lib_destroying_delete) && defined(__cpp_sized_deallocation)
void DynamicMessage::operator delete(DynamicMessage* msg,
std::destroying_delete_t) {
const size_t size = msg->type_info_->size;
const size_t size = msg->type_info_->class_data.allocation_size();
msg->~DynamicMessage();
::operator delete(msg, size);
}
@ -574,9 +563,16 @@ DynamicMessage::~DynamicMessage() {
}
}
void* DynamicMessage::NewImpl(const void* prototype, void* mem, Arena* arena) {
const auto* type_info =
static_cast<const DynamicMessage*>(prototype)->type_info_;
memset(mem, 0, type_info->class_data.allocation_size());
return new (mem) DynamicMessage(type_info, arena);
}
void DynamicMessage::DeleteImpl(void* ptr, bool free_memory) {
auto* msg = static_cast<DynamicMessage*>(ptr);
const size_t size = msg->type_info_->size;
const size_t size = msg->type_info_->class_data.allocation_size();
msg->~DynamicMessage();
if (free_memory) {
internal::SizedDelete(ptr, size);
@ -607,18 +603,6 @@ void DynamicMessage::CrossLinkPrototypes() {
}
}
Message* DynamicMessage::New(Arena* arena) const {
if (arena != nullptr) {
void* new_base = Arena::CreateArray<char>(arena, type_info_->size);
memset(new_base, 0, type_info_->size);
return new (new_base) DynamicMessage(type_info_, arena);
} else {
void* new_base = operator new(type_info_->size);
memset(new_base, 0, type_info_->size);
return new (new_base) DynamicMessage(type_info_);
}
}
const MessageLite::ClassData* DynamicMessage::GetClassData() const {
return type_info_->class_data.base();
}
@ -751,9 +735,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
type_info->weak_field_map_offset = -1;
// Align the final size to make sure no clever allocators think that
// alignment is not necessary.
type_info->size = size;
type_info->class_data.message_creator =
internal::MessageCreator(DynamicMessage::NewImpl, size);
// Construct the reflection object.
@ -787,7 +770,7 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock(
PROTOBUF_FIELD_OFFSET(DynamicMessage, _internal_metadata_),
type_info->extensions_offset,
type_info->oneof_case_offset,
type_info->size,
static_cast<int>(type_info->class_data.allocation_size()),
type_info->weak_field_map_offset,
nullptr, // inlined_string_indices_
0, // inlined_string_donated_offset_

@ -531,6 +531,10 @@ class PROTOBUF_EXPORT ExtensionSet {
// as .dll.
int SpaceUsedExcludingSelf() const;
static constexpr size_t InternalGetArenaOffset(internal::InternalVisibility) {
return PROTOBUF_FIELD_OFFSET(ExtensionSet, arena_);
}
private:
template <typename Type>
friend class PrimitiveTypeTraits;

@ -3359,7 +3359,6 @@ void Reflection::PopulateTcParseFieldAux(
break;
case internal::TailCallTableInfo::kSubTable:
case internal::TailCallTableInfo::kSubMessageWeak:
case internal::TailCallTableInfo::kCreateInArena:
case internal::TailCallTableInfo::kMessageVerifyFunc:
case internal::TailCallTableInfo::kSelfVerifyFunc:
ABSL_LOG(FATAL) << "Not supported";

@ -428,8 +428,6 @@ struct alignas(uint64_t) TcParseTableBase {
: message_default_p(msg) {}
constexpr FieldAux(const TcParseTableBase* table) : table(table) {}
constexpr FieldAux(MapAuxInfo map_info) : map_info(map_info) {}
constexpr FieldAux(void (*create_in_arena)(Arena*, void*))
: create_in_arena(create_in_arena) {}
constexpr FieldAux(LazyEagerVerifyFnType verify_func)
: verify_func(verify_func) {}
struct {
@ -441,7 +439,6 @@ struct alignas(uint64_t) TcParseTableBase {
const uint32_t* enum_data;
const TcParseTableBase* table;
MapAuxInfo map_info;
void (*create_in_arena)(Arena*, void*);
LazyEagerVerifyFnType verify_func;
const MessageLite* message_default() const {

@ -908,9 +908,8 @@ TailCallTableInfo::TailCallTableInfo(
if (message_options.uses_codegen) {
// If we don't use codegen we can't add these.
auto* map_value = field->message_type()->map_value();
if (auto* sub = map_value->message_type()) {
aux_entries.push_back({kCreateInArena});
aux_entries.back().desc = sub;
if (map_value->message_type() != nullptr) {
aux_entries.push_back({kSubTable, {map_value}});
} else if (map_value->type() == FieldDescriptor::TYPE_ENUM &&
!cpp::HasPreservingUnknownEnumSemantics(map_value)) {
aux_entries.push_back({kEnumValidator, {map_value}});

@ -112,7 +112,6 @@ struct PROTOBUF_EXPORT TailCallTableInfo {
kEnumValidator,
kNumericOffset,
kMapAuxInfo,
kCreateInArena,
};
struct AuxEntry {
AuxType type;

@ -822,11 +822,6 @@ class PROTOBUF_EXPORT TcParser final {
};
}
template <typename T>
static void CreateInArenaStorageCb(Arena* arena, void* p) {
Arena::CreateInArenaStorage(static_cast<T*>(p), arena);
}
private:
// Optimized small tag varint parser for int32/int64
template <typename FieldType>

@ -357,7 +357,7 @@ PROTOBUF_NOINLINE const char* TcParser::FastEndG2(PROTOBUF_TC_PARAM_DECL) {
inline PROTOBUF_ALWAYS_INLINE MessageLite* TcParser::NewMessage(
const TcParseTableBase* table, Arena* arena) {
return table->default_instance()->New(arena);
return table->class_data->New(arena);
}
MessageLite* TcParser::AddMessage(const TcParseTableBase* table,
@ -2522,7 +2522,7 @@ PROTOBUF_ALWAYS_INLINE inline void TcParser::InitializeMapNodeEntry(
map.arena());
break;
case MapTypeCard::kMessage:
aux[1].create_in_arena(map.arena(), reinterpret_cast<MessageLite*>(obj));
aux[1].table->class_data->PlacementNew(obj, map.arena());
break;
default:
Unreachable();

@ -21,6 +21,7 @@
#include <atomic>
#include <climits>
#include <cstddef>
#include <initializer_list>
#include <memory>
#include <string>
#include <type_traits>
@ -31,6 +32,7 @@
#include "absl/base/call_once.h"
#include "absl/base/casts.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "google/protobuf/any.h"
#include "google/protobuf/has_bits.h"
#include "google/protobuf/implicit_weak_message.h"
@ -375,6 +377,19 @@ inline void AddToRepeatedPtrField(google::protobuf::RepeatedPtrField<std::string
dest.Add(std::move(value));
}
constexpr absl::optional<uintptr_t> EncodePlacementArenaOffsets(
std::initializer_list<size_t> offsets) {
uintptr_t arena_bits = 0;
for (size_t offset : offsets) {
offset /= sizeof(Arena*);
if (offset >= sizeof(arena_bits) * 8) {
return absl::nullopt;
}
arena_bits |= uintptr_t{1} << offset;
}
return arena_bits;
}
} // namespace internal
} // namespace protobuf
} // namespace google

@ -69,8 +69,9 @@ constexpr MessageLite::ClassDataLite<1> ImplicitWeakMessage::class_data_ = {
nullptr, // on_demand_register_arena_dtor
nullptr, // is_initialized (always true)
MergeImpl,
internal::MessageCreator(NewImpl<ImplicitWeakMessage>,
sizeof(ImplicitWeakMessage)),
GetDeleteImpl<ImplicitWeakMessage>(),
GetNewImpl<ImplicitWeakMessage>(),
&ClearImpl,
&ByteSizeLongImpl,
&_InternalSerializeImpl,

@ -59,10 +59,6 @@ class PROTOBUF_EXPORT ImplicitWeakMessage final : public MessageLite {
const ClassData* GetClassData() const PROTOBUF_FINAL;
MessageLite* New(Arena* arena) const PROTOBUF_FINAL {
return Arena::Create<ImplicitWeakMessage>(arena);
}
void Clear() PROTOBUF_FINAL { data_->clear(); }
size_t ByteSizeLong() const PROTOBUF_FINAL {
@ -218,6 +214,11 @@ struct WeakRepeatedPtrField {
RepeatedPtrField<T> weak;
};
static constexpr size_t InternalGetArenaOffset(
internal::InternalVisibility visibility) {
return decltype(weak)::InternalGetArenaOffset(visibility);
}
private:
WeakRepeatedPtrField(Arena* arena, const WeakRepeatedPtrField& rhs)
: WeakRepeatedPtrField(arena) {

@ -1625,6 +1625,10 @@ class Map : private internal::KeyMapBase<internal::KeyForBase<Key>> {
return SpaceUsedInternal() + internal::SpaceUsedInValues(this);
}
static constexpr size_t InternalGetArenaOffset(internal::InternalVisibility) {
return PROTOBUF_FIELD_OFFSET(Map, alloc_);
}
private:
struct Rank1 {};
struct Rank0 : Rank1 {};

@ -103,10 +103,6 @@ class MapEntry : public Message {
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
Message* New(Arena* arena) const PROTOBUF_FINAL {
return Arena::Create<Derived>(arena);
}
struct _Internal;
protected:

@ -406,6 +406,10 @@ class PROTOBUF_EXPORT MapFieldBase : public MapFieldBaseForParse {
return internal::ToIntSize(SpaceUsedExcludingSelfLong());
}
static constexpr size_t InternalGetArenaOffset(internal::InternalVisibility) {
return PROTOBUF_FIELD_OFFSET(MapFieldBase, payload_);
}
protected:
// Gets the size of space used by map field.
size_t SpaceUsedExcludingSelfNoLock() const {
@ -608,6 +612,12 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
void InternalSwap(TypeDefinedMapFieldBase* other);
static constexpr size_t InternalGetArenaOffsetAlt(
internal::InternalVisibility access) {
return PROTOBUF_FIELD_OFFSET(TypeDefinedMapFieldBase, map_) +
decltype(map_)::InternalGetArenaOffset(access);
}
protected:
friend struct MapFieldTestPeer;

@ -8,6 +8,7 @@
#ifndef GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__
#define GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__
#include <cstddef>
#include <type_traits>
#include "absl/log/absl_check.h"
@ -74,6 +75,12 @@ class MapFieldLite {
void Swap(MapFieldLite* other) { map_.swap(other->map_); }
void InternalSwap(MapFieldLite* other) { map_.InternalSwap(&other->map_); }
static constexpr size_t InternalGetArenaOffset(
internal::InternalVisibility access) {
return PROTOBUF_FIELD_OFFSET(MapFieldLite, map_) +
decltype(map_)::InternalGetArenaOffset(access);
}
private:
typedef void DestructorSkippable_;

@ -261,13 +261,9 @@ class PROTOBUF_EXPORT Message : public MessageLite {
// Construct a new instance on the arena. Ownership is passed to the caller
// if arena is a nullptr.
#if defined(PROTOBUF_CUSTOM_VTABLE)
Message* New(Arena* arena) const {
return static_cast<Message*>(MessageLite::New(arena));
}
#else // PROTOBUF_CUSTOM_VTABLE
Message* New(Arena* arena) const override = 0;
#endif // PROTOBUF_CUSTOM_VTABLE
// Make this message into a copy of the given message. The given message
// must have the same descriptor, but need not necessarily be the same class.

@ -64,6 +64,15 @@ void MessageLite::CheckTypeAndMergeFrom(const MessageLite& other) {
data->merge_to_from(*this, other);
}
MessageLite* MessageLite::New(Arena* arena) const {
auto* data = GetClassData();
// The `instance->New()` expression requires using the actual instance
// instead of the prototype for the inner function call.
// Certain custom instances have special per-instance state that needs to be
// copied.
return data->message_creator.New(this, data->prototype, arena);
}
bool MessageLite::IsInitialized() const {
auto* data = GetClassData();
return data->is_initialized != nullptr ? data->is_initialized(*this) : true;

@ -19,12 +19,16 @@
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <iosfwd>
#include <new>
#include <string>
#include <type_traits>
#include "absl/base/attributes.h"
#include "absl/base/casts.h"
#include "absl/log/absl_check.h"
#include "absl/numeric/bits.h"
#include "absl/strings/cord.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/arena.h"
@ -66,6 +70,67 @@ class ZeroCopyOutputStream;
} // namespace io
namespace internal {
class MessageCreator {
public:
using Func = void* (*)(const void*, void*, Arena*);
// Use -1/0/1 to be able to use <0, ==0, >0
enum Tag : int8_t {
kFunc = -1,
kZeroInit = 0,
kMemcpy = 1,
};
constexpr MessageCreator()
: allocation_size_(), tag_(), arena_bits_(uintptr_t{}) {}
static constexpr MessageCreator ZeroInit(uint32_t allocation_size,
uintptr_t arena_bits = 0) {
MessageCreator out;
out.allocation_size_ = allocation_size;
out.tag_ = kZeroInit;
out.arena_bits_ = arena_bits;
return out;
}
static constexpr MessageCreator CopyInit(uint32_t allocation_size,
uintptr_t arena_bits = 0) {
MessageCreator out;
out.allocation_size_ = allocation_size;
out.tag_ = kMemcpy;
out.arena_bits_ = arena_bits;
return out;
}
constexpr MessageCreator(Func func, uint32_t allocation_size)
: allocation_size_(allocation_size), tag_(kFunc), func_(func) {}
// Template for testing.
template <bool test_call = false, typename MessageLite>
MessageLite* New(const MessageLite* prototype_for_func,
const MessageLite* prototype_for_copy, Arena* arena) const;
template <bool test_call = false, typename MessageLite>
MessageLite* PlacementNew(const MessageLite* prototype_for_func,
const MessageLite* prototype_for_copy, void* mem,
Arena* arena) const;
Tag tag() const { return tag_; }
uint32_t allocation_size() const { return allocation_size_; }
uintptr_t arena_bits() const {
ABSL_DCHECK_NE(+tag(), +kFunc);
return arena_bits_;
}
private:
uint32_t allocation_size_;
Tag tag_;
union {
Func func_;
uintptr_t arena_bits_;
};
};
// Allow easy change to regular int on platforms where the atomic might have a
// perf impact.
//
@ -248,13 +313,7 @@ class PROTOBUF_EXPORT MessageLite {
// Construct a new instance on the arena. Ownership is passed to the caller
// if arena is a nullptr.
#if defined(PROTOBUF_CUSTOM_VTABLE)
MessageLite* New(Arena* arena) const {
return static_cast<MessageLite*>(_class_data_->new_message(this, arena));
}
#else
virtual MessageLite* New(Arena* arena) const = 0;
#endif // PROTOBUF_CUSTOM_VTABLE
MessageLite* New(Arena* arena) const;
// Returns the arena, if any, that directly owns this message and its internal
// memory (Arena::Own is different in that the arena doesn't directly own the
@ -555,16 +614,25 @@ class PROTOBUF_EXPORT MessageLite {
return static_cast<T*>(Arena::DefaultConstruct<T>(arena));
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
template <typename T>
static void* NewImpl(const void* prototype, Arena* arena) {
return static_cast<const T*>(prototype)->New(arena);
static void* NewImpl(const void*, void* mem, Arena* arena) {
return ::new (mem) T(arena);
}
template <typename T>
static constexpr auto GetNewImpl() {
return NewImpl<T>;
static constexpr internal::MessageCreator GetNewImpl() {
#if defined(__cpp_if_constexpr)
if constexpr (internal::EnableCustomNewFor<T>()) {
#else
// Equally valid code, but might be more work for the compiler
if (internal::EnableCustomNewFor<T>()) {
#endif
return T::InternalNewImpl_();
} else {
return internal::MessageCreator(&T::PlacementNew_, sizeof(T));
}
}
#if defined(PROTOBUF_CUSTOM_VTABLE)
template <typename T>
static void DeleteImpl(void* msg, bool free_memory) {
static_cast<T*>(msg)->~T();
@ -587,8 +655,6 @@ class PROTOBUF_EXPORT MessageLite {
// When custom vtables are off we avoid instantiating the functions because we
// will not use them anyway. Less work for the compiler.
template <typename T>
using GetNewImpl = std::nullptr_t;
template <typename T>
using GetDeleteImpl = std::nullptr_t;
template <typename T>
using GetClearImpl = std::nullptr_t;
@ -632,7 +698,7 @@ class PROTOBUF_EXPORT MessageLite {
// We could save more data by omitting any optional pointer that would
// otherwise be null. We can have some metadata in ClassData telling us if we
// have them and their offset.
using NewMessageF = void* (*)(const void* prototype, Arena* arena);
friend internal::MessageCreator;
using DeleteMessageF = void (*)(void* msg, bool free_memory);
struct ClassData {
const MessageLite* prototype;
@ -640,9 +706,9 @@ class PROTOBUF_EXPORT MessageLite {
void (*on_demand_register_arena_dtor)(MessageLite& msg, Arena& arena);
bool (*is_initialized)(const MessageLite&);
void (*merge_to_from)(MessageLite& to, const MessageLite& from_msg);
internal::MessageCreator message_creator;
#if defined(PROTOBUF_CUSTOM_VTABLE)
DeleteMessageF delete_message;
NewMessageF new_message;
void (*clear)(MessageLite&);
size_t (*byte_size_long)(const MessageLite&);
uint8_t* (*serialize)(const MessageLite& msg, uint8_t* ptr,
@ -666,12 +732,14 @@ class PROTOBUF_EXPORT MessageLite {
bool (*is_initialized)(const MessageLite&),
void (*merge_to_from)(MessageLite& to,
const MessageLite& from_msg),
internal::MessageCreator message_creator,
uint32_t cached_size_offset, bool is_lite)
: prototype(prototype),
tc_table(tc_table),
on_demand_register_arena_dtor(on_demand_register_arena_dtor),
is_initialized(is_initialized),
merge_to_from(merge_to_from),
message_creator(message_creator),
cached_size_offset(cached_size_offset),
is_lite(is_lite) {}
#endif // !PROTOBUF_CUSTOM_VTABLE
@ -684,8 +752,8 @@ class PROTOBUF_EXPORT MessageLite {
void (*on_demand_register_arena_dtor)(MessageLite&, Arena&),
bool (*is_initialized)(const MessageLite&),
void (*merge_to_from)(MessageLite& to, const MessageLite& from_msg),
DeleteMessageF delete_message, //
NewMessageF new_message, //
internal::MessageCreator message_creator, //
DeleteMessageF delete_message, //
void (*clear)(MessageLite&),
size_t (*byte_size_long)(const MessageLite&),
uint8_t* (*serialize)(const MessageLite& msg, uint8_t* ptr,
@ -696,9 +764,9 @@ class PROTOBUF_EXPORT MessageLite {
on_demand_register_arena_dtor(on_demand_register_arena_dtor),
is_initialized(is_initialized),
merge_to_from(merge_to_from),
message_creator(message_creator),
#if defined(PROTOBUF_CUSTOM_VTABLE)
delete_message(delete_message),
new_message(new_message),
clear(clear),
byte_size_long(byte_size_long),
serialize(serialize),
@ -711,6 +779,18 @@ class PROTOBUF_EXPORT MessageLite {
ABSL_DCHECK(!is_lite);
return *static_cast<const ClassDataFull*>(this);
}
MessageLite* New(Arena* arena) const {
return message_creator.New(prototype, prototype, arena);
}
MessageLite* PlacementNew(void* mem, Arena* arena) const {
return message_creator.PlacementNew(prototype, prototype, mem, arena);
}
uint32_t allocation_size() const {
return message_creator.allocation_size();
}
};
template <size_t N>
struct ClassDataLite {
@ -873,6 +953,7 @@ class PROTOBUF_EXPORT MessageLite {
friend class internal::WeakFieldMap;
friend class internal::WireFormatLite;
friend class internal::RustMapHelper;
friend struct internal::TcParseTableBase;
template <typename Type>
friend class Arena::InternalHelper;
@ -1079,6 +1160,122 @@ inline void AssertDownCast(const MessageLite& from, const MessageLite& to) {
<< "Cannot downcast " << from.GetTypeName() << " to " << to.GetTypeName();
}
template <bool test_call, typename MessageLite>
PROTOBUF_ALWAYS_INLINE inline MessageLite* MessageCreator::PlacementNew(
const MessageLite* prototype_for_func,
const MessageLite* prototype_for_copy, void* mem, Arena* arena) const {
const Tag as_tag = tag();
// When the feature is not enabled we skip the `as_tag` check since it is
// unnecessary. Except for testing, where we want to test the copy logic even
// when we can't use it for real messages.
constexpr bool kMustBeFunc = !test_call && !internal::EnableCustomNew();
static_assert(kFunc < 0 && !(kZeroInit < 0) && !(kMemcpy < 0),
"Only kFunc must be the only negative value");
if (ABSL_PREDICT_FALSE(kMustBeFunc || as_tag < 0)) {
PROTOBUF_DEBUG_COUNTER("MessageCreator.Func").Inc();
return static_cast<MessageLite*>(func_(prototype_for_func, mem, arena));
}
char* dst = static_cast<char*>(mem);
const size_t size = allocation_size_;
const char* src = reinterpret_cast<const char*>(prototype_for_copy);
// These are a bit more efficient than calling normal memset/memcpy because:
// - We know the minimum size is 16. We have a fallback for when it is not.
// - We can "underflow" the buffer because those are the MessageLite bytes
// we will set later.
#ifndef PROTO2_OPENSOURCE
// This manual handling shows a 1.85% improvement in the parsing
// microbenchmark.
// TODO: Verify this is still the case.
#endif // !PROTO2_OPENSOUCE
if (as_tag == kZeroInit) {
// Make sure the input is really all zeros.
ABSL_DCHECK(std::all_of(src + sizeof(MessageLite), src + size,
[](auto c) { return c == 0; }));
if (sizeof(MessageLite) != 16) {
memset(dst, 0, size);
} else if (size <= 32) {
memset(dst + size - 16, 0, 16);
} else if (size <= 64) {
memset(dst + 16, 0, 16);
memset(dst + size - 32, 0, 32);
} else {
for (size_t offset = 16; offset + 64 < size; offset += 64) {
absl::PrefetchToLocalCacheForWrite(dst + offset + 64);
memset(dst + offset, 0, 64);
}
memset(dst + size - 64, 0, 64);
}
} else {
ABSL_DCHECK_EQ(+as_tag, +kMemcpy);
if (sizeof(MessageLite) != 16) {
memcpy(dst, src, size);
} else if (size <= 32) {
memcpy(dst + size - 16, src + size - 16, 16);
} else if (size <= 64) {
memcpy(dst + 16, src + 16, 16);
memcpy(dst + size - 32, src + size - 32, 32);
} else {
for (size_t offset = 16; offset + 64 < size; offset += 64) {
absl::PrefetchToLocalCache(src + offset + 64);
absl::PrefetchToLocalCacheForWrite(dst + offset + 64);
memcpy(dst + offset, src + offset, 64);
}
memcpy(dst + size - 64, src + size - 64, 64);
}
}
if (arena_bits() != 0) {
if (as_tag == kZeroInit) {
PROTOBUF_DEBUG_COUNTER("MessageCreator.ZeroArena").Inc();
} else {
PROTOBUF_DEBUG_COUNTER("MessageCreator.McpyArena").Inc();
}
} else {
if (as_tag == kZeroInit) {
PROTOBUF_DEBUG_COUNTER("MessageCreator.Zero").Inc();
} else {
PROTOBUF_DEBUG_COUNTER("MessageCreator.Mcpy").Inc();
}
}
if (internal::PerformDebugChecks() || arena != nullptr) {
if (uintptr_t offsets = arena_bits()) {
do {
const size_t offset = absl::countr_zero(offsets) * sizeof(Arena*);
ABSL_DCHECK_LE(offset + sizeof(Arena*), size);
// Verify we are overwriting a null pointer. If we are not, there is a
// bug somewhere.
ABSL_DCHECK_EQ(*reinterpret_cast<Arena**>(dst + offset), nullptr);
memcpy(dst + offset, &arena, sizeof(arena));
offsets &= offsets - 1;
} while (offsets != 0);
}
}
// The second memcpy overwrites part of the first, but the compiler should
// avoid the double-write. It's easier than trying to avoid the overlap.
memcpy(dst, static_cast<const void*>(prototype_for_copy),
sizeof(MessageLite));
memcpy(dst + PROTOBUF_FIELD_OFFSET(MessageLite, _internal_metadata_), &arena,
sizeof(arena));
return Launder(reinterpret_cast<MessageLite*>(mem));
}
template <bool test_call, typename MessageLite>
PROTOBUF_ALWAYS_INLINE inline MessageLite* MessageCreator::New(
const MessageLite* prototype_for_func,
const MessageLite* prototype_for_copy, Arena* arena) const {
return PlacementNew<test_call>(prototype_for_func, prototype_for_copy,
arena != nullptr
? arena->AllocateAligned(allocation_size_)
: ::operator new(allocation_size_),
arena);
}
} // namespace internal
std::string ShortFormat(const MessageLite& message_lite);

@ -10,6 +10,8 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <vector>
#include <gtest/gtest.h>
@ -20,6 +22,7 @@
#include "google/protobuf/has_bits.h"
#include "google/protobuf/internal_visibility.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/port.h"
#include "google/protobuf/unittest.pb.h"
#include "google/protobuf/unittest_import.pb.h"
#include "google/protobuf/unittest_lite.pb.h"

@ -260,6 +260,15 @@ inline constexpr bool DebugHardenClearOneofMessageOnArena() {
#endif
}
constexpr bool PerformDebugChecks() {
#if defined(NDEBUG) && !defined(PROTOBUF_ASAN) && !defined(PROTOBUF_MSAN) && \
!defined(PROTOBUF_TSAN)
return false;
#else
return true;
#endif
}
// Returns true if pointers are 8B aligned, leaving least significant 3 bits
// available.
inline constexpr bool PtrIsAtLeast8BAligned() { return alignof(void*) >= 8; }
@ -325,6 +334,31 @@ inline void PrefetchToLocalCache(const void* ptr) {
absl::PrefetchToLocalCache(ptr);
}
template <typename T>
constexpr T* Launder(T* p) {
#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606L
return std::launder(p);
#elif ABSL_HAVE_BUILTIN(__builtin_launder)
return __builtin_launder(p);
#else
return p;
#endif
}
#if ABSL_HAVE_BUILTIN(__is_bitwise_cloneable)
constexpr bool EnableCustomNew() { return true; }
template <typename T>
constexpr bool EnableCustomNewFor() {
return __is_bitwise_cloneable(T);
}
#else
constexpr bool EnableCustomNew() { return false; }
template <typename T>
constexpr bool EnableCustomNewFor() {
return false;
}
#endif
constexpr bool IsOss() { return true; }
// Counter library for debugging internal protobuf logic.

@ -443,6 +443,11 @@ class RepeatedField final
// This is public due to it being called by generated code.
inline void InternalSwap(RepeatedField* other);
static constexpr size_t InternalGetArenaOffset(internal::InternalVisibility) {
return PROTOBUF_FIELD_OFFSET(RepeatedField, soo_rep_) +
PROTOBUF_FIELD_OFFSET(internal::ShortSooRep, arena_and_size);
}
private:
using InternalArenaConstructable_ = void;
// We use std::max in order to share template instantiations between

@ -535,6 +535,10 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// Gets the Arena on which this RepeatedPtrField stores its elements.
inline Arena* GetArena() const { return arena_; }
static constexpr size_t InternalGetArenaOffset(internal::InternalVisibility) {
return PROTOBUF_FIELD_OFFSET(RepeatedPtrFieldBase, arena_);
}
private:
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
@ -1225,6 +1229,8 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
internal::RepeatedPtrFieldBase::InternalSwap(other);
}
using RepeatedPtrFieldBase::InternalGetArenaOffset;
private:
using InternalArenaConstructable_ = void;

@ -1853,3 +1853,27 @@ message TestMessageWithManyRepeatedPtrFields {
repeated string repeated_string_31 = 31;
repeated string repeated_string_32 = 32;
}
message MessageCreatorZeroInit {
optional int32 i = 1;
optional double d = 2;
optional MessageCreatorZeroInit m = 3;
oneof one {
string os = 10;
string oc = 11 [ctype=CORD];
fixed64 of = 12;
MessageCreatorZeroInit ol = 13 [lazy=true];
}
}
message MessageCreatorMemcpy {
optional string s = 1;
repeated int32 i = 2 [packed=true];
optional MessageCreatorMemcpy m = 3 [lazy=true];
map<int32, int32> m2 = 4;
}
message MessageCreatorFunc {
// This one is ArenaDtorNeeds::kRequired so we must run the constructor.
optional string c = 3 [ctype=CORD];
}

Loading…
Cancel
Save