mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Clean up gc_scan() implementation
The HT handling no longer needs to be shared, so move it into the right branch. Also use a couple of early gotos to reduce nesting.
This commit is contained in:
parent
5f8ed7765a
commit
5bde82a442
1 changed files with 77 additions and 83 deletions
|
@ -991,13 +991,15 @@ static void gc_mark_roots(gc_stack *stack)
|
|||
|
||||
static void gc_scan(zend_refcounted *ref, gc_stack *stack)
|
||||
{
|
||||
HashTable *ht = NULL;
|
||||
Bucket *p, *end;
|
||||
zval *zv;
|
||||
GC_STACK_DCL(stack);
|
||||
|
||||
tail_call:
|
||||
if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
|
||||
if (!GC_REF_CHECK_COLOR(ref, GC_WHITE)) {
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (GC_REFCOUNT(ref) > 0) {
|
||||
if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) {
|
||||
GC_REF_SET_BLACK(ref);
|
||||
|
@ -1009,21 +1011,20 @@ tail_call:
|
|||
gc_scan_black(ref, _stack->next);
|
||||
_stack->next->prev = _stack;
|
||||
}
|
||||
} else {
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (GC_TYPE(ref) == IS_OBJECT) {
|
||||
zend_object *obj = (zend_object*)ref;
|
||||
|
||||
if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) {
|
||||
int n;
|
||||
zval *zv, *end;
|
||||
|
||||
ht = obj->handlers->get_gc(obj, &zv, &n);
|
||||
HashTable *ht = obj->handlers->get_gc(obj, &zv, &n);
|
||||
if (UNEXPECTED(ht)) {
|
||||
if (GC_REF_CHECK_COLOR(ht, GC_GREY)) {
|
||||
GC_REF_SET_COLOR(ht, GC_WHITE);
|
||||
GC_STACK_PUSH((zend_refcounted *) ht);
|
||||
}
|
||||
ht = NULL;
|
||||
}
|
||||
|
||||
if (!n) goto next;
|
||||
|
@ -1047,23 +1048,9 @@ tail_call:
|
|||
goto tail_call;
|
||||
}
|
||||
}
|
||||
goto next;
|
||||
} else if (GC_TYPE(ref) == IS_ARRAY) {
|
||||
ZEND_ASSERT((zend_array*)ref != &EG(symbol_table));
|
||||
ht = (zend_array*)ref;
|
||||
} else if (GC_TYPE(ref) == IS_REFERENCE) {
|
||||
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
|
||||
ref = Z_COUNTED(((zend_reference*)ref)->val);
|
||||
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
|
||||
GC_REF_SET_COLOR(ref, GC_WHITE);
|
||||
goto tail_call;
|
||||
}
|
||||
}
|
||||
goto next;
|
||||
} else {
|
||||
goto next;
|
||||
}
|
||||
|
||||
HashTable *ht = (HashTable *)ref;
|
||||
ZEND_ASSERT(ht != &EG(symbol_table));
|
||||
if (!ht->nNumUsed) goto next;
|
||||
p = ht->arData;
|
||||
end = p + ht->nNumUsed;
|
||||
|
@ -1101,6 +1088,13 @@ tail_call:
|
|||
GC_REF_SET_COLOR(ref, GC_WHITE);
|
||||
goto tail_call;
|
||||
}
|
||||
} else if (GC_TYPE(ref) == IS_REFERENCE) {
|
||||
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
|
||||
ref = Z_COUNTED(((zend_reference*)ref)->val);
|
||||
if (GC_REF_CHECK_COLOR(ref, GC_GREY)) {
|
||||
GC_REF_SET_COLOR(ref, GC_WHITE);
|
||||
goto tail_call;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue