Lines Matching refs:chunk
352 #define ZEND_MM_PAGE_ADDR(chunk, page_num) \ argument
353 ((void*)(((zend_mm_page*)(chunk)) + (page_num)))
876 static zend_always_inline void zend_mm_chunk_init(zend_mm_heap *heap, zend_mm_chunk *chunk) argument
878 chunk->heap = heap;
879 chunk->next = heap->main_chunk;
880 chunk->prev = heap->main_chunk->prev;
881 chunk->prev->next = chunk;
882 chunk->next->prev = chunk;
884 chunk->free_pages = ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE;
885 chunk->free_tail = ZEND_MM_FIRST_PAGE;
887 chunk->num = chunk->prev->num + 1;
889 chunk->free_map[0] = (1L << ZEND_MM_FIRST_PAGE) - 1;
890 chunk->map[0] = ZEND_MM_LRUN(ZEND_MM_FIRST_PAGE);
917 zend_mm_chunk *chunk = heap->main_chunk; local
922 if (UNEXPECTED(chunk->free_pages < pages_count)) {
925 } else if (UNEXPECTED(chunk->free_pages + chunk->free_tail == ZEND_MM_PAGES)) {
926 if (UNEXPECTED(ZEND_MM_PAGES - chunk->free_tail < pages_count)) {
929 page_num = chunk->free_tail;
934 int free_tail = chunk->free_tail;
935 zend_mm_bitset *bitset = chunk->free_map;
976 uint32_t free_tail = chunk->free_tail;
977 zend_mm_bitset *bitset = chunk->free_map;
1005 chunk->free_tail = page_num + pages_count;
1009 chunk->free_tail = page_num;
1036 if (chunk->next == heap->main_chunk) {
1040 chunk = heap->cached_chunks;
1041 heap->cached_chunks = chunk->next;
1057 chunk = (zend_mm_chunk*)zend_mm_chunk_alloc(heap, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE);
1058 if (UNEXPECTED(chunk == NULL)) {
1061 …(chunk = (zend_mm_chunk*)zend_mm_chunk_alloc(heap, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE)) != NUL…
1090 zend_mm_chunk_init(heap, chunk);
1095 chunk = chunk->next;
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;
1108 chunk->next = heap->main_chunk->next;
1109 chunk->prev = heap->main_chunk;
1110 chunk->prev->next = chunk;
1111 chunk->next->prev = chunk;
1114 chunk->free_pages -= pages_count;
1115 zend_mm_bitset_set_range(chunk->free_map, page_num, pages_count);
1116 chunk->map[page_num] = ZEND_MM_LRUN(pages_count);
1117 if (page_num == chunk->free_tail) {
1118 chunk->free_tail = page_num + pages_count;
1120 return ZEND_MM_PAGE_ADDR(chunk, page_num);
1147 static zend_always_inline void zend_mm_delete_chunk(zend_mm_heap *heap, zend_mm_chunk *chunk) argument
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;
1160 chunk->next = heap->cached_chunks;
1161 heap->cached_chunks = chunk;
1174 if (!heap->cached_chunks || chunk->num > heap->cached_chunks->num) {
1175 zend_mm_chunk_free(heap, chunk, ZEND_MM_CHUNK_SIZE);
1178 chunk->next = heap->cached_chunks->next;
1180 heap->cached_chunks = chunk;
1185 static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm_chunk *chunk, uint… argument
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;
1194 …if (free_chunk && chunk != heap->main_chunk && chunk->free_pages == ZEND_MM_PAGES - ZEND_MM_FIRST_…
1195 zend_mm_delete_chunk(heap, chunk);
1199 static zend_never_inline void zend_mm_free_pages(zend_mm_heap *heap, zend_mm_chunk *chunk, int page… argument
1201 zend_mm_free_pages_ex(heap, chunk, page_num, pages_count, 1);
1204 static zend_always_inline void zend_mm_free_large(zend_mm_heap *heap, zend_mm_chunk *chunk, int pag… argument
1209 zend_mm_free_pages(heap, chunk, page_num, pages_count);
1341 zend_mm_chunk *chunk; local
1356 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(bin, ZEND_MM_CHUNK_SIZE);
1358 chunk->map[page_num] = ZEND_MM_SRUN(bin_num);
1363 chunk->map[page_num+i] = ZEND_MM_NRUN(bin_num, i);
1447 zend_mm_chunk *chunk; local
1452 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1454 info = chunk->map[page_num];
1455 ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
1526 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); local
1528 zend_mm_page_info info = chunk->map[page_num];
1530 ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
1537 zend_mm_free_large(heap, chunk, page_num, pages_count);
1549 zend_mm_chunk *chunk; local
1557 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1559 info = chunk->map[page_num];
1560 ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
1693 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); local
1695 zend_mm_page_info info = chunk->map[page_num];
1707 ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
1781 chunk->map[page_num] = ZEND_MM_LRUN(new_pages_count);
1782 chunk->free_pages += rest_pages_count;
1783 zend_mm_bitset_reset_range(chunk->free_map, page_num + new_pages_count, rest_pages_count);
1799 …zend_mm_bitset_is_free_range(chunk->free_map, page_num + old_pages_count, new_pages_count - old_pa…
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_…
1810 chunk->map[page_num] = ZEND_MM_LRUN(new_pages_count);
2022 …zend_mm_chunk *chunk = (zend_mm_chunk*)zend_mm_chunk_alloc_int(ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_S… local
2025 if (UNEXPECTED(chunk == NULL)) {
2031 heap = &chunk->heap_slot;
2032 chunk->heap = heap;
2033 chunk->next = chunk;
2034 chunk->prev = chunk;
2035 chunk->free_pages = ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE;
2036 chunk->free_tail = ZEND_MM_FIRST_PAGE;
2037 chunk->num = 0;
2038 chunk->free_map[0] = (Z_L(1) << ZEND_MM_FIRST_PAGE) - 1;
2039 chunk->map[0] = ZEND_MM_LRUN(ZEND_MM_FIRST_PAGE);
2040 heap->main_chunk = chunk;
2075 zend_mm_chunk *chunk; local
2097 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(p, ZEND_MM_CHUNK_SIZE);
2098 ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
2102 info = chunk->map[page_num];
2106 info = chunk->map[page_num];
2115 chunk->map[page_num] = ZEND_MM_SRUN_EX(i, free_counter);
2126 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(p, ZEND_MM_CHUNK_SIZE);
2127 ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
2131 info = chunk->map[page_num];
2135 info = chunk->map[page_num];
2159 chunk = heap->main_chunk;
2162 while (i < chunk->free_tail) {
2163 if (zend_mm_bitset_is_set(chunk->free_map, i)) {
2164 info = chunk->map[i];
2171 zend_mm_free_pages_ex(heap, chunk, i, pages_count, 0);
2175 chunk->map[i] = ZEND_MM_SRUN(bin_num);
2185 if (chunk->free_pages == ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE) {
2186 zend_mm_chunk *next_chunk = chunk->next;
2188 zend_mm_delete_chunk(heap, chunk);
2189 chunk = next_chunk;
2191 chunk = chunk->next;
2193 } while (chunk != heap->main_chunk);
2607 zend_mm_chunk *chunk = AG(mm_heap)->main_chunk; local
2610 if (ptr >= (void*)chunk
2611 && ptr < (void*)((char*)chunk + ZEND_MM_CHUNK_SIZE)) {
2614 chunk = chunk->next;
2615 } while (chunk != AG(mm_heap)->main_chunk);
2683 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_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); \
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"); \
2714 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); local
2718 …ZEND_MM_CHECK(chunk->heap == AG(mm_heap) && ZEND_MM_ALIGNED_OFFSET(page_offset, ZEND_MM_PAGE_SIZE)…
2719 ZEND_ASSERT(chunk->map[page_num] & ZEND_MM_IS_LRUN);
2720 ZEND_ASSERT(ZEND_MM_LRUN_PAGES(chunk->map[page_num]) == pages_count);
2721 zend_mm_free_large(AG(mm_heap), chunk, page_num, pages_count);
3209 zend_mm_chunk *chunk; local
3214 …chunk = (zend_mm_chunk*)handlers->chunk_alloc(&tmp_storage, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE…
3215 if (UNEXPECTED(chunk == NULL)) {
3221 heap = &chunk->heap_slot;
3222 chunk->heap = heap;
3223 chunk->next = chunk;
3224 chunk->prev = chunk;
3225 chunk->free_pages = ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE;
3226 chunk->free_tail = ZEND_MM_FIRST_PAGE;
3227 chunk->num = 0;
3228 chunk->free_map[0] = (Z_L(1) << ZEND_MM_FIRST_PAGE) - 1;
3229 chunk->map[0] = ZEND_MM_LRUN(ZEND_MM_FIRST_PAGE);
3230 heap->main_chunk = chunk;
3259 handlers->chunk_free(&tmp_storage, chunk, ZEND_MM_CHUNK_SIZE);