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))
240 size_t size; /* current memory usage */ member
312 size_t size; member
322 #define _BIN_DATA_SIZE(num, size, elements, pages, x, y) size, argument
327 #define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y) elements, argument
332 #define _BIN_DATA_PAGES(num, size, elements, pages, x, y) pages, argument
375 size_t size) in zend_mm_safe_error() argument
387 size); in zend_mm_safe_error()
423 static void *zend_mm_mmap_fixed(void *addr, size_t size) in zend_mm_mmap_fixed() argument
426 return VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap_fixed()
429 …void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON /*| MAP_POPULATE | MAP… in zend_mm_mmap_fixed()
437 if (munmap(ptr, size) != 0) { in zend_mm_mmap_fixed()
448 static void *zend_mm_mmap(size_t size) in zend_mm_mmap() argument
451 void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap()
464 if (zend_mm_use_huge_pages && size == ZEND_MM_CHUNK_SIZE) { in zend_mm_mmap()
465 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0); in zend_mm_mmap()
472 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in zend_mm_mmap()
484 static void zend_mm_munmap(void *addr, size_t size) in zend_mm_munmap() argument
493 if (munmap(addr, size) != 0) { in zend_mm_munmap()
544 static zend_always_inline int zend_mm_bitset_find_zero(zend_mm_bitset *bitset, int size) argument
554 } while (i < size);
558 static zend_always_inline int zend_mm_bitset_find_one(zend_mm_bitset *bitset, int size) argument
568 } while (i < size);
572 static zend_always_inline int zend_mm_bitset_find_zero_and_set(zend_mm_bitset *bitset, int size) argument
584 } while (i < size);
707 static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment) argument
709 void *ptr = zend_mm_mmap(size);
715 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);
746 madvise(ptr, size, MADV_HUGEPAGE);
753 static void *zend_mm_chunk_alloc(zend_mm_heap *heap, size_t size, size_t alignment) argument
757 void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment);
762 return zend_mm_chunk_alloc_int(size, alignment);
765 static void zend_mm_chunk_free(zend_mm_heap *heap, void *addr, size_t size) argument
769 heap->storage->handlers.chunk_free(heap->storage, addr, size);
773 zend_mm_munmap(addr, size);
835 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
839 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s…
841 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
849 static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count, size_t size ZEND_FILE_LI…
986 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1004 …u) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1013 size_t size = heap->real_size + ZEND_MM_CHUNK_SIZE; local
1014 size_t peak = MAX(heap->real_peak, size);
1015 heap->real_size = size;
1057 static zend_always_inline void *zend_mm_alloc_large(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_…
1059 int pages_count = (int)ZEND_MM_SIZE_TO_NUM(size, ZEND_MM_PAGE_SIZE);
1061 …void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORI…
1067 size_t size = heap->size + pages_count * ZEND_MM_PAGE_SIZE; local
1068 size_t peak = MAX(heap->peak, size);
1069 heap->size = size;
1133 heap->size -= pages_count * ZEND_MM_PAGE_SIZE;
1143 static zend_always_inline int zend_mm_small_size_to_bit(int size) argument
1146 return (__builtin_clz(size) ^ 0x1f) + 1;
1150 if (!BitScanReverse(&index, (unsigned long)size)) {
1158 if (size <= 0x00ff) {n -= 8; size = size << 8;}
1159 if (size <= 0x0fff) {n -= 4; size = size << 4;}
1160 if (size <= 0x3fff) {n -= 2; size = size << 2;}
1161 if (size <= 0x7fff) {n -= 1;}
1174 static zend_always_inline int zend_mm_small_size_to_bin(size_t size) argument
1182 if (UNEXPECTED(size <= 2)) return 0;
1183 n = zend_mm_small_size_to_bit(size - 1);
1184 return ((size-1) >> f1[n]) + f2[n];
1188 if (size <= 64) {
1190 return (size - !!size) >> 3;
1192 t1 = size - 1;
1202 #define ZEND_MM_SMALL_SIZE_TO_BIN(size) zend_mm_small_size_to_bin(size) argument
1241 dbg->size = 0;
1252 dbg->size = 0;
1260 static zend_always_inline void *zend_mm_alloc_small(zend_mm_heap *heap, size_t size, int bin_num ZE… argument
1264 size_t size = heap->size + bin_data_size[bin_num]; local
1265 size_t peak = MAX(heap->peak, size);
1266 heap->size = size;
1285 heap->size -= bin_data_size[bin_num];
1291 dbg->size = 0;
1328 static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D…
1332 size_t real_size = size;
1336 size = MAX(size, 1);
1337 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1338 if (UNEXPECTED(size < real_size)) {
1343 if (size <= ZEND_MM_MAX_SMALL_SIZE) {
1344 …ptr = zend_mm_alloc_small(heap, size, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND…
1347 dbg->size = real_size;
1354 } else if (size <= ZEND_MM_MAX_LARGE_SIZE) {
1355 ptr = zend_mm_alloc_large(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1358 dbg->size = real_size;
1367 size = real_size;
1369 return zend_mm_alloc_huge(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1408 return dbg->size;
1426 static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size ZEND… argument
1440 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1444 real_size = size;
1445 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1447 if (size > ZEND_MM_MAX_LARGE_SIZE) {
1449 size = real_size;
1456 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE));
1458 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE);
1474 heap->size -= old_size - new_size;
1490 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1492 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1505 heap->size += new_size - old_size;
1506 heap->peak = MAX(heap->peak, heap->size);
1522 size_t real_size = size;
1524 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1531 if (size <= ZEND_MM_MAX_SMALL_SIZE) {
1532 int bin_num = ZEND_MM_SMALL_SIZE_TO_BIN(size);
1536 dbg->size = real_size;
1548 if (size > ZEND_MM_MAX_SMALL_SIZE && size <= ZEND_MM_MAX_LARGE_SIZE) {
1549 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE);
1553 dbg->size = real_size;
1566 heap->size -= rest_pages_count * ZEND_MM_PAGE_SIZE;
1573 dbg->size = real_size;
1589 size_t size = heap->size + (new_size - old_size); local
1590 size_t peak = MAX(heap->peak, size);
1591 heap->size = size;
1600 dbg->size = real_size;
1612 size = real_size;
1622 ret = zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1626 heap->peak = MAX(orig_peak, heap->size);
1638 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_size ZEND… argument
1640 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEN…
1645 list->size = size;
1648 list->dbg.size = dbg_size;
1663 size_t size; local
1670 size = list->size;
1672 return size;
1686 return list->size;
1695 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s… argument
1697 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1703 list->size = size;
1705 list->dbg.size = dbg_size;
1717 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
1724 size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE));
1726 size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE);
1736 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1738 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1754 …u) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1756 …_error(heap, "Out of memory (allocated %zu) (tried to allocate %zu bytes)", heap->real_size, size);
1762 …zend_mm_add_huge_block(heap, ptr, new_size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1768 size_t size = heap->real_size + new_size; local
1769 size_t peak = MAX(heap->real_peak, size);
1770 heap->real_size = size;
1774 size_t size = heap->size + new_size; local
1775 size_t peak = MAX(heap->peak, size);
1776 heap->size = size;
1787 size_t size; local
1790 size = zend_mm_del_huge_block(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1791 zend_mm_chunk_free(heap, ptr, size);
1793 heap->real_size -= size;
1796 heap->size -= size;
1841 heap->size = 0;
1985 if (dbg->size != 0) {
1988 dbg->size = 0;
2043 zend_mm_chunk_free(heap, p->ptr, p->size);
2070 leak.size = list->dbg.size;
2085 zend_mm_chunk_free(heap, q->ptr, q->size);
2101 if (dbg->size != 0) {
2103 leak.size = dbg->size;
2112 dbg->size = 0;
2132 leak.size = dbg->size;
2192 zend_mm_chunk_free(heap, q->ptr, q->size);
2259 heap->size = heap->peak = 0;
2268 ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_…
2270 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2278 void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC Z…
2280 …return zend_mm_realloc_heap(heap, ptr, size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELA…
2283 void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size … argument
2285 …return zend_mm_realloc_heap(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
2322 # define ZEND_MM_CUSTOM_ALLOCATOR(size) do { \ argument
2325 …return AG(mm_heap)->custom_heap.debug._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
2327 return AG(mm_heap)->custom_heap.std._malloc(size); \
2342 # define ZEND_MM_CUSTOM_ALLOCATOR(size) argument
2354 ZEND_API void* ZEND_FASTCALL _emalloc_large(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2357 ZEND_MM_CUSTOM_ALLOCATOR(size);
2358 return zend_mm_alloc_large(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2361 ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size) argument
2364 ZEND_MM_CUSTOM_ALLOCATOR(size);
2365 return zend_mm_alloc_huge(AG(mm_heap), size);
2396 ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
2404 uint32_t pages_count = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE) / ZEND_MM_PAGE_SIZE;
2413 ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) argument
2421 ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2427 …return AG(mm_heap)->custom_heap.debug._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
2429 return AG(mm_heap)->custom_heap.std._malloc(size);
2433 return zend_mm_alloc_heap(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2452 ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG…
2457 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2459 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2462 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2465 ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC … argument
2470 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2472 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2475 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
2486 ZEND_API void* ZEND_FASTCALL _safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_… argument
2488 return emalloc_rel(zend_safe_address_guarded(nmemb, size, offset));
2491 ZEND_API void* ZEND_FASTCALL _safe_malloc(size_t nmemb, size_t size, size_t offset) argument
2493 return pemalloc(zend_safe_address_guarded(nmemb, size, offset), 1);
2496 ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEN… argument
2498 return erealloc_rel(ptr, zend_safe_address_guarded(nmemb, size, offset));
2501 ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) argument
2503 return perealloc(ptr, zend_safe_address_guarded(nmemb, size, offset), 1);
2507 ZEND_API void* ZEND_FASTCALL _ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
2511 p = _safe_emalloc(nmemb, size, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2515 memset(p, 0, size * nmemb);
2586 size_t usage = AG(mm_heap)->size;
2793 heap->size = 0;