Skip to content

Commit 1ae0b68

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 9af705e + 72b7d99 commit 1ae0b68

File tree

4 files changed

+21
-31
lines changed

4 files changed

+21
-31
lines changed

Zend/tests/gc_017.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ $a->insert($c);
3131
unset($a);
3232
unset($b);
3333
unset($c);
34-
var_dump(gc_collect_cycles() >= 7);
34+
var_dump(gc_collect_cycles());
3535
echo "ok\n"
3636
?>
3737
--EXPECTF--
3838
string(1) "%s"
3939
string(1) "%s"
4040
string(1) "%s"
41-
bool(true)
41+
int(4)
4242
ok

Zend/tests/gc_033.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ for ($i=0; $i<9999; $i++) {
2727
var_dump(gc_collect_cycles());
2828
?>
2929
--EXPECT--
30-
int(20001)
30+
int(10002)

Zend/tests/gc_041.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ $o->nested[] =& $o->nested;
1818
$o->ryat = $o;
1919
$x =& $o->chtg;
2020
unset($o);
21-
gc_collect_cycles();
21+
var_dump(gc_collect_cycles());
2222
var_dump($x);
2323
?>
2424
--EXPECT--
25+
int(0)
2526
object(ryat)#1 (3) {
2627
["ryat"]=>
2728
*RECURSION*
@@ -32,4 +33,4 @@ object(ryat)#1 (3) {
3233
[0]=>
3334
*RECURSION*
3435
}
35-
}
36+
}

Zend/zend_gc.c

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,10 +1175,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
11751175
ht = NULL;
11761176
if (!n) goto next;
11771177
while (!Z_REFCOUNTED_P(--end)) {
1178-
/* count non-refcounted for compatibility ??? */
1179-
if (Z_TYPE_P(zv) != IS_UNDEF) {
1180-
count++;
1181-
}
11821178
if (zv == end) goto next;
11831179
}
11841180
} else {
@@ -1192,9 +1188,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
11921188
GC_REF_SET_BLACK(ref);
11931189
GC_STACK_PUSH(ref);
11941190
}
1195-
/* count non-refcounted for compatibility ??? */
1196-
} else if (Z_TYPE_P(zv) != IS_UNDEF) {
1197-
count++;
11981191
}
11991192
zv++;
12001193
}
@@ -1242,10 +1235,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
12421235
if (Z_REFCOUNTED_P(zv)) {
12431236
break;
12441237
}
1245-
/* count non-refcounted for compatibility ??? */
1246-
if (Z_TYPE_P(zv) != IS_UNDEF) {
1247-
count++;
1248-
}
12491238
if (p == end) goto next;
12501239
}
12511240
while (p != end) {
@@ -1260,9 +1249,6 @@ static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *sta
12601249
GC_REF_SET_BLACK(ref);
12611250
GC_STACK_PUSH(ref);
12621251
}
1263-
/* count non-refcounted for compatibility ??? */
1264-
} else if (Z_TYPE_P(zv) != IS_UNDEF) {
1265-
count++;
12661252
}
12671253
p++;
12681254
}
@@ -1324,11 +1310,12 @@ static int gc_collect_roots(uint32_t *flags, gc_stack *stack)
13241310
return count;
13251311
}
13261312

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)
13281314
{
13291315
HashTable *ht = NULL;
13301316
Bucket *p, *end;
13311317
zval *zv;
1318+
int count = 0;
13321319

13331320
tail_call:
13341321
do {
@@ -1337,18 +1324,20 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
13371324
gc_remove_from_roots(root);
13381325
GC_REF_SET_INFO(ref, 0);
13391326
root = NULL;
1327+
count++;
13401328
} else if (GC_REF_ADDRESS(ref) != 0
13411329
&& GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
13421330
GC_TRACE_REF(ref, "removing from buffer");
13431331
GC_REMOVE_FROM_BUFFER(ref);
1332+
count++;
13441333
} else if (GC_TYPE(ref) == IS_REFERENCE) {
13451334
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
13461335
ref = Z_COUNTED(((zend_reference*)ref)->val);
13471336
goto tail_call;
13481337
}
1349-
return;
1338+
return count;
13501339
} else {
1351-
return;
1340+
return count;
13521341
}
13531342

13541343
if (GC_TYPE(ref) == IS_OBJECT) {
@@ -1361,15 +1350,15 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
13611350
ht = obj->handlers->get_gc(obj, &zv, &n);
13621351
end = zv + n;
13631352
if (EXPECTED(!ht)) {
1364-
if (!n) return;
1353+
if (!n) return count;
13651354
while (!Z_REFCOUNTED_P(--end)) {
1366-
if (zv == end) return;
1355+
if (zv == end) return count;
13671356
}
13681357
}
13691358
while (zv != end) {
13701359
if (Z_REFCOUNTED_P(zv)) {
13711360
ref = Z_COUNTED_P(zv);
1372-
gc_remove_nested_data_from_buffer(ref, NULL);
1361+
count += gc_remove_nested_data_from_buffer(ref, NULL);
13731362
}
13741363
zv++;
13751364
}
@@ -1378,15 +1367,15 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
13781367
goto tail_call;
13791368
}
13801369
} else {
1381-
return;
1370+
return count;
13821371
}
13831372
} else if (GC_TYPE(ref) == IS_ARRAY) {
13841373
ht = (zend_array*)ref;
13851374
} else {
1386-
return;
1375+
return count;
13871376
}
13881377

1389-
if (!ht->nNumUsed) return;
1378+
if (!ht->nNumUsed) return count;
13901379
p = ht->arData;
13911380
end = p + ht->nNumUsed;
13921381
while (1) {
@@ -1398,7 +1387,7 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
13981387
if (Z_REFCOUNTED_P(zv)) {
13991388
break;
14001389
}
1401-
if (p == end) return;
1390+
if (p == end) return count;
14021391
}
14031392
while (p != end) {
14041393
zv = &p->val;
@@ -1407,7 +1396,7 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
14071396
}
14081397
if (Z_REFCOUNTED_P(zv)) {
14091398
ref = Z_COUNTED_P(zv);
1410-
gc_remove_nested_data_from_buffer(ref, NULL);
1399+
count += gc_remove_nested_data_from_buffer(ref, NULL);
14111400
}
14121401
p++;
14131402
}
@@ -1514,7 +1503,7 @@ ZEND_API int zend_gc_collect_cycles(void)
15141503
if (GC_IS_GARBAGE(current->ref)) {
15151504
p = GC_GET_PTR(current->ref);
15161505
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);
15181507
}
15191508
}
15201509
current++;

0 commit comments

Comments
 (0)