Lines Matching refs:size

149 #define ZEND_MM_ALIGNED_OFFSET(size, alignment) \  argument
150 (((size_t)(size)) & ((alignment) - 1))
151 #define ZEND_MM_ALIGNED_BASE(size, alignment) \ argument
152 (((size_t)(size)) & ~((alignment) - 1))
153 #define ZEND_MM_SIZE_TO_NUM(size, alignment) \ argument
154 (((size_t)(size) + ((alignment) - 1)) / (alignment))
238 size_t size; /* current memory usage */ member
310 size_t size; member
320 #define _BIN_DATA_SIZE(num, size, elements, pages, x, y) size, argument
325 #define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y) elements, argument
330 #define _BIN_DATA_PAGES(num, size, elements, pages, x, y) pages, argument
373 size_t size) in zend_mm_safe_error() argument
385 size); in zend_mm_safe_error()
421 static void *zend_mm_mmap_fixed(void *addr, size_t size) in zend_mm_mmap_fixed() argument
424 return VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap_fixed()
427 …void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON /*| MAP_POPULATE | MAP… in zend_mm_mmap_fixed()
435 if (munmap(ptr, size) != 0) { in zend_mm_mmap_fixed()
446 static void *zend_mm_mmap(size_t size) in zend_mm_mmap() argument
449 void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap()
462 if (zend_mm_use_huge_pages && size == ZEND_MM_CHUNK_SIZE) { in zend_mm_mmap()
463 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0); in zend_mm_mmap()
470 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in zend_mm_mmap()
482 static void zend_mm_munmap(void *addr, size_t size) in zend_mm_munmap() argument
491 if (munmap(addr, size) != 0) { in zend_mm_munmap()
542 static zend_always_inline int zend_mm_bitset_find_zero(zend_mm_bitset *bitset, int size) argument
552 } while (i < size);
556 static zend_always_inline int zend_mm_bitset_find_one(zend_mm_bitset *bitset, int size) argument
566 } while (i < size);
570 static zend_always_inline int zend_mm_bitset_find_zero_and_set(zend_mm_bitset *bitset, int size) argument
582 } while (i < size);
705 static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment) argument
707 void *ptr = zend_mm_mmap(size);
714 madvise(ptr, size, MADV_HUGEPAGE);
722 zend_mm_munmap(ptr, size);
723 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
726 zend_mm_munmap(ptr, size + alignment - REAL_PAGE_SIZE);
727 ptr = zend_mm_mmap_fixed((void*)((char*)ptr + (alignment - offset)), size);
730 zend_mm_munmap(ptr, size);
743 zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
747 madvise(ptr, size, MADV_HUGEPAGE);
755 static void *zend_mm_chunk_alloc(zend_mm_heap *heap, size_t size, size_t alignment) argument
759 void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment);
764 return zend_mm_chunk_alloc_int(size, alignment);
767 static void zend_mm_chunk_free(zend_mm_heap *heap, void *addr, size_t size) argument
771 heap->storage->handlers.chunk_free(heap->storage, addr, size);
775 zend_mm_munmap(addr, size);
837 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
841 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s…
843 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
851 static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count, size_t size ZEND_FILE_LI…
988 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1006 …u) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1015 size_t size = heap->real_size + ZEND_MM_CHUNK_SIZE; local
1016 size_t peak = MAX(heap->real_peak, size);
1017 heap->real_size = size;
1059 static zend_always_inline void *zend_mm_alloc_large(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_…
1061 int pages_count = (int)ZEND_MM_SIZE_TO_NUM(size, ZEND_MM_PAGE_SIZE);
1063 …void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORI…
1069 size_t size = heap->size + pages_count * ZEND_MM_PAGE_SIZE; local
1070 size_t peak = MAX(heap->peak, size);
1071 heap->size = size;
1135 heap->size -= pages_count * ZEND_MM_PAGE_SIZE;
1145 static zend_always_inline int zend_mm_small_size_to_bit(int size) argument
1148 return (__builtin_clz(size) ^ 0x1f) + 1;
1152 if (!BitScanReverse(&index, (unsigned long)size)) {
1160 if (size <= 0x00ff) {n -= 8; size = size << 8;}
1161 if (size <= 0x0fff) {n -= 4; size = size << 4;}
1162 if (size <= 0x3fff) {n -= 2; size = size << 2;}
1163 if (size <= 0x7fff) {n -= 1;}
1176 static zend_always_inline int zend_mm_small_size_to_bin(size_t size) argument
1184 if (UNEXPECTED(size <= 2)) return 0;
1185 n = zend_mm_small_size_to_bit(size - 1);
1186 return ((size-1) >> f1[n]) + f2[n];
1190 if (size <= 64) {
1192 return (size - !!size) >> 3;
1194 t1 = size - 1;
1204 #define ZEND_MM_SMALL_SIZE_TO_BIN(size) zend_mm_small_size_to_bin(size) argument
1243 dbg->size = 0;
1254 dbg->size = 0;
1262 static zend_always_inline void *zend_mm_alloc_small(zend_mm_heap *heap, size_t size, int bin_num ZE… argument
1266 size_t size = heap->size + bin_data_size[bin_num]; local
1267 size_t peak = MAX(heap->peak, size);
1268 heap->size = size;
1287 heap->size -= bin_data_size[bin_num];
1293 dbg->size = 0;
1330 static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D…
1334 size_t real_size = size;
1338 size = MAX(size, 1);
1339 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1340 if (UNEXPECTED(size < real_size)) {
1345 if (size <= ZEND_MM_MAX_SMALL_SIZE) {
1346 …ptr = zend_mm_alloc_small(heap, size, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND…
1349 dbg->size = real_size;
1356 } else if (size <= ZEND_MM_MAX_LARGE_SIZE) {
1357 ptr = zend_mm_alloc_large(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1360 dbg->size = real_size;
1369 size = real_size;
1371 return zend_mm_alloc_huge(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1410 return dbg->size;
1428 static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size ZEND… argument
1442 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1446 real_size = size;
1447 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1449 if (size > ZEND_MM_MAX_LARGE_SIZE) {
1451 size = real_size;
1458 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE));
1460 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE);
1476 heap->size -= old_size - new_size;
1492 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1494 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1507 heap->size += new_size - old_size;
1508 heap->peak = MAX(heap->peak, heap->size);
1524 size_t real_size = size;
1526 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1533 if (size <= ZEND_MM_MAX_SMALL_SIZE) {
1534 int bin_num = ZEND_MM_SMALL_SIZE_TO_BIN(size);
1538 dbg->size = real_size;
1550 if (size > ZEND_MM_MAX_SMALL_SIZE && size <= ZEND_MM_MAX_LARGE_SIZE) {
1551 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE);
1555 dbg->size = real_size;
1568 heap->size -= rest_pages_count * ZEND_MM_PAGE_SIZE;
1575 dbg->size = real_size;
1591 size_t size = heap->size + (new_size - old_size); local
1592 size_t peak = MAX(heap->peak, size);
1593 heap->size = size;
1602 dbg->size = real_size;
1614 size = real_size;
1624 ret = zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1628 heap->peak = MAX(orig_peak, heap->size);
1640 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_size ZEND… argument
1642 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEN…
1647 list->size = size;
1650 list->dbg.size = dbg_size;
1665 size_t size; local
1672 size = list->size;
1674 return size;
1688 return list->size;
1697 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s… argument
1699 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1705 list->size = size;
1707 list->dbg.size = dbg_size;
1719 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
1730 size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, alignment);
1733 if (UNEXPECTED(new_size < size)) {
1734 …zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", size, a…
1743 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1745 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1761 …u) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1763 …_error(heap, "Out of memory (allocated %zu) (tried to allocate %zu bytes)", heap->real_size, size);
1769 …zend_mm_add_huge_block(heap, ptr, new_size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1775 size_t size = heap->real_size + new_size; local
1776 size_t peak = MAX(heap->real_peak, size);
1777 heap->real_size = size;
1781 size_t size = heap->size + new_size; local
1782 size_t peak = MAX(heap->peak, size);
1783 heap->size = size;
1794 size_t size; local
1797 size = zend_mm_del_huge_block(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1798 zend_mm_chunk_free(heap, ptr, size);
1800 heap->real_size -= size;
1803 heap->size -= size;
1848 heap->size = 0;
1992 if (dbg->size != 0) {
1995 dbg->size = 0;
2050 zend_mm_chunk_free(heap, p->ptr, p->size);
2077 leak.size = list->dbg.size;
2092 zend_mm_chunk_free(heap, q->ptr, q->size);
2108 if (dbg->size != 0) {
2110 leak.size = dbg->size;
2119 dbg->size = 0;
2139 leak.size = dbg->size;
2199 zend_mm_chunk_free(heap, q->ptr, q->size);
2266 heap->size = heap->peak = 0;
2275 ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_…
2277 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2285 void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC Z…
2287 …return zend_mm_realloc_heap(heap, ptr, size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELA…
2290 void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size … argument
2292 …return zend_mm_realloc_heap(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
2329 # define ZEND_MM_CUSTOM_ALLOCATOR(size) do { \ argument
2332 …return AG(mm_heap)->custom_heap.debug._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
2334 return AG(mm_heap)->custom_heap.std._malloc(size); \
2349 # define ZEND_MM_CUSTOM_ALLOCATOR(size) argument
2361 ZEND_API void* ZEND_FASTCALL _emalloc_large(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2364 ZEND_MM_CUSTOM_ALLOCATOR(size);
2365 return zend_mm_alloc_large(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2368 ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size) argument
2371 ZEND_MM_CUSTOM_ALLOCATOR(size);
2372 return zend_mm_alloc_huge(AG(mm_heap), size);
2403 ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
2411 uint32_t pages_count = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE) / ZEND_MM_PAGE_SIZE;
2420 ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) argument
2428 ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2434 …return AG(mm_heap)->custom_heap.debug._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
2436 return AG(mm_heap)->custom_heap.std._malloc(size);
2440 return zend_mm_alloc_heap(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2459 ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG…
2464 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2466 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2469 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2472 ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC … argument
2477 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2479 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2482 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
2493 ZEND_API void* ZEND_FASTCALL _safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_… argument
2495 return emalloc_rel(zend_safe_address_guarded(nmemb, size, offset));
2498 ZEND_API void* ZEND_FASTCALL _safe_malloc(size_t nmemb, size_t size, size_t offset) argument
2500 return pemalloc(zend_safe_address_guarded(nmemb, size, offset), 1);
2503 ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEN… argument
2505 return erealloc_rel(ptr, zend_safe_address_guarded(nmemb, size, offset));
2508 ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) argument
2510 return perealloc(ptr, zend_safe_address_guarded(nmemb, size, offset), 1);
2514 ZEND_API void* ZEND_FASTCALL _ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
2518 p = _safe_emalloc(nmemb, size, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2519 memset(p, 0, size * nmemb);
2584 size_t usage = AG(mm_heap)->size;
2790 heap->size = 0;