Lines Matching refs:ref

44 # define GC_TRACE_REF(ref, format, ...) \  argument
46 gc_trace_ref((zend_refcounted *) ref); \
49 # define GC_TRACE_SET_COLOR(ref, color) \ argument
50 GC_TRACE_REF(ref, "->%s", gc_color_name(color))
52 # define GC_TRACE_REF(ref, format, ...) argument
53 # define GC_TRACE_SET_COLOR(ref, new_color) argument
57 #define GC_REF_SET_ADDRESS(ref, a) \ argument
58 GC_INFO_SET_ADDRESS(GC_INFO(ref), a)
59 #define GC_REF_GET_COLOR(ref) \ argument
60 GC_INFO_GET_COLOR(GC_INFO(ref))
61 #define GC_REF_SET_COLOR(ref, c) \ argument
62 do { GC_TRACE_SET_COLOR(ref, c); GC_INFO_SET_COLOR(GC_INFO(ref), c); } while (0)
63 #define GC_REF_SET_BLACK(ref) \ argument
64 do { GC_TRACE_SET_COLOR(ref, GC_BLACK); GC_INFO_SET_BLACK(GC_INFO(ref)); } while (0)
65 #define GC_REF_SET_PURPLE(ref) \ argument
66 do { GC_TRACE_SET_COLOR(ref, GC_PURPLE); GC_INFO_SET_PURPLE(GC_INFO(ref)); } while (0)
78 static void gc_trace_ref(zend_refcounted *ref) { in gc_trace_ref() argument
79 if (GC_TYPE(ref) == IS_OBJECT) { in gc_trace_ref()
80 zend_object *obj = (zend_object *) ref; in gc_trace_ref()
82 ref, GC_REFCOUNT(ref), GC_ADDRESS(GC_INFO(ref)), in gc_trace_ref()
83 gc_color_name(GC_REF_GET_COLOR(ref)), in gc_trace_ref()
85 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_trace_ref()
86 zend_array *arr = (zend_array *) ref; in gc_trace_ref()
88 ref, GC_REFCOUNT(ref), GC_ADDRESS(GC_INFO(ref)), in gc_trace_ref()
89 gc_color_name(GC_REF_GET_COLOR(ref)), in gc_trace_ref()
93 ref, GC_REFCOUNT(ref), GC_ADDRESS(GC_INFO(ref)), in gc_trace_ref()
94 gc_color_name(GC_REF_GET_COLOR(ref)), in gc_trace_ref()
95 zend_get_type_by_const(GC_TYPE(ref))); in gc_trace_ref()
211 ZEND_API void ZEND_FASTCALL gc_possible_root(zend_refcounted *ref) in gc_possible_root() argument
219 ZEND_ASSERT(GC_TYPE(ref) == IS_ARRAY || GC_TYPE(ref) == IS_OBJECT); in gc_possible_root()
220 ZEND_ASSERT(EXPECTED(GC_REF_GET_COLOR(ref) == GC_BLACK)); in gc_possible_root()
221 ZEND_ASSERT(!GC_ADDRESS(GC_INFO(ref))); in gc_possible_root()
235 GC_REFCOUNT(ref)++; in gc_possible_root()
237 GC_REFCOUNT(ref)--; in gc_possible_root()
238 if (UNEXPECTED(GC_REFCOUNT(ref)) == 0) { in gc_possible_root()
239 zval_dtor_func_for_ptr(ref); in gc_possible_root()
242 if (UNEXPECTED(GC_INFO(ref))) { in gc_possible_root()
258 GC_TRACE_SET_COLOR(ref, GC_PURPLE); in gc_possible_root()
259 GC_INFO(ref) = (newRoot - GC_G(buf)) | GC_PURPLE; in gc_possible_root()
260 newRoot->ref = ref; in gc_possible_root()
272 static zend_always_inline gc_root_buffer* gc_find_additional_buffer(zend_refcounted *ref) in gc_find_additional_buffer() argument
278 uint32_t idx = GC_ADDRESS(GC_INFO(ref)) - GC_ROOT_BUFFER_MAX_ENTRIES; in gc_find_additional_buffer()
281 if (root->ref == ref) { in gc_find_additional_buffer()
292 ZEND_API void ZEND_FASTCALL gc_remove_from_buffer(zend_refcounted *ref) in gc_remove_from_buffer() argument
296 ZEND_ASSERT(GC_ADDRESS(GC_INFO(ref))); in gc_remove_from_buffer()
300 if (EXPECTED(GC_ADDRESS(GC_INFO(ref)) < GC_ROOT_BUFFER_MAX_ENTRIES)) { in gc_remove_from_buffer()
301 root = GC_G(buf) + GC_ADDRESS(GC_INFO(ref)); in gc_remove_from_buffer()
304 root = gc_find_additional_buffer(ref); in gc_remove_from_buffer()
307 if (GC_REF_GET_COLOR(ref) != GC_BLACK) { in gc_remove_from_buffer()
308 GC_TRACE_SET_COLOR(ref, GC_PURPLE); in gc_remove_from_buffer()
310 GC_INFO(ref) = 0; in gc_remove_from_buffer()
318 static void gc_scan_black(zend_refcounted *ref) in gc_scan_black() argument
326 GC_REF_SET_BLACK(ref); in gc_scan_black()
328 if (GC_TYPE(ref) == IS_OBJECT && !(GC_FLAGS(ref) & IS_OBJ_FREE_CALLED)) { in gc_scan_black()
330 zend_object *obj = (zend_object*)ref; in gc_scan_black()
349 ref = Z_COUNTED_P(zv); in gc_scan_black()
350 GC_REFCOUNT(ref)++; in gc_scan_black()
351 if (GC_REF_GET_COLOR(ref) != GC_BLACK) { in gc_scan_black()
352 gc_scan_black(ref); in gc_scan_black()
358 ref = Z_COUNTED_P(zv); in gc_scan_black()
359 GC_REFCOUNT(ref)++; in gc_scan_black()
360 if (GC_REF_GET_COLOR(ref) != GC_BLACK) { in gc_scan_black()
368 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_scan_black()
369 if ((zend_array*)ref != &EG(symbol_table)) { in gc_scan_black()
370 ht = (zend_array*)ref; in gc_scan_black()
374 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_scan_black()
375 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_scan_black()
376 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_scan_black()
377 GC_REFCOUNT(ref)++; in gc_scan_black()
378 if (GC_REF_GET_COLOR(ref) != GC_BLACK) { in gc_scan_black()
407 ref = Z_COUNTED_P(zv); in gc_scan_black()
408 GC_REFCOUNT(ref)++; in gc_scan_black()
409 if (GC_REF_GET_COLOR(ref) != GC_BLACK) { in gc_scan_black()
410 gc_scan_black(ref); in gc_scan_black()
419 ref = Z_COUNTED_P(zv); in gc_scan_black()
420 GC_REFCOUNT(ref)++; in gc_scan_black()
421 if (GC_REF_GET_COLOR(ref) != GC_BLACK) { in gc_scan_black()
426 static void gc_mark_grey(zend_refcounted *ref) in gc_mark_grey() argument
433 if (GC_REF_GET_COLOR(ref) != GC_GREY) { in gc_mark_grey()
436 GC_REF_SET_COLOR(ref, GC_GREY); in gc_mark_grey()
438 if (GC_TYPE(ref) == IS_OBJECT && !(GC_FLAGS(ref) & IS_OBJ_FREE_CALLED)) { in gc_mark_grey()
440 zend_object *obj = (zend_object*)ref; in gc_mark_grey()
459 ref = Z_COUNTED_P(zv); in gc_mark_grey()
460 GC_REFCOUNT(ref)--; in gc_mark_grey()
461 gc_mark_grey(ref); in gc_mark_grey()
466 ref = Z_COUNTED_P(zv); in gc_mark_grey()
467 GC_REFCOUNT(ref)--; in gc_mark_grey()
473 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_mark_grey()
474 if (((zend_array*)ref) == &EG(symbol_table)) { in gc_mark_grey()
475 GC_REF_SET_BLACK(ref); in gc_mark_grey()
478 ht = (zend_array*)ref; in gc_mark_grey()
480 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_mark_grey()
481 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_mark_grey()
483 Z_TYPE(((zend_reference*)ref)->val) == IS_OBJECT) { in gc_mark_grey()
484 Z_TYPE_INFO(((zend_reference*)ref)->val) = IS_NULL; in gc_mark_grey()
487 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_mark_grey()
488 GC_REFCOUNT(ref)--; in gc_mark_grey()
520 ref = Z_COUNTED_P(zv); in gc_mark_grey()
521 GC_REFCOUNT(ref)--; in gc_mark_grey()
522 gc_mark_grey(ref); in gc_mark_grey()
535 ref = Z_COUNTED_P(zv); in gc_mark_grey()
536 GC_REFCOUNT(ref)--; in gc_mark_grey()
547 if (GC_REF_GET_COLOR(current->ref) == GC_PURPLE) { in gc_mark_roots()
548 gc_mark_grey(current->ref); in gc_mark_roots()
554 static void gc_scan(zend_refcounted *ref) in gc_scan() argument
561 if (GC_REF_GET_COLOR(ref) == GC_GREY) { in gc_scan()
562 if (GC_REFCOUNT(ref) > 0) { in gc_scan()
563 gc_scan_black(ref); in gc_scan()
565 GC_REF_SET_COLOR(ref, GC_WHITE); in gc_scan()
566 if (GC_TYPE(ref) == IS_OBJECT && !(GC_FLAGS(ref) & IS_OBJ_FREE_CALLED)) { in gc_scan()
568 zend_object *obj = (zend_object*)ref; in gc_scan()
587 ref = Z_COUNTED_P(zv); in gc_scan()
588 gc_scan(ref); in gc_scan()
593 ref = Z_COUNTED_P(zv); in gc_scan()
599 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_scan()
600 if ((zend_array*)ref == &EG(symbol_table)) { in gc_scan()
601 GC_REF_SET_BLACK(ref); in gc_scan()
604 ht = (zend_array*)ref; in gc_scan()
606 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_scan()
607 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_scan()
608 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_scan()
636 ref = Z_COUNTED_P(zv); in gc_scan()
637 gc_scan(ref); in gc_scan()
645 ref = Z_COUNTED_P(zv); in gc_scan()
656 gc_scan(current->ref); in gc_scan_roots()
661 static void gc_add_garbage(zend_refcounted *ref) in gc_add_garbage() argument
669 GC_INFO(ref) = buf - GC_G(buf); in gc_add_garbage()
671 GC_REF_SET_ADDRESS(ref, buf - GC_G(buf)); in gc_add_garbage()
678 GC_INFO(ref) = buf - GC_G(buf); in gc_add_garbage()
680 GC_REF_SET_ADDRESS(ref, buf - GC_G(buf)); in gc_add_garbage()
696 GC_INFO(ref) = GC_ROOT_BUFFER_MAX_ENTRIES + GC_G(additional_buffer)->used; in gc_add_garbage()
698 GC_REF_SET_ADDRESS(ref, GC_ROOT_BUFFER_MAX_ENTRIES) + GC_G(additional_buffer)->used; in gc_add_garbage()
703 GC_REFCOUNT(ref)++; in gc_add_garbage()
704 buf->ref = ref; in gc_add_garbage()
712 static int gc_collect_white(zend_refcounted *ref, uint32_t *flags) argument
720 if (GC_REF_GET_COLOR(ref) == GC_WHITE) {
722 GC_REF_SET_BLACK(ref);
725 if (GC_TYPE(ref) != IS_REFERENCE) {
729 if (GC_TYPE(ref) == IS_OBJECT && !(GC_FLAGS(ref) & IS_OBJ_FREE_CALLED)) {
731 zend_object *obj = (zend_object*)ref;
741 if (!GC_INFO(ref)) {
743 if (!GC_ADDRESS(GC_INFO(ref))) {
745 gc_add_garbage(ref);
767 ref = Z_COUNTED_P(zv);
768 GC_REFCOUNT(ref)++;
769 count += gc_collect_white(ref, flags);
777 ref = Z_COUNTED_P(zv);
778 GC_REFCOUNT(ref)++;
784 } else if (GC_TYPE(ref) == IS_ARRAY) {
787 if (!GC_INFO(ref)) {
789 if (!GC_ADDRESS(GC_INFO(ref))) {
791 gc_add_garbage(ref);
793 ht = (zend_array*)ref;
794 } else if (GC_TYPE(ref) == IS_REFERENCE) {
795 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
796 ref = Z_COUNTED(((zend_reference*)ref)->val);
797 GC_REFCOUNT(ref)++;
829 ref = Z_COUNTED_P(zv);
830 GC_REFCOUNT(ref)++;
831 count += gc_collect_white(ref, flags);
842 ref = Z_COUNTED_P(zv);
843 GC_REFCOUNT(ref)++;
857 if (GC_REF_GET_COLOR(current->ref) == GC_BLACK) {
858 if (EXPECTED(GC_ADDRESS(GC_INFO(current->ref)) < GC_ROOT_BUFFER_MAX_ENTRIES)) {
863 GC_INFO(current->ref) = 0; /* reset GC_ADDRESS() and keep GC_BLACK */
870 GC_REFCOUNT(current->ref)++;
871 if (GC_REF_GET_COLOR(current->ref) == GC_WHITE) {
872 count += gc_collect_white(current->ref, flags);
899 static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buffer *root) argument
907 (GC_ADDRESS(GC_INFO(ref)) != 0 &&
908 GC_REF_GET_COLOR(ref) == GC_BLACK)) {
909 GC_TRACE_REF(ref, "removing from buffer");
910 GC_REFCOUNT(ref)--;
912 if (EXPECTED(GC_ADDRESS(GC_INFO(root->ref)) < GC_ROOT_BUFFER_MAX_ENTRIES)) {
917 GC_INFO(ref) = 0;
920 GC_REMOVE_FROM_BUFFER(ref);
923 if (GC_TYPE(ref) == IS_OBJECT && !(GC_FLAGS(ref) & IS_OBJ_FREE_CALLED)) {
925 zend_object *obj = (zend_object*)ref;
944 ref = Z_COUNTED_P(zv);
945 gc_remove_nested_data_from_buffer(ref, NULL);
950 ref = Z_COUNTED_P(zv);
956 } else if (GC_TYPE(ref) == IS_ARRAY) {
957 ht = (zend_array*)ref;
958 } else if (GC_TYPE(ref) == IS_REFERENCE) {
959 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
960 ref = Z_COUNTED(((zend_reference*)ref)->val);
988 ref = Z_COUNTED_P(zv);
989 gc_remove_nested_data_from_buffer(ref, NULL);
997 ref = Z_COUNTED_P(zv);
1071 current->refcount = GC_REFCOUNT(current->ref);
1078 p = current->ref;
1101 if (GC_REFCOUNT(current->ref) > current->refcount) {
1102 gc_remove_nested_data_from_buffer(current->ref, current);
1114 p = current->ref;
1134 p = current->ref = (zend_refcounted*)(((char*)obj) - obj->handlers->offset);
1149 p = current->ref;