Skip to content

Commit 8603a98

Browse files
committed
Improve
1 parent 8765994 commit 8603a98

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Zend/zend_alloc.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ static zend_always_inline zend_mm_free_slot* zend_mm_decode_free_slot(zend_mm_he
13981398
#endif
13991399
}
14001400

1401-
static zend_always_inline void zend_mm_set_next_free_slot(const char *from, zend_mm_heap *heap, uint32_t bin_num, zend_mm_free_slot *slot, zend_mm_free_slot *next)
1401+
static zend_always_inline void zend_mm_set_next_free_slot(zend_mm_heap *heap, uint32_t bin_num, zend_mm_free_slot *slot, zend_mm_free_slot *next)
14021402
{
14031403
ZEND_ASSERT(bin_data_size[bin_num] >= ZEND_MM_MIN_USEABLE_BIN_SIZE);
14041404

@@ -1450,6 +1450,8 @@ static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, uint
14501450
/* insufficient memory */
14511451
return NULL;
14521452
}
1453+
// bin is poisoned, do not unpoision inside this function
1454+
// zend_mm_set_next_free_slot automatically unpoisons and repoisons before return
14531455

14541456
chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(bin, ZEND_MM_CHUNK_SIZE);
14551457

@@ -1465,13 +1467,12 @@ static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, uint
14651467
} while (i < bin_pages[bin_num]);
14661468
}
14671469
ZEND_MM_POISON_CHUNK_HDR(chunk, heap);
1468-
ZEND_MM_UNPOISON_HEAP(heap);
14691470

14701471
/* create a linked list of elements from 1 to last */
14711472
end = (zend_mm_free_slot*)((char*)bin + (bin_data_size[bin_num] * (bin_elements[bin_num] - 1)));
14721473
heap->free_slot[bin_num] = p = (zend_mm_free_slot*)((char*)bin + bin_data_size[bin_num]);
14731474
do {
1474-
zend_mm_set_next_free_slot("alloc_small", heap, bin_num, p, (zend_mm_free_slot*)((char*)p + bin_data_size[bin_num]));
1475+
zend_mm_set_next_free_slot(heap, bin_num, p, (zend_mm_free_slot*)((char*)p + bin_data_size[bin_num]));
14751476
#if ZEND_DEBUG
14761477
do {
14771478
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)));
@@ -1482,7 +1483,7 @@ static zend_never_inline void *zend_mm_alloc_small_slow(zend_mm_heap *heap, uint
14821483
p = (zend_mm_free_slot*)((char*)p + bin_data_size[bin_num]);
14831484
} while (p != end);
14841485

1485-
zend_mm_set_next_free_slot("alloc_small", heap, bin_num, p, NULL);
1486+
zend_mm_set_next_free_slot(heap, bin_num, p, NULL);
14861487

14871488
#if ZEND_DEBUG
14881489
do {
@@ -1536,7 +1537,7 @@ static zend_always_inline void zend_mm_free_small(zend_mm_heap *heap, void *ptr,
15361537
#endif
15371538

15381539
p = (zend_mm_free_slot*)ptr;
1539-
zend_mm_set_next_free_slot("free_small", heap, bin_num, p, heap->free_slot[bin_num]);
1540+
zend_mm_set_next_free_slot(heap, bin_num, p, heap->free_slot[bin_num]);
15401541
heap->free_slot[bin_num] = p;
15411542

15421543
ZEND_MM_POISON(p, bin_data_size[bin_num]);
@@ -2291,7 +2292,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
22912292
if (q == (zend_mm_free_slot*)&heap->free_slot[i]) {
22922293
q->next_free_slot = p;
22932294
} else {
2294-
zend_mm_set_next_free_slot("gc", heap, i, q, p);
2295+
zend_mm_set_next_free_slot(heap, i, q, p);
22952296
}
22962297
} else {
22972298
q = p;

0 commit comments

Comments
 (0)