From abc9bae7c19d9fff4b0be0ffd3a01f947d3b487a Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 30 Jan 2024 07:55:57 -0800 Subject: [PATCH] Move the Metadata members into ClassData to devirtualize GetMetadata. This centralizes the implementation in a single place, reducing code generation bloat and removing one virtual function. PiperOrigin-RevId: 602725967 --- src/google/protobuf/arena_unittest.cc | 1 - src/google/protobuf/compiler/cpp/file.cc | 27 +- src/google/protobuf/compiler/cpp/helpers.cc | 11 +- src/google/protobuf/compiler/cpp/helpers.h | 26 +- src/google/protobuf/compiler/cpp/message.cc | 143 ++++----- .../compiler/java/java_features.pb.cc | 27 +- .../protobuf/compiler/java/java_features.pb.h | 5 +- src/google/protobuf/compiler/plugin.pb.cc | 51 ++-- src/google/protobuf/compiler/plugin.pb.h | 20 +- src/google/protobuf/cpp_features.pb.cc | 27 +- src/google/protobuf/cpp_features.pb.h | 5 +- src/google/protobuf/descriptor.h | 30 +- src/google/protobuf/descriptor.pb.cc | 275 ++++++++---------- src/google/protobuf/descriptor.pb.h | 160 ++++------ src/google/protobuf/dynamic_message.cc | 56 ++-- .../protobuf/generated_message_bases.cc | 15 +- src/google/protobuf/generated_message_bases.h | 8 +- .../protobuf/generated_message_reflection.cc | 119 +++----- .../protobuf/generated_message_reflection.h | 12 +- src/google/protobuf/map_entry.h | 29 +- src/google/protobuf/map_test.inc | 2 +- src/google/protobuf/message.cc | 21 ++ src/google/protobuf/message.h | 6 +- src/google/protobuf/message_lite.h | 39 ++- 24 files changed, 480 insertions(+), 635 deletions(-) diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index d1afa07d8f..59974a1db3 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -426,7 +426,6 @@ class DispatcherTestProto : public Message { explicit DispatcherTestProto(Arena*) { ABSL_LOG(FATAL); } DispatcherTestProto(Arena*, const DispatcherTestProto&) { ABSL_LOG(FATAL); } DispatcherTestProto* New(Arena*) const final { ABSL_LOG(FATAL); } - Metadata GetMetadata() const final { ABSL_LOG(FATAL); } const ClassData* GetClassData() const final { ABSL_LOG(FATAL); } }; // We use a specialization to inject behavior for the test. diff --git a/src/google/protobuf/compiler/cpp/file.cc b/src/google/protobuf/compiler/cpp/file.cc index 32b874ef4a..36ae027bc1 100644 --- a/src/google/protobuf/compiler/cpp/file.cc +++ b/src/google/protobuf/compiler/cpp/file.cc @@ -1044,12 +1044,6 @@ GetMessagesToPinGloballyForWeakDescriptors(const FileDescriptor* file) { } void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) { - if (!message_generators_.empty()) { - p->Emit({{"len", message_generators_.size()}}, R"cc( - static ::_pb::Metadata $file_level_metadata$[$len$]; - )cc"); - } - if (!enum_generators_.empty()) { p->Emit({{"len", enum_generators_.size()}}, R"cc( static const ::_pb::EnumDescriptor* $file_level_enum_descriptors$[$len$]; @@ -1248,13 +1242,10 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) { : absl::StrCat(p->LookupVar("desc_table"), "_deps")}, {"num_deps", num_deps}, {"num_msgs", message_generators_.size()}, - {"msgs_ptr", message_generators_.empty() - ? "nullptr" - : std::string(p->LookupVar("file_level_metadata"))}, }, R"cc( static ::absl::once_flag $desc_table$_once; - const ::_pbi::DescriptorTable $desc_table$ = { + PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable $desc_table$ = { false, $eager$, $file_proto_len$, @@ -1267,25 +1258,9 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) { schemas, file_default_instances, $tablename$::offsets, - $msgs_ptr$, $file_level_enum_descriptors$, $file_level_service_descriptors$, }; - - // This function exists to be marked as weak. - // It can significantly speed up compilation by breaking up LLVM's SCC - // in the .pb.cc translation units. Large translation units see a - // reduction of more than 35% of walltime for optimized builds. Without - // the weak attribute all the messages in the file, including all the - // vtables and everything they use become part of the same SCC through - // a cycle like: - // GetMetadata -> descriptor table -> default instances -> - // vtables -> GetMetadata - // By adding a weak function here we break the connection from the - // individual vtables back into the descriptor table. - PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* $desc_table$_getter() { - return &$desc_table$; - } )cc"); // For descriptor.proto and cpp_features.proto we want to avoid doing any diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index 6e2cf10fbf..be9563933e 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -1311,11 +1312,11 @@ void GenerateUtf8CheckCodeForCord(io::Printer* p, const FieldDescriptor* field, void FlattenMessagesInFile(const FileDescriptor* file, std::vector* result) { - for (int i = 0; i < file->message_type_count(); i++) { - ForEachMessage(file->message_type(i), [&](const Descriptor* descriptor) { - result->push_back(descriptor); - }); - } + internal::cpp::VisitDescriptorsInFileOrder(file, + [&](const Descriptor* descriptor) { + result->push_back(descriptor); + return std::false_type{}; + }); } // TopologicalSortMessagesInFile topologically sorts and returns a vector of diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h index 0fe8de99cd..aa6e346173 100644 --- a/src/google/protobuf/compiler/cpp/helpers.h +++ b/src/google/protobuf/compiler/cpp/helpers.h @@ -27,6 +27,7 @@ #include "google/protobuf/compiler/cpp/names.h" #include "google/protobuf/compiler/cpp/options.h" #include "google/protobuf/compiler/scc.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/port.h" @@ -632,19 +633,6 @@ inline std::vector FlattenMessagesInFile( std::vector TopologicalSortMessagesInFile( const FileDescriptor* file, MessageSCCAnalyzer& scc_analyzer); -template -void ForEachMessage(const Descriptor* descriptor, F&& func) { - for (int i = 0; i < descriptor->nested_type_count(); i++) - ForEachMessage(descriptor->nested_type(i), std::forward(func)); - func(descriptor); -} - -template -void ForEachMessage(const FileDescriptor* descriptor, F&& func) { - for (int i = 0; i < descriptor->message_type_count(); i++) - ForEachMessage(descriptor->message_type(i), std::forward(func)); -} - bool HasWeakFields(const Descriptor* desc, const Options& options); bool HasWeakFields(const FileDescriptor* desc, const Options& options); @@ -828,18 +816,18 @@ inline bool HasSimpleBaseClass(const Descriptor* desc, const Options& options) { inline bool HasSimpleBaseClasses(const FileDescriptor* file, const Options& options) { - bool v = false; - ForEachMessage(file, [&v, &options](const Descriptor* desc) { - v |= HasSimpleBaseClass(desc, options); - }); - return v; + return internal::cpp::VisitDescriptorsInFileOrder( + file, [&](const Descriptor* desc) { + return HasSimpleBaseClass(desc, options); + }); } // Returns true if this message has a _tracker_ field. inline bool HasTracker(const Descriptor* desc, const Options& options) { return options.field_listener_options.inject_field_listener_events && desc->file()->options().optimize_for() != - google::protobuf::FileOptions::LITE_RUNTIME; + google::protobuf::FileOptions::LITE_RUNTIME && + !IsMapEntryMessage(desc); } // Returns true if this message needs an Impl_ struct for it's data. diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index e07622bfdb..40b6feb9ea 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -1353,9 +1353,9 @@ void MessageGenerator::GenerateMapEntryClassDefinition(io::Printer* p) { } else { format(" static bool ValidateValue(void*) { return true; }\n"); } - if (HasDescriptorMethods(descriptor_->file(), options_)) { - format(" ::$proto_ns$::Metadata GetMetadata() const final;\n"); - } + p->Emit(R"cc( + const $superclass$::ClassData* GetClassData() const final; + )cc"); format( " friend struct ::$tablename$;\n" "};\n"); @@ -1387,6 +1387,7 @@ void MessageGenerator::GenerateImplDefinition(io::Printer* p) { p->Emit(R"cc( static ::$proto_ns$::AccessListener<$Msg$> _tracker_; + static void TrackerOnGetMetadata() { $annotate_reflection$; } )cc"); }}, {"inlined_string_donated", @@ -1852,21 +1853,12 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { break; } }}, - {"get_class_data", - [&] { - if (HasSimpleBaseClass(descriptor_, options_)) return; - - p->Emit(R"cc( - const ::$proto_ns$::MessageLite::ClassData* GetClassData() - const final; - )cc"); - }}, {"get_metadata", [&] { if (!HasDescriptorMethods(descriptor_->file(), options_)) return; p->Emit(R"cc( - ::$proto_ns$::Metadata GetMetadata() const final; + ::$proto_ns$::Metadata GetMetadata() const; )cc"); }}, {"decl_split_methods", @@ -2070,7 +2062,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) { *this = ::std::move(from); } $arena_dtor$; - $get_class_data$; + const $superclass$::ClassData* GetClassData() const final; public: $get_metadata$; @@ -2164,50 +2156,12 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) { auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_)); Formatter format(p); - const auto pin_weak_descriptor = [&] { - if (!UsingImplicitWeakDescriptor(descriptor_->file(), options_)) return; - p->Emit( - R"cc( - ::_pbi::StrongPointer(&_$classname$_default_instance_); - )cc"); - - // For CODE_SIZE types, we need to pin the submessages too. - // SPEED types will pin them via the TcParse table automatically. - if (HasGeneratedMethods(descriptor_->file(), options_)) return; - for (int i = 0; i < descriptor_->field_count(); ++i) { - auto* field = descriptor_->field(i); - if (field->type() != field->TYPE_MESSAGE) continue; - p->Emit( - { - {"sub_default_name", - QualifiedDefaultInstanceName(field->message_type(), options_)}, - }, - R"cc( - ::_pbi::StrongPointer(&$sub_default_name$); - )cc"); - } - }; - if (IsMapEntryMessage(descriptor_)) { format( "$classname$::$classname$() {}\n" "$classname$::$classname$(::$proto_ns$::Arena* arena)\n" " : SuperType(arena) {}\n"); - if (HasDescriptorMethods(descriptor_->file(), options_)) { - p->Emit( - { - {"pin_weak_descriptor", pin_weak_descriptor}, - {"index", index_in_file_messages_}, - }, - R"cc( - ::$proto_ns$::Metadata $classname$::GetMetadata() const { - $pin_weak_descriptor$; - return ::_pbi::AssignDescriptors(&$desc_table$_getter, - &$desc_table$_once, - $file_level_metadata$[$index$]); - } - )cc"); - } + GenerateClassData(p); return; } @@ -2329,20 +2283,12 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) { format("\n"); if (HasDescriptorMethods(descriptor_->file(), options_)) { - p->Emit( - { - {"pin_weak_descriptor", pin_weak_descriptor}, - {"index", index_in_file_messages_}, - }, - R"cc( - ::$proto_ns$::Metadata $classname$::GetMetadata() const { - $annotate_reflection$; - $pin_weak_descriptor$; - return ::_pbi::AssignDescriptors(&$desc_table$_getter, - &$desc_table$_once, - $file_level_metadata$[$index$]); - } - )cc"); + // Same as the base class, but it avoids virtual dispatch. + p->Emit(R"cc( + ::$proto_ns$::Metadata $classname$::GetMetadata() const { + return $superclass$::GetMetadataImpl(GetClassData()->full()); + } + )cc"); } if (HasTracker(descriptor_, options_)) { @@ -3603,9 +3549,6 @@ void MessageGenerator::GenerateSwap(io::Printer* p) { } void MessageGenerator::GenerateClassData(io::Printer* p) { - Formatter format(p); - if (HasSimpleBaseClass(descriptor_, options_)) return; - const auto on_demand_register_arena_dtor = [&] { if (NeedsArenaDestructor() == ArenaDtorNeeds::kOnDemand) { p->Emit(R"cc( @@ -3619,13 +3562,47 @@ void MessageGenerator::GenerateClassData(io::Printer* p) { }; if (HasDescriptorMethods(descriptor_->file(), options_)) { + const auto pin_weak_descriptor = [&] { + if (!UsingImplicitWeakDescriptor(descriptor_->file(), options_)) return; + + p->Emit(R"cc( + ::_pbi::StrongPointer(&_$classname$_default_instance_); + )cc"); + + // For CODE_SIZE types, we need to pin the submessages too. + // SPEED types will pin them via the TcParse table automatically. + if (HasGeneratedMethods(descriptor_->file(), options_)) return; + for (int i = 0; i < descriptor_->field_count(); ++i) { + auto* field = descriptor_->field(i); + if (field->type() != field->TYPE_MESSAGE) continue; + p->Emit({{"sub_default_name", QualifiedDefaultInstanceName( + field->message_type(), options_)}}, + R"cc( + ::_pbi::StrongPointer(&$sub_default_name$); + )cc"); + } + }; p->Emit( { {"on_demand_register_arena_dtor", on_demand_register_arena_dtor}, + {"pin_weak_descriptor", pin_weak_descriptor}, + {"tracker_on_get_metadata", + [&] { + if (HasTracker(descriptor_, options_)) { + p->Emit(R"cc( + &Impl_::TrackerOnGetMetadata, + )cc"); + } else { + p->Emit(R"cc( + nullptr, // tracker + )cc"); + } + }}, }, R"cc( const ::$proto_ns$::MessageLite::ClassData* $classname$::GetClassData() const { + $pin_weak_descriptor$; PROTOBUF_CONSTINIT static const ::$proto_ns$::MessageLite:: ClassDataFull _data_ = { { @@ -3635,8 +3612,10 @@ void MessageGenerator::GenerateClassData(io::Printer* p) { }, &$classname$::MergeImpl, &$classname$::kDescriptorMethods, + &$desc_table$, + $tracker_on_get_metadata$, }; - return &_data_; + return _data_.base(); } )cc"); } else { @@ -3648,21 +3627,17 @@ void MessageGenerator::GenerateClassData(io::Printer* p) { R"cc( const ::$proto_ns$::MessageLite::ClassData* $classname$::GetClassData() const { - struct ClassData_ { - ::$proto_ns$::MessageLite::ClassData header; - char type_name[$type_size$]; - }; - - PROTOBUF_CONSTINIT static const ClassData_ _data_ = { + PROTOBUF_CONSTINIT static const ClassDataLite<$type_size$> _data_ = { - $on_demand_register_arena_dtor$, - PROTOBUF_FIELD_OFFSET($classname$, $cached_size$), - true, - }, - "$full_name$", - }; + { + $on_demand_register_arena_dtor$, + PROTOBUF_FIELD_OFFSET($classname$, $cached_size$), + true, + }, + "$full_name$", + }; - return &_data_.header; + return _data_.base(); } )cc"); } diff --git a/src/google/protobuf/compiler/java/java_features.pb.cc b/src/google/protobuf/compiler/java/java_features.pb.cc index 391b79d58c..52514f43ec 100644 --- a/src/google/protobuf/compiler/java/java_features.pb.cc +++ b/src/google/protobuf/compiler/java/java_features.pb.cc @@ -43,7 +43,6 @@ struct JavaFeaturesDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOC_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 JavaFeaturesDefaultTypeInternal _JavaFeatures_default_instance_; } // namespace pb -static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto[1]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto[1]; static constexpr const ::_pb::ServiceDescriptor** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto = nullptr; @@ -90,7 +89,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2 &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto = { +PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto = { false, false, 430, @@ -103,25 +102,9 @@ const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fja schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto, }; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto_getter() { - return &descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto; -} namespace pb { const ::google::protobuf::EnumDescriptor* JavaFeatures_Utf8Validation_descriptor() { ::google::protobuf::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto); @@ -198,8 +181,10 @@ JavaFeatures::GetClassData() const { }, &JavaFeatures::MergeImpl, &JavaFeatures::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void JavaFeatures::Clear() { // @@protoc_insertion_point(message_clear_start:pb.JavaFeatures) @@ -366,9 +351,7 @@ void JavaFeatures::InternalSwap(JavaFeatures* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata JavaFeatures::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto_once, - file_level_metadata_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto[0]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } PROTOBUF_CONSTINIT PROTOC_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::_pbi:: diff --git a/src/google/protobuf/compiler/java/java_features.pb.h b/src/google/protobuf/compiler/java/java_features.pb.h index 4fb7d24c28..a2c8b71b2f 100644 --- a/src/google/protobuf/compiler/java/java_features.pb.h +++ b/src/google/protobuf/compiler/java/java_features.pb.h @@ -214,11 +214,10 @@ class PROTOC_EXPORT JavaFeatures final : public ::google::protobuf::Message : JavaFeatures(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using Utf8Validation = JavaFeatures_Utf8Validation; static constexpr Utf8Validation UTF8_VALIDATION_UNKNOWN = JavaFeatures_Utf8Validation_UTF8_VALIDATION_UNKNOWN; diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index dbc5482468..26a7aa65e2 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -129,7 +129,6 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOC_EXPORT } // namespace compiler } // namespace protobuf } // namespace google -static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; static constexpr const ::_pb::ServiceDescriptor** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; @@ -251,7 +250,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2 &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { +PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { false, false, 952, @@ -264,25 +263,9 @@ const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fpl schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, }; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() { - return &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -} namespace google { namespace protobuf { namespace compiler { @@ -384,8 +367,10 @@ Version::GetClassData() const { }, &Version::MergeImpl, &Version::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void Version::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version) @@ -607,9 +592,7 @@ void Version::InternalSwap(Version* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata Version::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -695,8 +678,10 @@ CodeGeneratorRequest::GetClassData() const { }, &CodeGeneratorRequest::MergeImpl, &CodeGeneratorRequest::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void CodeGeneratorRequest::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest) @@ -957,9 +942,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* PROTOBUF_RESTRICT } ::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -1042,8 +1025,10 @@ CodeGeneratorResponse_File::GetClassData() const { }, &CodeGeneratorResponse_File::MergeImpl, &CodeGeneratorResponse_File::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void CodeGeneratorResponse_File::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File) @@ -1279,9 +1264,7 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* PROTOB } ::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -1362,8 +1345,10 @@ CodeGeneratorResponse::GetClassData() const { }, &CodeGeneratorResponse::MergeImpl, &CodeGeneratorResponse::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void CodeGeneratorResponse::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse) @@ -1614,9 +1599,7 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* PROTOBUF_RESTRIC } ::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // @@protoc_insertion_point(namespace_scope) } // namespace compiler diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index f1e3444c32..f90137ce47 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -231,11 +231,10 @@ class PROTOC_EXPORT Version final : public ::google::protobuf::Message : Version(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -445,11 +444,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::google::protobuf : CodeGeneratorResponse_File(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -675,11 +673,10 @@ class PROTOC_EXPORT CodeGeneratorResponse final : public ::google::protobuf::Mes : CodeGeneratorResponse(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using File = CodeGeneratorResponse_File; using Feature = CodeGeneratorResponse_Feature; @@ -929,11 +926,10 @@ class PROTOC_EXPORT CodeGeneratorRequest final : public ::google::protobuf::Mess : CodeGeneratorRequest(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- diff --git a/src/google/protobuf/cpp_features.pb.cc b/src/google/protobuf/cpp_features.pb.cc index 03a6be877d..50783e6ee4 100644 --- a/src/google/protobuf/cpp_features.pb.cc +++ b/src/google/protobuf/cpp_features.pb.cc @@ -42,7 +42,6 @@ struct CppFeaturesDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CppFeaturesDefaultTypeInternal _CppFeatures_default_instance_; } // namespace pb -static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fcpp_5ffeatures_2eproto[1]; static constexpr const ::_pb::EnumDescriptor** file_level_enum_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto = nullptr; static constexpr const ::_pb::ServiceDescriptor** @@ -83,7 +82,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2 &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto = { +PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto = { false, false, 213, @@ -96,25 +95,9 @@ const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcpp_5ffeature schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcpp_5ffeatures_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fcpp_5ffeatures_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcpp_5ffeatures_2eproto, }; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_getter() { - return &descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto; -} namespace pb { // =================================================================== @@ -165,8 +148,10 @@ CppFeatures::GetClassData() const { }, &CppFeatures::MergeImpl, &CppFeatures::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void CppFeatures::Clear() { // @@protoc_insertion_point(message_clear_start:pb.CppFeatures) @@ -297,9 +282,7 @@ void CppFeatures::InternalSwap(CppFeatures* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata CppFeatures::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_once, - file_level_metadata_google_2fprotobuf_2fcpp_5ffeatures_2eproto[0]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } PROTOBUF_CONSTINIT PROTOBUF_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::_pbi:: diff --git a/src/google/protobuf/cpp_features.pb.h b/src/google/protobuf/cpp_features.pb.h index 5b3e4e73f3..86d75f0b04 100644 --- a/src/google/protobuf/cpp_features.pb.h +++ b/src/google/protobuf/cpp_features.pb.h @@ -183,11 +183,10 @@ class PROTOBUF_EXPORT CppFeatures final : public ::google::protobuf::Message : CppFeatures(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 03d9558c12..199740620b 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -2871,13 +2871,41 @@ enum class Utf8CheckMode { }; PROTOBUF_EXPORT Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, bool is_lite); -#endif // !SWIG // Returns whether or not this file is lazily initialized rather than // pre-main via static initialization. This has to be done for our bootstrapped // protos to avoid linker bloat in lite runtimes. PROTOBUF_EXPORT bool IsLazilyInitializedFile(absl::string_view filename); +template +auto VisitDescriptorsInFileOrder(const Descriptor* desc, + F& f) -> decltype(f(desc)) { + for (int i = 0; i < desc->nested_type_count(); i++) { + if (auto res = VisitDescriptorsInFileOrder(desc->nested_type(i), f)) { + return res; + } + } + if (auto res = f(desc)) return res; + return {}; +} + +// Visit the messages in post-order traversal. +// We need several pieces of code to follow the same order because we use the +// index of types during array lookups. +// If any call returns a "truthy" value, it stops visitation and returns that +// value right away. Otherwise returns `{}` after visiting all types. +template +auto VisitDescriptorsInFileOrder(const FileDescriptor* file, + F f) -> decltype(f(file->message_type(0))) { + for (int i = 0; i < file->message_type_count(); i++) { + if (auto res = VisitDescriptorsInFileOrder(file->message_type(i), f)) { + return res; + } + } + return {}; +} +#endif // !SWIG + } // namespace cpp } // namespace internal diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 199161c334..9ec5f894a2 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -999,7 +999,6 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; } // namespace protobuf } // namespace google -static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[32]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[17]; static constexpr const ::_pb::ServiceDescriptor** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; @@ -1900,7 +1899,7 @@ const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] AB "buf.Reflection" }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { +PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { false, false, 9574, @@ -1913,25 +1912,9 @@ const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2e schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, }; - -// This function exists to be marked as weak. -// It can significantly speed up compilation by breaking up LLVM's SCC -// in the .pb.cc translation units. Large translation units see a -// reduction of more than 35% of walltime for optimized builds. Without -// the weak attribute all the messages in the file, including all the -// vtables and everything they use become part of the same SCC through -// a cycle like: -// GetMetadata -> descriptor table -> default instances -> -// vtables -> GetMetadata -// By adding a weak function here we break the connection from the -// individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() { - return &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; -} namespace google { namespace protobuf { namespace internal { @@ -2405,8 +2388,10 @@ FileDescriptorSet::GetClassData() const { }, &FileDescriptorSet::MergeImpl, &FileDescriptorSet::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FileDescriptorSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet) @@ -2534,9 +2519,7 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* PROTOBUF_RESTRICT other) } ::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -2638,8 +2621,10 @@ FileDescriptorProto::GetClassData() const { }, &FileDescriptorProto::MergeImpl, &FileDescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FileDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto) @@ -3129,9 +3114,7 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* PROTOBUF_RESTRICT ot } ::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -3212,8 +3195,10 @@ DescriptorProto_ExtensionRange::GetClassData() const { }, &DescriptorProto_ExtensionRange::MergeImpl, &DescriptorProto_ExtensionRange::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void DescriptorProto_ExtensionRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange) @@ -3416,9 +3401,7 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange } ::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -3474,8 +3457,10 @@ DescriptorProto_ReservedRange::GetClassData() const { }, &DescriptorProto_ReservedRange::MergeImpl, &DescriptorProto_ReservedRange::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void DescriptorProto_ReservedRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange) @@ -3642,9 +3627,7 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* } ::google::protobuf::Metadata DescriptorProto_ReservedRange::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -3732,8 +3715,10 @@ DescriptorProto::GetClassData() const { }, &DescriptorProto::MergeImpl, &DescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void DescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto) @@ -4140,9 +4125,7 @@ void DescriptorProto::InternalSwap(DescriptorProto* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata DescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -4224,8 +4207,10 @@ ExtensionRangeOptions_Declaration::GetClassData() const { }, &ExtensionRangeOptions_Declaration::MergeImpl, &ExtensionRangeOptions_Declaration::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void ExtensionRangeOptions_Declaration::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ExtensionRangeOptions.Declaration) @@ -4477,9 +4462,7 @@ void ExtensionRangeOptions_Declaration::InternalSwap(ExtensionRangeOptions_Decla } ::google::protobuf::Metadata ExtensionRangeOptions_Declaration::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -4557,8 +4540,10 @@ ExtensionRangeOptions::GetClassData() const { }, &ExtensionRangeOptions::MergeImpl, &ExtensionRangeOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void ExtensionRangeOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ExtensionRangeOptions) @@ -4808,9 +4793,7 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* PROTOBUF_RESTRIC } ::google::protobuf::Metadata ExtensionRangeOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -4908,8 +4891,10 @@ FieldDescriptorProto::GetClassData() const { }, &FieldDescriptorProto::MergeImpl, &FieldDescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FieldDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto) @@ -5336,9 +5321,7 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* PROTOBUF_RESTRICT } ::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -5410,8 +5393,10 @@ OneofDescriptorProto::GetClassData() const { }, &OneofDescriptorProto::MergeImpl, &OneofDescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void OneofDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto) @@ -5593,9 +5578,7 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* PROTOBUF_RESTRICT } ::google::protobuf::Metadata OneofDescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -5651,8 +5634,10 @@ EnumDescriptorProto_EnumReservedRange::GetClassData() const { }, &EnumDescriptorProto_EnumReservedRange::MergeImpl, &EnumDescriptorProto_EnumReservedRange::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void EnumDescriptorProto_EnumReservedRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto.EnumReservedRange) @@ -5819,9 +5804,7 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu } ::google::protobuf::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -5899,8 +5882,10 @@ EnumDescriptorProto::GetClassData() const { }, &EnumDescriptorProto::MergeImpl, &EnumDescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void EnumDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto) @@ -6164,9 +6149,7 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* PROTOBUF_RESTRICT ot } ::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -6244,8 +6227,10 @@ EnumValueDescriptorProto::GetClassData() const { }, &EnumValueDescriptorProto::MergeImpl, &EnumValueDescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void EnumValueDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto) @@ -6456,9 +6441,7 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* PROTOBUF_R } ::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -6532,8 +6515,10 @@ ServiceDescriptorProto::GetClassData() const { }, &ServiceDescriptorProto::MergeImpl, &ServiceDescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void ServiceDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto) @@ -6744,9 +6729,7 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* PROTOBUF_RESTR } ::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -6836,8 +6819,10 @@ MethodDescriptorProto::GetClassData() const { }, &MethodDescriptorProto::MergeImpl, &MethodDescriptorProto::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void MethodDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto) @@ -7127,9 +7112,7 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* PROTOBUF_RESTRIC } ::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -7247,8 +7230,10 @@ FileOptions::GetClassData() const { }, &FileOptions::MergeImpl, &FileOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FileOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions) @@ -7945,9 +7930,7 @@ void FileOptions::InternalSwap(FileOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata FileOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -8033,8 +8016,10 @@ MessageOptions::GetClassData() const { }, &MessageOptions::MergeImpl, &MessageOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void MessageOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions) @@ -8335,9 +8320,7 @@ void MessageOptions::InternalSwap(MessageOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata MessageOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -8405,8 +8388,10 @@ FieldOptions_EditionDefault::GetClassData() const { }, &FieldOptions_EditionDefault::MergeImpl, &FieldOptions_EditionDefault::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FieldOptions_EditionDefault::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions.EditionDefault) @@ -8574,9 +8559,7 @@ void FieldOptions_EditionDefault::InternalSwap(FieldOptions_EditionDefault* PROT } ::google::protobuf::Metadata FieldOptions_EditionDefault::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -8666,8 +8649,10 @@ FieldOptions::GetClassData() const { }, &FieldOptions::MergeImpl, &FieldOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FieldOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions) @@ -9124,9 +9109,7 @@ void FieldOptions::InternalSwap(FieldOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata FieldOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -9200,8 +9183,10 @@ OneofOptions::GetClassData() const { }, &OneofOptions::MergeImpl, &OneofOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void OneofOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions) @@ -9388,9 +9373,7 @@ void OneofOptions::InternalSwap(OneofOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata OneofOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -9476,8 +9459,10 @@ EnumOptions::GetClassData() const { }, &EnumOptions::MergeImpl, &EnumOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void EnumOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions) @@ -9738,9 +9723,7 @@ void EnumOptions::InternalSwap(EnumOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata EnumOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -9826,8 +9809,10 @@ EnumValueOptions::GetClassData() const { }, &EnumValueOptions::MergeImpl, &EnumValueOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void EnumValueOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions) @@ -10070,9 +10055,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata EnumValueOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -10152,8 +10135,10 @@ ServiceOptions::GetClassData() const { }, &ServiceOptions::MergeImpl, &ServiceOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void ServiceOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions) @@ -10371,9 +10356,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata ServiceOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -10459,8 +10442,10 @@ MethodOptions::GetClassData() const { }, &MethodOptions::MergeImpl, &MethodOptions::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void MethodOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions) @@ -10708,9 +10693,7 @@ void MethodOptions::InternalSwap(MethodOptions* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata MethodOptions::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -10781,8 +10764,10 @@ UninterpretedOption_NamePart::GetClassData() const { }, &UninterpretedOption_NamePart::MergeImpl, &UninterpretedOption_NamePart::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void UninterpretedOption_NamePart::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart) @@ -10952,9 +10937,7 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* PR } ::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -11041,8 +11024,10 @@ UninterpretedOption::GetClassData() const { }, &UninterpretedOption::MergeImpl, &UninterpretedOption::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void UninterpretedOption::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption) @@ -11345,9 +11330,7 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* PROTOBUF_RESTRICT ot } ::google::protobuf::Metadata UninterpretedOption::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -11426,8 +11409,10 @@ FeatureSet::GetClassData() const { }, &FeatureSet::MergeImpl, &FeatureSet::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FeatureSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FeatureSet) @@ -11700,9 +11685,7 @@ void FeatureSet::InternalSwap(FeatureSet* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata FeatureSet::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -11777,8 +11760,10 @@ FeatureSetDefaults_FeatureSetEditionDefault::GetClassData() const { }, &FeatureSetDefaults_FeatureSetEditionDefault::MergeImpl, &FeatureSetDefaults_FeatureSetEditionDefault::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FeatureSetDefaults_FeatureSetEditionDefault::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault) @@ -11955,9 +11940,7 @@ void FeatureSetDefaults_FeatureSetEditionDefault::InternalSwap(FeatureSetDefault } ::google::protobuf::Metadata FeatureSetDefaults_FeatureSetEditionDefault::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -12035,8 +12018,10 @@ FeatureSetDefaults::GetClassData() const { }, &FeatureSetDefaults::MergeImpl, &FeatureSetDefaults::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void FeatureSetDefaults::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FeatureSetDefaults) @@ -12229,9 +12214,7 @@ void FeatureSetDefaults::InternalSwap(FeatureSetDefaults* PROTOBUF_RESTRICT othe } ::google::protobuf::Metadata FeatureSetDefaults::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -12310,8 +12293,10 @@ SourceCodeInfo_Location::GetClassData() const { }, &SourceCodeInfo_Location::MergeImpl, &SourceCodeInfo_Location::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void SourceCodeInfo_Location::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location) @@ -12574,9 +12559,7 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* PROTOBUF_RES } ::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[28]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -12637,8 +12620,10 @@ SourceCodeInfo::GetClassData() const { }, &SourceCodeInfo::MergeImpl, &SourceCodeInfo::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void SourceCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) @@ -12765,9 +12750,7 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* PROTOBUF_RESTRICT other) { } ::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[29]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -12850,8 +12833,10 @@ GeneratedCodeInfo_Annotation::GetClassData() const { }, &GeneratedCodeInfo_Annotation::MergeImpl, &GeneratedCodeInfo_Annotation::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void GeneratedCodeInfo_Annotation::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation) @@ -13106,9 +13091,7 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* PR } ::google::protobuf::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[30]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // =================================================================== @@ -13169,8 +13152,10 @@ GeneratedCodeInfo::GetClassData() const { }, &GeneratedCodeInfo::MergeImpl, &GeneratedCodeInfo::kDescriptorMethods, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, + nullptr, // tracker }; - return &_data_; + return _data_.base(); } PROTOBUF_NOINLINE void GeneratedCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo) @@ -13297,9 +13282,7 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* PROTOBUF_RESTRICT other) } ::google::protobuf::Metadata GeneratedCodeInfo::GetMetadata() const { - return ::_pbi::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[31]); + return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full()); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 6424422d93..232475b222 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -813,11 +813,10 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::google::prot : UninterpretedOption_NamePart(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -1001,11 +1000,10 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::google::protobuf: : SourceCodeInfo_Location(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -1267,11 +1265,10 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::google::prot : GeneratedCodeInfo_Annotation(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using Semantic = GeneratedCodeInfo_Annotation_Semantic; static constexpr Semantic NONE = GeneratedCodeInfo_Annotation_Semantic_NONE; @@ -1522,11 +1519,10 @@ class PROTOBUF_EXPORT FieldOptions_EditionDefault final : public ::google::proto : FieldOptions_EditionDefault(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -1710,11 +1706,10 @@ class PROTOBUF_EXPORT FeatureSet final : public ::google::protobuf::Message : FeatureSet(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using FieldPresence = FeatureSet_FieldPresence; static constexpr FieldPresence FIELD_PRESENCE_UNKNOWN = FeatureSet_FieldPresence_FIELD_PRESENCE_UNKNOWN; @@ -2245,11 +2240,10 @@ class PROTOBUF_EXPORT ExtensionRangeOptions_Declaration final : public ::google: : ExtensionRangeOptions_Declaration(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -2478,11 +2472,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::goo : EnumDescriptorProto_EnumReservedRange(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -2660,11 +2653,10 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::google::pro : DescriptorProto_ReservedRange(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -2842,11 +2834,10 @@ class PROTOBUF_EXPORT UninterpretedOption final : public ::google::protobuf::Mes : UninterpretedOption(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using NamePart = UninterpretedOption_NamePart; @@ -3114,11 +3105,10 @@ class PROTOBUF_EXPORT SourceCodeInfo final : public ::google::protobuf::Message : SourceCodeInfo(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using Location = SourceCodeInfo_Location; @@ -3289,11 +3279,10 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::google::protobuf::Messa : GeneratedCodeInfo(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using Annotation = GeneratedCodeInfo_Annotation; @@ -3464,11 +3453,10 @@ class PROTOBUF_EXPORT FeatureSetDefaults_FeatureSetEditionDefault final : public : FeatureSetDefaults_FeatureSetEditionDefault(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -3650,11 +3638,10 @@ class PROTOBUF_EXPORT ServiceOptions final : public ::google::protobuf::Message : ServiceOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -4035,11 +4022,10 @@ class PROTOBUF_EXPORT OneofOptions final : public ::google::protobuf::Message : OneofOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -4407,11 +4393,10 @@ class PROTOBUF_EXPORT MethodOptions final : public ::google::protobuf::Message : MethodOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using IdempotencyLevel = MethodOptions_IdempotencyLevel; static constexpr IdempotencyLevel IDEMPOTENCY_UNKNOWN = MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN; @@ -4825,11 +4810,10 @@ class PROTOBUF_EXPORT MessageOptions final : public ::google::protobuf::Message : MessageOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -5262,11 +5246,10 @@ class PROTOBUF_EXPORT FileOptions final : public ::google::protobuf::Message : FileOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using OptimizeMode = FileOptions_OptimizeMode; static constexpr OptimizeMode SPEED = FileOptions_OptimizeMode_SPEED; @@ -5961,11 +5944,10 @@ class PROTOBUF_EXPORT FieldOptions final : public ::google::protobuf::Message : FieldOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using EditionDefault = FieldOptions_EditionDefault; using CType = FieldOptions_CType; @@ -6578,11 +6560,10 @@ class PROTOBUF_EXPORT FeatureSetDefaults final : public ::google::protobuf::Mess : FeatureSetDefaults(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using FeatureSetEditionDefault = FeatureSetDefaults_FeatureSetEditionDefault; @@ -6780,11 +6761,10 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::google::protobuf::M : ExtensionRangeOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using Declaration = ExtensionRangeOptions_Declaration; using VerificationState = ExtensionRangeOptions_VerificationState; @@ -7204,11 +7184,10 @@ class PROTOBUF_EXPORT EnumValueOptions final : public ::google::protobuf::Messag : EnumValueOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -7602,11 +7581,10 @@ class PROTOBUF_EXPORT EnumOptions final : public ::google::protobuf::Message : EnumOptions(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -8013,11 +7991,10 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : public ::google::protobuf::Me : OneofDescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -8205,11 +8182,10 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : public ::google::protobuf::M : MethodDescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -8461,11 +8437,10 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : public ::google::protobuf::Me : FieldDescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using Type = FieldDescriptorProto_Type; static constexpr Type TYPE_DOUBLE = FieldDescriptorProto_Type_TYPE_DOUBLE; @@ -8849,11 +8824,10 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::google::protobuf : EnumValueDescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -9054,11 +9028,10 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::google::pr : DescriptorProto_ExtensionRange(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -9253,11 +9226,10 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::google::protobuf:: : ServiceDescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -9464,11 +9436,10 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : public ::google::protobuf::Mes : EnumDescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using EnumReservedRange = EnumDescriptorProto_EnumReservedRange; @@ -9725,11 +9696,10 @@ class PROTOBUF_EXPORT DescriptorProto final : public ::google::protobuf::Message : DescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- using ExtensionRange = DescriptorProto_ExtensionRange; using ReservedRange = DescriptorProto_ReservedRange; @@ -10082,11 +10052,10 @@ class PROTOBUF_EXPORT FileDescriptorProto final : public ::google::protobuf::Mes : FileDescriptorProto(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- @@ -10488,11 +10457,10 @@ class PROTOBUF_EXPORT FileDescriptorSet final : public ::google::protobuf::Messa : FileDescriptorSet(arena) { *this = ::std::move(from); } - const ::google::protobuf::MessageLite::ClassData* GetClassData() - const final; + const ::google::protobuf::Message::ClassData* GetClassData() const final; public: - ::google::protobuf::Metadata GetMetadata() const final; + ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index 0c4ee1b7e0..3856082889 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -202,20 +202,7 @@ class DynamicMessage final : public Message { Message* New(Arena* arena) const override; - const ClassData* GetClassData() const final { - ABSL_CONST_INIT static const ClassDataFull data = { - { - nullptr, // on_demand_register_arena_dtor - PROTOBUF_FIELD_OFFSET(DynamicMessage, cached_byte_size_), - false, - }, - &MergeImpl, - &kDescriptorMethods, - }; - return &data; - } - - Metadata GetMetadata() const override; + const ClassData* GetClassData() const final; #if defined(__cpp_lib_destroying_delete) && defined(__cpp_sized_deallocation) static void operator delete(DynamicMessage* msg, std::destroying_delete_t); @@ -267,13 +254,11 @@ struct DynamicMessageFactory::TypeInfo { // Not owned by the TypeInfo. DynamicMessageFactory* factory; // The factory that created this object. const DescriptorPool* pool; // The factory's DescriptorPool. - const Descriptor* type; // Type of this DynamicMessage. // Warning: The order in which the following pointers are defined is // important (the prototype must be deleted *before* the offsets). std::unique_ptr offsets; std::unique_ptr has_bits_indices; - std::unique_ptr reflection; // Don't use a unique_ptr to hold the prototype: the destructor for // DynamicMessage needs to know whether it is the prototype, and does so by // looking back at this field. This would assume details about the @@ -281,10 +266,25 @@ struct DynamicMessageFactory::TypeInfo { const DynamicMessage* prototype; int weak_field_map_offset; // The offset for the weak_field_map; + DynamicMessage::ClassDataFull class_data = { + { + nullptr, // on_demand_register_arena_dtor + PROTOBUF_FIELD_OFFSET(DynamicMessage, cached_byte_size_), + false, + }, + &DynamicMessage::MergeImpl, + &DynamicMessage::kDescriptorMethods, + nullptr, // descriptor_table + nullptr, // get_metadata_tracker + }; + TypeInfo() : prototype(nullptr) {} ~TypeInfo() { delete prototype; + delete class_data.reflection; + + auto* type = class_data.descriptor; // Scribble the payload to prevent unsanitized opt builds from silently // allowing use-after-free bugs where the factory is destroyed but the @@ -337,8 +337,9 @@ inline void* DynamicMessage::MutableOneofCaseRaw(int i) { return OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32_t) * i); } inline void* DynamicMessage::MutableOneofFieldRaw(const FieldDescriptor* f) { - return OffsetToPointer(type_info_->offsets[type_info_->type->field_count() + - f->containing_oneof()->index()]); + return OffsetToPointer( + type_info_->offsets[type_info_->class_data.descriptor->field_count() + + f->containing_oneof()->index()]); } void DynamicMessage::SharedCtor(bool lock_factory) { @@ -351,7 +352,7 @@ void DynamicMessage::SharedCtor(bool lock_factory) { // in practice that's not strictly necessary for types that don't have a // constructor.) - const Descriptor* descriptor = type_info_->type; + const Descriptor* descriptor = type_info_->class_data.descriptor; Arena* arena = GetArena(); // Initialize oneof cases. int oneof_count = 0; @@ -465,7 +466,7 @@ void DynamicMessage::operator delete(DynamicMessage* msg, #endif DynamicMessage::~DynamicMessage() { - const Descriptor* descriptor = type_info_->type; + const Descriptor* descriptor = type_info_->class_data.descriptor; _internal_metadata_.Delete(); @@ -565,7 +566,7 @@ void DynamicMessage::CrossLinkPrototypes() { ABSL_CHECK(is_prototype()); DynamicMessageFactory* factory = type_info_->factory; - const Descriptor* descriptor = type_info_->type; + const Descriptor* descriptor = type_info_->class_data.descriptor; // Cross-link default messages. for (int i = 0; i < descriptor->field_count(); i++) { @@ -596,11 +597,8 @@ Message* DynamicMessage::New(Arena* arena) const { } } -Metadata DynamicMessage::GetMetadata() const { - Metadata metadata; - metadata.descriptor = type_info_->type; - metadata.reflection = type_info_->reflection.get(); - return metadata; +const MessageLite::ClassData* DynamicMessage::GetClassData() const { + return type_info_->class_data.base(); } // =================================================================== @@ -640,7 +638,7 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( TypeInfo* type_info = new TypeInfo; *target = type_info; - type_info->type = type; + type_info->class_data.descriptor = type; type_info->pool = (pool_ == nullptr) ? type->file()->pool() : pool_; type_info->factory = this; @@ -773,8 +771,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( -1, // sizeof_split_ }; - type_info->reflection.reset( - new Reflection(type_info->type, schema, type_info->pool, this)); + type_info->class_data.reflection = new Reflection( + type_info->class_data.descriptor, schema, type_info->pool, this); // Cross link prototypes. prototype->CrossLinkPrototypes(); diff --git a/src/google/protobuf/generated_message_bases.cc b/src/google/protobuf/generated_message_bases.cc index 9ebd820c12..3e453c53e9 100644 --- a/src/google/protobuf/generated_message_bases.cc +++ b/src/google/protobuf/generated_message_bases.cc @@ -35,7 +35,7 @@ ZeroFieldsBase::~ZeroFieldsBase() { } size_t ZeroFieldsBase::ByteSizeLong() const { - return MaybeComputeUnknownFieldsSize(0, &_cached_size_); + return MaybeComputeUnknownFieldsSize(0, &_impl_._cached_size_); } const char* ZeroFieldsBase::_InternalParse(const char* ptr, @@ -97,19 +97,6 @@ void ZeroFieldsBase::InternalSwap(ZeroFieldsBase* other) { _internal_metadata_.Swap(&other->_internal_metadata_); } -const Message::ClassData* ZeroFieldsBase::GetClassData() const { - ABSL_CONST_INIT static const ClassDataFull data = { - { - nullptr, // on_demand_register_arena_dtor - PROTOBUF_FIELD_OFFSET(ZeroFieldsBase, _cached_size_), - false, - }, - &MergeImpl, - &kDescriptorMethods, - }; - return &data; -} - } // namespace internal } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/generated_message_bases.h b/src/google/protobuf/generated_message_bases.h index 9e649d62ce..030caab529 100644 --- a/src/google/protobuf/generated_message_bases.h +++ b/src/google/protobuf/generated_message_bases.h @@ -32,7 +32,7 @@ class PROTOBUF_EXPORT ZeroFieldsBase : public Message { ABSL_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final { return true; } size_t ByteSizeLong() const final; - int GetCachedSize() const { return _cached_size_.Get(); } + int GetCachedSize() const { return _impl_._cached_size_.Get(); } const char* _InternalParse(const char* ptr, internal::ParseContext* ctx) final; ::uint8_t* _InternalSerialize(::uint8_t* target, @@ -45,13 +45,13 @@ class PROTOBUF_EXPORT ZeroFieldsBase : public Message { ZeroFieldsBase& operator=(const ZeroFieldsBase&) = delete; ~ZeroFieldsBase() override; - const ClassData* GetClassData() const final; - static void MergeImpl(MessageLite& to, const MessageLite& from); static void CopyImpl(Message& to, const Message& from); void InternalSwap(ZeroFieldsBase* other); - mutable internal::CachedSize _cached_size_; + struct { + mutable internal::CachedSize _cached_size_; + } _impl_; }; } // namespace internal diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index d0543d1340..bebe33eb98 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -41,6 +41,7 @@ #include "google/protobuf/map_field.h" #include "google/protobuf/message.h" #include "google/protobuf/message_lite.h" +#include "google/protobuf/port.h" #include "google/protobuf/raw_ptr.h" #include "google/protobuf/repeated_field.h" #include "google/protobuf/repeated_ptr_field.h" @@ -3528,13 +3529,11 @@ ReflectionSchema MigrationToReflectionSchema( class AssignDescriptorsHelper { public: AssignDescriptorsHelper(MessageFactory* factory, - Metadata* file_level_metadata, const EnumDescriptor** file_level_enum_descriptors, const MigrationSchema* schemas, const Message* const* default_instance_data, const uint32_t* offsets) : factory_(factory), - file_level_metadata_(file_level_metadata), file_level_enum_descriptors_(file_level_enum_descriptors), schemas_(schemas), default_instance_data_(default_instance_data), @@ -3545,19 +3544,27 @@ class AssignDescriptorsHelper { AssignMessageDescriptor(descriptor->nested_type(i)); } - file_level_metadata_->descriptor = descriptor; - - file_level_metadata_->reflection = - new Reflection(descriptor, - MigrationToReflectionSchema(default_instance_data_, - offsets_, *schemas_), - DescriptorPool::internal_generated_pool(), factory_); + // If there is no default instance we only want to initialize the descriptor + // without updating the reflection. + if (default_instance_data_[0] != nullptr) { + auto& class_data = default_instance_data_[0]->GetClassData()->full(); + // If there is no descriptor_table in the class data, then it is not + // interested in receiving reflection information either. + if (class_data.descriptor_table != nullptr) { + class_data.descriptor = descriptor; + + class_data.reflection = OnShutdownDelete(new Reflection( + descriptor, + MigrationToReflectionSchema(default_instance_data_, offsets_, + *schemas_), + DescriptorPool::internal_generated_pool(), factory_)); + } + } for (int i = 0; i < descriptor->enum_type_count(); i++) { AssignEnumDescriptor(descriptor->enum_type(i)); } schemas_++; default_instance_data_++; - file_level_metadata_++; } void AssignEnumDescriptor(const EnumDescriptor* descriptor) { @@ -3565,11 +3572,8 @@ class AssignDescriptorsHelper { file_level_enum_descriptors_++; } - const Metadata* GetCurrentMetadataPtr() const { return file_level_metadata_; } - private: MessageFactory* factory_; - Metadata* file_level_metadata_; const EnumDescriptor** file_level_enum_descriptors_; const MigrationSchema* schemas_; const Message* const* default_instance_data_; @@ -3578,36 +3582,6 @@ class AssignDescriptorsHelper { namespace { -// We have the routines that assign descriptors and build reflection -// automatically delete the allocated reflection. MetadataOwner owns -// all the allocated reflection instances. -struct MetadataOwner { - ~MetadataOwner() { - for (auto range : metadata_arrays) { - for (const Metadata* m = range.first; m < range.second; m++) { - delete m->reflection; - } - } - } - - void AddArray(const Metadata* begin, const Metadata* end) { - mu.Lock(); - metadata_arrays.push_back(std::make_pair(begin, end)); - mu.Unlock(); - } - - static MetadataOwner* Instance() { - static MetadataOwner* res = OnShutdownDelete(new MetadataOwner); - return res; - } - - private: - MetadataOwner() = default; // private because singleton - - absl::Mutex mu; - std::vector> metadata_arrays; -}; - void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) { // Ensure the file descriptor is added to the pool. { @@ -3649,9 +3623,9 @@ void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) { MessageFactory* factory = MessageFactory::generated_factory(); - AssignDescriptorsHelper helper( - factory, table->file_level_metadata, table->file_level_enum_descriptors, - table->schemas, table->default_instances, table->offsets); + AssignDescriptorsHelper helper(factory, table->file_level_enum_descriptors, + table->schemas, table->default_instances, + table->offsets); for (int i = 0; i < file->message_type_count(); i++) { helper.AssignMessageDescriptor(file->message_type(i)); @@ -3665,8 +3639,6 @@ void AssignDescriptorsImpl(const DescriptorTable* table, bool eager) { table->file_level_service_descriptors[i] = file->service(i); } } - MetadataOwner::Instance()->AddArray(table->file_level_metadata, - helper.GetCurrentMetadataPtr()); } void MaybeInitializeLazyDescriptors(const DescriptorTable* table) { @@ -3697,17 +3669,6 @@ void AddDescriptorsImpl(const DescriptorTable* table) { } // namespace -// Separate function because it needs to be a friend of -// Reflection -void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) { - for (int i = 0; i < size; i++) { - const Reflection* reflection = file_level_metadata[i].reflection; - MessageFactory::InternalRegisterGeneratedMessage( - file_level_metadata[i].descriptor, - reflection->schema_.default_instance_); - } -} - namespace internal { void AddDescriptors(const DescriptorTable* table) { @@ -3720,20 +3681,13 @@ void AddDescriptors(const DescriptorTable* table) { AddDescriptorsImpl(table); } -Metadata AssignDescriptors(const DescriptorTable* (*table)(), - absl::once_flag* once, const Metadata& metadata) { - absl::call_once(*once, [=] { - auto* t = table(); - MaybeInitializeLazyDescriptors(t); - AssignDescriptorsImpl(t, t->is_eager); - }); - - return metadata; +void AssignDescriptorsOnceInnerCall(const DescriptorTable* table) { + MaybeInitializeLazyDescriptors(table); + AssignDescriptorsImpl(table, table->is_eager); } void AssignDescriptors(const DescriptorTable* table) { - MaybeInitializeLazyDescriptors(table); - absl::call_once(*table->once, AssignDescriptorsImpl, table, table->is_eager); + absl::call_once(*table->once, [=] { AssignDescriptorsOnceInnerCall(table); }); } AddDescriptorsRunner::AddDescriptorsRunner(const DescriptorTable* table) { @@ -3742,7 +3696,14 @@ AddDescriptorsRunner::AddDescriptorsRunner(const DescriptorTable* table) { void RegisterFileLevelMetadata(const DescriptorTable* table) { AssignDescriptors(table); - RegisterAllTypesInternal(table->file_level_metadata, table->num_messages); + auto* file = DescriptorPool::internal_generated_pool()->FindFileByName( + table->filename); + auto defaults = table->default_instances; + internal::cpp::VisitDescriptorsInFileOrder(file, [&](auto* desc) { + MessageFactory::InternalRegisterGeneratedMessage(desc, *defaults); + ++defaults; + return std::false_type{}; + }); } void UnknownFieldSetSerializer(const uint8_t* base, uint32_t offset, @@ -3823,9 +3784,19 @@ const Message* GetPrototypeForWeakDescriptor(const DescriptorTable* table, // Fallback to dynamic messages. // Register the dep and generate the prototype via the generated pool. AssignDescriptors(table); - ABSL_CHECK(table->file_level_metadata[index].descriptor != nullptr); - return MessageFactory::generated_factory()->GetPrototype( - table->file_level_metadata[index].descriptor); + + const FileDescriptor* file = + DescriptorPool::internal_generated_pool()->FindFileByName( + table->filename); + + const Descriptor* descriptor = internal::cpp::VisitDescriptorsInFileOrder( + file, [&](auto* desc) -> const Descriptor* { + if (index == 0) return desc; + --index; + return nullptr; + }); + + return MessageFactory::generated_factory()->GetPrototype(descriptor); } } // namespace internal diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 7b4281357b..b888661b40 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -310,7 +310,6 @@ struct PROTOBUF_EXPORT DescriptorTable { const Message* const* default_instances; const uint32_t* offsets; // update the following descriptor arrays. - Metadata* file_level_metadata; const EnumDescriptor** file_level_enum_descriptors; const ServiceDescriptor** file_level_service_descriptors; }; @@ -321,14 +320,9 @@ struct PROTOBUF_EXPORT DescriptorTable { // called the first time anyone calls descriptor() or GetReflection() on one of // the types defined in the file. AssignDescriptors() is thread-safe. void PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* table); - -// Overload used to implement GetMetadataStatic in the generated code. -// See comments in compiler/cpp/file.cc as to why. -// It takes a `Metadata` and returns it to allow for tail calls and reduce -// binary size. -Metadata PROTOBUF_EXPORT AssignDescriptors(const DescriptorTable* (*table)(), - absl::once_flag* once, - const Metadata& metadata); +// As above, but the caller did the call_once call already. +void PROTOBUF_EXPORT +AssignDescriptorsOnceInnerCall(const DescriptorTable* table); // These cannot be in lite so we put them in the reflection. PROTOBUF_EXPORT void UnknownFieldSetSerializer(const uint8_t* base, diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index 3a1712bfad..ad7acdd855 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -44,28 +44,6 @@ namespace google { namespace protobuf { namespace internal { -// Base class to keep common fields and virtual function overrides. -class MapEntryBase : public Message { - protected: - using Message::Message; - - const ClassData* GetClassData() const final { - ABSL_CONST_INIT static const ClassDataFull data = { - { - nullptr, // on_demand_register_arena_dtor - PROTOBUF_FIELD_OFFSET(MapEntryBase, _cached_size_), - false, - }, - &MergeImpl, - &kDescriptorMethods, - }; - return &data; - } - - HasBits<1> _has_bits_{}; - mutable CachedSize _cached_size_{}; -}; - // MapEntry is the returned google::protobuf::Message when calling AddMessage of // google::protobuf::Reflection. In order to let it work with generated message // reflection, its in-memory type is the same as generated message with the same @@ -95,7 +73,7 @@ class MapEntryBase : public Message { template -class MapEntry : public MapEntryBase { +class MapEntry : public Message { // Provide utilities to parse/serialize key/value. Provide utilities to // manipulate internal stored type. using KeyTypeHandler = MapTypeHandler; @@ -123,7 +101,7 @@ class MapEntry : public MapEntryBase { value_(ValueTypeHandler::Constinit()) {} explicit MapEntry(Arena* arena) - : MapEntryBase(arena), + : Message(arena), key_(KeyTypeHandler::Constinit()), value_(ValueTypeHandler::Constinit()) {} @@ -191,6 +169,9 @@ class MapEntry : public MapEntryBase { WireFormatLite::FieldType> friend class MapField; + HasBits<1> _has_bits_{}; + mutable CachedSize _cached_size_{}; + KeyOnMemory key_; ValueOnMemory value_; }; diff --git a/src/google/protobuf/map_test.inc b/src/google/protobuf/map_test.inc index cbd0f44618..de5a2e26dd 100644 --- a/src/google/protobuf/map_test.inc +++ b/src/google/protobuf/map_test.inc @@ -2326,7 +2326,7 @@ class MyMapEntry public: constexpr MyMapEntry() {} using MyMapEntry::MapEntry::MapEntry; - Metadata GetMetadata() const override { ABSL_CHECK(false); } + const ClassData* GetClassData() const override { ABSL_CHECK(false); } static bool ValidateKey(void*) { return true; } static bool ValidateValue(void*) { return true; } }; diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index 16f0862309..bcb4f0aa3b 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -17,6 +17,8 @@ #include #include +#include "absl/base/call_once.h" +#include "absl/base/optimization.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/hash/hash.h" @@ -132,6 +134,25 @@ void Message::DiscardUnknownFields() { return ReflectionOps::DiscardUnknownFields(this); } +Metadata Message::GetMetadata() const { + return GetMetadataImpl(GetClassData()->full()); +} + +Metadata Message::GetMetadataImpl(const ClassDataFull& data) { + auto* table = data.descriptor_table; + // Only codegen types provide a table. DynamicMessage does not provide a table + // and instead eagerly initializes the descriptor/reflection members. + if (ABSL_PREDICT_TRUE(table != nullptr)) { + if (ABSL_PREDICT_FALSE(data.get_metadata_tracker != nullptr)) { + data.get_metadata_tracker(); + } + absl::call_once(*table->once, [table] { + internal::AssignDescriptorsOnceInnerCall(table); + }); + } + return {data.descriptor, data.reflection}; +} + const char* Message::_InternalParse(const char* ptr, internal::ParseContext* ctx) { #if defined(PROTOBUF_USE_TABLE_PARSER_ON_REFLECTION) diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index 6e08d0f2d8..e19a9a05f9 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -363,7 +363,8 @@ class PROTOBUF_EXPORT Message : public MessageLite { protected: // Get a struct containing the metadata for the Message, which is used in turn // to implement GetDescriptor() and GetReflection() above. - virtual Metadata GetMetadata() const = 0; + Metadata GetMetadata() const; + static Metadata GetMetadataImpl(const ClassDataFull& data); inline explicit Message(Arena* arena) : MessageLite(arena) {} size_t ComputeUnknownFieldsSize(size_t total_size, @@ -1251,9 +1252,6 @@ class PROTOBUF_EXPORT Reflection final { void AddEnumValueInternal(Message* message, const FieldDescriptor* field, int value) const; - friend inline // inline so nobody can call this function. - void - RegisterAllTypesInternal(const Metadata* file_level_metadata, int size); friend inline const char* ParseLenDelim(int field_number, const FieldDescriptor* field, Message* msg, diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index c04cc48b9e..17bf95eea1 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -51,6 +51,8 @@ class RepeatedPtrField; class FastReflectionMessageMutator; class FastReflectionStringSetter; class Reflection; +class Descriptor; +class AssignDescriptorsHelper; namespace io { @@ -123,6 +125,7 @@ class SwapFieldHelper; // See parse_context.h for explanation class ParseContext; +struct DescriptorTable; class ExtensionSet; class LazyField; class RepeatedPtrFieldBase; @@ -527,6 +530,11 @@ class PROTOBUF_EXPORT MessageLite { // Note: The order of arguments in the functions is chosen so that it has // the same ABI as the member function that calls them. Eg the `this` // pointer becomes the first argument in the free function. + // + // Future work: + // 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. struct ClassData { void (*on_demand_register_arena_dtor)(MessageLite& msg, Arena& arena); @@ -544,6 +552,7 @@ class PROTOBUF_EXPORT MessageLite { is_lite(is_lite) {} const ClassDataFull& full() const { + ABSL_DCHECK(!is_lite); return *static_cast(this); } }; @@ -551,18 +560,43 @@ class PROTOBUF_EXPORT MessageLite { struct ClassDataLite { ClassData header; const char type_name[N]; + + constexpr const ClassData* base() const { return &header; } }; struct ClassDataFull : ClassData { constexpr ClassDataFull(ClassData base, void (*merge_to_from)(MessageLite& to, const MessageLite& from_msg), - const DescriptorMethods* descriptor_methods) + const DescriptorMethods* descriptor_methods, + const internal::DescriptorTable* descriptor_table, + void (*get_metadata_tracker)()) : ClassData(base), merge_to_from(merge_to_from), - descriptor_methods(descriptor_methods) {} + descriptor_methods(descriptor_methods), + descriptor_table(descriptor_table), + reflection(), + descriptor(), + get_metadata_tracker(get_metadata_tracker) {} + + constexpr const ClassData* base() const { return this; } void (*merge_to_from)(MessageLite& to, const MessageLite& from_msg); const DescriptorMethods* descriptor_methods; + + // Codegen types will provide a DescriptorTable to do lazy + // registration/initialization of the reflection objects. + // Other types, like DynamicMessage, keep the table as null but eagerly + // populate `reflection`/`descriptor` fields. + const internal::DescriptorTable* descriptor_table; + // Accesses are protected by the once_flag in `descriptor_table`. When the + // table is null these are populated from the beginning and need to + // protection. + mutable const Reflection* reflection; + mutable const Descriptor* descriptor; + + // When an access tracker is installed, this function notifies the tracker + // that GetMetadata was called. + void (*get_metadata_tracker)(); }; // GetClassData() returns a pointer to a ClassData struct which @@ -609,6 +643,7 @@ class PROTOBUF_EXPORT MessageLite { private: friend class FastReflectionMessageMutator; + friend class AssignDescriptorsHelper; friend class FastReflectionStringSetter; friend class Message; friend class Reflection;