Lines Matching refs:size

148 #define ZEND_MM_ALIGNED_OFFSET(size, alignment) \  argument
149 (((size_t)(size)) & ((alignment) - 1))
150 #define ZEND_MM_ALIGNED_BASE(size, alignment) \ argument
151 (((size_t)(size)) & ~((alignment) - 1))
152 #define ZEND_MM_SIZE_TO_NUM(size, alignment) \ argument
153 (((size_t)(size) + ((alignment) - 1)) / (alignment))
247 size_t size; /* current memory usage */ member
319 size_t size; member
329 #define _BIN_DATA_SIZE(num, size, elements, pages, x, y) size, argument
334 #define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y) elements, argument
339 #define _BIN_DATA_PAGES(num, size, elements, pages, x, y) pages, argument
382 size_t size) in zend_mm_safe_error() argument
394 size); in zend_mm_safe_error()
430 static void *zend_mm_mmap_fixed(void *addr, size_t size) in zend_mm_mmap_fixed() argument
433 return VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap_fixed()
436 …void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON /*| MAP_POPULATE | MAP… in zend_mm_mmap_fixed()
444 if (munmap(ptr, size) != 0) { in zend_mm_mmap_fixed()
455 static void *zend_mm_mmap(size_t size) in zend_mm_mmap() argument
458 void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap()
471 if (zend_mm_use_huge_pages && size == ZEND_MM_CHUNK_SIZE) { in zend_mm_mmap()
472 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0); in zend_mm_mmap()
479 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); in zend_mm_mmap()
491 static void zend_mm_munmap(void *addr, size_t size) in zend_mm_munmap() argument
500 if (munmap(addr, size) != 0) { in zend_mm_munmap()
590 static zend_always_inline int zend_mm_bitset_find_zero(zend_mm_bitset *bitset, int size) argument
600 } while (i < size);
604 static zend_always_inline int zend_mm_bitset_find_one(zend_mm_bitset *bitset, int size) argument
614 } while (i < size);
618 static zend_always_inline int zend_mm_bitset_find_zero_and_set(zend_mm_bitset *bitset, int size) argument
630 } while (i < size);
753 static void *zend_mm_chunk_alloc_int(size_t size, size_t alignment) argument
755 void *ptr = zend_mm_mmap(size);
761 madvise(ptr, size, MADV_HUGEPAGE);
768 zend_mm_munmap(ptr, size);
769 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
772 zend_mm_munmap(ptr, size + alignment - REAL_PAGE_SIZE);
773 ptr = zend_mm_mmap_fixed((void*)((char*)ptr + (alignment - offset)), size);
776 zend_mm_munmap(ptr, size);
789 zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
792 madvise(ptr, size, MADV_HUGEPAGE);
799 static void *zend_mm_chunk_alloc(zend_mm_heap *heap, size_t size, size_t alignment) argument
803 void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment);
808 return zend_mm_chunk_alloc_int(size, alignment);
811 static void zend_mm_chunk_free(zend_mm_heap *heap, void *addr, size_t size) argument
815 heap->storage->handlers.chunk_free(heap->storage, addr, size);
819 zend_mm_munmap(addr, size);
881 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
885 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s…
887 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
895 static void *zend_mm_alloc_pages(zend_mm_heap *heap, int pages_count, size_t size ZEND_FILE_LINE_DC…
1032 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1050 …u) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1059 size_t size = heap->real_size + ZEND_MM_CHUNK_SIZE; local
1060 size_t peak = MAX(heap->real_peak, size);
1061 heap->real_size = size;
1103 static zend_always_inline void *zend_mm_alloc_large(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_…
1105 int pages_count = (int)ZEND_MM_SIZE_TO_NUM(size, ZEND_MM_PAGE_SIZE);
1107 …void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORI…
1113 size_t size = heap->size + pages_count * ZEND_MM_PAGE_SIZE; local
1114 size_t peak = MAX(heap->peak, size);
1115 heap->size = size;
1179 heap->size -= pages_count * ZEND_MM_PAGE_SIZE;
1189 static zend_always_inline int zend_mm_small_size_to_bit(int size) argument
1192 return (__builtin_clz(size) ^ 0x1f) + 1;
1196 if (!BitScanReverse(&index, (unsigned long)size)) {
1204 if (size <= 0x00ff) {n -= 8; size = size << 8;}
1205 if (size <= 0x0fff) {n -= 4; size = size << 4;}
1206 if (size <= 0x3fff) {n -= 2; size = size << 2;}
1207 if (size <= 0x7fff) {n -= 1;}
1220 static zend_always_inline int zend_mm_small_size_to_bin(size_t size) argument
1228 if (UNEXPECTED(size <= 2)) return 0;
1229 n = zend_mm_small_size_to_bit(size - 1);
1230 return ((size-1) >> f1[n]) + f2[n];
1234 if (size <= 64) {
1236 return (size - !!size) >> 3;
1238 t1 = size - 1;
1248 #define ZEND_MM_SMALL_SIZE_TO_BIN(size) zend_mm_small_size_to_bin(size) argument
1286 dbg->size = 0;
1297 dbg->size = 0;
1305 static zend_always_inline void *zend_mm_alloc_small(zend_mm_heap *heap, size_t size, int bin_num ZE… argument
1309 size_t size = heap->size + bin_data_size[bin_num]; local
1310 size_t peak = MAX(heap->peak, size);
1311 heap->size = size;
1330 heap->size -= bin_data_size[bin_num];
1336 dbg->size = 0;
1373 static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D…
1377 size_t real_size = size;
1381 size = MAX(size, 1);
1382 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1383 if (UNEXPECTED(size < real_size)) {
1388 if (size <= ZEND_MM_MAX_SMALL_SIZE) {
1389 …ptr = zend_mm_alloc_small(heap, size, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND…
1392 dbg->size = real_size;
1399 } else if (size <= ZEND_MM_MAX_LARGE_SIZE) {
1400 ptr = zend_mm_alloc_large(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1403 dbg->size = real_size;
1412 size = real_size;
1414 return zend_mm_alloc_huge(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1453 return dbg->size;
1471 static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size ZEND… argument
1485 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1489 real_size = size;
1490 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1492 if (size > ZEND_MM_MAX_LARGE_SIZE) {
1494 size = real_size;
1501 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE));
1503 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE);
1519 heap->size -= old_size - new_size;
1535 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1537 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1550 heap->size += new_size - old_size;
1551 heap->peak = MAX(heap->peak, heap->size);
1567 size_t real_size = size;
1569 size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
1576 if (size <= ZEND_MM_MAX_SMALL_SIZE) {
1577 int bin_num = ZEND_MM_SMALL_SIZE_TO_BIN(size);
1581 dbg->size = real_size;
1593 if (size > ZEND_MM_MAX_SMALL_SIZE && size <= ZEND_MM_MAX_LARGE_SIZE) {
1594 new_size = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE);
1598 dbg->size = real_size;
1611 heap->size -= rest_pages_count * ZEND_MM_PAGE_SIZE;
1618 dbg->size = real_size;
1634 size_t size = heap->size + (new_size - old_size); local
1635 size_t peak = MAX(heap->peak, size);
1636 heap->size = size;
1645 dbg->size = real_size;
1657 size = real_size;
1667 ret = zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1671 heap->peak = MAX(orig_peak, heap->size);
1683 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_size ZEND… argument
1685 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEN…
1690 list->size = size;
1693 list->dbg.size = dbg_size;
1708 size_t size; local
1715 size = list->size;
1717 return size;
1731 return list->size;
1740 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s… argument
1742 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1748 list->size = size;
1750 list->dbg.size = dbg_size;
1762 static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
1769 size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, MAX(REAL_PAGE_SIZE, ZEND_MM_CHUNK_SIZE));
1771 size_t new_size = ZEND_MM_ALIGNED_SIZE_EX(size, REAL_PAGE_SIZE);
1781 …austed at %s:%d (tried to allocate %zu bytes)", heap->limit, __zend_filename, __zend_lineno, size);
1783 …ap, "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->limit, size);
1799 …u) at %s:%d (tried to allocate %zu bytes)", heap->real_size, __zend_filename, __zend_lineno, size);
1801 …_error(heap, "Out of memory (allocated %zu) (tried to allocate %zu bytes)", heap->real_size, size);
1807 …zend_mm_add_huge_block(heap, ptr, new_size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1813 size_t size = heap->real_size + new_size; local
1814 size_t peak = MAX(heap->real_peak, size);
1815 heap->real_size = size;
1819 size_t size = heap->size + new_size; local
1820 size_t peak = MAX(heap->peak, size);
1821 heap->size = size;
1832 size_t size; local
1835 size = zend_mm_del_huge_block(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1836 zend_mm_chunk_free(heap, ptr, size);
1838 heap->real_size -= size;
1841 heap->size -= size;
1886 heap->size = 0;
2029 if (dbg->size != 0) {
2032 dbg->size = 0;
2087 zend_mm_chunk_free(heap, p->ptr, p->size);
2114 leak.size = list->dbg.size;
2129 zend_mm_chunk_free(heap, q->ptr, q->size);
2145 if (dbg->size != 0) {
2147 leak.size = dbg->size;
2156 dbg->size = 0;
2176 leak.size = dbg->size;
2236 zend_mm_chunk_free(heap, q->ptr, q->size);
2303 heap->size = heap->peak = 0;
2312 ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_…
2314 return zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2322 void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC Z…
2324 …return zend_mm_realloc_heap(heap, ptr, size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELA…
2327 void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size … argument
2329 …return zend_mm_realloc_heap(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
2366 # define ZEND_MM_CUSTOM_ALLOCATOR(size) do { \ argument
2369 …return AG(mm_heap)->custom_heap.debug._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
2371 return AG(mm_heap)->custom_heap.std._malloc(size); \
2386 # define ZEND_MM_CUSTOM_ALLOCATOR(size) argument
2398 ZEND_API void* ZEND_FASTCALL _emalloc_large(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2401 ZEND_MM_CUSTOM_ALLOCATOR(size);
2402 return zend_mm_alloc_large(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2405 ZEND_API void* ZEND_FASTCALL _emalloc_huge(size_t size) argument
2408 ZEND_MM_CUSTOM_ALLOCATOR(size);
2409 return zend_mm_alloc_huge(AG(mm_heap), size);
2440 ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
2448 int pages_count = ZEND_MM_ALIGNED_SIZE_EX(size, ZEND_MM_PAGE_SIZE) / ZEND_MM_PAGE_SIZE;
2457 ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) argument
2465 ZEND_API void* ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2471 …return AG(mm_heap)->custom_heap.debug._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
2473 return AG(mm_heap)->custom_heap.std._malloc(size);
2477 return zend_mm_alloc_heap(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2496 ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG…
2501 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2503 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2506 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2509 ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC … argument
2514 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2516 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2519 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
2530 ZEND_API void* ZEND_FASTCALL _safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_… argument
2532 return emalloc_rel(zend_safe_address_guarded(nmemb, size, offset));
2535 ZEND_API void* ZEND_FASTCALL _safe_malloc(size_t nmemb, size_t size, size_t offset) argument
2537 return pemalloc(zend_safe_address_guarded(nmemb, size, offset), 1);
2540 ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEN… argument
2542 return erealloc_rel(ptr, zend_safe_address_guarded(nmemb, size, offset));
2545 ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) argument
2547 return perealloc(ptr, zend_safe_address_guarded(nmemb, size, offset), 1);
2551 ZEND_API void* ZEND_FASTCALL _ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
2555 p = _safe_emalloc(nmemb, size, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2559 memset(p, 0, size * nmemb);
2630 size_t usage = AG(mm_heap)->size;
2837 heap->size = 0;