protobuf/src/google/protobuf/dynamic_message.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 //
35 // DynamicMessage is implemented by constructing a data structure which
36 // has roughly the same memory layout as a generated message would have.
37 // Then, we use Reflection to implement our reflection interface. All
38 // the other operations we need to implement (e.g. parsing, copying,
39 // etc.) are already implemented in terms of Reflection, so the rest is
40 // easy.
41 //
42 // The up side of this strategy is that it's very efficient. We don't
43 // need to use hash_maps or generic representations of fields. The
44 // down side is that this is a low-level memory management hack which
45 // can be tricky to get right.
46 //
47 // As mentioned in the header, we only expose a DynamicMessageFactory
48 // publicly, not the DynamicMessage class itself. This is because
49 // GenericMessageReflection wants to have a pointer to a "default"
50 // copy of the class, with all fields initialized to their default
51 // values. We only want to construct one of these per message type,
52 // so DynamicMessageFactory stores a cache of default messages for
53 // each type it sees (each unique Descriptor pointer). The code
54 // refers to the "default" copy of the class as the "prototype".
55 //
56 // Note on memory allocation: This module often calls "operator new()"
57 // to allocate untyped memory, rather than calling something like
58 // "new uint8_t[]". This is because "operator new()" means "Give me some
59 // space which I can use as I please." while "new uint8_t[]" means "Give
60 // me an array of 8-bit integers.". In practice, the later may return
61 // a pointer that is not aligned correctly for general use. I believe
62 // Item 8 of "More Effective C++" discusses this in more detail, though
63 // I don't have the book on me right now so I'm not sure.
64 
65 #include <google/protobuf/dynamic_message.h>
66 
67 #include <algorithm>
68 #include <cstddef>
69 #include <memory>
70 #include <new>
71 #include <unordered_map>
72 
73 #include <google/protobuf/descriptor.pb.h>
74 #include <google/protobuf/descriptor.h>
75 #include <google/protobuf/generated_message_reflection.h>
76 #include <google/protobuf/generated_message_util.h>
77 #include <google/protobuf/unknown_field_set.h>
78 #include <google/protobuf/stubs/hash.h>
79 #include <google/protobuf/arenastring.h>
80 #include <google/protobuf/extension_set.h>
81 #include <google/protobuf/map_field.h>
82 #include <google/protobuf/map_field_inl.h>
83 #include <google/protobuf/map_type_handler.h>
84 #include <google/protobuf/reflection_ops.h>
85 #include <google/protobuf/repeated_field.h>
86 #include <google/protobuf/wire_format.h>
87 
88 #include <google/protobuf/port_def.inc> // NOLINT
89 
90 namespace google {
91 namespace protobuf {
92 
93 using internal::DynamicMapField;
94 using internal::ExtensionSet;
95 using internal::MapField;
96 
97 
98 using internal::ArenaStringPtr;
99 
100 // ===================================================================
101 // Some helper tables and functions...
102 
104  public:
105  static bool IsLazyField(const Reflection* reflection,
106  const FieldDescriptor* field) {
107  return reflection->IsLazyField(field);
108  }
109 };
110 
111 namespace {
112 
113 bool IsMapFieldInApi(const FieldDescriptor* field) { return field->is_map(); }
114 
115 // Sync with helpers.h.
116 inline bool HasHasbit(const FieldDescriptor* field) {
117  // This predicate includes proto3 message fields only if they have "optional".
118  // Foo submsg1 = 1; // HasHasbit() == false
119  // optional Foo submsg2 = 2; // HasHasbit() == true
120  // This is slightly odd, as adding "optional" to a singular proto3 field does
121  // not change the semantics or API. However whenever any field in a message
122  // has a hasbit, it forces reflection to include hasbit offsets for *all*
123  // fields, even if almost all of them are set to -1 (no hasbit). So to avoid
124  // causing a sudden size regression for ~all proto3 messages, we give proto3
125  // message fields a hasbit only if "optional" is present. If the user is
126  // explicitly writing "optional", it is likely they are writing it on
127  // primitive fields also.
128  return (field->has_optional_keyword() || field->is_required()) &&
129  !field->options().weak();
130 }
131 
132 inline bool InRealOneof(const FieldDescriptor* field) {
133  return field->containing_oneof() &&
135 }
136 
137 // Compute the byte size of the in-memory representation of the field.
138 int FieldSpaceUsed(const FieldDescriptor* field) {
139  typedef FieldDescriptor FD; // avoid line wrapping
140  if (field->label() == FD::LABEL_REPEATED) {
141  switch (field->cpp_type()) {
142  case FD::CPPTYPE_INT32:
143  return sizeof(RepeatedField<int32_t>);
144  case FD::CPPTYPE_INT64:
145  return sizeof(RepeatedField<int64_t>);
146  case FD::CPPTYPE_UINT32:
147  return sizeof(RepeatedField<uint32_t>);
148  case FD::CPPTYPE_UINT64:
149  return sizeof(RepeatedField<uint64_t>);
150  case FD::CPPTYPE_DOUBLE:
151  return sizeof(RepeatedField<double>);
152  case FD::CPPTYPE_FLOAT:
153  return sizeof(RepeatedField<float>);
154  case FD::CPPTYPE_BOOL:
155  return sizeof(RepeatedField<bool>);
156  case FD::CPPTYPE_ENUM:
157  return sizeof(RepeatedField<int>);
158  case FD::CPPTYPE_MESSAGE:
159  if (IsMapFieldInApi(field)) {
160  return sizeof(DynamicMapField);
161  } else {
162  return sizeof(RepeatedPtrField<Message>);
163  }
164 
165  case FD::CPPTYPE_STRING:
166  switch (field->options().ctype()) {
167  default: // TODO(kenton): Support other string reps.
169  return sizeof(RepeatedPtrField<std::string>);
170  }
171  break;
172  }
173  } else {
174  switch (field->cpp_type()) {
175  case FD::CPPTYPE_INT32:
176  return sizeof(int32_t);
177  case FD::CPPTYPE_INT64:
178  return sizeof(int64_t);
179  case FD::CPPTYPE_UINT32:
180  return sizeof(uint32_t);
181  case FD::CPPTYPE_UINT64:
182  return sizeof(uint64_t);
183  case FD::CPPTYPE_DOUBLE:
184  return sizeof(double);
185  case FD::CPPTYPE_FLOAT:
186  return sizeof(float);
187  case FD::CPPTYPE_BOOL:
188  return sizeof(bool);
189  case FD::CPPTYPE_ENUM:
190  return sizeof(int);
191 
192  case FD::CPPTYPE_MESSAGE:
193  return sizeof(Message*);
194 
195  case FD::CPPTYPE_STRING:
196  switch (field->options().ctype()) {
197  default: // TODO(kenton): Support other string reps.
199  return sizeof(ArenaStringPtr);
200  }
201  break;
202  }
203  }
204 
205  GOOGLE_LOG(DFATAL) << "Can't get here.";
206  return 0;
207 }
208 
209 inline int DivideRoundingUp(int i, int j) { return (i + (j - 1)) / j; }
210 
211 static const int kSafeAlignment = sizeof(uint64_t);
212 static const int kMaxOneofUnionSize = sizeof(uint64_t);
213 
214 inline int AlignTo(int offset, int alignment) {
215  return DivideRoundingUp(offset, alignment) * alignment;
216 }
217 
218 // Rounds the given byte offset up to the next offset aligned such that any
219 // type may be stored at it.
220 inline int AlignOffset(int offset) { return AlignTo(offset, kSafeAlignment); }
221 
222 #define bitsizeof(T) (sizeof(T) * 8)
223 
224 } // namespace
225 
226 // ===================================================================
227 
228 class DynamicMessage : public Message {
229  public:
230  explicit DynamicMessage(const DynamicMessageFactory::TypeInfo* type_info);
231 
232  // This should only be used by GetPrototypeNoLock() to avoid dead lock.
233  DynamicMessage(DynamicMessageFactory::TypeInfo* type_info, bool lock_factory);
234 
235  ~DynamicMessage();
236 
237  // Called on the prototype after construction to initialize message fields.
238  // Cross linking the default instances allows for fast reflection access of
239  // unset message fields. Without it we would have to go to the MessageFactory
240  // to get the prototype, which is a much more expensive operation.
241  //
242  // Generated messages do not cross-link to avoid dynamic initialization of the
243  // global instances.
244  // Instead, they keep the default instances in the FieldDescriptor objects.
245  void CrossLinkPrototypes();
246 
247  // implements Message ----------------------------------------------
248 
249  Message* New(Arena* arena) const override;
250 
251  int GetCachedSize() const override;
252  void SetCachedSize(int size) const override;
253 
254  Metadata GetMetadata() const override;
255 
256 #if defined(__cpp_lib_destroying_delete) && defined(__cpp_sized_deallocation)
257  static void operator delete(DynamicMessage* msg, std::destroying_delete_t);
258 #else
259  // We actually allocate more memory than sizeof(*this) when this
260  // class's memory is allocated via the global operator new. Thus, we need to
261  // manually call the global operator delete. Calling the destructor is taken
262  // care of for us. This makes DynamicMessage compatible with -fsized-delete.
263  // It doesn't work for MSVC though.
264 #ifndef _MSC_VER
265  static void operator delete(void* ptr) { ::operator delete(ptr); }
266 #endif // !_MSC_VER
267 #endif
268 
269  private:
271  Arena* arena);
272 
273  void SharedCtor(bool lock_factory);
274 
275  // Needed to get the offset of the internal metadata member.
276  friend class DynamicMessageFactory;
277 
278  bool is_prototype() const;
279 
280  inline int OffsetValue(int v, FieldDescriptor::Type type) const {
282  return v & ~0x1u;
283  }
284  return v;
285  }
286 
287  inline void* OffsetToPointer(int offset) {
288  return reinterpret_cast<uint8_t*>(this) + offset;
289  }
290  inline const void* OffsetToPointer(int offset) const {
291  return reinterpret_cast<const uint8_t*>(this) + offset;
292  }
293 
294  void* MutableRaw(int i);
295  void* MutableExtensionsRaw();
296  void* MutableWeakFieldMapRaw();
297  void* MutableOneofCaseRaw(int i);
298  void* MutableOneofFieldRaw(const FieldDescriptor* f);
299 
301  mutable std::atomic<int> cached_byte_size_;
303 };
304 
306  int size;
310 
311  // Not owned by the TypeInfo.
312  DynamicMessageFactory* factory; // The factory that created this object.
313  const DescriptorPool* pool; // The factory's DescriptorPool.
314  const Descriptor* type; // Type of this DynamicMessage.
315 
316  // Warning: The order in which the following pointers are defined is
317  // important (the prototype must be deleted *before* the offsets).
318  std::unique_ptr<uint32_t[]> offsets;
319  std::unique_ptr<uint32_t[]> has_bits_indices;
320  std::unique_ptr<const Reflection> reflection;
321  // Don't use a unique_ptr to hold the prototype: the destructor for
322  // DynamicMessage needs to know whether it is the prototype, and does so by
323  // looking back at this field. This would assume details about the
324  // implementation of unique_ptr.
326  int weak_field_map_offset; // The offset for the weak_field_map;
327 
328  TypeInfo() : prototype(nullptr) {}
329 
330  ~TypeInfo() { delete prototype; }
331 };
332 
334  : type_info_(type_info), cached_byte_size_(0) {
335  SharedCtor(true);
336 }
337 
339  Arena* arena)
340  : Message(arena), type_info_(type_info), cached_byte_size_(0) {
341  SharedCtor(true);
342 }
343 
345  bool lock_factory)
346  : type_info_(type_info), cached_byte_size_(0) {
347  // The prototype in type_info has to be set before creating the prototype
348  // instance on memory. e.g., message Foo { map<int32_t, Foo> a = 1; }. When
349  // creating prototype for Foo, prototype of the map entry will also be
350  // created, which needs the address of the prototype of Foo (the value in
351  // map). To break the cyclic dependency, we have to assign the address of
352  // prototype into type_info first.
353  type_info->prototype = this;
354  SharedCtor(lock_factory);
355 }
356 
357 inline void* DynamicMessage::MutableRaw(int i) {
358  return OffsetToPointer(
360 }
363 }
366 }
369 }
371  return OffsetToPointer(
373  f->containing_oneof()->index()],
374  f->type()));
375 }
376 
377 void DynamicMessage::SharedCtor(bool lock_factory) {
378  // We need to call constructors for various fields manually and set
379  // default values where appropriate. We use placement new to call
380  // constructors. If you haven't heard of placement new, I suggest Googling
381  // it now. We use placement new even for primitive types that don't have
382  // constructors for consistency. (In theory, placement new should be used
383  // any time you are trying to convert untyped memory to typed memory, though
384  // in practice that's not strictly necessary for types that don't have a
385  // constructor.)
386 
388  // Initialize oneof cases.
389  int oneof_count = 0;
390  for (int i = 0; i < descriptor->oneof_decl_count(); ++i) {
391  if (descriptor->oneof_decl(i)->is_synthetic()) continue;
392  new (MutableOneofCaseRaw(oneof_count++)) uint32_t{0};
393  }
394 
395  if (type_info_->extensions_offset != -1) {
396  new (MutableExtensionsRaw()) ExtensionSet(GetArenaForAllocation());
397  }
398  for (int i = 0; i < descriptor->field_count(); i++) {
399  const FieldDescriptor* field = descriptor->field(i);
400  void* field_ptr = MutableRaw(i);
401  if (InRealOneof(field)) {
402  continue;
403  }
404  switch (field->cpp_type()) {
405 #define HANDLE_TYPE(CPPTYPE, TYPE) \
406  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
407  if (!field->is_repeated()) { \
408  new (field_ptr) TYPE(field->default_value_##TYPE()); \
409  } else { \
410  new (field_ptr) RepeatedField<TYPE>(GetArenaForAllocation()); \
411  } \
412  break;
413 
414  HANDLE_TYPE(INT32, int32_t);
415  HANDLE_TYPE(INT64, int64_t);
416  HANDLE_TYPE(UINT32, uint32_t);
417  HANDLE_TYPE(UINT64, uint64_t);
418  HANDLE_TYPE(DOUBLE, double);
419  HANDLE_TYPE(FLOAT, float);
420  HANDLE_TYPE(BOOL, bool);
421 #undef HANDLE_TYPE
422 
424  if (!field->is_repeated()) {
425  new (field_ptr) int{field->default_value_enum()->number()};
426  } else {
427  new (field_ptr) RepeatedField<int>(GetArenaForAllocation());
428  }
429  break;
430 
432  switch (field->options().ctype()) {
433  default: // TODO(kenton): Support other string reps.
435  if (!field->is_repeated()) {
436  const std::string* default_value =
437  field->default_value_string().empty()
439  : nullptr;
440  ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr();
441  asp->UnsafeSetDefault(default_value);
442  } else {
443  new (field_ptr)
444  RepeatedPtrField<std::string>(GetArenaForAllocation());
445  }
446  break;
447  }
448  break;
449 
451  if (!field->is_repeated()) {
452  new (field_ptr) Message*(nullptr);
453  } else {
454  if (IsMapFieldInApi(field)) {
455  // We need to lock in most cases to avoid data racing. Only not lock
456  // when the constructor is called inside GetPrototype(), in which
457  // case we have already locked the factory.
458  if (lock_factory) {
459  if (GetArenaForAllocation() != nullptr) {
460  new (field_ptr) DynamicMapField(
461  type_info_->factory->GetPrototype(field->message_type()),
463  if (GetOwningArena() != nullptr) {
464  // Needs to destroy the mutex member.
465  GetOwningArena()->OwnDestructor(
466  static_cast<DynamicMapField*>(field_ptr));
467  }
468  } else {
469  new (field_ptr) DynamicMapField(
470  type_info_->factory->GetPrototype(field->message_type()));
471  }
472  } else {
473  if (GetArenaForAllocation() != nullptr) {
474  new (field_ptr)
475  DynamicMapField(type_info_->factory->GetPrototypeNoLock(
476  field->message_type()),
478  if (GetOwningArena() != nullptr) {
479  // Needs to destroy the mutex member.
480  GetOwningArena()->OwnDestructor(
481  static_cast<DynamicMapField*>(field_ptr));
482  }
483  } else {
484  new (field_ptr)
485  DynamicMapField(type_info_->factory->GetPrototypeNoLock(
486  field->message_type()));
487  }
488  }
489  } else {
490  new (field_ptr) RepeatedPtrField<Message>(GetArenaForAllocation());
491  }
492  }
493  break;
494  }
495  }
496  }
497 }
498 
499 bool DynamicMessage::is_prototype() const {
500  return type_info_->prototype == this ||
501  // If type_info_->prototype is nullptr, then we must be constructing
502  // the prototype now, which means we must be the prototype.
503  type_info_->prototype == nullptr;
504 }
505 
506 #if defined(__cpp_lib_destroying_delete) && defined(__cpp_sized_deallocation)
507 void DynamicMessage::operator delete(DynamicMessage* msg,
508  std::destroying_delete_t) {
509  const size_t size = msg->type_info_->size;
510  msg->~DynamicMessage();
511  ::operator delete(msg, size);
512 }
513 #endif
514 
517 
519 
520  if (type_info_->extensions_offset != -1) {
521  reinterpret_cast<ExtensionSet*>(MutableExtensionsRaw())->~ExtensionSet();
522  }
523 
524  // We need to manually run the destructors for repeated fields and strings,
525  // just as we ran their constructors in the DynamicMessage constructor.
526  // We also need to manually delete oneof fields if it is set and is string
527  // or message.
528  // Additionally, if any singular embedded messages have been allocated, we
529  // need to delete them, UNLESS we are the prototype message of this type,
530  // in which case any embedded messages are other prototypes and shouldn't
531  // be touched.
532  for (int i = 0; i < descriptor->field_count(); i++) {
533  const FieldDescriptor* field = descriptor->field(i);
534  if (InRealOneof(field)) {
535  void* field_ptr = MutableOneofCaseRaw(field->containing_oneof()->index());
536  if (*(reinterpret_cast<const int32_t*>(field_ptr)) == field->number()) {
537  field_ptr = MutableOneofFieldRaw(field);
538  if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
539  switch (field->options().ctype()) {
540  default:
541  case FieldOptions::STRING: {
542  // Oneof string fields are never set as a default instance.
543  // We just need to pass some arbitrary default string to make it
544  // work. This allows us to not have the real default accessible
545  // from reflection.
546  const std::string* default_value = nullptr;
547  reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(
548  default_value, nullptr);
549  break;
550  }
551  }
552  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
553  delete *reinterpret_cast<Message**>(field_ptr);
554  }
555  }
556  continue;
557  }
558  void* field_ptr = MutableRaw(i);
559 
560  if (field->is_repeated()) {
561  switch (field->cpp_type()) {
562 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
563  case FieldDescriptor::CPPTYPE_##UPPERCASE: \
564  reinterpret_cast<RepeatedField<LOWERCASE>*>(field_ptr) \
565  ->~RepeatedField<LOWERCASE>(); \
566  break
567 
568  HANDLE_TYPE(INT32, int32_t);
569  HANDLE_TYPE(INT64, int64_t);
570  HANDLE_TYPE(UINT32, uint32_t);
571  HANDLE_TYPE(UINT64, uint64_t);
572  HANDLE_TYPE(DOUBLE, double);
573  HANDLE_TYPE(FLOAT, float);
574  HANDLE_TYPE(BOOL, bool);
575  HANDLE_TYPE(ENUM, int);
576 #undef HANDLE_TYPE
577 
579  switch (field->options().ctype()) {
580  default: // TODO(kenton): Support other string reps.
582  reinterpret_cast<RepeatedPtrField<std::string>*>(field_ptr)
583  ->~RepeatedPtrField<std::string>();
584  break;
585  }
586  break;
587 
589  if (IsMapFieldInApi(field)) {
590  reinterpret_cast<DynamicMapField*>(field_ptr)->~DynamicMapField();
591  } else {
592  reinterpret_cast<RepeatedPtrField<Message>*>(field_ptr)
593  ->~RepeatedPtrField<Message>();
594  }
595  break;
596  }
597 
598  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
599  switch (field->options().ctype()) {
600  default: // TODO(kenton): Support other string reps.
601  case FieldOptions::STRING: {
602  const std::string* default_value =
603  reinterpret_cast<const ArenaStringPtr*>(
605  type_info_->offsets[i]))
606  ->GetPointer();
607  reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(default_value,
608  nullptr);
609  break;
610  }
611  }
612  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
613  if (!is_prototype()) {
614  Message* message = *reinterpret_cast<Message**>(field_ptr);
615  if (message != nullptr) {
616  delete message;
617  }
618  }
619  }
620  }
621 }
622 
624  // This should only be called on the prototype message.
626 
629 
630  // Cross-link default messages.
631  for (int i = 0; i < descriptor->field_count(); i++) {
632  const FieldDescriptor* field = descriptor->field(i);
633  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
634  !field->options().weak() && !InRealOneof(field) &&
635  !field->is_repeated()) {
636  void* field_ptr = MutableRaw(i);
637  // For fields with message types, we need to cross-link with the
638  // prototype for the field's type.
639  // For singular fields, the field is just a pointer which should
640  // point to the prototype.
641  *reinterpret_cast<const Message**>(field_ptr) =
642  factory->GetPrototypeNoLock(field->message_type());
643  }
644  }
645 }
646 
648  if (arena != nullptr) {
649  void* new_base = Arena::CreateArray<char>(arena, type_info_->size);
650  memset(new_base, 0, type_info_->size);
651  return new (new_base) DynamicMessage(type_info_, arena);
652  } else {
653  void* new_base = operator new(type_info_->size);
654  memset(new_base, 0, type_info_->size);
655  return new (new_base) DynamicMessage(type_info_);
656  }
657 }
658 
659 int DynamicMessage::GetCachedSize() const {
660  return cached_byte_size_.load(std::memory_order_relaxed);
661 }
662 
663 void DynamicMessage::SetCachedSize(int size) const {
664  cached_byte_size_.store(size, std::memory_order_relaxed);
665 }
666 
669  metadata.descriptor = type_info_->type;
670  metadata.reflection = type_info_->reflection.get();
671  return metadata;
672 }
673 
674 // ===================================================================
675 
677  : pool_(nullptr), delegate_to_generated_factory_(false) {}
678 
680  : pool_(pool), delegate_to_generated_factory_(false) {}
681 
683  for (auto iter = prototypes_.begin(); iter != prototypes_.end(); ++iter) {
684  delete iter->second;
685  }
686 }
687 
690  return GetPrototypeNoLock(type);
691 }
692 
694  const Descriptor* type) {
696  type->file()->pool() == DescriptorPool::generated_pool()) {
698  }
699 
700  const TypeInfo** target = &prototypes_[type];
701  if (*target != nullptr) {
702  // Already exists.
703  return (*target)->prototype;
704  }
705 
706  TypeInfo* type_info = new TypeInfo;
707  *target = type_info;
708 
709  type_info->type = type;
710  type_info->pool = (pool_ == nullptr) ? type->file()->pool() : pool_;
711  type_info->factory = this;
712 
713  // We need to construct all the structures passed to Reflection's constructor.
714  // This includes:
715  // - A block of memory that contains space for all the message's fields.
716  // - An array of integers indicating the byte offset of each field within
717  // this block.
718  // - A big bitfield containing a bit for each field indicating whether
719  // or not that field is set.
720  int real_oneof_count = 0;
721  for (int i = 0; i < type->oneof_decl_count(); i++) {
722  if (!type->oneof_decl(i)->is_synthetic()) {
723  real_oneof_count++;
724  }
725  }
726 
727  // Compute size and offsets.
728  uint32_t* offsets = new uint32_t[type->field_count() + real_oneof_count];
729  type_info->offsets.reset(offsets);
730 
731  // Decide all field offsets by packing in order.
732  // We place the DynamicMessage object itself at the beginning of the allocated
733  // space.
734  int size = sizeof(DynamicMessage);
735  size = AlignOffset(size);
736 
737  // Next the has_bits, which is an array of uint32s.
738  type_info->has_bits_offset = -1;
739  int max_hasbit = 0;
740  for (int i = 0; i < type->field_count(); i++) {
741  if (HasHasbit(type->field(i))) {
742  if (type_info->has_bits_offset == -1) {
743  // At least one field in the message requires a hasbit, so allocate
744  // hasbits.
745  type_info->has_bits_offset = size;
746  uint32_t* has_bits_indices = new uint32_t[type->field_count()];
747  for (int j = 0; j < type->field_count(); j++) {
748  // Initialize to -1, fields that need a hasbit will overwrite.
749  has_bits_indices[j] = static_cast<uint32_t>(-1);
750  }
751  type_info->has_bits_indices.reset(has_bits_indices);
752  }
753  type_info->has_bits_indices[i] = max_hasbit++;
754  }
755  }
756 
757  if (max_hasbit > 0) {
758  int has_bits_array_size = DivideRoundingUp(max_hasbit, bitsizeof(uint32_t));
759  size += has_bits_array_size * sizeof(uint32_t);
760  size = AlignOffset(size);
761  }
762 
763  // The oneof_case, if any. It is an array of uint32s.
764  if (real_oneof_count > 0) {
765  type_info->oneof_case_offset = size;
766  size += real_oneof_count * sizeof(uint32_t);
767  size = AlignOffset(size);
768  }
769 
770  // The ExtensionSet, if any.
771  if (type->extension_range_count() > 0) {
772  type_info->extensions_offset = size;
773  size += sizeof(ExtensionSet);
774  size = AlignOffset(size);
775  } else {
776  // No extensions.
777  type_info->extensions_offset = -1;
778  }
779 
780  // All the fields.
781  //
782  // TODO(b/31226269): Optimize the order of fields to minimize padding.
783  for (int i = 0; i < type->field_count(); i++) {
784  // Make sure field is aligned to avoid bus errors.
785  // Oneof fields do not use any space.
786  if (!InRealOneof(type->field(i))) {
787  int field_size = FieldSpaceUsed(type->field(i));
788  size = AlignTo(size, std::min(kSafeAlignment, field_size));
789  offsets[i] = size;
790  size += field_size;
791  }
792  }
793 
794  // The oneofs.
795  for (int i = 0; i < type->oneof_decl_count(); i++) {
796  if (!type->oneof_decl(i)->is_synthetic()) {
797  size = AlignTo(size, kSafeAlignment);
798  offsets[type->field_count() + i] = size;
799  size += kMaxOneofUnionSize;
800  }
801  }
802 
803  type_info->weak_field_map_offset = -1;
804 
805  // Align the final size to make sure no clever allocators think that
806  // alignment is not necessary.
807  type_info->size = size;
808 
809  // Construct the reflection object.
810 
811  // Compute the size of default oneof instance and offsets of default
812  // oneof fields.
813  for (int i = 0; i < type->oneof_decl_count(); i++) {
814  if (type->oneof_decl(i)->is_synthetic()) continue;
815  for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {
816  const FieldDescriptor* field = type->oneof_decl(i)->field(j);
817  // oneof fields are not accessed through offsets, but we still have the
818  // entry from a legacy implementation. This should be removed at some
819  // point.
820  // Mark the field to prevent unintentional access through reflection.
821  // Don't use the top bit because that is for unused fields.
822  offsets[field->index()] = internal::kInvalidFieldOffsetTag;
823  }
824  }
825 
826  // Allocate the prototype fields.
827  void* base = operator new(size);
828  memset(base, 0, size);
829 
830  // We have already locked the factory so we should not lock in the constructor
831  // of dynamic message to avoid dead lock.
832  DynamicMessage* prototype = new (base) DynamicMessage(type_info, false);
833 
834  internal::ReflectionSchema schema = {
835  type_info->prototype,
836  type_info->offsets.get(),
837  type_info->has_bits_indices.get(),
838  type_info->has_bits_offset,
839  PROTOBUF_FIELD_OFFSET(DynamicMessage, _internal_metadata_),
840  type_info->extensions_offset,
841  type_info->oneof_case_offset,
842  type_info->size,
843  type_info->weak_field_map_offset,
844  nullptr /* inlined_string_indices_ */,
845  0 /* inlined_string_donated_offset_ */};
846 
847  type_info->reflection.reset(
848  new Reflection(type_info->type, schema, type_info->pool, this));
849 
850  // Cross link prototypes.
851  prototype->CrossLinkPrototypes();
852 
853  return prototype;
854 }
855 
856 } // namespace protobuf
857 } // namespace google
858 
859 #include <google/protobuf/port_undef.inc> // NOLINT
google::protobuf::DynamicMessage::MutableRaw
void * MutableRaw(int i)
Definition: protobuf/src/google/protobuf/dynamic_message.cc:357
google::protobuf::FieldDescriptor::Type
Type
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:521
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
google::protobuf::DynamicMessage::TypeInfo::reflection
std::unique_ptr< const Reflection > reflection
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:250
google::protobuf::DynamicMessageFactory::TypeInfo::prototype
const DynamicMessage * prototype
Definition: protobuf/src/google/protobuf/dynamic_message.cc:325
google::protobuf::DynamicMessageFactory::prototypes_mutex_
internal::WrappedMutex prototypes_mutex_
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.h:137
google::protobuf::FieldDescriptor::options
const FieldOptions & options() const
google::protobuf::DynamicMessageFactory::TypeInfo::TypeInfo
TypeInfo()
Definition: protobuf/src/google/protobuf/dynamic_message.cc:328
google::protobuf::DynamicMessageFactory::TypeInfo::pool
const DescriptorPool * pool
Definition: protobuf/src/google/protobuf/dynamic_message.cc:313
google::protobuf::DynamicMessage::MutableOneofFieldRaw
void * MutableOneofFieldRaw(const FieldDescriptor *f)
Definition: protobuf/src/google/protobuf/dynamic_message.cc:370
google::protobuf::FieldDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:515
absl::str_format_internal::LengthMod::j
@ j
google::protobuf::DynamicMessageFactory::delegate_to_generated_factory_
bool delegate_to_generated_factory_
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.h:128
google::protobuf::DynamicMessageFactory::GetPrototypeNoLock
const Message * GetPrototypeNoLock(const Descriptor *type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:658
MutexLock
#define MutexLock(x)
Definition: bloaty/third_party/re2/util/mutex.h:125
google::protobuf::DynamicMessageReflectionHelper
Definition: protobuf/src/google/protobuf/dynamic_message.cc:103
bool
bool
Definition: setup_once.h:312
metadata
Definition: cq_verifier.cc:48
google::protobuf::OneofDescriptor::is_synthetic
bool is_synthetic() const
memset
return memset(p, 0, total)
google::protobuf::FieldDescriptor::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:562
google::protobuf::compiler::cpp::HasHasbit
bool HasHasbit(const FieldDescriptor *field)
Definition: protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h:443
google::protobuf::DynamicMessage::TypeInfo::offsets
std::unique_ptr< uint32[]> offsets
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:248
bitsizeof
#define bitsizeof(T)
Definition: protobuf/src/google/protobuf/dynamic_message.cc:222
google::protobuf::FieldDescriptor::label
Label label() const
google::protobuf.internal::InternalMetadata::Delete
void Delete()
Definition: protobuf/src/google/protobuf/metadata_lite.h:79
false
#define false
Definition: setup_once.h:323
google::protobuf::FieldDescriptor::has_optional_keyword
bool has_optional_keyword() const
Arena
Definition: arena.c:39
metadata
struct metadata metadata
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf::MessageFactory::generated_factory
static MessageFactory * generated_factory()
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.cc:645
TypeInfo
Definition: protobuf/php/ext/google/protobuf/def.h:69
u
OPENSSL_EXPORT pem_password_cb void * u
Definition: pem.h:351
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf::MessageFactory::GetPrototype
virtual const Message * GetPrototype(const Descriptor *type)=0
pool_
DescriptorPool pool_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:181
google::protobuf::DynamicMessageFactory::TypeInfo::offsets
std::unique_ptr< uint32_t[]> offsets
Definition: protobuf/src/google/protobuf/dynamic_message.cc:318
google::protobuf::Reflection::IsLazyField
bool IsLazyField(const FieldDescriptor *field) const
Definition: protobuf/src/google/protobuf/message.h:1011
google::protobuf::DynamicMessage::GetMetadata
Metadata GetMetadata() const override
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:619
google::protobuf::DynamicMessage::~DynamicMessage
~DynamicMessage()
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:458
google::protobuf::DynamicMessageFactory::TypeInfo::~TypeInfo
~TypeInfo()
Definition: protobuf/src/google/protobuf/dynamic_message.cc:330
google::protobuf::Reflection
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:397
google::protobuf::DynamicMessage::MutableOneofCaseRaw
void * MutableOneofCaseRaw(int i)
Definition: protobuf/src/google/protobuf/dynamic_message.cc:367
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf::HANDLE_TYPE
HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1)
google::protobuf::python::cmessage::UnknownFieldSet
static PyObject * UnknownFieldSet(CMessage *self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:2512
google::protobuf::DynamicMessage::TypeInfo::oneof_case_offset
int oneof_case_offset
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:237
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
BOOL
int BOOL
Definition: undname.c:46
Descriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:121
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
google::protobuf::DynamicMessage::MutableWeakFieldMapRaw
void * MutableWeakFieldMapRaw()
Definition: protobuf/src/google/protobuf/dynamic_message.cc:364
google::protobuf::DynamicMessageFactory::TypeInfo
Definition: protobuf/src/google/protobuf/dynamic_message.cc:305
google::protobuf::DynamicMessage::type_info_
const TypeInfo * type_info_
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:312
google::protobuf::DynamicMessageFactory::TypeInfo::size
int size
Definition: protobuf/src/google/protobuf/dynamic_message.cc:306
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf.internal::AlignTo
PROTOBUF_ALWAYS_INLINE void * AlignTo(void *ptr, size_t align)
Definition: third_party/protobuf/src/google/protobuf/arena.h:95
google::protobuf::FieldDescriptor::is_required
bool is_required() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2059
FieldDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:133
google::protobuf::DynamicMessage::New
Message * New() const override
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:597
google::protobuf::Descriptor::field
const FieldDescriptor * field(int index) const
google::protobuf::DynamicMessage::MutableExtensionsRaw
void * MutableExtensionsRaw()
Definition: protobuf/src/google/protobuf/dynamic_message.cc:361
google::protobuf::DynamicMessageFactory::TypeInfo::weak_field_map_offset
int weak_field_map_offset
Definition: protobuf/src/google/protobuf/dynamic_message.cc:326
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
google::protobuf::DynamicMessage::TypeInfo::extensions_offset
int extensions_offset
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:239
google::protobuf::DynamicMessageFactory::TypeInfo::oneof_case_offset
int oneof_case_offset
Definition: protobuf/src/google/protobuf/dynamic_message.cc:308
xds_interop_client.int
int
Definition: xds_interop_client.py:113
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
google::protobuf::FieldDescriptor::containing_oneof
const OneofDescriptor * containing_oneof
Definition: protobuf/src/google/protobuf/descriptor.h:932
google::protobuf::DynamicMessage::OffsetToPointer
void * OffsetToPointer(int offset)
Definition: protobuf/src/google/protobuf/dynamic_message.cc:287
google::protobuf::DynamicMessage::OffsetToPointer
const void * OffsetToPointer(int offset) const
Definition: protobuf/src/google/protobuf/dynamic_message.cc:290
google::protobuf::DynamicMessageFactory::pool_
const DescriptorPool * pool_
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.h:127
google::protobuf.internal::GetEmptyStringAlreadyInited
const PROTOBUF_EXPORT std::string & GetEmptyStringAlreadyInited()
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:153
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf::DescriptorPool
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1539
google::protobuf::DynamicMessageFactory::TypeInfo::reflection
std::unique_ptr< const Reflection > reflection
Definition: protobuf/src/google/protobuf/dynamic_message.cc:320
google::protobuf::DynamicMessageFactory::TypeInfo::factory
DynamicMessageFactory * factory
Definition: protobuf/src/google/protobuf/dynamic_message.cc:312
gen_synthetic_protos.base
base
Definition: gen_synthetic_protos.py:31
google::protobuf::DynamicMessage::TypeInfo::weak_field_map_offset
int weak_field_map_offset
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:256
google::protobuf::DynamicMessage::GetCachedSize
int GetCachedSize() const override
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:611
min
#define min(a, b)
Definition: qsort.h:83
google::protobuf::Descriptor::field_count
int field_count() const
google::protobuf::DynamicMessage::type_info_
const DynamicMessageFactory::TypeInfo * type_info_
Definition: protobuf/src/google/protobuf/dynamic_message.cc:300
google::protobuf::DynamicMessage
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:232
google::protobuf::MessageLite::GetOwningArena
Arena * GetOwningArena() const
Definition: protobuf/src/google/protobuf/message_lite.h:439
google::protobuf.internal::kInvalidFieldOffsetTag
@ kInvalidFieldOffsetTag
Definition: protobuf/src/google/protobuf/generated_message_reflection.h:327
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
FieldOptions::STRING
static constexpr CType STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:4721
absl::memory_internal::GetPointer
typename T::pointer GetPointer
Definition: third_party/abseil-cpp/absl/memory/memory.h:270
google::protobuf::DynamicMessage::cached_byte_size_
std::atomic< int > cached_byte_size_
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:314
google::protobuf::DynamicMessageFactory::TypeInfo::has_bits_offset
int has_bits_offset
Definition: protobuf/src/google/protobuf/dynamic_message.cc:307
google::protobuf::DynamicMessageFactory
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.h:80
google::protobuf::DynamicMessage::OffsetValue
int OffsetValue(int v, FieldDescriptor::Type type) const
Definition: protobuf/src/google/protobuf/dynamic_message.cc:280
google::protobuf::DynamicMessage::SharedCtor
void SharedCtor(bool lock_factory)
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:340
alignment
static const std::size_t alignment
Definition: cxa_demangle.cpp:4721
google::protobuf::Message
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:205
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
phony_transport::Destroy
void Destroy(grpc_transport *)
Definition: bm_call_create.cc:443
google::protobuf::MessageLite::GetArenaForAllocation
Arena * GetArenaForAllocation() const
Definition: protobuf/src/google/protobuf/message_lite.h:443
google::protobuf::FieldDescriptor::type
Type type() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2052
google::protobuf::DynamicMessage::is_prototype
bool is_prototype() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:298
google::protobuf::DynamicMessage::DynamicMessageFactory
friend class DynamicMessageFactory
Definition: protobuf/src/google/protobuf/dynamic_message.cc:276
google::protobuf::DynamicMessageFactory::~DynamicMessageFactory
~DynamicMessageFactory()
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:644
google::protobuf::DynamicMessageFactory::TypeInfo::extensions_offset
int extensions_offset
Definition: protobuf/src/google/protobuf/dynamic_message.cc:309
google::protobuf::FieldDescriptor::CPPTYPE_ENUM
@ CPPTYPE_ENUM
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:561
google::protobuf::DescriptorPool::generated_pool
static const DescriptorPool * generated_pool()
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.cc:1326
FieldOptions::ctype
PROTOBUF_NAMESPACE_ID::FieldOptions_CType ctype() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:12216
google::protobuf::DynamicMessageFactory::TypeInfo::type
const Descriptor * type
Definition: protobuf/src/google/protobuf/dynamic_message.cc:314
google::protobuf::MessageLite::_internal_metadata_
internal::InternalMetadata _internal_metadata_
Definition: protobuf/src/google/protobuf/message_lite.h:445
GOOGLE_CHECK
#define GOOGLE_CHECK(EXPRESSION)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:153
google::protobuf::Descriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:231
google::protobuf::FieldDescriptor::TYPE_MESSAGE
@ TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:536
google::protobuf::DynamicMessage::CrossLinkPrototypes
void CrossLinkPrototypes()
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:574
google::protobuf::DynamicMessage::TypeInfo::type
const Descriptor * type
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:244
pool
InternalDescriptorPool * pool
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:807
google::protobuf::DynamicMessage::TypeInfo::prototype
const DynamicMessage * prototype
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:255
google::protobuf::DynamicMessage::SetCachedSize
void SetCachedSize(int size) const override
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:615
google::protobuf::DynamicMessageFactory::DynamicMessage
friend class DynamicMessage
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.h:139
iter
Definition: test_winkernel.cpp:47
google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE
@ CPPTYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:563
TypeInfo::type
upb_fieldtype_t type
Definition: protobuf/php/ext/google/protobuf/def.h:70
grpc_binder::Metadata
std::vector< std::pair< std::string, std::string > > Metadata
Definition: transaction.h:38
google::protobuf::DynamicMessageFactory::prototypes_
std::unique_ptr< PrototypeMap > prototypes_
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.h:135
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
google::protobuf::DynamicMessageReflectionHelper::IsLazyField
static bool IsLazyField(const Reflection *reflection, const FieldDescriptor *field)
Definition: protobuf/src/google/protobuf/dynamic_message.cc:105
google::protobuf::DynamicMessage::DynamicMessage
DynamicMessage(const TypeInfo *type_info)
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:318
google::protobuf::DynamicMessageFactory::DynamicMessageFactory
DynamicMessageFactory()
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:634
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
FieldOptions::weak
bool weak() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:12358
google::protobuf::DynamicMessageFactory::TypeInfo::has_bits_indices
std::unique_ptr< uint32_t[]> has_bits_indices
Definition: protobuf/src/google/protobuf/dynamic_message.cc:319
google::protobuf::DynamicMessage::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage)
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
google::protobuf::DynamicMessage::TypeInfo::size
int size
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:235
DescriptorPool
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:110
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:146
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
google::protobuf::FieldDescriptor::cpp_type
CppType cpp_type() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2139
google::protobuf::DynamicMessage::TypeInfo::factory
DynamicMessageFactory * factory
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:242
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
google::protobuf::DynamicMessageFactory::GetPrototype
const Message * GetPrototype(const Descriptor *type) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/dynamic_message.cc:653
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
offset
voidpf uLong offset
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:142
google::protobuf::FieldDescriptor::is_map
bool is_map() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2075
RepeatedField
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:403


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:18