Skip to content

Commit 5bf89ce

Browse files
author
Andi Gutmans
committed
- Hopefully fix bug php#11476 and improve garbage to be freed very quickly.
Tree tagged as PRE_GRANULAR_GARBAGE_FIX before commiting.
1 parent 7690887 commit 5bf89ce

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

Zend/zend_execute.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,9 @@ ZEND_API void execute(zend_op_array *op_array ELS_DC)
10081008
zend_timeout(0);
10091009
}
10101010
#endif
1011+
1012+
zend_clean_garbage(ELS_C);
1013+
10111014
switch(opline->opcode) {
10121015
case ZEND_ADD:
10131016
EG(binary_op) = add_function;

Zend/zend_execute_locks.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ static inline zend_pzval_lock_func(zval *z)
1313
static inline zend_pzval_unlock_func(zval *z ELS_DC)
1414
{
1515
((z)->refcount--);
16-
if (!(z)->refcount) {
17-
(z)->refcount = 1;
18-
(z)->is_ref = 0;
19-
if (EG(garbage_ptr) == 4) {
20-
zval_ptr_dtor(&EG(garbage)[0]);
21-
zval_ptr_dtor(&EG(garbage)[1]);
22-
EG(garbage)[0] = EG(garbage)[2];
23-
EG(garbage)[1] = EG(garbage)[3];
24-
EG(garbage_ptr) -= 2;
25-
}
26-
EG(garbage)[EG(garbage_ptr)++] = (z);
27-
}
16+
if (!(z)->refcount) {
17+
(z)->refcount = 1;
18+
(z)->is_ref = 0;
19+
EG(garbage)[EG(garbage_ptr)++] = (z);
20+
}
21+
}
22+
23+
static inline zend_clean_garbage(ELS_D)
24+
{
25+
while (EG(garbage_ptr)) {
26+
zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]);
27+
}
2828
}
2929

3030
#define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(pzv); }

Zend/zend_globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ struct _zend_executor_globals {
181181
int (*unary_op)(zval *result, zval *op1);
182182
int (*binary_op)(zval *result, zval *op1, zval *op2);
183183

184-
zval *garbage[4];
184+
zval *garbage[2];
185185
int garbage_ptr;
186186

187187
zval *user_error_handler;

0 commit comments

Comments
 (0)