Lines Matching refs:size
153 #define ZEND_MM_ALIGNED_OFFSET(size, alignment) \ argument
154 (((size_t)(size)) & ((alignment) - 1))
155 #define ZEND_MM_ALIGNED_BASE(size, alignment) \ argument
156 (((size_t)(size)) & ~((alignment) - 1))
157 #define ZEND_MM_SIZE_TO_NUM(size, alignment) \ argument
158 (((size_t)(size) + ((alignment) - 1)) / (alignment))
242 size_t size; /* current memory usage */ member
315 size_t size; member
325 #define _BIN_DATA_SIZE(num, size, elements, pages, x, y) size, argument
330 #define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y) elements, argument
335 #define _BIN_DATA_PAGES(num, size, elements, pages, x, y) pages, argument
378 size_t size) in zend_mm_safe_error() argument
390 size); in zend_mm_safe_error()
420 static void zend_mm_munmap(void *addr, size_t size) in zend_mm_munmap() argument
449 if (munmap(addr, size) != 0) { in zend_mm_munmap()
458 static void *zend_mm_mmap_fixed(void *addr, size_t size) in zend_mm_mmap_fixed() argument
461 void *ptr = VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap_fixed()
483 …void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, flags /*| MAP_POPULATE | MAP_HUGETLB*/, ZEND_… in zend_mm_mmap_fixed()
491 zend_mm_munmap(ptr, size); in zend_mm_mmap_fixed()
499 static void *zend_mm_mmap(size_t size) in zend_mm_mmap() argument
502 void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap()
515 if (zend_mm_use_huge_pages && size == ZEND_MM_CHUNK_SIZE) { in zend_mm_mmap()
523 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, mflags, fd, 0); in zend_mm_mmap()
525 zend_mmap_set_name(ptr, size, "zend_alloc"); in zend_mm_mmap()
531 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, ZEND_MM_FD, 0); in zend_mm_mmap()
539 zend_mmap_set_name(ptr, size, "zend_alloc"); in zend_mm_mmap()
706 static zend_always_inline void zend_mm_hugepage(void* ptr, size_t size) argument
709 (void)madvise(ptr, size, MADV_HUGEPAGE);
712 (void)memcntl(ptr, size, MC_HAT_ADVISE, (char *)&m, 0, 0);
718 static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment) argument
720 void *ptr = zend_mm_mmap(size);
726 zend_mm_hugepage(ptr, size);
733 zend_mm_munmap(ptr, size);
734 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
740 zend_mm_munmap(ptr, size + alignment - REAL_PAGE_SIZE);
741 ptr = zend_mm_mmap_fixed((void*)((char*)ptr + offset), size);
743 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
762 zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
765 zend_mm_hugepage(ptr, size);
772 static void *zend_mm_chunk_alloc(zend_mm_heap *heap, size_t size, size_t alignment) argument
776 void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment);
781 return zend_mm_chunk_alloc_int(size, alignment);
784 static void zend_mm_chunk_free(zend_mm_heap *heap, void *addr, size_t size) argument
788 heap->storage->handlers.chunk_free(heap->storage, addr, size);
792 zend_mm_munmap(addr, size);
863 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
867 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s…
869 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
877 static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count, size_t size ZEND_FILE_LI…
1014 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1032 …s) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1041 size_t size = heap->real_size + ZEND_MM_CHUNK_SIZE; local
1042 size_t peak = MAX(heap->real_peak, size);
1043 heap->real_size = size;
1085 static zend_always_inline void *zend_mm_alloc_large_ex(zend_mm_heap *heap, size_t size ZEND_FILE_LI…
1087 int pages_count = (int)ZEND_MM_SIZE_TO_NUM(size, ZEND_MM_PAGE_SIZE);
1089 …void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORI…
1095 size_t size = heap->size + pages_count * ZEND_MM_PAGE_SIZE; local
1096 size_t peak = MAX(heap->peak, size);
1097 heap->size = size;
1105 static zend_never_inline void *zend_mm_alloc_large(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D…
1107 return zend_mm_alloc_large_ex(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1110 static zend_never_inline void *zend_mm_alloc_large(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D…
1112 return zend_mm_alloc_large_ex(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1173 heap->size -= pages_count * ZEND_MM_PAGE_SIZE;
1183 static zend_always_inline int zend_mm_small_size_to_bit(int size) argument
1186 return (__builtin_clz(size) ^ 0x1f) + 1;
1190 if (!BitScanReverse(&index, (unsigned long)size)) {
1198 if (size <= 0x00ff) {n -= 8; size = size << 8;}
1199 if (size <= 0x0fff) {n -= 4; size = size << 4;}
1200 if (size <= 0x3fff) {n -= 2; size = size << 2;}
1201 if (size <= 0x7fff) {n -= 1;}
1214 static zend_always_inline int zend_mm_small_size_to_bin(size_t size) argument
1222 if (UNEXPECTED(size <= 2)) return 0;
1223 n = zend_mm_small_size_to_bit(size - 1);
1224 return ((size-1) >> f1[n]) + f2[n];
1228 if (size <= 64) {
1230 return (size - !!size) >> 3;
1232 t1 = size - 1;
1242 #define ZEND_MM_SMALL_SIZE_TO_BIN(size) zend_mm_small_size_to_bin(size) argument
1281 dbg->size = 0;
1292 dbg->size = 0;
1304 size_t size = heap->size + bin_data_size[bin_num]; local
1305 size_t peak = MAX(heap->peak, size);
1306 heap->size = size;
1325 heap->size -= bin_data_size[bin_num];
1331 dbg->size = 0;
1368 static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D…
1372 size_t real_size = size;
1376 size = MAX(size, 1);
1377 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1378 if (UNEXPECTED(size < real_size)) {
1383 if (EXPECTED(size <= ZEND_MM_MAX_SMALL_SIZE)) {
1384 …ptr = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_…
1387 dbg->size = real_size;
1394 } else if (EXPECTED(size <= ZEND_MM_MAX_LARGE_SIZE)) {
1395 ptr = zend_mm_alloc_large(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1398 dbg->size = real_size;
1407 size = real_size;
1409 return zend_mm_alloc_huge(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1448 return dbg->size;
1466 static zend_never_inline void *zend_mm_realloc_slow(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1474 ret = zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1478 heap->peak = MAX(orig_peak, heap->size);
1484 static zend_never_inline void *zend_mm_realloc_huge(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1494 real_size = size;
1495 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1497 if (size > ZEND_MM_MAX_LARGE_SIZE) {
1499 size = real_size;
1506 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE));
1508 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE);
1524 heap->size -= old_size - new_size;
1540 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1542 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1555 heap->size += new_size - old_size;
1556 heap->peak = MAX(heap->peak, heap->size);
1568 …return zend_mm_realloc_slow(heap, ptr, size, MIN(old_size, copy_size) ZEND_FILE_LINE_RELAY_CC ZEND…
1571 static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, bo… argument
1584 return _zend_mm_alloc(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1586 …return zend_mm_realloc_huge(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1593 size_t real_size = size;
1595 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1606 if (size <= old_size) {
1608 if (old_bin_num > 0 && size < bin_data_size[old_bin_num - 1]) {
1610 …ret = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_…
1611 copy_size = use_copy_size ? MIN(size, copy_size) : size;
1618 } else if (size <= ZEND_MM_MAX_SMALL_SIZE) {
1625 …ret = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_…
1630 heap->peak = MAX(orig_peak, heap->size);
1640 dbg->size = real_size;
1652 if (size > ZEND_MM_MAX_SMALL_SIZE && size <= ZEND_MM_MAX_LARGE_SIZE) {
1653 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE);
1657 dbg->size = real_size;
1670 heap->size -= rest_pages_count * ZEND_MM_PAGE_SIZE;
1677 dbg->size = real_size;
1693 size_t size = heap->size + (new_size - old_size); local
1694 size_t peak = MAX(heap->peak, size);
1695 heap->size = size;
1704 dbg->size = real_size;
1716 size = real_size;
1721 …return zend_mm_realloc_slow(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1729 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_size ZEND… argument
1731 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEN…
1736 list->size = size;
1739 list->dbg.size = dbg_size;
1754 size_t size; local
1761 size = list->size;
1763 return size;
1777 return list->size;
1786 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s… argument
1788 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1794 list->size = size;
1796 list->dbg.size = dbg_size;
1808 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
1819 size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, alignment);
1822 if (UNEXPECTED(new_size < size)) {
1823 …zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", size, a…
1832 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1834 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1850 …s) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1852 …(heap, "Out of memory (allocated %zu bytes) (tried to allocate %zu bytes)", heap->real_size, size);
1858 …zend_mm_add_huge_block(heap, ptr, new_size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1864 size_t size = heap->real_size + new_size; local
1865 size_t peak = MAX(heap->real_peak, size);
1866 heap->real_size = size;
1870 size_t size = heap->size + new_size; local
1871 size_t peak = MAX(heap->peak, size);
1872 heap->size = size;
1883 size_t size; local
1886 size = zend_mm_del_huge_block(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1887 zend_mm_chunk_free(heap, ptr, size);
1889 heap->real_size -= size;
1892 heap->size -= size;
1933 heap->size = 0;
2077 if (dbg->size != 0) {
2080 dbg->size = 0;
2136 zend_mm_chunk_free(heap, p->ptr, p->size);
2163 leak.size = list->dbg.size;
2178 zend_mm_chunk_free(heap, q->ptr, q->size);
2194 if (dbg->size != 0) {
2196 leak.size = dbg->size;
2205 dbg->size = 0;
2225 leak.size = dbg->size;
2256 static void *tracked_malloc(size_t size);
2278 heap->size = 0;
2304 zend_mm_chunk_free(heap, q->ptr, q->size);
2356 heap->size = heap->peak = 0;
2380 ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_…
2382 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2390 void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC Z…
2392 …return zend_mm_realloc_heap(heap, ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_R…
2395 void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size … argument
2397 …return zend_mm_realloc_heap(heap, ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_O…
2461 && ptr < (void*)((char*)block + block->size)) {
2472 static ZEND_COLD void* ZEND_FASTCALL _malloc_custom(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
2475 …return AG(mm_heap)->custom_heap.debug._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
2477 return AG(mm_heap)->custom_heap.std._malloc(size);
2490 static ZEND_COLD void* ZEND_FASTCALL _realloc_custom(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_…
2493 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2495 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2504 # define ZEND_MM_CUSTOM_ALLOCATOR(size) do { \ argument
2506 return _malloc_custom(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); \
2516 # define ZEND_MM_CUSTOM_ALLOCATOR(size) argument
2528 ZEND_API void* ZEND_FASTCALL _emalloc_large(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2530 ZEND_MM_CUSTOM_ALLOCATOR(size);
2531 …return zend_mm_alloc_large_ex(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_…
2534 ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size) argument
2536 ZEND_MM_CUSTOM_ALLOCATOR(size);
2537 return zend_mm_alloc_huge(AG(mm_heap), size);
2568 ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
2575 uint32_t pages_count = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE) / ZEND_MM_PAGE_SIZE;
2584 ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) argument
2592 ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2596 return _malloc_custom(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2599 return zend_mm_alloc_heap(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2613 ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG…
2617 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2620 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE…
2623 ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC … argument
2627 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2630 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE…
2643 ZEND_API void* ZEND_FASTCALL _safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_… argument
2645 …return _emalloc(zend_safe_address_guarded(nmemb, size, offset) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_L…
2648 ZEND_API void* ZEND_FASTCALL _safe_malloc(size_t nmemb, size_t size, size_t offset) argument
2650 return pemalloc(zend_safe_address_guarded(nmemb, size, offset), 1);
2653 ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEN… argument
2655 …return _erealloc(ptr, zend_safe_address_guarded(nmemb, size, offset) ZEND_FILE_LINE_RELAY_CC ZEND_…
2658 ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) argument
2660 return perealloc(ptr, zend_safe_address_guarded(nmemb, size, offset), 1);
2663 ZEND_API void* ZEND_FASTCALL _ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
2667 size = zend_safe_address_guarded(nmemb, size, 0);
2668 p = _emalloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2669 memset(p, 0, size);
2759 size_t usage = AG(mm_heap)->size;
2782 AG(mm_heap)->peak = AG(mm_heap)->size;
2798 static zend_always_inline void tracked_add(zend_mm_heap *heap, void *ptr, size_t size) { argument
2802 ZVAL_LONG(&size_zv, size);
2814 if (add_size > heap->limit - heap->size && !heap->overflow) {
2827 static void *tracked_malloc(size_t size) argument
2830 tracked_check_limit(heap, size);
2832 void *ptr = malloc(size);
2837 tracked_add(heap, ptr, size);
2838 heap->size += size;
2849 heap->size -= Z_LVAL_P(size_zv);
2874 heap->size += new_size - old_size;
3084 heap->size = 0;