Back to index

php5  5.3.10
Defines | Functions | Variables
zend_gc.c File Reference
#include "zend.h"
#include "zend_API.h"

Go to the source code of this file.

Defines

#define GC_ROOT_BUFFER_MAX_ENTRIES   10000
#define FREE_LIST_END   ((zval_gc_info*)(~(zend_uintptr_t)GC_COLOR))

Functions

static void root_buffer_dtor (zend_gc_globals *gc_globals TSRMLS_DC)
static void gc_globals_ctor_ex (zend_gc_globals *gc_globals TSRMLS_DC)
ZEND_API void gc_globals_ctor (TSRMLS_D)
ZEND_API void gc_globals_dtor (TSRMLS_D)
ZEND_API void gc_reset (TSRMLS_D)
ZEND_API void gc_init (TSRMLS_D)
ZEND_API void gc_zval_possible_root (zval *zv TSRMLS_DC)
ZEND_API void gc_zobj_possible_root (zval *zv TSRMLS_DC)
ZEND_API void gc_remove_zval_from_buffer (zval *zv TSRMLS_DC)
static void zval_scan_black (zval *pz TSRMLS_DC)
static void zobj_scan_black (struct _store_object *obj, zval *pz TSRMLS_DC)
static void zval_mark_grey (zval *pz TSRMLS_DC)
static void zobj_mark_grey (struct _store_object *obj, zval *pz TSRMLS_DC)
static void gc_mark_roots (TSRMLS_D)
static int zval_scan (zval *pz TSRMLS_DC)
static void zobj_scan (zval *pz TSRMLS_DC)
static void gc_scan_roots (TSRMLS_D)
static void zval_collect_white (zval *pz TSRMLS_DC)
static void zobj_collect_white (zval *pz TSRMLS_DC)
static void gc_collect_roots (TSRMLS_D)
ZEND_API int gc_collect_cycles (TSRMLS_D)

Variables

ZEND_API zend_gc_globals gc_globals

Define Documentation

Definition at line 649 of file zend_gc.c.

#define GC_ROOT_BUFFER_MAX_ENTRIES   10000

Definition at line 25 of file zend_gc.c.


Function Documentation

Definition at line 651 of file zend_gc.c.

{
       int count = 0;

       if (GC_G(roots).next != &GC_G(roots)) {
              zval_gc_info *p, *q, *orig_free_list, *orig_next_to_free;

              if (GC_G(gc_active)) {
                     return 0;
              }
              GC_G(gc_runs)++;
              GC_G(zval_to_free) = FREE_LIST_END;
              GC_G(gc_active) = 1;
              gc_mark_roots(TSRMLS_C);
              gc_scan_roots(TSRMLS_C);
              gc_collect_roots(TSRMLS_C);

              orig_free_list = GC_G(free_list);
              orig_next_to_free = GC_G(next_to_free);
              p = GC_G(free_list) = GC_G(zval_to_free);
              GC_G(zval_to_free) = NULL;
              GC_G(gc_active) = 0;

              /* First call destructors */
              while (p != FREE_LIST_END) {
                     if (Z_TYPE(p->z) == IS_OBJECT) {
                            if (EG(objects_store).object_buckets &&
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].valid &&
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount <= 0 &&
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.dtor &&
                                   !EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].destructor_called) {

                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].destructor_called = 1;
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount++;
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.dtor(EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.object, Z_OBJ_HANDLE(p->z) TSRMLS_CC);
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount--;
                            }
                     }
                     count++;
                     p = p->u.next;
              }

              /* Destroy zvals */
              p = GC_G(free_list);
              while (p != FREE_LIST_END) {
                     GC_G(next_to_free) = p->u.next;
                     if (Z_TYPE(p->z) == IS_OBJECT) {
                            if (EG(objects_store).object_buckets &&
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].valid &&
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount <= 0) {
                                   EG(objects_store).object_buckets[Z_OBJ_HANDLE(p->z)].bucket.obj.refcount = 1;
                                   Z_TYPE(p->z) = IS_NULL;
                                   zend_objects_store_del_ref_by_handle_ex(Z_OBJ_HANDLE(p->z), Z_OBJ_HT(p->z) TSRMLS_CC);
                            }
                     } else if (Z_TYPE(p->z) == IS_ARRAY) {
                            Z_TYPE(p->z) = IS_NULL;
                            zend_hash_destroy(Z_ARRVAL(p->z));
                            FREE_HASHTABLE(Z_ARRVAL(p->z));
                     } else {
                            zval_dtor(&p->z);
                            Z_TYPE(p->z) = IS_NULL;
                     }
                     p = GC_G(next_to_free);
              }

              /* Free zvals */
              p = GC_G(free_list);
              while (p != FREE_LIST_END) {
                     q = p->u.next;
                     FREE_ZVAL_EX(&p->z);
                     p = q;
              }
              GC_G(collected) += count;
              GC_G(free_list) = orig_free_list;
              GC_G(next_to_free) = orig_next_to_free;
       }

       return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void gc_collect_roots ( TSRMLS_D  ) [static]

