@@ -1175,10 +1175,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
1175
1175
ht = NULL ;
1176
1176
if (!n ) goto next ;
1177
1177
while (!Z_REFCOUNTED_P (-- end )) {
1178
- /* count non-refcounted for compatibility ??? */
1179
- if (Z_TYPE_P (zv ) != IS_UNDEF ) {
1180
- count ++ ;
1181
- }
1182
1178
if (zv == end ) goto next ;
1183
1179
}
1184
1180
} else {
@@ -1192,9 +1188,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
1192
1188
GC_REF_SET_BLACK (ref );
1193
1189
GC_STACK_PUSH (ref );
1194
1190
}
1195
- /* count non-refcounted for compatibility ??? */
1196
- } else if (Z_TYPE_P (zv ) != IS_UNDEF ) {
1197
- count ++ ;
1198
1191
}
1199
1192
zv ++ ;
1200
1193
}
@@ -1242,10 +1235,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
1242
1235
if (Z_REFCOUNTED_P (zv )) {
1243
1236
break ;
1244
1237
}
1245
- /* count non-refcounted for compatibility ??? */
1246
- if (Z_TYPE_P (zv ) != IS_UNDEF ) {
1247
- count ++ ;
1248
- }
1249
1238
if (p == end ) goto next ;
1250
1239
}
1251
1240
while (p != end ) {
@@ -1260,9 +1249,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
1260
1249
GC_REF_SET_BLACK (ref );
1261
1250
GC_STACK_PUSH (ref );
1262
1251
}
1263
- /* count non-refcounted for compatibility ??? */
1264
- } else if (Z_TYPE_P (zv ) != IS_UNDEF ) {
1265
- count ++ ;
1266
1252
}
1267
1253
p ++ ;
1268
1254
}
@@ -1324,11 +1310,12 @@ static int gc_collect_roots(uint32_t *flags, gc_stack *stack)
1324
1310
return count ;
1325
1311
}
1326
1312
1327
- static void gc_remove_nested_data_from_buffer (zend_refcounted * ref , gc_root_buffer * root )
1313
+ static int gc_remove_nested_data_from_buffer (zend_refcounted * ref , gc_root_buffer * root )
1328
1314
{
1329
1315
HashTable * ht = NULL ;
1330
1316
Bucket * p , * end ;
1331
1317
zval * zv ;
1318
+ int count = 0 ;
1332
1319
1333
1320
tail_call :
1334
1321
do {
@@ -1337,18 +1324,20 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
1337
1324
gc_remove_from_roots (root );
1338
1325
GC_REF_SET_INFO (ref , 0 );
1339
1326
root = NULL ;
1327
+ count ++ ;
1340
1328
} else if (GC_REF_ADDRESS (ref ) != 0
1341
1329
&& GC_REF_CHECK_COLOR (ref , GC_BLACK )) {
1342
1330
GC_TRACE_REF (ref , "removing from buffer" );
1343
1331
GC_REMOVE_FROM_BUFFER (ref );
1332
+ count ++ ;
1344
1333
} else if (GC_TYPE (ref ) == IS_REFERENCE ) {
1345
1334
if (Z_REFCOUNTED (((zend_reference * )ref )-> val )) {
1346
1335
ref = Z_COUNTED (((zend_reference * )ref )-> val );
1347
1336
goto tail_call ;
1348
1337
}
1349
- return ;
1338
+ return count ;
1350
1339
} else {
1351
- return ;
1340
+ return count ;
1352
1341
}
1353
1342
1354
1343
if (GC_TYPE (ref ) == IS_OBJECT ) {
@@ -1361,15 +1350,15 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
1361
1350
ht = obj -> handlers -> get_gc (obj , & zv , & n );
1362
1351
end = zv + n ;
1363
1352
if (EXPECTED (!ht )) {
1364
- if (!n ) return ;
1353
+ if (!n ) return count ;
1365
1354
while (!Z_REFCOUNTED_P (-- end )) {
1366
- if (zv == end ) return ;
1355
+ if (zv == end ) return count ;
1367
1356
}
1368
1357
}
1369
1358
while (zv != end ) {
1370
1359
if (Z_REFCOUNTED_P (zv )) {
1371
1360
ref = Z_COUNTED_P (zv );
1372
- gc_remove_nested_data_from_buffer (ref , NULL );
1361
+ count += gc_remove_nested_data_from_buffer (ref , NULL );
1373
1362
}
1374
1363
zv ++ ;
1375
1364
}
@@ -1378,15 +1367,15 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
1378
1367
goto tail_call ;
1379
1368
}
1380
1369
} else {
1381
- return ;
1370
+ return count ;
1382
1371
}
1383
1372
} else if (GC_TYPE (ref ) == IS_ARRAY ) {
1384
1373
ht = (zend_array * )ref ;
1385
1374
} else {
1386
- return ;
1375
+ return count ;
1387
1376
}
1388
1377
1389
- if (!ht -> nNumUsed ) return ;
1378
+ if (!ht -> nNumUsed ) return count ;
1390
1379
p = ht -> arData ;
1391
1380
end = p + ht -> nNumUsed ;
1392
1381
while (1 ) {
@@ -1398,7 +1387,7 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
1398
1387
if (Z_REFCOUNTED_P (zv )) {
1399
1388
break ;
1400
1389
}
1401
- if (p == end ) return ;
1390
+ if (p == end ) return count ;
1402
1391
}
1403
1392
while (p != end ) {
1404
1393
zv = & p -> val ;
@@ -1407,7 +1396,7 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
1407
1396
}
1408
1397
if (Z_REFCOUNTED_P (zv )) {
1409
1398
ref = Z_COUNTED_P (zv );
1410
- gc_remove_nested_data_from_buffer (ref , NULL );
1399
+ count += gc_remove_nested_data_from_buffer (ref , NULL );
1411
1400
}
1412
1401
p ++ ;
1413
1402
}
@@ -1514,7 +1503,7 @@ ZEND_API int zend_gc_collect_cycles(void)
1514
1503
if (GC_IS_GARBAGE (current -> ref )) {
1515
1504
p = GC_GET_PTR (current -> ref );
1516
1505
if (GC_REFCOUNT (p ) > refcounts [idx ]) {
1517
- gc_remove_nested_data_from_buffer (p , current );
1506
+ count -= gc_remove_nested_data_from_buffer (p , current );
1518
1507
}
1519
1508
}
1520
1509
current ++ ;
0 commit comments