Auto-generate files after cl/647802280

pull/17283/head
Protobuf Team Bot 8 months ago
parent d3172f5d73
commit a4f9ddd8fc
  1. 13
      php/ext/google/protobuf/php-upb.c
  2. 9
      php/ext/google/protobuf/php-upb.h
  3. 13
      ruby/ext/google/protobuf_c/ruby-upb.c
  4. 9
      ruby/ext/google/protobuf_c/ruby-upb.h

@ -4719,6 +4719,10 @@ upb_alloc upb_alloc_global = {&upb_global_allocfunc};
// Must be last.
static UPB_ATOMIC(size_t) max_block_size = 32 << 10;
void upb_Arena_SetMaxBlockSize(size_t max) { max_block_size = max; }
typedef struct upb_MemBlock {
// Atomic only for the benefit of SpaceAllocated().
UPB_ATOMIC(struct upb_MemBlock*) next;
@ -4956,7 +4960,14 @@ static bool _upb_Arena_AllocBlock(upb_Arena* a, size_t size) {
if (!ai->block_alloc) return false;
upb_MemBlock* last_block = upb_Atomic_Load(&ai->blocks, memory_order_acquire);
size_t last_size = last_block != NULL ? last_block->size : 128;
size_t block_size = UPB_MAX(size, last_size * 2) + kUpb_MemblockReserve;
// Don't naturally grow beyond the max block size.
size_t clamped_size = UPB_MIN(last_size * 2, max_block_size);
// We may need to exceed the max block size if the user requested a large
// allocation.
size_t block_size = UPB_MAX(size, clamped_size) + kUpb_MemblockReserve;
upb_MemBlock* block =
upb_malloc(_upb_ArenaInternal_BlockAlloc(ai), block_size);

@ -763,6 +763,15 @@ UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size);
UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
size_t size);
// Sets the maximum block size for all arenas. This is a global configuration
// setting that will affect all existing and future arenas. If
// upb_Arena_Malloc() is called with a size larger than this, we will exceed
// this size and allocate a larger block.
//
// This API is meant for experimentation only. It will likely be removed in
// the future.
void upb_Arena_SetMaxBlockSize(size_t max);
// Shrinks the last alloc from arena.
// REQUIRES: (ptr, oldsize) was the last malloc/realloc from this arena.
// We could also add a upb_Arena_TryShrinkLast() which is simply a no-op if

@ -4207,6 +4207,10 @@ upb_alloc upb_alloc_global = {&upb_global_allocfunc};
// Must be last.
static UPB_ATOMIC(size_t) max_block_size = 32 << 10;
void upb_Arena_SetMaxBlockSize(size_t max) { max_block_size = max; }
typedef struct upb_MemBlock {
// Atomic only for the benefit of SpaceAllocated().
UPB_ATOMIC(struct upb_MemBlock*) next;
@ -4444,7 +4448,14 @@ static bool _upb_Arena_AllocBlock(upb_Arena* a, size_t size) {
if (!ai->block_alloc) return false;
upb_MemBlock* last_block = upb_Atomic_Load(&ai->blocks, memory_order_acquire);
size_t last_size = last_block != NULL ? last_block->size : 128;
size_t block_size = UPB_MAX(size, last_size * 2) + kUpb_MemblockReserve;
// Don't naturally grow beyond the max block size.
size_t clamped_size = UPB_MIN(last_size * 2, max_block_size);
// We may need to exceed the max block size if the user requested a large
// allocation.
size_t block_size = UPB_MAX(size, clamped_size) + kUpb_MemblockReserve;
upb_MemBlock* block =
upb_malloc(_upb_ArenaInternal_BlockAlloc(ai), block_size);

@ -765,6 +765,15 @@ UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size);
UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
size_t size);
// Sets the maximum block size for all arenas. This is a global configuration
// setting that will affect all existing and future arenas. If
// upb_Arena_Malloc() is called with a size larger than this, we will exceed
// this size and allocate a larger block.
//
// This API is meant for experimentation only. It will likely be removed in
// the future.
void upb_Arena_SetMaxBlockSize(size_t max);
// Shrinks the last alloc from arena.
// REQUIRES: (ptr, oldsize) was the last malloc/realloc from this arena.
// We could also add a upb_Arena_TryShrinkLast() which is simply a no-op if

Loading…
Cancel
Save