Definition at line 623 of file zend_gc.c.

{
       gc_root_buffer *current = GC_G(roots).next;

       while (current != &GC_G(roots)) {
              if (current->handle) {
                     if (EG(objects_store).object_buckets) {
                            struct _store_object *obj = &EG(objects_store).object_buckets[current->handle].bucket.obj;
                            zval z;

                            GC_SET_ADDRESS(obj->buffered, NULL);
                            INIT_PZVAL(&z);
                            Z_OBJ_HANDLE(z) = current->handle;
                            Z_OBJ_HT(z) = current->u.handlers;
                            zobj_collect_white(&z TSRMLS_CC);
                     }
              } else {
                     GC_ZVAL_SET_ADDRESS(current->u.pz, NULL);
                     zval_collect_white(current->u.pz TSRMLS_CC);
              }

              GC_REMOVE_FROM_BUFFER(current);
              current = current->next;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 72 of file zend_gc.c.

{
#ifdef ZTS
       ts_allocate_id(&gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
#else
       gc_globals_ctor_ex(&gc_globals);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void gc_globals_ctor_ex ( zend_gc_globals *gc_globals  TSRMLS_DC) [static]

Definition at line 41 of file zend_gc.c.

{
       gc_globals->gc_enabled = 0;
       gc_globals->gc_active = 0;

       gc_globals->buf = NULL;

       gc_globals->roots.next = &gc_globals->roots;
       gc_globals->roots.prev = &gc_globals->roots;
       gc_globals->unused = NULL;
       gc_globals->zval_to_free = NULL;
       gc_globals->free_list = NULL;
       gc_globals->next_to_free = NULL;

       gc_globals->gc_runs = 0;
       gc_globals->collected = 0;

#if GC_BENCH
       gc_globals->root_buf_length = 0;
       gc_globals->root_buf_peak = 0;
       gc_globals->zval_possible_root = 0;
       gc_globals->zobj_possible_root = 0;
       gc_globals->zval_buffered = 0;
       gc_globals->zobj_buffered = 0;
       gc_globals->zval_remove_from_buffer = 0;
       gc_globals->zobj_remove_from_buffer = 0;
       gc_globals->zval_marked_grey = 0;
       gc_globals->zobj_marked_grey = 0;
#endif
}

Here is the caller graph for this function:

Definition at line 81 of file zend_gc.c.

{
#ifndef ZTS
       root_buffer_dtor(&gc_globals TSRMLS_DC);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 121 of file zend_gc.c.

{
       if (GC_G(buf) == NULL && GC_G(gc_enabled)) {
              GC_G(buf) = (gc_root_buffer*) malloc(sizeof(gc_root_buffer) * GC_ROOT_BUFFER_MAX_ENTRIES);
              GC_G(last_unused) = &GC_G(buf)[GC_ROOT_BUFFER_MAX_ENTRIES];
              gc_reset(TSRMLS_C);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void gc_mark_roots ( TSRMLS_D  ) [static]

Definition at line 412 of file zend_gc.c.

{
       gc_root_buffer *current = GC_G(roots).next;

       while (current != &GC_G(roots)) {
              if (current->handle) {
                     if (EG(objects_store).object_buckets) {
                            struct _store_object *obj = &EG(objects_store).object_buckets[current->handle].bucket.obj;

                            if (GC_GET_COLOR(obj->buffered) == GC_PURPLE) {
                                   zval z;

                                   INIT_PZVAL(&z);
                                   Z_OBJ_HANDLE(z) = current->handle;
                                   Z_OBJ_HT(z) = current->u.handlers;
                                   zobj_mark_grey(obj, &z TSRMLS_CC);
                            } else {
                                   GC_SET_ADDRESS(obj->buffered, NULL);
                                   GC_REMOVE_FROM_BUFFER(current);
                            }
                     }
              } else {
                     if (GC_ZVAL_GET_COLOR(current->u.pz) == GC_PURPLE) {
                            zval_mark_grey(current->u.pz TSRMLS_CC);
                     } else {
                            GC_ZVAL_SET_ADDRESS(current->u.pz, NULL);
                            GC_REMOVE_FROM_BUFFER(current);
                     }
              }
              current = current->next;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void gc_remove_zval_from_buffer ( zval *zv  TSRMLS_DC)

Definition at line 249 of file zend_gc.c.

{
       gc_root_buffer* root_buffer = GC_ADDRESS(((zval_gc_info*)zv)->u.buffered);

       if (UNEXPECTED(GC_G(free_list) != NULL &&
                         GC_ZVAL_GET_COLOR(zv) == GC_BLACK) &&
                         (GC_ZVAL_ADDRESS(zv) < GC_G(buf) ||
                          GC_ZVAL_ADDRESS(zv) >= GC_G(last_unused))) {
              /* The given zval is a garbage that is going to be deleted by
               * currently running GC */
              if (GC_G(next_to_free) == (zval_gc_info*)zv) {
                     GC_G(next_to_free) = ((zval_gc_info*)zv)->u.next;
              }
              return;
       }
       GC_BENCH_INC(zval_remove_from_buffer);
       GC_REMOVE_FROM_BUFFER(root_buffer);
       ((zval_gc_info*)zv)->u.buffered = NULL;
}

Definition at line 88 of file zend_gc.c.

{
       GC_G(gc_runs) = 0;
       GC_G(collected) = 0;

#if GC_BENCH
       GC_G(root_buf_length) = 0;
       GC_G(root_buf_peak) = 0;
       GC_G(zval_possible_root) = 0;
       GC_G(zobj_possible_root) = 0;
       GC_G(zval_buffered) = 0;
       GC_G(zobj_buffered) = 0;
       GC_G(zval_remove_from_buffer) = 0;
       GC_G(zobj_remove_from_buffer) = 0;
       GC_G(zval_marked_grey) = 0;
       GC_G(zobj_marked_grey) = 0;
#endif

       GC_G(roots).next = &GC_G(roots);
       GC_G(roots).prev = &GC_G(roots);

       if (GC_G(buf)) {
              GC_G(unused) = NULL;
              GC_G(first_unused) = GC_G(buf);

              GC_G(zval_to_free) = NULL;
       } else {
              GC_G(unused) = NULL;
              GC_G(first_unused) = NULL;
              GC_G(last_unused) = NULL;
       }
}

Here is the caller graph for this function:

static void gc_scan_roots ( TSRMLS_D  ) [static]

Definition at line 524 of file zend_gc.c.

{
       gc_root_buffer *current = GC_G(roots).next;

       while (current != &GC_G(roots)) {
              if (current->handle) {
                     zval z;

                     INIT_PZVAL(&z);
                     Z_OBJ_HANDLE(z) = current->handle;
                     Z_OBJ_HT(z) = current->u.handlers;
                     zobj_scan(&z TSRMLS_CC);
              } else {
                     zval_scan(current->u.pz TSRMLS_CC);
              }
              current = current->next;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void gc_zobj_possible_root ( zval *zv  TSRMLS_DC)

Definition at line 193 of file zend_gc.c.

{
       struct _store_object *obj;

       if (UNEXPECTED(Z_OBJ_HT_P(zv)->get_properties == NULL ||
           EG(objects_store).object_buckets == NULL)) {
              return;
       }

       GC_BENCH_INC(zobj_possible_root);

       obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zv)].bucket.obj;
       if (GC_GET_COLOR(obj->buffered) != GC_PURPLE) {
              GC_SET_PURPLE(obj->buffered);
              if (!GC_ADDRESS(obj->buffered)) {
                     gc_root_buffer *newRoot = GC_G(unused);

                     if (newRoot) {
                            GC_G(unused) = newRoot->prev;
                     } else if (GC_G(first_unused) != GC_G(last_unused)) {
                            newRoot = GC_G(first_unused);
                            GC_G(first_unused)++;
                     } else {
                            if (!GC_G(gc_enabled)) {
                                   GC_ZVAL_SET_BLACK(zv);
                                   return;
                            }
                            zv->refcount__gc++;
                            gc_collect_cycles(TSRMLS_C);
                            zv->refcount__gc--;
                            newRoot = GC_G(unused);
                            if (!newRoot) {
                                   return;
                            }
                            obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zv)].bucket.obj;
                            GC_SET_PURPLE(obj->buffered);
                            GC_G(unused) = newRoot->prev;
                     }

                     newRoot->next = GC_G(roots).next;
                     newRoot->prev = &GC_G(roots);
                     GC_G(roots).next->prev = newRoot;
                     GC_G(roots).next = newRoot;

                     GC_SET_ADDRESS(obj->buffered, newRoot);

                     newRoot->handle = Z_OBJ_HANDLE_P(zv);
                     newRoot->u.handlers = Z_OBJ_HT_P(zv);

                     GC_BENCH_INC(zobj_buffered);
                     GC_BENCH_INC(root_buf_length);
                     GC_BENCH_PEAK(root_buf_peak, root_buf_length);
              }
       }
}

Here is the call graph for this function:

ZEND_API void gc_zval_possible_root ( zval *zv  TSRMLS_DC)

Definition at line 130 of file zend_gc.c.

{
       if (UNEXPECTED(GC_G(free_list) != NULL &&
                      GC_ZVAL_ADDRESS(zv) != NULL &&
                         GC_ZVAL_GET_COLOR(zv) == GC_BLACK) &&
                         (GC_ZVAL_ADDRESS(zv) < GC_G(buf) ||
                          GC_ZVAL_ADDRESS(zv) >= GC_G(last_unused))) {
              /* The given zval is a garbage that is going to be deleted by
               * currently running GC */
              return;
       }

       if (zv->type == IS_OBJECT) {
              GC_ZOBJ_CHECK_POSSIBLE_ROOT(zv);
              return;
       }

       GC_BENCH_INC(zval_possible_root);

       if (GC_ZVAL_GET_COLOR(zv) != GC_PURPLE) {
              GC_ZVAL_SET_PURPLE(zv);

              if (!GC_ZVAL_ADDRESS(zv)) {
                     gc_root_buffer *newRoot = GC_G(unused);

                     if (newRoot) {
                            GC_G(unused) = newRoot->prev;
                     } else if (GC_G(first_unused) != GC_G(last_unused)) {
                            newRoot = GC_G(first_unused);
                            GC_G(first_unused)++;
                     } else {
                            if (!GC_G(gc_enabled)) {
                                   GC_ZVAL_SET_BLACK(zv);
                                   return;
                            }
                            zv->refcount__gc++;
                            gc_collect_cycles(TSRMLS_C);
                            zv->refcount__gc--;
                            newRoot = GC_G(unused);
                            if (!newRoot) {
                                   return;
                            }
                            GC_ZVAL_SET_PURPLE(zv);
                            GC_G(unused) = newRoot->prev;
                     }

                     newRoot->next = GC_G(roots).next;
                     newRoot->prev = &GC_G(roots);
                     GC_G(roots).next->prev = newRoot;
                     GC_G(roots).next = newRoot;

                     GC_ZVAL_SET_ADDRESS(zv, newRoot);

                     newRoot->handle = 0;
                     newRoot->u.pz = zv;

                     GC_BENCH_INC(zval_buffered);
                     GC_BENCH_INC(root_buf_length);
                     GC_BENCH_PEAK(root_buf_peak, root_buf_length);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void root_buffer_dtor ( zend_gc_globals *gc_globals  TSRMLS_DC) [static]

Definition at line 33 of file zend_gc.c.

{
       if (gc_globals->buf) {
              free(gc_globals->buf);
              gc_globals->buf = NULL;
       }      
}

Here is the caller graph for this function:

static void zobj_collect_white ( zval *pz  TSRMLS_DC) [static]

Definition at line 593 of file zend_gc.c.

{
       Bucket *p;

       if (EG(objects_store).object_buckets) {
              struct _store_object *obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;

              if (obj->buffered == (gc_root_buffer*)GC_WHITE) {
                     GC_SET_BLACK(obj->buffered);

                     if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                                  Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
                            HashTable *props = Z_OBJPROP_P(pz);
                            if(!props) {
                                   return;
                            }
                            p = props->pListHead;
                            while (p != NULL) {
                                   pz = *(zval**)p->pData;
                                   if (Z_TYPE_P(pz) != IS_ARRAY || Z_ARRVAL_P(pz) != &EG(symbol_table)) {
                                          pz->refcount__gc++;
                                   }
                                   zval_collect_white(pz TSRMLS_CC);
                                   p = p->pListNext;
                            }
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void zobj_mark_grey ( struct _store_object *  obj,
zval *pz  TSRMLS_DC 
) [static]

Definition at line 386 of file zend_gc.c.

{
       Bucket *p;

       if (GC_GET_COLOR(obj->buffered) != GC_GREY) {
              GC_BENCH_INC(zobj_marked_grey);
              GC_SET_COLOR(obj->buffered, GC_GREY);
              if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                           Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
                     HashTable *props = Z_OBJPROP_P(pz);
                     if(!props) {
                            return;
                     }
                     p = props->pListHead;
                     while (p != NULL) {
                            pz = *(zval**)p->pData;
                            if (Z_TYPE_P(pz) != IS_ARRAY || Z_ARRVAL_P(pz) != &EG(symbol_table)) {
                                   pz->refcount__gc--;
                            }
                            zval_mark_grey(pz TSRMLS_CC);
                            p = p->pListNext;
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void zobj_scan ( zval *pz  TSRMLS_DC) [static]

Definition at line 495 of file zend_gc.c.

{
       Bucket *p;

       if (EG(objects_store).object_buckets) {
              struct _store_object *obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;

              if (GC_GET_COLOR(obj->buffered) == GC_GREY) {
                     if (obj->refcount > 0) {
                            zobj_scan_black(obj, pz TSRMLS_CC);
                     } else {
                            GC_SET_COLOR(obj->buffered, GC_WHITE);
                            if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                                         Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
                                   HashTable *props = Z_OBJPROP_P(pz);
                                   if(!props) {
                                          return;
                                   }
                                   p = props->pListHead;
                                   while (p != NULL) {
                                          zval_scan(*(zval**)p->pData TSRMLS_CC);
                                          p = p->pListNext;
                                   }
                            }
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void zobj_scan_black ( struct _store_object *  obj,
zval *pz  TSRMLS_DC 
) [static]

Definition at line 313 of file zend_gc.c.

{
       Bucket *p;

       GC_SET_BLACK(obj->buffered);
       if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                    Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
              HashTable *props = Z_OBJPROP_P(pz);
              if(!props) {
                     return;
              }
              p = props->pListHead;
              while (p != NULL) {
                     pz = *(zval**)p->pData;
                     if (Z_TYPE_P(pz) != IS_ARRAY || Z_ARRVAL_P(pz) != &EG(symbol_table)) {
                            pz->refcount__gc++;
                     }
                     if (GC_ZVAL_GET_COLOR(pz) != GC_BLACK) {
                            zval_scan_black(pz TSRMLS_CC);
                     }
                     p = p->pListNext;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void zval_collect_white ( zval *pz  TSRMLS_DC) [static]

Definition at line 543 of file zend_gc.c.

{
       Bucket *p;

tail_call:
       if (((zval_gc_info*)(pz))->u.buffered == (gc_root_buffer*)GC_WHITE) {
              p = NULL;
              GC_ZVAL_SET_BLACK(pz);

              if (Z_TYPE_P(pz) == IS_OBJECT && EG(objects_store).object_buckets) {
                     struct _store_object *obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;

                     if (obj->buffered == (gc_root_buffer*)GC_WHITE) {
                            GC_SET_BLACK(obj->buffered);

                            if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                                         Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
                                   HashTable *props = Z_OBJPROP_P(pz);
                                   if(!props) {
                                          return;
                                   }
                                   p = props->pListHead;
                            }
                     }
              } else {
                     if (Z_TYPE_P(pz) == IS_ARRAY) {
                            p = Z_ARRVAL_P(pz)->pListHead;
                     }
              }

              /* restore refcount and put into list to free */
              pz->refcount__gc++;
              ((zval_gc_info*)pz)->u.next = GC_G(zval_to_free);
              GC_G(zval_to_free) = (zval_gc_info*)pz;

              while (p != NULL) {
                     pz = *(zval**)p->pData;
                     if (Z_TYPE_P(pz) != IS_ARRAY || Z_ARRVAL_P(pz) != &EG(symbol_table)) {
                            pz->refcount__gc++;
                     }
                     if (p->pListNext == NULL) {
                            goto tail_call;
                     } else {
                            zval_collect_white(pz TSRMLS_CC);
                     }
                     p = p->pListNext;
              }
       }
}

Here is the caller graph for this function:

static void zval_mark_grey ( zval *pz  TSRMLS_DC) [static]

Definition at line 338 of file zend_gc.c.

{
       Bucket *p;

tail_call:
       if (GC_ZVAL_GET_COLOR(pz) != GC_GREY) {
              p = NULL;
              GC_BENCH_INC(zval_marked_grey);
              GC_ZVAL_SET_COLOR(pz, GC_GREY);

              if (Z_TYPE_P(pz) == IS_OBJECT && EG(objects_store).object_buckets) {
                     struct _store_object *obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;

                     obj->refcount--;
                     if (GC_GET_COLOR(obj->buffered) != GC_GREY) {
                            GC_BENCH_INC(zobj_marked_grey);
                            GC_SET_COLOR(obj->buffered, GC_GREY);
                            if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                                         Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
                                   HashTable *props = Z_OBJPROP_P(pz);
                                   if(!props) {
                                          return;
                                   }
                                   p = props->pListHead;
                            }
                     }
              } else if (Z_TYPE_P(pz) == IS_ARRAY) {
                     if (Z_ARRVAL_P(pz) == &EG(symbol_table)) {
                            GC_ZVAL_SET_BLACK(pz);
                     } else {
                            p = Z_ARRVAL_P(pz)->pListHead;
                     }
              }
              while (p != NULL) {
                     pz = *(zval**)p->pData;
                     if (Z_TYPE_P(pz) != IS_ARRAY || Z_ARRVAL_P(pz) != &EG(symbol_table)) {
                            pz->refcount__gc--;
                     }
                     if (p->pListNext == NULL) {
                            goto tail_call;
                     } else {
                            zval_mark_grey(pz TSRMLS_CC);
                     }
                     p = p->pListNext;
              }
       }
}

Here is the caller graph for this function:

static int zval_scan ( zval *pz  TSRMLS_DC) [static]

Definition at line 445 of file zend_gc.c.

{
       Bucket *p;

tail_call:    
       if (GC_ZVAL_GET_COLOR(pz) == GC_GREY) {
              p = NULL;
              if (pz->refcount__gc > 0) {
                     zval_scan_black(pz TSRMLS_CC);
              } else {
                     GC_ZVAL_SET_COLOR(pz, GC_WHITE);
                     if (Z_TYPE_P(pz) == IS_OBJECT && EG(objects_store).object_buckets) {
                            struct _store_object *obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;

                            if (GC_GET_COLOR(obj->buffered) == GC_GREY) {
                                   if (obj->refcount > 0) {
                                          zobj_scan_black(obj, pz TSRMLS_CC);
                                   } else {
                                          GC_SET_COLOR(obj->buffered, GC_WHITE);
                                          if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                                                       Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
                                                 HashTable *props = Z_OBJPROP_P(pz);
                                                 if(!props) {
                                                        return 0;
                                                 }
                                                 p = props->pListHead;
                                          }
                                   }
                            }
                     } else if (Z_TYPE_P(pz) == IS_ARRAY) {
                            if (Z_ARRVAL_P(pz) == &EG(symbol_table)) {
                                   GC_ZVAL_SET_BLACK(pz);
                            } else {
                                   p = Z_ARRVAL_P(pz)->pListHead;
                            }
                     }
              }
              while (p != NULL) {
                     if (p->pListNext == NULL) {
                            pz = *(zval**)p->pData;
                            goto tail_call;
                     } else {
                            zval_scan(*(zval**)p->pData TSRMLS_CC);
                     }
                     p = p->pListNext;
              }
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void zval_scan_black ( zval *pz  TSRMLS_DC) [static]

Definition at line 269 of file zend_gc.c.

{
       Bucket *p;

tail_call:
       p = NULL;
       GC_ZVAL_SET_BLACK(pz);

       if (Z_TYPE_P(pz) == IS_OBJECT && EG(objects_store).object_buckets) {
              struct _store_object *obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;

              obj->refcount++;
              if (GC_GET_COLOR(obj->buffered) != GC_BLACK) {
                     GC_SET_BLACK(obj->buffered);
                     if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
                                  Z_OBJ_HANDLER_P(pz, get_properties) != NULL)) {
                            HashTable *props = Z_OBJPROP_P(pz);
                            if(!props) {
                                   return;
                            }
                            p = props->pListHead;
                     }
              }
       } else if (Z_TYPE_P(pz) == IS_ARRAY) {
              if (Z_ARRVAL_P(pz) != &EG(symbol_table)) {
                     p = Z_ARRVAL_P(pz)->pListHead;
              }
       }
       while (p != NULL) {
              pz = *(zval**)p->pData;
              if (Z_TYPE_P(pz) != IS_ARRAY || Z_ARRVAL_P(pz) != &EG(symbol_table)) {
                     pz->refcount__gc++;
              }
              if (GC_ZVAL_GET_COLOR(pz) != GC_BLACK) {
                     if (p->pListNext == NULL) {
                            goto tail_call;
                     } else {
                            zval_scan_black(pz TSRMLS_CC);
                     }
              }
              p = p->pListNext;
       }
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 30 of file zend_gc.c.