third_party/protobuf/src/google/protobuf/arena.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 #include <google/protobuf/arena.h>
32 
33 #include <algorithm>
34 #include <atomic>
35 #include <cstddef>
36 #include <cstdint>
37 #include <limits>
38 #include <typeinfo>
39 
40 #include <google/protobuf/arena_impl.h>
41 
42 #include <google/protobuf/stubs/mutex.h>
43 #ifdef ADDRESS_SANITIZER
44 #include <sanitizer/asan_interface.h>
45 #endif // ADDRESS_SANITIZER
46 
47 #include <google/protobuf/port_def.inc>
48 
49 namespace google {
50 namespace protobuf {
51 namespace internal {
52 
54  size_t last_size, size_t min_bytes) {
55  AllocationPolicy policy; // default policy
56  if (policy_ptr) policy = *policy_ptr;
57  size_t size;
58  if (last_size != 0) {
59  // Double the current block size, up to a limit.
60  auto max_size = policy.max_block_size;
61  size = std::min(2 * last_size, max_size);
62  } else {
63  size = policy.start_block_size;
64  }
65  // Verify that min_bytes + kBlockHeaderSize won't overflow.
66  GOOGLE_CHECK_LE(min_bytes,
69 
70  void* mem;
71  if (policy.block_alloc == nullptr) {
72  mem = ::operator new(size);
73  } else {
74  mem = policy.block_alloc(size);
75  }
76  return {mem, size};
77 }
78 
80  public:
81  GetDeallocator(const AllocationPolicy* policy, size_t* space_allocated)
82  : dealloc_(policy ? policy->block_dealloc : nullptr),
83  space_allocated_(space_allocated) {}
84 
86 #ifdef ADDRESS_SANITIZER
87  // This memory was provided by the underlying allocator as unpoisoned,
88  // so return it in an unpoisoned state.
89  ASAN_UNPOISON_MEMORY_REGION(mem.ptr, mem.size);
90 #endif // ADDRESS_SANITIZER
91  if (dealloc_) {
92  dealloc_(mem.ptr, mem.size);
93  } else {
94 #if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
95  ::operator delete(mem.ptr, mem.size);
96 #else
97  ::operator delete(mem.ptr);
98 #endif
99  }
100  *space_allocated_ += mem.size;
101  }
102 
103  private:
104  void (*dealloc_)(void*, size_t);
106 };
107 
108 SerialArena::SerialArena(Block* b, void* owner) : space_allocated_(b->size) {
109  owner_ = owner;
110  head_ = b;
112  limit_ = b->Pointer(b->size & static_cast<size_t>(-8));
113 }
114 
117 
118  auto b = new (mem.ptr) Block{nullptr, mem.size};
119  return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, owner);
120 }
121 
122 template <typename Deallocator>
123 SerialArena::Memory SerialArena::Free(Deallocator deallocator) {
124  Block* b = head_;
125  Memory mem = {b, b->size};
126  while (b->next) {
127  b = b->next; // We must first advance before deleting this block
128  deallocator(mem);
129  mem = {b, b->size};
130  }
131  return mem;
132 }
133 
134 PROTOBUF_NOINLINE
135 std::pair<void*, SerialArena::CleanupNode*>
137  size_t n, const AllocationPolicy* policy) {
138  AllocateNewBlock(n + kCleanupSize, policy);
140 }
141 
142 PROTOBUF_NOINLINE
144  const AllocationPolicy* policy) {
145  AllocateNewBlock(n, policy);
146  return AllocateFromExisting(n);
147 }
148 
149 void SerialArena::AllocateNewBlock(size_t n, const AllocationPolicy* policy) {
150  // Sync limit to block
151  head_->start = reinterpret_cast<CleanupNode*>(limit_);
152 
153  // Record how much used in this block.
155 
156  auto mem = AllocateMemory(policy, head_->size, n);
157  // We don't want to emit an expensive RMW instruction that requires
158  // exclusive access to a cacheline. Hence we write it in terms of a
159  // regular add.
160  auto relaxed = std::memory_order_relaxed;
161  space_allocated_.store(space_allocated_.load(relaxed) + mem.size, relaxed);
162  head_ = new (mem.ptr) Block{head_, mem.size};
165 
166 #ifdef ADDRESS_SANITIZER
167  ASAN_POISON_MEMORY_REGION(ptr_, limit_ - ptr_);
168 #endif // ADDRESS_SANITIZER
169 }
170 
172  uint64_t space_used = ptr_ - head_->Pointer(kBlockHeaderSize);
173  space_used += space_used_;
174  // Remove the overhead of the SerialArena itself.
175  space_used -= ThreadSafeArena::kSerialArenaSize;
176  return space_used;
177 }
178 
180  Block* b = head_;
181  b->start = reinterpret_cast<CleanupNode*>(limit_);
182  do {
183  auto* limit = reinterpret_cast<CleanupNode*>(
184  b->Pointer(b->size & static_cast<size_t>(-8)));
185  auto it = b->start;
186  auto num = limit - it;
187  if (num > 0) {
188  for (; it < limit; it++) {
189  it->cleanup(it->elem);
190  }
191  }
192  b = b->next;
193  } while (b);
194 }
195 
196 
199 #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
201  static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ =
202  new internal::ThreadLocalStorage<ThreadCache>();
203  return *thread_cache_->Get();
204 }
205 #elif defined(PROTOBUF_USE_DLLS)
206 ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
207  static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_ = {
208  0, static_cast<LifecycleIdAtomic>(-1), nullptr};
209  return thread_cache_;
210 }
211 #else
212 PROTOBUF_THREAD_LOCAL ThreadSafeArena::ThreadCache
213  ThreadSafeArena::thread_cache_ = {0, static_cast<LifecycleIdAtomic>(-1),
214  nullptr};
215 #endif
216 
218  GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(mem) & 7, 0u);
219  GOOGLE_DCHECK(!AllocPolicy()); // Reset should call InitializeWithPolicy instead.
220  Init();
221 
222  // Ignore initial block if it is too small.
223  if (mem != nullptr && size >= kBlockHeaderSize + kSerialArenaSize) {
226  }
227 }
228 
230  AllocationPolicy policy) {
231 #ifndef NDEBUG
232  const uint64_t old_alloc_policy = alloc_policy_.get_raw();
233  // If there was a policy (e.g., in Reset()), make sure flags were preserved.
234 #define GOOGLE_DCHECK_POLICY_FLAGS_() \
235  if (old_alloc_policy > 3) \
236  GOOGLE_CHECK_EQ(old_alloc_policy & 3, alloc_policy_.get_raw() & 3)
237 #else
238 #define GOOGLE_DCHECK_POLICY_FLAGS_()
239 #endif // NDEBUG
240 
241  if (policy.IsDefault()) {
242  // Legacy code doesn't use the API above, but provides the initial block
243  // through ArenaOptions. I suspect most do not touch the allocation
244  // policy parameters.
247  return;
248  }
249  GOOGLE_DCHECK_EQ(reinterpret_cast<uintptr_t>(mem) & 7, 0u);
250  Init();
251 
252  // Ignore initial block if it is too small. We include an optional
253  // AllocationPolicy in this check, so that this can be allocated on the
254  // first block.
255  constexpr size_t kAPSize = internal::AlignUpTo8(sizeof(AllocationPolicy));
256  constexpr size_t kMinimumSize = kBlockHeaderSize + kSerialArenaSize + kAPSize;
257 
258  // The value for alloc_policy_ stores whether or not allocations should be
259  // recorded.
261  policy.metrics_collector != nullptr &&
262  policy.metrics_collector->RecordAllocs());
263  // Make sure we have an initial block to store the AllocationPolicy.
264  if (mem != nullptr && size >= kMinimumSize) {
266  } else {
267  auto tmp = AllocateMemory(&policy, 0, kMinimumSize);
268  mem = tmp.ptr;
269  size = tmp.size;
270  }
272 
273  auto sa = threads_.load(std::memory_order_relaxed);
274  // We ensured enough space so this cannot fail.
275  void* p;
276  if (!sa || !sa->MaybeAllocateAligned(kAPSize, &p)) {
277  GOOGLE_LOG(FATAL) << "MaybeAllocateAligned cannot fail here.";
278  return;
279  }
280  new (p) AllocationPolicy{policy};
281  // Low bits store flags, so they mustn't be overwritten.
282  GOOGLE_DCHECK_EQ(0, reinterpret_cast<uintptr_t>(p) & 3);
283  alloc_policy_.set_policy(reinterpret_cast<AllocationPolicy*>(p));
285 
286 #undef GOOGLE_DCHECK_POLICY_FLAGS_
287 }
288 
290 #ifndef NDEBUG
291  const bool was_message_owned = IsMessageOwned();
292 #endif // NDEBUG
293  ThreadCache& tc = thread_cache();
294  auto id = tc.next_lifecycle_id;
295  // We increment lifecycle_id's by multiples of two so we can use bit 0 as
296  // a tag.
297  constexpr uint64_t kDelta = 2;
298  constexpr uint64_t kInc = ThreadCache::kPerThreadIds * kDelta;
299  if (PROTOBUF_PREDICT_FALSE((id & (kInc - 1)) == 0)) {
300  constexpr auto relaxed = std::memory_order_relaxed;
301  // On platforms that don't support uint64_t atomics we can certainly not
302  // afford to increment by large intervals and expect uniqueness due to
303  // wrapping, hence we only add by 1.
304  id = lifecycle_id_generator_.id.fetch_add(1, relaxed) * kInc;
305  }
306  tc.next_lifecycle_id = id + kDelta;
307  // Message ownership is stored in tag_and_id_, and is set in the constructor.
308  // This flag bit must be preserved, even across calls to Reset().
310  hint_.store(nullptr, std::memory_order_relaxed);
311  threads_.store(nullptr, std::memory_order_relaxed);
312 #ifndef NDEBUG
313  GOOGLE_CHECK_EQ(was_message_owned, IsMessageOwned());
314 #endif // NDEBUG
315 }
316 
319  serial->set_next(NULL);
320  threads_.store(serial, std::memory_order_relaxed);
321  CacheSerialArena(serial);
322 }
323 
325  // Have to do this in a first pass, because some of the destructors might
326  // refer to memory in other blocks.
327  CleanupList();
328 
329  size_t space_allocated = 0;
330  auto mem = Free(&space_allocated);
331 
332  // Policy is about to get deleted.
333  auto* p = alloc_policy_.get();
334  ArenaMetricsCollector* collector = p ? p->metrics_collector : nullptr;
335 
337  space_allocated += mem.size;
338  } else {
339  GetDeallocator(alloc_policy_.get(), &space_allocated)(mem);
340  }
341 
342  if (collector) collector->OnDestroy(space_allocated);
343 }
344 
345 SerialArena::Memory ThreadSafeArena::Free(size_t* space_allocated) {
346  SerialArena::Memory mem = {nullptr, 0};
347  auto deallocator = GetDeallocator(alloc_policy_.get(), space_allocated);
348  PerSerialArena([deallocator, &mem](SerialArena* a) {
349  if (mem.ptr) deallocator(mem);
350  mem = a->Free(deallocator);
351  });
352  return mem;
353 }
354 
356  // Have to do this in a first pass, because some of the destructors might
357  // refer to memory in other blocks.
358  CleanupList();
359 
360  // Discard all blocks except the special block (if present).
361  size_t space_allocated = 0;
362  auto mem = Free(&space_allocated);
363 
364  AllocationPolicy* policy = alloc_policy_.get();
365  if (policy) {
366  auto saved_policy = *policy;
368  space_allocated += mem.size;
369  } else {
370  GetDeallocator(alloc_policy_.get(), &space_allocated)(mem);
371  mem.ptr = nullptr;
372  mem.size = 0;
373  }
374  ArenaMetricsCollector* collector = saved_policy.metrics_collector;
375  if (collector) collector->OnReset(space_allocated);
376  InitializeWithPolicy(mem.ptr, mem.size, saved_policy);
377  } else {
379  // Nullptr policy
381  space_allocated += mem.size;
382  InitializeFrom(mem.ptr, mem.size);
383  } else {
384  GetDeallocator(alloc_policy_.get(), &space_allocated)(mem);
385  Init();
386  }
387  }
388 
389  return space_allocated;
390 }
391 
392 std::pair<void*, SerialArena::CleanupNode*>
394  const std::type_info* type) {
396  if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
398  return arena->AllocateAlignedWithCleanup(n, alloc_policy_.get());
399  } else {
401  }
402 }
403 
404 void ThreadSafeArena::AddCleanup(void* elem, void (*cleanup)(void*)) {
406  if (PROTOBUF_PREDICT_FALSE(!GetSerialArenaFast(&arena))) {
408  }
409  arena->AddCleanup(elem, cleanup, AllocPolicy());
410 }
411 
412 PROTOBUF_NOINLINE
414  const std::type_info* type) {
418  if (PROTOBUF_PREDICT_TRUE(GetSerialArenaFast(&arena))) {
419  return arena->AllocateAligned(n, alloc_policy_.get());
420  }
421  }
424 }
425 
426 PROTOBUF_NOINLINE
427 std::pair<void*, SerialArena::CleanupNode*>
429  size_t n, const std::type_info* type) {
433  if (GetSerialArenaFast(&arena)) {
434  return arena->AllocateAlignedWithCleanup(n, alloc_policy_.get());
435  }
436  }
439 }
440 
442  SerialArena* serial = threads_.load(std::memory_order_acquire);
443  uint64_t res = 0;
444  for (; serial; serial = serial->next()) {
445  res += serial->SpaceAllocated();
446  }
447  return res;
448 }
449 
451  SerialArena* serial = threads_.load(std::memory_order_acquire);
452  uint64_t space_used = 0;
453  for (; serial; serial = serial->next()) {
454  space_used += serial->SpaceUsed();
455  }
456  return space_used - (alloc_policy_.get() ? sizeof(AllocationPolicy) : 0);
457 }
458 
460  PerSerialArena([](SerialArena* a) { a->CleanupList(); });
461 }
462 
463 PROTOBUF_NOINLINE
465  // Look for this SerialArena in our linked list.
466  SerialArena* serial = threads_.load(std::memory_order_acquire);
467  for (; serial; serial = serial->next()) {
468  if (serial->owner() == me) {
469  break;
470  }
471  }
472 
473  if (!serial) {
474  // This thread doesn't have any SerialArena, which also means it doesn't
475  // have any blocks yet. So we'll allocate its first block now.
476  serial = SerialArena::New(
478 
479  SerialArena* head = threads_.load(std::memory_order_relaxed);
480  do {
481  serial->set_next(head);
482  } while (!threads_.compare_exchange_weak(
483  head, serial, std::memory_order_release, std::memory_order_relaxed));
484  }
485 
486  CacheSerialArena(serial);
487  return serial;
488 }
489 
490 } // namespace internal
491 
492 PROTOBUF_FUNC_ALIGN(32)
493 void* Arena::AllocateAlignedNoHook(size_t n) {
494  return impl_.AllocateAligned(n, nullptr);
495 }
496 
497 PROTOBUF_FUNC_ALIGN(32)
498 void* Arena::AllocateAlignedWithHook(size_t n, const std::type_info* type) {
499  return impl_.AllocateAligned(n, type);
500 }
501 
502 PROTOBUF_FUNC_ALIGN(32)
503 std::pair<void*, internal::SerialArena::CleanupNode*>
504 Arena::AllocateAlignedWithCleanup(size_t n, const std::type_info* type) {
505  return impl_.AllocateAlignedWithCleanup(n, type);
506 }
507 
508 } // namespace protobuf
509 } // namespace google
510 
511 #include <google/protobuf/port_undef.inc>
google::protobuf.internal::ThreadSafeArena::Reset
uint64_t Reset()
Definition: third_party/protobuf/src/google/protobuf/arena.cc:355
google::protobuf.internal::SerialArena::kCleanupSize
static constexpr size_t kCleanupSize
Definition: protobuf/src/google/protobuf/arena_impl.h:328
google::protobuf.internal::ThreadSafeArena::SpaceAllocated
uint64_t SpaceAllocated() const
Definition: third_party/protobuf/src/google/protobuf/arena.cc:441
google::protobuf.internal::GetDeallocator::space_allocated_
size_t * space_allocated_
Definition: third_party/protobuf/src/google/protobuf/arena.cc:105
google::protobuf.internal::ThreadSafeArena::~ThreadSafeArena
~ThreadSafeArena()
Definition: third_party/protobuf/src/google/protobuf/arena.cc:324
google::protobuf.internal::TaggedAllocationPolicyPtr::should_record_allocs
bool should_record_allocs() const
Definition: protobuf/src/google/protobuf/arena_impl.h:144
regen-readme.it
it
Definition: regen-readme.py:15
google::protobuf.internal::ThreadSafeArena::SetInitialBlock
void SetInitialBlock(void *mem, size_t size)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:317
google::protobuf.internal::SerialArena
Definition: protobuf/src/google/protobuf/arena_impl.h:191
const
#define const
Definition: bloaty/third_party/zlib/zconf.h:230
google::protobuf.internal::AllocationPolicy::block_alloc
void *(* block_alloc)(size_t)
Definition: protobuf/src/google/protobuf/arena_impl.h:100
google::protobuf.internal::ThreadSafeArena::CacheSerialArena
void CacheSerialArena(SerialArena *serial)
Definition: protobuf/src/google/protobuf/arena_impl.h:435
google::protobuf.internal::SerialArena::AllocateNewBlock
void AllocateNewBlock(size_t n, const AllocationPolicy *policy)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:149
google::protobuf.internal::ThreadSafeArena::lifecycle_id_generator_
static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_
Definition: protobuf/src/google/protobuf/arena_impl.h:524
google::protobuf.internal::ThreadSafeArena::hint_
std::atomic< SerialArena * > hint_
Definition: protobuf/src/google/protobuf/arena_impl.h:416
google::protobuf.internal::SerialArena::New
static SerialArena * New(SerialArena::Memory mem, void *owner)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:115
google::protobuf.internal::AllocationPolicy::IsDefault
bool IsDefault() const
Definition: protobuf/src/google/protobuf/arena_impl.h:104
google::protobuf.internal::ThreadSafeArena::AddCleanup
void AddCleanup(void *elem, void(*cleanup)(void *))
Definition: third_party/protobuf/src/google/protobuf/arena.cc:404
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:194
google::protobuf.internal::AllocationPolicy::start_block_size
size_t start_block_size
Definition: protobuf/src/google/protobuf/arena_impl.h:98
google::protobuf.internal::GetDeallocator::operator()
void operator()(SerialArena::Memory mem) const
Definition: third_party/protobuf/src/google/protobuf/arena.cc:85
Arena
Definition: arena.c:39
google::protobuf.internal::GetDeallocator::GetDeallocator
GetDeallocator(const AllocationPolicy *policy, size_t *space_allocated)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:81
google::protobuf.internal::SerialArena::AllocateAlignedWithCleanupFallback
std::pair< void *, CleanupNode * > AllocateAlignedWithCleanupFallback(size_t n, const AllocationPolicy *policy)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:136
GOOGLE_CHECK_EQ
#define GOOGLE_CHECK_EQ(A, B)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:156
google::protobuf.internal::AlignUpTo8
size_t AlignUpTo8(size_t n)
Definition: bloaty/third_party/protobuf/src/google/protobuf/arena_impl.h:53
elem
Timer elem
Definition: event_engine/iomgr_event_engine/timer_heap_test.cc:109
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.internal::ThreadSafeArena::kSerialArenaSize
static constexpr size_t kSerialArenaSize
Definition: protobuf/src/google/protobuf/arena_impl.h:548
google::protobuf.internal::ThreadSafeArena::AllocPolicy
const AllocationPolicy * AllocPolicy() const
Definition: protobuf/src/google/protobuf/arena_impl.h:418
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
google::protobuf.internal::SerialArena::set_next
void set_next(SerialArena *next)
Definition: protobuf/src/google/protobuf/arena_impl.h:274
google::protobuf.internal::ThreadSafeArena::InitializeFrom
void InitializeFrom(void *mem, size_t size)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:217
google::protobuf.internal::SerialArena::head_
Block * head_
Definition: protobuf/src/google/protobuf/arena_impl.h:304
google::protobuf.internal::ThreadSafeArena::ThreadCache::kPerThreadIds
static constexpr size_t kPerThreadIds
Definition: protobuf/src/google/protobuf/arena_impl.h:505
google::protobuf.internal::TaggedAllocationPolicyPtr::is_user_owned_initial_block
bool is_user_owned_initial_block() const
Definition: protobuf/src/google/protobuf/arena_impl.h:137
google::protobuf.internal::SerialArena::CleanupNode
Definition: protobuf/src/google/protobuf/arena_impl.h:200
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
google::protobuf.internal::ArenaMetricsCollector::RecordAllocs
bool RecordAllocs()
Definition: protobuf/src/google/protobuf/arena_impl.h:86
google::protobuf.internal::SerialArena::CleanupList
void CleanupList()
Definition: third_party/protobuf/src/google/protobuf/arena.cc:179
google::protobuf.internal::ThreadSafeArena::AllocateAlignedWithCleanup
std::pair< void *, SerialArena::CleanupNode * > AllocateAlignedWithCleanup(size_t n, const std::type_info *type)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:393
google::protobuf.internal::SerialArena::AllocateFromExisting
void * AllocateFromExisting(size_t n)
Definition: protobuf/src/google/protobuf/arena_impl.h:223
google::protobuf.internal::SerialArena::Block
Definition: protobuf/src/google/protobuf/arena_impl.h:289
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
impl_
std::shared_ptr< ExternalConnectionAcceptorImpl > impl_
Definition: external_connection_acceptor_impl.cc:43
google::protobuf.internal::ThreadSafeArena::kMessageOwnedArena
@ kMessageOwnedArena
Definition: protobuf/src/google/protobuf/arena_impl.h:410
google::protobuf.internal::ThreadSafeArena::thread_cache
static ThreadCache & thread_cache()
Definition: protobuf/src/google/protobuf/arena_impl.h:535
google::protobuf.internal::SerialArena::AllocateAligned
void * AllocateAligned(size_t n, const AllocationPolicy *policy)
Definition: protobuf/src/google/protobuf/arena_impl.h:213
google::protobuf.internal::SerialArena::owner
void * owner() const
Definition: protobuf/src/google/protobuf/arena_impl.h:272
google::protobuf.internal::AllocationPolicy::metrics_collector
ArenaMetricsCollector * metrics_collector
Definition: protobuf/src/google/protobuf/arena_impl.h:102
google::protobuf.internal::SerialArena::Block::Pointer
char * Pointer(size_t n)
Definition: protobuf/src/google/protobuf/arena_impl.h:292
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf.internal::TaggedAllocationPolicyPtr::RecordAlloc
void RecordAlloc(const std::type_info *allocated_type, size_t n) const
Definition: protobuf/src/google/protobuf/arena_impl.h:151
google::protobuf.internal::SerialArena::AllocateAlignedWithCleanup
std::pair< void *, CleanupNode * > AllocateAlignedWithCleanup(size_t n, const AllocationPolicy *policy)
Definition: protobuf/src/google/protobuf/arena_impl.h:242
google::protobuf.internal::SerialArena::AllocateAlignedFallback
void * AllocateAlignedFallback(size_t n, const AllocationPolicy *policy)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:143
google::protobuf.internal::GetDeallocator::dealloc_
void(* dealloc_)(void *, size_t)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:104
google::protobuf.internal::GetDeallocator
Definition: third_party/protobuf/src/google/protobuf/arena.cc:79
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
min
#define min(a, b)
Definition: qsort.h:83
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
google::protobuf.internal::ThreadSafeArena::Free
SerialArena::Memory Free(size_t *space_allocated)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:345
google::protobuf.internal::ThreadSafeArena::CacheAlignedLifecycleIdGenerator::id
std::atomic< LifecycleIdAtomic > id
Definition: protobuf/src/google/protobuf/arena_impl.h:522
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
google::protobuf.internal::AllocationPolicy
Definition: protobuf/src/google/protobuf/arena_impl.h:94
google::protobuf.internal::SerialArena::Free
Memory Free(Deallocator deallocator)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:123
mem
void * mem
Definition: libc.cpp:91
google::protobuf.internal::SerialArena::next
SerialArena * next() const
Definition: protobuf/src/google/protobuf/arena_impl.h:273
FATAL
#define FATAL(msg)
Definition: task.h:88
google::protobuf.internal::ThreadSafeArena::alloc_policy_
TaggedAllocationPolicyPtr alloc_policy_
Definition: protobuf/src/google/protobuf/arena_impl.h:412
google::protobuf.internal::SerialArena::Block::size
const size_t size
Definition: protobuf/src/google/protobuf/arena_impl.h:298
google::protobuf.internal::SerialArena::limit_
char * limit_
Definition: protobuf/src/google/protobuf/arena_impl.h:313
google::protobuf.internal::ThreadSafeArena::SpaceUsed
uint64_t SpaceUsed() const
Definition: third_party/protobuf/src/google/protobuf/arena.cc:450
google::protobuf.internal::TaggedAllocationPolicyPtr::set_should_record_allocs
void set_should_record_allocs(bool v)
Definition: protobuf/src/google/protobuf/arena_impl.h:147
google::protobuf.internal::SerialArena::SpaceUsed
uint64_t SpaceUsed() const
Definition: third_party/protobuf/src/google/protobuf/arena.cc:171
google::protobuf.internal::SerialArena::Memory
Definition: protobuf/src/google/protobuf/arena_impl.h:193
google::protobuf.internal::ThreadSafeArena::CleanupList
void CleanupList()
Definition: third_party/protobuf/src/google/protobuf/arena.cc:459
google::protobuf.internal::SerialArena::space_used_
size_t space_used_
Definition: protobuf/src/google/protobuf/arena_impl.h:306
google::protobuf.internal::TaggedAllocationPolicyPtr::get_raw
uintptr_t get_raw() const
Definition: protobuf/src/google/protobuf/arena_impl.h:149
google::protobuf.internal::SerialArena::SerialArena
SerialArena(Block *b, void *owner)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:108
google::protobuf.internal::SerialArena::space_allocated_
std::atomic< size_t > space_allocated_
Definition: protobuf/src/google/protobuf/arena_impl.h:307
google::protobuf.internal::ThreadSafeArena::GetSerialArenaFallback
SerialArena * GetSerialArenaFallback(void *me)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:464
google::protobuf.internal::SerialArena::SpaceAllocated
uint64_t SpaceAllocated() const
Definition: protobuf/src/google/protobuf/arena_impl.h:206
google::protobuf.internal::ArenaMetricsCollector::OnReset
virtual void OnReset(uint64_t space_allocated)=0
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
google::protobuf.internal::TaggedAllocationPolicyPtr::get
AllocationPolicy * get()
Definition: protobuf/src/google/protobuf/arena_impl.h:124
google::protobuf.internal::TaggedAllocationPolicyPtr::set_is_user_owned_initial_block
void set_is_user_owned_initial_block(bool v)
Definition: protobuf/src/google/protobuf/arena_impl.h:140
google::protobuf.internal::ThreadSafeArena::InitializeWithPolicy
void InitializeWithPolicy(void *mem, size_t size, AllocationPolicy policy)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:229
xds_manager.num
num
Definition: xds_manager.py:56
google::protobuf.internal::AllocateMemory
static SerialArena::Memory AllocateMemory(const AllocationPolicy *policy_ptr, size_t last_size, size_t min_bytes)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:53
GOOGLE_DCHECK_POLICY_FLAGS_
#define GOOGLE_DCHECK_POLICY_FLAGS_()
GOOGLE_DCHECK_EQ
#define GOOGLE_DCHECK_EQ
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:196
google::protobuf.internal::ThreadSafeArena::GetSerialArenaFast
PROTOBUF_NDEBUG_INLINE bool GetSerialArenaFast(SerialArena **arena)
Definition: protobuf/src/google/protobuf/arena_impl.h:445
google::protobuf.internal::ThreadSafeArena::IsMessageOwned
PROTOBUF_ALWAYS_INLINE bool IsMessageOwned() const
Definition: protobuf/src/google/protobuf/arena_impl.h:402
google::protobuf.internal::SerialArena::ptr_
char * ptr_
Definition: protobuf/src/google/protobuf/arena_impl.h:312
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf.internal::SerialArena::Block::start
CleanupNode * start
Definition: protobuf/src/google/protobuf/arena_impl.h:299
google::protobuf.internal::ThreadSafeArena::Init
void Init()
Definition: third_party/protobuf/src/google/protobuf/arena.cc:289
google::protobuf.internal::ThreadSafeArena::PerSerialArena
void PerSerialArena(Functor fn)
Definition: protobuf/src/google/protobuf/arena_impl.h:474
google::protobuf.internal::AllocationPolicy::max_block_size
size_t max_block_size
Definition: protobuf/src/google/protobuf/arena_impl.h:99
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
cleanup
Definition: cleanup.py:1
google::protobuf.internal::ThreadSafeArena::thread_cache_
static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_
Definition: protobuf/src/google/protobuf/arena_impl.h:534
google::protobuf.internal::ThreadSafeArena::kBlockHeaderSize
static constexpr size_t kBlockHeaderSize
Definition: protobuf/src/google/protobuf/arena_impl.h:547
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
google::protobuf.internal::ThreadSafeArena::threads_
std::atomic< SerialArena * > threads_
Definition: protobuf/src/google/protobuf/arena_impl.h:415
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:146
google::protobuf.internal::ArenaMetricsCollector
Definition: protobuf/src/google/protobuf/arena_impl.h:62
google::protobuf.internal::ThreadSafeArena::CacheAlignedLifecycleIdGenerator
Definition: protobuf/src/google/protobuf/arena_impl.h:521
google::protobuf.internal::SerialArena::AllocateFromExistingWithCleanupFallback
std::pair< void *, CleanupNode * > AllocateFromExistingWithCleanupFallback(size_t n)
Definition: protobuf/src/google/protobuf/arena_impl.h:252
GOOGLE_DCHECK_LE
#define GOOGLE_DCHECK_LE
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:199
google::protobuf.internal::SerialArena::owner_
void * owner_
Definition: protobuf/src/google/protobuf/arena_impl.h:303
google::protobuf.internal::ThreadSafeArena::ThreadCache
Definition: protobuf/src/google/protobuf/arena_impl.h:490
pair
std::pair< std::string, std::string > pair
Definition: abseil-cpp/absl/container/internal/raw_hash_set_benchmark.cc:78
google::protobuf.internal::ThreadSafeArena::AllocateAlignedFallback
void * AllocateAlignedFallback(size_t n, const std::type_info *type)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:413
google::protobuf.internal::ThreadSafeArena::AllocateAlignedWithCleanupFallback
std::pair< void *, SerialArena::CleanupNode * > AllocateAlignedWithCleanupFallback(size_t n, const std::type_info *type)
Definition: third_party/protobuf/src/google/protobuf/arena.cc:428
google::protobuf.internal::TaggedAllocationPolicyPtr::set_policy
void set_policy(AllocationPolicy *policy)
Definition: protobuf/src/google/protobuf/arena_impl.h:119
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf.internal::LifecycleIdAtomic
uint64_t LifecycleIdAtomic
Definition: protobuf/src/google/protobuf/arena_impl.h:59
GOOGLE_CHECK_LE
#define GOOGLE_CHECK_LE(A, B)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:159
google::protobuf.internal::SerialArena::kBlockHeaderSize
static constexpr size_t kBlockHeaderSize
Definition: protobuf/src/google/protobuf/arena_impl.h:327
google::protobuf.internal::ArenaMetricsCollector::OnDestroy
virtual void OnDestroy(uint64_t space_allocated)=0
google::protobuf.internal::ThreadSafeArena::ThreadCache::next_lifecycle_id
uint64_t next_lifecycle_id
Definition: protobuf/src/google/protobuf/arena_impl.h:508
google::protobuf.internal::ThreadSafeArena::tag_and_id_
uint64_t tag_and_id_
Definition: protobuf/src/google/protobuf/arena_impl.h:408


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:42