73# define getpid _getpid
86#ifdef __SANITIZE_ADDRESS__
87# include <sanitizer/asan_interface.h>
94# define MAP_ANON MAP_ANONYMOUS
98# define MAP_FAILED ((void*)-1)
101# define MAP_POPULATE 0
103# if defined(_SC_PAGESIZE) || (_SC_PAGE_SIZE)
104# define REAL_PAGE_SIZE _real_page_size
107# ifdef MAP_ALIGNED_SUPER
108# define MAP_HUGETLB MAP_ALIGNED_SUPER
112#ifndef REAL_PAGE_SIZE
113# define REAL_PAGE_SIZE ZEND_MM_PAGE_SIZE
123# define ZEND_MM_FD -1
125# include <mach/vm_statistics.h>
129# define ZEND_MM_FD VM_MAKE_TAG(250U)
133# define ZEND_MM_STAT 1
136# define ZEND_MM_LIMIT 1
138#ifndef ZEND_MM_CUSTOM
139# define ZEND_MM_CUSTOM 1
142#ifndef ZEND_MM_STORAGE
143# define ZEND_MM_STORAGE 1
146# define ZEND_MM_ERROR 1
148#ifndef ZEND_MM_HEAP_PROTECTION
149# define ZEND_MM_HEAP_PROTECTION 1
152#if ZEND_MM_HEAP_PROTECTION
154# if UINTPTR_MAX == UINT64_MAX
155# define ZEND_MM_MIN_USEABLE_BIN_SIZE 16
156# elif UINTPTR_MAX == UINT32_MAX
157# define ZEND_MM_MIN_USEABLE_BIN_SIZE 8
161# if ZEND_MM_MIN_USEABLE_BIN_SIZE < ZEND_MM_MIN_SMALL_SIZE
165# define ZEND_MM_MIN_USEABLE_BIN_SIZE ZEND_MM_MIN_SMALL_SIZE
169# define ZEND_MM_CHECK(condition, message) do { \
170 if (UNEXPECTED(!(condition))) { \
171 zend_mm_panic(message); \
179#define ZEND_MM_ALIGNED_OFFSET(size, alignment) \
180 (((size_t)(size)) & ((alignment) - 1))
181#define ZEND_MM_ALIGNED_BASE(size, alignment) \
182 (((size_t)(size)) & ~((alignment) - 1))
183#define ZEND_MM_SIZE_TO_NUM(size, alignment) \
184 (((size_t)(size) + ((alignment) - 1)) / (alignment))
186#define ZEND_MM_BITSET_LEN (sizeof(zend_mm_bitset) * 8)
187#define ZEND_MM_PAGE_MAP_LEN (ZEND_MM_PAGES / ZEND_MM_BITSET_LEN)
191#define ZEND_MM_IS_FRUN 0x00000000
192#define ZEND_MM_IS_LRUN 0x40000000
193#define ZEND_MM_IS_SRUN 0x80000000
195#define ZEND_MM_LRUN_PAGES_MASK 0x000003ff
196#define ZEND_MM_LRUN_PAGES_OFFSET 0
198#define ZEND_MM_SRUN_BIN_NUM_MASK 0x0000001f
199#define ZEND_MM_SRUN_BIN_NUM_OFFSET 0
201#define ZEND_MM_SRUN_FREE_COUNTER_MASK 0x01ff0000
202#define ZEND_MM_SRUN_FREE_COUNTER_OFFSET 16
204#define ZEND_MM_NRUN_OFFSET_MASK 0x01ff0000
205#define ZEND_MM_NRUN_OFFSET_OFFSET 16
207#define ZEND_MM_LRUN_PAGES(info) (((info) & ZEND_MM_LRUN_PAGES_MASK) >> ZEND_MM_LRUN_PAGES_OFFSET)
208#define ZEND_MM_SRUN_BIN_NUM(info) (((info) & ZEND_MM_SRUN_BIN_NUM_MASK) >> ZEND_MM_SRUN_BIN_NUM_OFFSET)
209#define ZEND_MM_SRUN_FREE_COUNTER(info) (((info) & ZEND_MM_SRUN_FREE_COUNTER_MASK) >> ZEND_MM_SRUN_FREE_COUNTER_OFFSET)
210#define ZEND_MM_NRUN_OFFSET(info) (((info) & ZEND_MM_NRUN_OFFSET_MASK) >> ZEND_MM_NRUN_OFFSET_OFFSET)
212#define ZEND_MM_FRUN() ZEND_MM_IS_FRUN
213#define ZEND_MM_LRUN(count) (ZEND_MM_IS_LRUN | ((count) << ZEND_MM_LRUN_PAGES_OFFSET))
214#define ZEND_MM_SRUN(bin_num) (ZEND_MM_IS_SRUN | ((bin_num) << ZEND_MM_SRUN_BIN_NUM_OFFSET))
215#define ZEND_MM_SRUN_EX(bin_num, count) (ZEND_MM_IS_SRUN | ((bin_num) << ZEND_MM_SRUN_BIN_NUM_OFFSET) | ((count) << ZEND_MM_SRUN_FREE_COUNTER_OFFSET))
216#define ZEND_MM_NRUN(bin_num, offset) (ZEND_MM_IS_SRUN | ZEND_MM_IS_LRUN | ((bin_num) << ZEND_MM_SRUN_BIN_NUM_OFFSET) | ((offset) << ZEND_MM_NRUN_OFFSET_OFFSET))
218#define ZEND_MM_BINS 30
220#if UINTPTR_MAX == UINT64_MAX
221# define BSWAPPTR(u) ZEND_BYTES_SWAP64(u)
223# define BSWAPPTR(u) ZEND_BYTES_SWAP32(u)
232static bool zend_mm_use_huge_pages =
false;
279#if ZEND_MM_STAT || ZEND_MM_LIMIT
321 char reserve[64 - (
sizeof(
void*) * 3 +
sizeof(uint32_t) * 3)];
348 zend_mm_debug_info
dbg;
352#define ZEND_MM_PAGE_ADDR(chunk, page_num) \
353 ((void*)(((zend_mm_page*)(chunk)) + (page_num)))
355#define _BIN_DATA_SIZE(num, size, elements, pages, x, y) size,
356static const uint32_t bin_data_size[] = {
360#define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y) elements,
361static const uint32_t bin_elements[] = {
365#define _BIN_DATA_PAGES(num, size, elements, pages, x, y) pages,
366static const uint32_t bin_pages[] = {
371ZEND_COLD void zend_debug_alloc_output(
char *format, ...)
376 va_start(
args, format);
390 fprintf(stderr,
"%s\n", message);
395#if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID)
405 const char *filename,
429static void stderr_last_error(
char *
msg)
449static void zend_mm_munmap(
void *
addr,
size_t size)
452 if (VirtualFree(
addr, 0, MEM_RELEASE) == 0) {
454 if (GetLastError() != ERROR_INVALID_ADDRESS) {
456 stderr_last_error(
"VirtualFree() failed");
462 MEMORY_BASIC_INFORMATION mbi;
463 if (VirtualQuery(
addr, &mbi,
sizeof(mbi)) == 0) {
465 stderr_last_error(
"VirtualQuery() failed");
469 addr = mbi.AllocationBase;
471 if (VirtualFree(
addr, 0, MEM_RELEASE) == 0) {
473 stderr_last_error(
"VirtualFree() failed");
487static void *zend_mm_mmap_fixed(
void *
addr,
size_t size)
490 void *
ptr = VirtualAlloc(
addr,
size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
494 if (GetLastError() != ERROR_INVALID_ADDRESS) {
496 stderr_last_error(
"VirtualAlloc() fixed failed");
505 int flags = MAP_PRIVATE | MAP_ANON;
507 flags |= MAP_FIXED | MAP_EXCL;
508#elif defined(MAP_TRYFIXED)
509 flags |= MAP_TRYFIXED;
515#if ZEND_MM_ERROR && !defined(MAP_EXCL) && !defined(MAP_TRYFIXED)
528static void *zend_mm_mmap(
size_t size)
531 void *
ptr = VirtualAlloc(
NULL,
size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
535 stderr_last_error(
"VirtualAlloc() failed");
543#if defined(MAP_HUGETLB) || defined(VM_FLAGS_SUPERPAGE_SIZE_2MB)
546 int mflags = MAP_PRIVATE | MAP_ANON;
547#if defined(MAP_HUGETLB)
548 mflags |= MAP_HUGETLB;
550 fd = VM_FLAGS_SUPERPAGE_SIZE_2MB;
554 zend_mmap_set_name(
ptr,
size,
"zend_alloc");
568 zend_mmap_set_name(
ptr,
size,
"zend_alloc");
580#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) && SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CTZL)
581 return __builtin_ctzl(~bitset);
582#elif (defined(__GNUC__) || __has_builtin(__builtin_ctzll)) && defined(PHP_HAVE_BUILTIN_CTZLL)
583 return __builtin_ctzll(~bitset);
588 if (!BitScanForward64(&index, ~bitset)) {
590 if (!BitScanForward(&index, ~bitset)) {
603#if SIZEOF_ZEND_LONG == 8
605 if ((bitset & 0xffffffff) == 0xffffffff) {
n += 32; bitset = bitset >>
Z_UL(32);}
608 if ((bitset & 0x0000ffff) == 0x0000ffff) {
n += 16; bitset = bitset >> 16;}
609 if ((bitset & 0x000000ff) == 0x000000ff) {
n += 8; bitset = bitset >> 8;}
610 if ((bitset & 0x0000000f) == 0x0000000f) {
n += 4; bitset = bitset >> 4;}
611 if ((bitset & 0x00000003) == 0x00000003) {
n += 2; bitset = bitset >> 2;}
612 return n + (bitset & 1);
634 zend_mm_bitset_set_bit(bitset,
start);
644 bitset[
pos++] |= tmp;
666 zend_mm_bitset_reset_bit(bitset,
start);
675 tmp = ~((
Z_UL(1) << bit) - 1);
676 bitset[
pos++] &= ~tmp;
698 return !zend_mm_bitset_is_set(bitset,
start);
708 if ((bitset[
pos++] & tmp) != 0) {
713 if (bitset[
pos++] != 0) {
720 return (bitset[
pos] & tmp) == 0;
726 return (bitset[
pos] & tmp) == 0;
737#if defined(MADV_HUGEPAGE)
739#elif defined(HAVE_MEMCNTL)
740 struct memcntl_mha m = {.mha_cmd = MHA_MAPSIZE_VA, .mha_pagesize =
ZEND_MM_CHUNK_SIZE, .mha_flags = 0};
741 (
void)memcntl(
ptr,
size, MC_HAT_ADVISE, (
char *)&m, 0, 0);
742#elif !defined(VM_FLAGS_SUPERPAGE_SIZE_2MB) && !defined(MAP_ALIGNED_SUPER)
747static void *zend_mm_chunk_alloc_int(
size_t size,
size_t alignment)
749 void *
ptr = zend_mm_mmap(
size);
754 if (zend_mm_use_huge_pages) {
757#ifdef __SANITIZE_ADDRESS__
758 ASAN_UNPOISON_MEMORY_REGION(
ptr,
size);
796 if (zend_mm_use_huge_pages) {
799# ifdef __SANITIZE_ADDRESS__
800 ASAN_UNPOISON_MEMORY_REGION(
ptr,
size);
807static void *zend_mm_chunk_alloc(
zend_mm_heap *heap,
size_t size,
size_t alignment)
812 ZEND_ASSERT(((uintptr_t)((
char*)
ptr + (alignment-1)) & (alignment-1)) == (uintptr_t)
ptr);
816 return zend_mm_chunk_alloc_int(
size, alignment);
830static int zend_mm_chunk_truncate(
zend_mm_heap *heap,
void *
addr,
size_t old_size,
size_t new_size)
842 zend_mm_munmap((
char*)
addr + new_size, old_size - new_size);
849static int zend_mm_chunk_extend(
zend_mm_heap *heap,
void *
addr,
size_t old_size,
size_t new_size)
862 void *
ptr = mremap(
addr, old_size, new_size, 0);
869#elif !defined(_WIN32)
870 return (zend_mm_mmap_fixed((
char*)
addr + old_size, new_size - old_size) !=
NULL);
887 chunk->num = chunk->prev->num + 1;
918 uint32_t page_num,
len;
922 if (
UNEXPECTED(chunk->free_pages < pages_count)) {
929 page_num = chunk->free_tail;
934 int free_tail = chunk->free_tail;
949 page_num = i + zend_mm_bitset_nts(tmp);
956 if (
len >= pages_count) {
958 }
else if (i >= free_tail) {
964 len = (i + zend_ulong_ntz(tmp)) - page_num;
965 if (
len >= pages_count) {
976 uint32_t free_tail = chunk->free_tail;
996 page_num = i + zend_mm_bitset_nts(tmp);
1004 if (
len >= pages_count &&
len < best_len) {
1005 chunk->free_tail = page_num + pages_count;
1009 chunk->free_tail = page_num;
1021 len = i + zend_ulong_ntz(tmp) - page_num;
1022 if (
len >= pages_count) {
1023 if (
len == pages_count) {
1025 }
else if (
len < best_len) {
1049 zend_mm_safe_error(heap,
"Allowed memory size of %zu bytes exhausted at %s:%d (tried to allocate %zu bytes)", heap->
limit, __zend_filename, __zend_lineno,
size);
1051 zend_mm_safe_error(heap,
"Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->
limit,
ZEND_MM_PAGE_SIZE * pages_count);
1065 zend_mm_safe_error(heap,
"Out of memory");
1067 zend_mm_safe_error(heap,
"Out of memory (allocated %zu bytes) at %s:%d (tried to allocate %zu bytes)", heap->
real_size, __zend_filename, __zend_lineno,
size);
1069 zend_mm_safe_error(heap,
"Out of memory (allocated %zu bytes) (tried to allocate %zu bytes)", heap->
real_size,
ZEND_MM_PAGE_SIZE * pages_count);
1090 zend_mm_chunk_init(heap, chunk);
1095 chunk = chunk->next;
1101 if (steps > 2 && pages_count < 8) {
1102 ZEND_MM_CHECK(chunk->next->prev == chunk,
"zend_mm_heap corrupted");
1103 ZEND_MM_CHECK(chunk->prev->next == chunk,
"zend_mm_heap corrupted");
1106 chunk->prev->next = chunk->next;
1107 chunk->next->prev = chunk->prev;
1114 chunk->free_pages -= pages_count;
1115 zend_mm_bitset_set_range(chunk->free_map, page_num, pages_count);
1117 if (page_num == chunk->free_tail) {
1118 chunk->free_tail = page_num + pages_count;
1149 ZEND_MM_CHECK(chunk->next->prev == chunk,
"zend_mm_heap corrupted");
1150 ZEND_MM_CHECK(chunk->prev->next == chunk,
"zend_mm_heap corrupted");
1152 chunk->next->prev = chunk->prev;
1153 chunk->prev->next = chunk->next;
1163#if ZEND_MM_STAT || ZEND_MM_LIMIT
1187 chunk->free_pages += pages_count;
1188 zend_mm_bitset_reset_range(chunk->free_map, page_num, pages_count);
1189 chunk->map[page_num] = 0;
1190 if (chunk->free_tail == page_num + pages_count) {
1192 chunk->free_tail = page_num;
1195 zend_mm_delete_chunk(heap, chunk);
1201 zend_mm_free_pages_ex(heap, chunk, page_num, pages_count, 1);
1209 zend_mm_free_pages(heap, chunk, page_num, pages_count);
1219#if (defined(__GNUC__) || __has_builtin(__builtin_clz)) && defined(PHP_HAVE_BUILTIN_CLZ)
1220 return (__builtin_clz(
size) ^ 0x1f) + 1;
1221#elif defined(_WIN32)
1222 unsigned long index;
1224 if (!BitScanReverse(&index, (
unsigned long)
size)) {
1229 return (((31 - (
int)index) ^ 0x1f) + 1);
1235 if (
size <= 0x7fff) {
n -= 1;}
1241# define MAX(a, b) (((a) > (b)) ? (a) : (b))
1245# define MIN(a, b) (((a) < (b)) ? (a) : (b))
1253 static const int f1[] = { 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9};
1254 static const int f2[] = { 0, 0, 0, 0, 0, 0, 0, 4, 8, 12, 16, 20, 24};
1257 n = zend_mm_small_size_to_bit(
size - 1);
1258 return ((
size-1) >> f1[
n]) + f2[
n];
1260 unsigned int t1,
t2;
1267 t2 = zend_mm_small_size_to_bit(
t1) - 3;
1271 return (
int)(
t1 +
t2);
1276#define ZEND_MM_SMALL_SIZE_TO_BIN(size) zend_mm_small_size_to_bin(size)
1278#if ZEND_MM_HEAP_PROTECTION
1291#define ZEND_MM_FREE_SLOT_PTR_SHADOW(free_slot, bin_num) \
1292 *((zend_mm_free_slot**)((char*)(free_slot) + bin_data_size[(bin_num)] - sizeof(zend_mm_free_slot*)))
1296#ifdef WORDS_BIGENDIAN
1305#ifdef WORDS_BIGENDIAN
1325 if (
UNEXPECTED(
next != zend_mm_decode_free_slot(heap, shadow))) {
1326 zend_mm_panic(
"zend_mm_heap corrupted");
1333# define zend_mm_set_next_free_slot(heap, bin_num, slot, next) do { \
1334 (slot)->next_free_slot = (next); \
1336# define zend_mm_get_next_free_slot(heap, bin_num, slot) (slot)->next_free_slot
1359 if (bin_pages[bin_num] > 1) {
1365 }
while (i < bin_pages[bin_num]);
1369 end = (
zend_mm_free_slot*)((
char*)bin + (bin_data_size[bin_num] * (bin_elements[bin_num] - 1)));
1372 zend_mm_set_next_free_slot(heap, bin_num,
p, (
zend_mm_free_slot*)((
char*)
p + bin_data_size[bin_num]));
1375 zend_mm_debug_info *
dbg = (zend_mm_debug_info*)((
char*)
p + bin_data_size[bin_num] -
ZEND_MM_ALIGNED_SIZE(
sizeof(zend_mm_debug_info)));
1383 p->next_free_slot =
NULL;
1386 zend_mm_debug_info *
dbg = (zend_mm_debug_info*)((
char*)
p + bin_data_size[bin_num] -
ZEND_MM_ALIGNED_SIZE(
sizeof(zend_mm_debug_info)));
1401 size_t size = heap->
size + bin_data_size[bin_num];
1410 heap->
free_slot[bin_num] = zend_mm_get_next_free_slot(heap, bin_num,
p);
1424 heap->
size -= bin_data_size[bin_num];
1429 zend_mm_debug_info *
dbg = (zend_mm_debug_info*)((
char*)
ptr + bin_data_size[bin_num] -
ZEND_MM_ALIGNED_SIZE(
sizeof(zend_mm_debug_info)));
1435 zend_mm_set_next_free_slot(heap, bin_num,
p, heap->
free_slot[bin_num]);
1454 info = chunk->map[page_num];
1455 ZEND_MM_CHECK(chunk->heap == heap,
"zend_mm_heap corrupted");
1458 return (zend_mm_debug_info*)((
char*)
ptr + bin_data_size[bin_num] -
ZEND_MM_ALIGNED_SIZE(
sizeof(zend_mm_debug_info)));
1470#if ZEND_MM_HEAP_PROTECTION
1476 size_t real_size =
size;
1477 zend_mm_debug_info *
dbg;
1490 dbg = zend_mm_get_debug_info(heap,
ptr);
1491 dbg->size = real_size;
1492 dbg->filename = __zend_filename;
1494 dbg->lineno = __zend_lineno;
1501 dbg = zend_mm_get_debug_info(heap,
ptr);
1502 dbg->size = real_size;
1503 dbg->filename = __zend_filename;
1505 dbg->lineno = __zend_lineno;
1530 ZEND_MM_CHECK(chunk->heap == heap,
"zend_mm_heap corrupted");
1537 zend_mm_free_large(heap, chunk, page_num, pages_count);
1551 zend_mm_debug_info *
dbg = zend_mm_get_debug_info(heap,
ptr);
1559 info = chunk->map[page_num];
1560 ZEND_MM_CHECK(chunk->heap == heap,
"zend_mm_heap corrupted");
1576 size_t orig_peak = heap->
peak;
1614 if (new_size == old_size) {
1621 }
else if (new_size < old_size) {
1623 if (zend_mm_chunk_truncate(heap,
ptr, old_size, new_size)) {
1624#if ZEND_MM_STAT || ZEND_MM_LIMIT
1628 heap->
size -= old_size - new_size;
1644 zend_mm_safe_error(heap,
"Allowed memory size of %zu bytes exhausted at %s:%d (tried to allocate %zu bytes)", heap->
limit, __zend_filename, __zend_lineno,
size);
1646 zend_mm_safe_error(heap,
"Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->
limit,
size);
1653 if (zend_mm_chunk_extend(heap,
ptr, old_size, new_size)) {
1654#if ZEND_MM_STAT || ZEND_MM_LIMIT
1659 heap->
size += new_size - old_size;
1682 zend_mm_debug_info *
dbg;
1696#if ZEND_MM_HEAP_PROTECTION
1702 size_t real_size =
size;
1707 ZEND_MM_CHECK(chunk->heap == heap,
"zend_mm_heap corrupted");
1712 old_size = bin_data_size[old_bin_num];
1715 if (
size <= old_size) {
1717 if (old_bin_num > 0 &&
size < bin_data_size[old_bin_num - 1]) {
1720 copy_size = use_copy_size ?
MIN(
size, copy_size) :
size;
1722 zend_mm_free_small(heap,
ptr, old_bin_num);
1732 size_t orig_peak = heap->
peak;
1735 copy_size = use_copy_size ?
MIN(old_size, copy_size) : old_size;
1737 zend_mm_free_small(heap,
ptr, old_bin_num);
1748 dbg = zend_mm_get_debug_info(heap,
ret);
1749 dbg->size = real_size;
1750 dbg->filename = __zend_filename;
1752 dbg->lineno = __zend_lineno;
1763 if (new_size == old_size) {
1765 dbg = zend_mm_get_debug_info(heap,
ptr);
1766 dbg->size = real_size;
1767 dbg->filename = __zend_filename;
1769 dbg->lineno = __zend_lineno;
1773 }
else if (new_size < old_size) {
1782 chunk->free_pages += rest_pages_count;
1783 zend_mm_bitset_reset_range(chunk->free_map, page_num + new_pages_count, rest_pages_count);
1785 dbg = zend_mm_get_debug_info(heap,
ptr);
1786 dbg->size = real_size;
1787 dbg->filename = __zend_filename;
1789 dbg->lineno = __zend_lineno;
1799 zend_mm_bitset_is_free_range(chunk->free_map, page_num + old_pages_count, new_pages_count - old_pages_count)) {
1802 size_t size = heap->
size + (new_size - old_size);
1808 chunk->free_pages -= new_pages_count - old_pages_count;
1809 zend_mm_bitset_set_range(chunk->free_map, page_num + old_pages_count, new_pages_count - old_pages_count);
1812 dbg = zend_mm_get_debug_info(heap,
ptr);
1813 dbg->size = real_size;
1814 dbg->filename = __zend_filename;
1816 dbg->lineno = __zend_lineno;
1829 copy_size =
MIN(old_size, copy_size);
1848 list->dbg.
size = dbg_size;
1849 list->dbg.filename = __zend_filename;
1851 list->dbg.lineno = __zend_lineno;
1861 while (list !=
NULL) {
1884 while (list !=
NULL) {
1901 while (list !=
NULL) {
1905 list->dbg.
size = dbg_size;
1906 list->dbg.filename = __zend_filename;
1908 list->dbg.lineno = __zend_lineno;
1941 zend_mm_safe_error(heap,
"Allowed memory size of %zu bytes exhausted at %s:%d (tried to allocate %zu bytes)", heap->
limit, __zend_filename, __zend_lineno,
size);
1943 zend_mm_safe_error(heap,
"Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)", heap->
limit,
size);
1957 zend_mm_safe_error(heap,
"Out of memory");
1959 zend_mm_safe_error(heap,
"Out of memory (allocated %zu bytes) at %s:%d (tried to allocate %zu bytes)", heap->
real_size, __zend_filename, __zend_lineno,
size);
1961 zend_mm_safe_error(heap,
"Out of memory (allocated %zu bytes) (tried to allocate %zu bytes)", heap->
real_size,
size);
1979 size_t size = heap->
size + new_size;
1996 zend_mm_chunk_free(heap,
ptr,
size);
1997#if ZEND_MM_STAT || ZEND_MM_LIMIT
2017 zend_mm_refresh_key(heap);
2027 fprintf(stderr,
"Can't initialize heap\n");
2031 heap = &chunk->heap_slot;
2033 chunk->next = chunk;
2034 chunk->prev = chunk;
2048#if ZEND_MM_STAT || ZEND_MM_LIMIT
2056 zend_mm_init_key(heap);
2058 heap->
limit = (size_t)
Z_L(-1) >> 1;
2068 heap->
pid = getpid();
2079 uint32_t i, free_counter;
2080 bool has_free_pages;
2081 size_t collected = 0;
2094 has_free_pages =
false;
2098 ZEND_MM_CHECK(chunk->heap == heap,
"zend_mm_heap corrupted");
2102 info = chunk->map[page_num];
2106 info = chunk->map[page_num];
2112 if (free_counter == bin_elements[i]) {
2113 has_free_pages =
true;
2116 p = zend_mm_get_next_free_slot(heap, i,
p);
2119 if (!has_free_pages) {
2127 ZEND_MM_CHECK(chunk->heap == heap,
"zend_mm_heap corrupted");
2131 info = chunk->map[page_num];
2135 info = chunk->map[page_num];
2142 p = zend_mm_get_next_free_slot(heap, i,
p);
2146 zend_mm_set_next_free_slot(heap, i, q,
p);
2153 p = zend_mm_get_next_free_slot(heap, i, q);
2162 while (i < chunk->free_tail) {
2163 if (zend_mm_bitset_is_set(chunk->free_map, i)) {
2164 info = chunk->map[i];
2167 int pages_count = bin_pages[bin_num];
2171 zend_mm_free_pages_ex(heap, chunk, i, pages_count, 0);
2172 collected += pages_count;
2177 i += bin_pages[bin_num];
2188 zend_mm_delete_chunk(heap, chunk);
2191 chunk = chunk->next;
2210 while (
j < bin_elements[bin_num]) {
2211 if (
dbg->size != 0) {
2222 dbg = (zend_mm_debug_info*)((
char*)
dbg + bin_data_size[bin_num]);
2225 zend_mm_bitset_reset_range(
p->free_map, i, bin_pages[bin_num]);
2235 while (i < p->free_tail) {
2236 if (zend_mm_bitset_is_set(
p->free_map, i)) {
2239 count += zend_mm_find_leaks_small(
p, i, 0, leak);
2240 i += bin_pages[bin_num];
2248 zend_mm_bitset_reset_range(
p->free_map, i, pages_count);
2268 if (
p->dbg.filename == list->dbg.filename &&
p->dbg.lineno == list->dbg.lineno) {
2269 prev->next =
p->next;
2270 zend_mm_chunk_free(heap,
p->ptr,
p->size);
2271 zend_mm_free_heap(heap,
p,
NULL, 0,
NULL, 0);
2298 leak.
filename = list->dbg.filename;
2300 leak.
lineno = list->dbg.lineno;
2305 repeated = zend_mm_find_leaks_huge(heap, list);
2306 total += 1 + repeated;
2312 zend_mm_chunk_free(heap, q->
ptr, q->
size);
2313 zend_mm_free_heap(heap, q,
NULL, 0,
NULL, 0);
2320 while (i < p->free_tail) {
2321 if (zend_mm_bitset_is_set(
p->free_map, i)) {
2327 while (
j < bin_elements[bin_num]) {
2328 if (
dbg->size != 0) {
2343 repeated = zend_mm_find_leaks_small(
p, i,
j + 1, &leak) +
2344 zend_mm_find_leaks(heap,
p, i + bin_pages[bin_num], &leak);
2345 total += 1 + repeated;
2350 dbg = (zend_mm_debug_info*)((
char*)
dbg + bin_data_size[bin_num]);
2353 i += bin_pages[bin_num];
2368 zend_mm_bitset_reset_range(
p->free_map, i, pages_count);
2370 repeated = zend_mm_find_leaks(heap,
p, i + pages_count, &leak);
2371 total += 1 + repeated;
2403 tracked_free_all(heap);
2431 char *tmp =
getenv(
"ZEND_ALLOC_PRINT_LEAKS");
2433 zend_mm_check_leaks(heap);
2444 zend_mm_chunk_free(heap, q->
ptr, q->
size);
2488 p->heap = &
p->heap_slot;
2499#if ZEND_MM_STAT || ZEND_MM_LIMIT
2510 memset(
p->free_map, 0,
sizeof(
p->free_map) +
sizeof(
p->map));
2514 pid_t pid = getpid();
2515 if (heap->
pid != pid) {
2516 zend_mm_init_key(heap);
2519 zend_mm_refresh_key(heap);
2574static int alloc_globals_id;
2575static size_t alloc_globals_offset;
2576# define AG(v) ZEND_TSRMG_FAST(alloc_globals_offset, zend_alloc_globals *, v)
2578# define AG(v) (alloc_globals.v)
2585 return !
AG(mm_heap)->use_custom_heap;
2594 if (
AG(mm_heap)->use_custom_heap) {
2595 if (
AG(mm_heap)->custom_heap._malloc == tracked_malloc) {
2606 if (
AG(mm_heap)->main_chunk) {
2610 if (
ptr >= (
void*)chunk
2614 chunk = chunk->next;
2615 }
while (chunk !=
AG(mm_heap)->main_chunk);
2620 if (
ptr >= block->ptr
2621 &&
ptr < (
void*)((
char*)block->ptr + block->size)) {
2624 block = block->next;
2630#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P)
2634# define ZEND_MM_CUSTOM_ALLOCATOR(size) do { \
2635 if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) { \
2636 return AG(mm_heap)->custom_heap._malloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); \
2639# define ZEND_MM_CUSTOM_DEALLOCATOR(ptr) do { \
2640 if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) { \
2641 AG(mm_heap)->custom_heap._free(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); \
2646# define ZEND_MM_CUSTOM_ALLOCATOR(size)
2647# define ZEND_MM_CUSTOM_DEALLOCATOR(ptr)
2650# define _ZEND_BIN_ALLOCATOR(_num, _size, _elements, _pages, _min_size, y) \
2651 ZEND_API void* ZEND_FASTCALL _emalloc_ ## _size(void) { \
2652 ZEND_MM_CUSTOM_ALLOCATOR(_size); \
2653 if (_size < _min_size) { \
2654 return _emalloc_ ## _min_size(); \
2656 return zend_mm_alloc_small(AG(mm_heap), _num ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); \
2663 ZEND_MM_CUSTOM_ALLOCATOR(
size);
2669 ZEND_MM_CUSTOM_ALLOCATOR(
size);
2670 return zend_mm_alloc_huge(
AG(mm_heap),
size);
2674# define _ZEND_BIN_FREE(_num, _size, _elements, _pages, _min_size, y) \
2675 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2676 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2677 if (_size < _min_size) { \
2678 _efree_ ## _min_size(ptr); \
2682 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE); \
2683 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2684 int page_num = page_offset / ZEND_MM_PAGE_SIZE; \
2685 ZEND_MM_CHECK(chunk->heap == AG(mm_heap), "zend_mm_heap corrupted"); \
2686 ZEND_ASSERT(chunk->map[page_num] & ZEND_MM_IS_SRUN); \
2687 ZEND_ASSERT(ZEND_MM_SRUN_BIN_NUM(chunk->map[page_num]) == _num); \
2688 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2692# define _ZEND_BIN_FREE(_num, _size, _elements, _pages, _min_size, y) \
2693 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2694 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2695 if (_size < _min_size) { \
2696 _efree_ ## _min_size(ptr); \
2700 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2701 ZEND_MM_CHECK(chunk->heap == AG(mm_heap), "zend_mm_heap corrupted"); \
2702 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2711 ZEND_MM_CUSTOM_DEALLOCATOR(
ptr);
2721 zend_mm_free_large(
AG(mm_heap), chunk, page_num, pages_count);
2728 ZEND_MM_CUSTOM_DEALLOCATOR(
ptr);
2729 zend_mm_free_huge(
AG(mm_heap),
ptr);
2803 size = zend_safe_address_guarded(nmemb,
size, 0);
2845 p = (
char *) malloc(length + 1);
2847 zend_out_of_memory();
2861 if (
UNEXPECTED(memory_limit < heap->real_size)) {
2870 }
while (memory_limit < heap->real_size);
2875 AG(mm_heap)->limit = memory_limit;
2883 return AG(mm_heap)->overflow;
2893 return AG(mm_heap)->real_size;
2895 size_t usage =
AG(mm_heap)->size;
2906 return AG(mm_heap)->real_peak;
2908 return AG(mm_heap)->peak;
2917 AG(mm_heap)->real_peak =
AG(mm_heap)->real_size;
2918 AG(mm_heap)->peak =
AG(mm_heap)->size;
2929 fprintf(stderr,
"Out of memory\n");
2937 ZEND_ASSERT((
void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2) ==
ptr);
2945 ZEND_ASSERT(size_zv &&
"Trying to free pointer not allocated through ZendMM");
2952 zend_mm_safe_error(heap,
2953 "Allowed memory size of %zu bytes exhausted at %s:%d (tried to allocate %zu bytes)",
2954 heap->
limit,
"file", 0, add_size);
2956 zend_mm_safe_error(heap,
2957 "Allowed memory size of %zu bytes exhausted (tried to allocate %zu bytes)",
2958 heap->
limit, add_size);
2966 tracked_check_limit(heap,
size);
2970 zend_out_of_memory();
2984 zval *size_zv = tracked_get_size_zv(heap,
ptr);
2993 size_t old_size = 0;
2995 old_size_zv = tracked_get_size_zv(heap,
ptr);
2999 if (new_size > old_size) {
3000 tracked_check_limit(heap, new_size - old_size);
3009 tracked_add(heap,
ptr, new_size);
3010 heap->
size += new_size - old_size;
3018 void *
ptr = (
void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2);
3029 tmp =
getenv(
"USE_ZEND_ALLOC");
3035 mm_heap->
limit = (size_t)
Z_L(-1) >> 1;
3055 tmp =
getenv(
"USE_ZEND_ALLOC_HUGE_PAGES");
3057 zend_mm_use_huge_pages =
true;
3059 alloc_globals->mm_heap = zend_mm_init();
3072# if defined(_SC_PAGESIZE)
3074# elif defined(_SC_PAGE_SIZE)
3079 ts_allocate_fast_id(&alloc_globals_id, &alloc_globals_offset,
sizeof(
zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
3081 alloc_globals_ctor(&alloc_globals);
3089 old_heap =
AG(mm_heap);
3102 return AG(mm_heap)->use_custom_heap;
3122 size_t (*_gc)(
void),
3123 void (*_shutdown)(
bool,
bool))
3128 if (!_malloc && !_free && !_realloc) {
3155 size_t (**_gc)(
void),
3156 void (**_shutdown)(
bool,
bool))
3168 if (_shutdown !=
NULL) {
3178 if (_shutdown !=
NULL) {
3202 return zend_mm_init();
3217 fprintf(stderr,
"Can't initialize heap\n");
3221 heap = &chunk->heap_slot;
3223 chunk->next = chunk;
3224 chunk->prev = chunk;
3238#if ZEND_MM_STAT || ZEND_MM_LIMIT
3246 zend_mm_init_key(heap);
3248 heap->
limit = (size_t)
Z_L(-1) >> 1;
3261 fprintf(stderr,
"Can't initialize heap\n");
3271 heap->
pid = getpid();
3280 void *tmp = malloc(
len);
3284 zend_out_of_memory();
3291 len = zend_safe_address_guarded(nmemb,
len, 0);
3299 p = realloc(
p,
len);
3303 zend_out_of_memory();
3314 char *tmp = strdup(
s);
3318 zend_out_of_memory();
3322size_t zend_mm_globals_size(
void)
fprintf($stream, string $format, mixed ... $values)
getenv(?string $name=null, bool $local_only=false)
prev(array|object &$array)
vsprintf(string $format, array $values)
count(Countable|array $value, int $mode=COUNT_NORMAL)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
#define __zend_orig_filename
#define __zend_orig_lineno
unsigned const char * end
unsigned const char * pos
const char * orig_filename
char bytes[ZEND_MM_PAGE_SIZE *8]
zend_mm_page_info map[ZEND_MM_PAGES]
char reserve[64 -(sizeof(void *) *3+sizeof(uint32_t) *3)]
zend_mm_page_map free_map
zend_mm_free_slot * next_free_slot
zend_mm_chunk_extend_t chunk_extend
zend_mm_chunk_truncate_t chunk_truncate
zend_mm_chunk_alloc_t chunk_alloc
zend_mm_chunk_free_t chunk_free
HashTable * tracked_allocs
void(* _shutdown)(bool full, bool silent)
struct _zend_mm_heap::@141134307255302353166333233161222346252336363001 custom_heap
zend_mm_chunk * cached_chunks
void *(* _malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
zend_random_bytes_insecure_state rand_state
void *(* _realloc)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
zend_mm_free_slot * free_slot[ZEND_MM_BINS]
zend_mm_storage * storage
int last_chunks_delete_boundary
int last_chunks_delete_count
void(* _free)(void *ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
zend_mm_huge_list * huge_list
zend_mm_chunk * main_chunk
char bytes[ZEND_MM_PAGE_SIZE]
const zend_mm_handlers handlers
PHP_WINUTIL_API char * php_win32_error_to_msg(HRESULT error)
PHP_WINUTIL_API void php_win32_error_msg_free(char *msg)
ZEND_ATTRIBUTE_NONNULL ZEND_API void(* zend_random_bytes_insecure)(zend_random_bytes_insecure_state *state, void *bytes, size_t size)
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format,...)
ZEND_API void zend_message_dispatcher(zend_long message, const void *data)
#define ZMSG_MEMORY_LEAK_DETECTED
#define ZMSG_MEMORY_LEAK_REPEATED
#define ZMSG_MEMORY_LEAKS_GRAND_TOTAL
#define ZMSG_LOG_SCRIPT_NAME
#define _BIN_DATA_ELEMENTS(num, size, elements, pages, x, y)
#define ZEND_MM_SRUN_FREE_COUNTER(info)
ZEND_API void *ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
struct _zend_alloc_globals zend_alloc_globals
ZEND_API void *ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#define _BIN_DATA_SIZE(num, size, elements, pages, x, y)
ZEND_API void *ZEND_FASTCALL _safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void * __zend_calloc(size_t nmemb, size_t len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#define ZEND_MM_ALIGNED_BASE(size, alignment)
#define ZEND_MM_LRUN(count)
ZEND_API void * __zend_realloc(void *p, size_t len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void __zend_free(void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void start_memory_manager(void)
#define ZEND_MM_BITSET_LEN
struct _zend_mm_free_slot zend_mm_free_slot
ZEND_API char *ZEND_FASTCALL _estrndup(const char *s, size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API size_t zend_memory_usage(bool real_usage)
ZEND_API char *ZEND_FASTCALL _estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
struct _zend_mm_huge_list zend_mm_huge_list
ZEND_API char *ZEND_FASTCALL zend_strndup(const char *s, size_t length)
ZEND_API void *ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#define ZEND_MM_SMALL_SIZE_TO_BIN(size)
ZEND_API void zend_mm_get_custom_handlers_ex(zend_mm_heap *heap, void *(**_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void(**_free)(void *ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void *(**_realloc)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), size_t(**_gc)(void), void(**_shutdown)(bool, bool))
ZEND_API void * __zend_malloc(size_t len ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
void *ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap)
ZEND_API zend_mm_heap * zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size)
ZEND_API bool zend_alloc_in_memory_limit_error_reporting(void)
#define ZEND_MM_SIZE_TO_NUM(size, alignment)
struct _zend_mm_bin zend_mm_bin
#define ZEND_MM_PAGE_ADDR(chunk, page_num)
struct _zend_mm_page zend_mm_page
#define ZEND_MM_SRUN_BIN_NUM(info)
uint32_t zend_mm_page_info
ZEND_API void *ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset)
ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap, void *(*_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void(*_free)(void *ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void *(*_realloc)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC))
#define ZEND_MM_FREE_SLOT_PTR_SHADOW(free_slot, bin_num)
ZEND_API void *ZEND_FASTCALL _safe_malloc(size_t nmemb, size_t size, size_t offset)
#define ZEND_MM_CHECK(condition, message)
ZEND_API char * __zend_strdup(const char *s)
ZEND_API bool is_zend_mm(void)
ZEND_API void zend_memory_reset_peak_usage(void)
zend_ulong zend_mm_bitset
ZEND_API size_t zend_memory_peak_usage(bool real_usage)
#define _BIN_DATA_PAGES(num, size, elements, pages, x, y)
ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API zend_mm_storage * zend_mm_get_storage(zend_mm_heap *heap)
#define ZEND_MM_SRUN_EX(bin_num, count)
#define ZEND_MM_PAGE_MAP_LEN
void *ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API zend_result zend_set_memory_limit(size_t memory_limit)
ZEND_API zend_mm_heap * zend_mm_set_heap(zend_mm_heap *new_heap)
#define ZEND_MM_MIN_USEABLE_BIN_SIZE
#define ZEND_MM_NRUN_OFFSET(info)
#define ZEND_MM_SRUN(bin_num)
ZEND_API size_t ZEND_FASTCALL _zend_mem_block_size(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void zend_mm_set_custom_handlers_ex(zend_mm_heap *heap, void *(*_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void(*_free)(void *ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void *(*_realloc)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), size_t(*_gc)(void), void(*_shutdown)(bool, bool))
ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
#define ZEND_MM_NRUN(bin_num, offset)
zend_mm_bitset zend_mm_page_map[ZEND_MM_PAGE_MAP_LEN]
#define ZEND_MM_LRUN_PAGES(info)
ZEND_API void zend_mm_get_custom_handlers(zend_mm_heap *heap, void *(**_malloc)(size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void(**_free)(void *ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC), void *(**_realloc)(void *, size_t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC))
ZEND_API void *ZEND_FASTCALL _ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API bool is_zend_ptr(const void *ptr)
struct _zend_mm_chunk zend_mm_chunk
ZEND_API zend_mm_heap * zend_mm_get_heap(void)
ZEND_API zend_mm_heap * zend_mm_startup(void)
ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown)
ZEND_API void *ZEND_FASTCALL _emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void *ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
#define ZEND_MM_ALIGNED_OFFSET(size, alignment)
struct _zend_mm_storage zend_mm_storage
#define ZEND_MM_ALIGNED_SIZE_EX(size, alignment)
#define ZEND_MM_CUSTOM_HEAP_STD
struct _zend_mm_handlers zend_mm_handlers
#define perealloc(ptr, size, persistent)
#define ZEND_MM_ALIGNED_SIZE(size)
#define pemalloc(size, persistent)
struct _zend_leak_info zend_leak_info
struct _zend_mm_heap zend_mm_heap
#define ZEND_MM_CUSTOM_HEAP_NONE
#define ZEND_MM_PAGE_SIZE
#define ZEND_MM_MAX_SMALL_SIZE
#define ZEND_MM_FIRST_PAGE
#define ZEND_MM_MAX_LARGE_SIZE
#define ZEND_MM_CHUNK_SIZE
#define ZEND_MM_BINS_INFO(_, x, y)
exit(string|int $status=0)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
ZEND_API zval *ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData)
ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht)
ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p)
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
#define ZEND_HASH_FOREACH_NUM_KEY(ht, _h)
#define ZEND_HASH_FOREACH_END()
#define ZEND_ATTRIBUTE_CONST
#define zend_never_inline
#define EXPECTED(condition)
#define ZEND_FILE_LINE_DC
#define zend_always_inline
#define ZEND_FILE_LINE_ORIG_RELAY_CC
#define ZEND_BIT_TEST(bits, bit)
#define ZEND_FILE_LINE_EMPTY_CC
#define ZEND_FILE_LINE_CC
#define UNEXPECTED(condition)
#define ZEND_FILE_LINE_RELAY_CC
#define ZEND_FILE_LINE_ORIG_DC
struct _zend_array HashTable
ZEND_RESULT_CODE zend_result