mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
Don't perform recursive get_gc call
On further consideration, we should be making use of the fact that zend_object_iterator is also a zend_object here, and let GC handle the get_gc call on it. Calling get_gc recursively like this is generally not safe, because there is only one gc_buffer. This also happens to be much simpler...
This commit is contained in:
parent
029d06992e
commit
0643301c75
@ -1637,12 +1637,6 @@ ZEND_API void zend_get_gc_buffer_grow(zend_get_gc_buffer *gc_buffer) {
|
||||
gc_buffer->cur = gc_buffer->start + old_capacity;
|
||||
}
|
||||
|
||||
ZEND_API void zend_get_gc_buffer_add_zvals(zend_get_gc_buffer *gc_buffer, zval *zvs, size_t n) {
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
zend_get_gc_buffer_add_zval(gc_buffer, &zvs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void zend_get_gc_buffer_release() {
|
||||
zend_get_gc_buffer *gc_buffer = &EG(get_gc_buffer);
|
||||
efree(gc_buffer->start);
|
||||
|
@ -93,7 +93,6 @@ typedef struct {
|
||||
|
||||
ZEND_API zend_get_gc_buffer *zend_get_gc_buffer_create(void);
|
||||
ZEND_API void zend_get_gc_buffer_grow(zend_get_gc_buffer *gc_buffer);
|
||||
ZEND_API void zend_get_gc_buffer_add_zvals(zend_get_gc_buffer *gc_buffer, zval *zvs, size_t n);
|
||||
|
||||
static zend_always_inline void zend_get_gc_buffer_add_zval(
|
||||
zend_get_gc_buffer *gc_buffer, zval *zv) {
|
||||
@ -115,15 +114,6 @@ static zend_always_inline void zend_get_gc_buffer_add_obj(
|
||||
gc_buffer->cur++;
|
||||
}
|
||||
|
||||
static zend_always_inline void zend_get_gc_buffer_add_ht(
|
||||
zend_get_gc_buffer *gc_buffer, HashTable *ht) {
|
||||
if (UNEXPECTED(gc_buffer->cur == gc_buffer->end)) {
|
||||
zend_get_gc_buffer_grow(gc_buffer);
|
||||
}
|
||||
ZVAL_ARR(gc_buffer->cur, ht);
|
||||
gc_buffer->cur++;
|
||||
}
|
||||
|
||||
static zend_always_inline void zend_get_gc_buffer_use(
|
||||
zend_get_gc_buffer *gc_buffer, zval **table, int *n) {
|
||||
*table = gc_buffer->start;
|
||||
|
@ -2103,15 +2103,8 @@ static HashTable *spl_dual_it_get_gc(zend_object *obj, zval **table, int *n)
|
||||
spl_dual_it_object *object = spl_dual_it_from_obj(obj);
|
||||
zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create();
|
||||
|
||||
if (object->inner.iterator && object->inner.iterator->funcs->get_gc) {
|
||||
zval *inner_table;
|
||||
int inner_n;
|
||||
HashTable *inner_ht = object->inner.iterator->funcs->get_gc(
|
||||
object->inner.iterator, &inner_table, &inner_n);
|
||||
zend_get_gc_buffer_add_zvals(gc_buffer, inner_table, inner_n);
|
||||
if (inner_ht) {
|
||||
zend_get_gc_buffer_add_ht(gc_buffer, inner_ht);
|
||||
}
|
||||
if (object->inner.iterator) {
|
||||
zend_get_gc_buffer_add_obj(gc_buffer, &object->inner.iterator->std);
|
||||
}
|
||||
|
||||
zend_get_gc_buffer_add_zval(gc_buffer, &object->current.data);
|
||||
|
Loading…
Reference in New Issue
Block a user