Lines Matching refs:ref

92 # define GC_TRACE_REF(ref, format, ...) \  argument
94 gc_trace_ref((zend_refcounted *) ref); \
97 # define GC_TRACE_SET_COLOR(ref, color) \ argument
98 GC_TRACE_REF(ref, "->%s", gc_color_name(color))
100 # define GC_TRACE_REF(ref, format, ...) argument
101 # define GC_TRACE_SET_COLOR(ref, new_color) argument
106 #define GC_REF_ADDRESS(ref) \ argument
107 (((GC_TYPE_INFO(ref)) & (GC_ADDRESS << GC_INFO_SHIFT)) >> GC_INFO_SHIFT)
109 #define GC_REF_COLOR(ref) \ argument
110 (((GC_TYPE_INFO(ref)) & (GC_COLOR << GC_INFO_SHIFT)) >> GC_INFO_SHIFT)
112 #define GC_REF_CHECK_COLOR(ref, color) \ argument
113 ((GC_TYPE_INFO(ref) & (GC_COLOR << GC_INFO_SHIFT)) == ((color) << GC_INFO_SHIFT))
115 #define GC_REF_SET_INFO(ref, info) do { \ argument
116 GC_TYPE_INFO(ref) = \
117 (GC_TYPE_INFO(ref) & (GC_TYPE_MASK | GC_FLAGS_MASK)) | \
121 #define GC_REF_SET_COLOR(ref, c) do { \ argument
122 GC_TRACE_SET_COLOR(ref, c); \
123 GC_TYPE_INFO(ref) = \
124 (GC_TYPE_INFO(ref) & ~(GC_COLOR << GC_INFO_SHIFT)) | \
128 #define GC_REF_SET_BLACK(ref) do { \ argument
129 GC_TRACE_SET_COLOR(ref, GC_BLACK); \
130 GC_TYPE_INFO(ref) &= ~(GC_COLOR << GC_INFO_SHIFT); \
133 #define GC_REF_SET_PURPLE(ref) do { \ argument
134 GC_TRACE_SET_COLOR(ref, GC_PURPLE); \
135 GC_TYPE_INFO(ref) |= (GC_COLOR << GC_INFO_SHIFT); \
206 zend_refcounted *ref; member
274 #define GC_STACK_PUSH(ref) \ argument
275 gc_stack_push(&_stack, &_top, ref);
291 static zend_always_inline void gc_stack_push(gc_stack **stack, size_t *top, zend_refcounted *ref) in gc_stack_push() argument
297 (*stack)->data[(*top)++] = ref; in gc_stack_push()
334 static zend_always_inline gc_root_buffer* gc_decompress(zend_refcounted *ref, uint32_t idx) in gc_decompress() argument
338 if (EXPECTED(GC_GET_PTR(root->ref) == ref)) { in gc_decompress()
346 if (GC_GET_PTR(root->ref) == ref) { in gc_decompress()
360 ZEND_ASSERT(GC_IS_UNUSED(root->ref)); in gc_fetch_unused()
361 GC_G(unused) = GC_LIST2IDX(root->ref); in gc_fetch_unused()
367 root->ref = GC_IDX2LIST(GC_G(unused)); in gc_link_unused()
391 static void gc_trace_ref(zend_refcounted *ref) { in gc_trace_ref() argument
392 if (GC_TYPE(ref) == IS_OBJECT) { in gc_trace_ref()
393 zend_object *obj = (zend_object *) ref; in gc_trace_ref()
395 ref, GC_REFCOUNT(ref), GC_REF_ADDRESS(ref), in gc_trace_ref()
396 gc_color_name(GC_REF_COLOR(ref)), in gc_trace_ref()
398 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_trace_ref()
399 zend_array *arr = (zend_array *) ref; in gc_trace_ref()
401 ref, GC_REFCOUNT(ref), GC_REF_ADDRESS(ref), in gc_trace_ref()
402 gc_color_name(GC_REF_COLOR(ref)), in gc_trace_ref()
406 ref, GC_REFCOUNT(ref), GC_REF_ADDRESS(ref), in gc_trace_ref()
407 gc_color_name(GC_REF_COLOR(ref)), in gc_trace_ref()
408 GC_TYPE(ref) == IS_REFERENCE in gc_trace_ref()
409 ? "reference" : zend_get_type_by_const(GC_TYPE(ref))); in gc_trace_ref()
502 GC_G(buf)[0].ref = NULL; in gc_enable()
582 static zend_never_inline void ZEND_FASTCALL gc_possible_root_when_full(zend_refcounted *ref) in gc_possible_root_when_full() argument
587 ZEND_ASSERT(GC_TYPE(ref) == IS_ARRAY || GC_TYPE(ref) == IS_OBJECT); in gc_possible_root_when_full()
588 ZEND_ASSERT(GC_INFO(ref) == 0); in gc_possible_root_when_full()
591 GC_ADDREF(ref); in gc_possible_root_when_full()
593 if (UNEXPECTED(GC_DELREF(ref)) == 0) { in gc_possible_root_when_full()
594 rc_dtor_func(ref); in gc_possible_root_when_full()
596 } else if (UNEXPECTED(GC_INFO(ref))) { in gc_possible_root_when_full()
614 newRoot->ref = ref; /* GC_ROOT tag is 0 */ in gc_possible_root_when_full()
615 GC_TRACE_SET_COLOR(ref, GC_PURPLE); in gc_possible_root_when_full()
618 GC_REF_SET_INFO(ref, idx | GC_PURPLE); in gc_possible_root_when_full()
626 ZEND_API void ZEND_FASTCALL gc_possible_root(zend_refcounted *ref) in gc_possible_root() argument
642 gc_possible_root_when_full(ref); in gc_possible_root()
646 ZEND_ASSERT(GC_TYPE(ref) == IS_ARRAY || GC_TYPE(ref) == IS_OBJECT); in gc_possible_root()
647 ZEND_ASSERT(GC_INFO(ref) == 0); in gc_possible_root()
650 newRoot->ref = ref; /* GC_ROOT tag is 0 */ in gc_possible_root()
651 GC_TRACE_SET_COLOR(ref, GC_PURPLE); in gc_possible_root()
654 GC_REF_SET_INFO(ref, idx | GC_PURPLE); in gc_possible_root()
662 static zend_never_inline void ZEND_FASTCALL gc_remove_compressed(zend_refcounted *ref, uint32_t idx) in gc_remove_compressed() argument
664 gc_root_buffer *root = gc_decompress(ref, idx); in gc_remove_compressed()
668 ZEND_API void ZEND_FASTCALL gc_remove_from_buffer(zend_refcounted *ref) in gc_remove_from_buffer() argument
671 uint32_t idx = GC_REF_ADDRESS(ref); in gc_remove_from_buffer()
675 if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_remove_from_buffer()
676 GC_TRACE_SET_COLOR(ref, GC_BLACK); in gc_remove_from_buffer()
678 GC_REF_SET_INFO(ref, 0); in gc_remove_from_buffer()
682 gc_remove_compressed(ref, idx); in gc_remove_from_buffer()
691 static void gc_scan_black(zend_refcounted *ref, gc_stack *stack) in gc_scan_black() argument
699 if (GC_TYPE(ref) == IS_OBJECT) { in gc_scan_black()
700 zend_object *obj = (zend_object*)ref; in gc_scan_black()
702 if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { in gc_scan_black()
721 ref = Z_COUNTED_P(zv); in gc_scan_black()
722 GC_ADDREF(ref); in gc_scan_black()
723 if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_scan_black()
724 GC_REF_SET_BLACK(ref); in gc_scan_black()
725 GC_STACK_PUSH(ref); in gc_scan_black()
731 ref = Z_COUNTED_P(zv); in gc_scan_black()
732 GC_ADDREF(ref); in gc_scan_black()
733 if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_scan_black()
734 GC_REF_SET_BLACK(ref); in gc_scan_black()
742 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_scan_black()
743 if ((zend_array*)ref != &EG(symbol_table)) { in gc_scan_black()
744 ht = (zend_array*)ref; in gc_scan_black()
748 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_scan_black()
749 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_scan_black()
750 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_scan_black()
751 GC_ADDREF(ref); in gc_scan_black()
752 if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_scan_black()
753 GC_REF_SET_BLACK(ref); in gc_scan_black()
783 ref = Z_COUNTED_P(zv); in gc_scan_black()
784 GC_ADDREF(ref); in gc_scan_black()
785 if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_scan_black()
786 GC_REF_SET_BLACK(ref); in gc_scan_black()
787 GC_STACK_PUSH(ref); in gc_scan_black()
796 ref = Z_COUNTED_P(zv); in gc_scan_black()
797 GC_ADDREF(ref); in gc_scan_black()
798 if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_scan_black()
799 GC_REF_SET_BLACK(ref); in gc_scan_black()
804 ref = GC_STACK_POP(); in gc_scan_black()
805 if (ref) { in gc_scan_black()
810 static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack) in gc_mark_grey() argument
820 if (GC_TYPE(ref) == IS_OBJECT) { in gc_mark_grey()
821 zend_object *obj = (zend_object*)ref; in gc_mark_grey()
823 if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { in gc_mark_grey()
842 ref = Z_COUNTED_P(zv); in gc_mark_grey()
843 GC_DELREF(ref); in gc_mark_grey()
844 if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_mark_grey()
845 GC_REF_SET_COLOR(ref, GC_GREY); in gc_mark_grey()
846 GC_STACK_PUSH(ref); in gc_mark_grey()
852 ref = Z_COUNTED_P(zv); in gc_mark_grey()
853 GC_DELREF(ref); in gc_mark_grey()
854 if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_mark_grey()
855 GC_REF_SET_COLOR(ref, GC_GREY); in gc_mark_grey()
863 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_mark_grey()
864 if (((zend_array*)ref) == &EG(symbol_table)) { in gc_mark_grey()
865 GC_REF_SET_BLACK(ref); in gc_mark_grey()
868 ht = (zend_array*)ref; in gc_mark_grey()
870 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_mark_grey()
871 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_mark_grey()
872 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_mark_grey()
873 GC_DELREF(ref); in gc_mark_grey()
874 if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_mark_grey()
875 GC_REF_SET_COLOR(ref, GC_GREY); in gc_mark_grey()
905 ref = Z_COUNTED_P(zv); in gc_mark_grey()
906 GC_DELREF(ref); in gc_mark_grey()
907 if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_mark_grey()
908 GC_REF_SET_COLOR(ref, GC_GREY); in gc_mark_grey()
909 GC_STACK_PUSH(ref); in gc_mark_grey()
918 ref = Z_COUNTED_P(zv); in gc_mark_grey()
919 GC_DELREF(ref); in gc_mark_grey()
920 if (!GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_mark_grey()
921 GC_REF_SET_COLOR(ref, GC_GREY); in gc_mark_grey()
926 ref = GC_STACK_POP(); in gc_mark_grey()
927 } while (ref); in gc_mark_grey()
942 while (!GC_IS_UNUSED(free->ref)) { in gc_compact()
945 while (GC_IS_UNUSED(scan->ref)) { in gc_compact()
949 p = scan->ref; in gc_compact()
950 free->ref = p; in gc_compact()
976 if (GC_IS_ROOT(current->ref)) { in gc_mark_roots()
977 if (GC_REF_CHECK_COLOR(current->ref, GC_PURPLE)) { in gc_mark_roots()
978 GC_REF_SET_COLOR(current->ref, GC_GREY); in gc_mark_roots()
979 gc_mark_grey(current->ref, stack); in gc_mark_roots()
986 static void gc_scan(zend_refcounted *ref, gc_stack *stack) in gc_scan() argument
994 if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { in gc_scan()
995 if (GC_REFCOUNT(ref) > 0) { in gc_scan()
996 if (!GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_scan()
997 GC_REF_SET_BLACK(ref); in gc_scan()
1003 gc_scan_black(ref, _stack->next); in gc_scan()
1007 if (GC_TYPE(ref) == IS_OBJECT) { in gc_scan()
1008 zend_object *obj = (zend_object*)ref; in gc_scan()
1010 if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { in gc_scan()
1029 ref = Z_COUNTED_P(zv); in gc_scan()
1030 if (GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_scan()
1031 GC_REF_SET_COLOR(ref, GC_WHITE); in gc_scan()
1032 GC_STACK_PUSH(ref); in gc_scan()
1038 ref = Z_COUNTED_P(zv); in gc_scan()
1039 if (GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_scan()
1040 GC_REF_SET_COLOR(ref, GC_WHITE); in gc_scan()
1048 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_scan()
1049 if ((zend_array*)ref == &EG(symbol_table)) { in gc_scan()
1050 GC_REF_SET_BLACK(ref); in gc_scan()
1053 ht = (zend_array*)ref; in gc_scan()
1055 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_scan()
1056 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_scan()
1057 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_scan()
1058 if (GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_scan()
1059 GC_REF_SET_COLOR(ref, GC_WHITE); in gc_scan()
1089 ref = Z_COUNTED_P(zv); in gc_scan()
1090 if (GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_scan()
1091 GC_REF_SET_COLOR(ref, GC_WHITE); in gc_scan()
1092 GC_STACK_PUSH(ref); in gc_scan()
1101 ref = Z_COUNTED_P(zv); in gc_scan()
1102 if (GC_REF_CHECK_COLOR(ref, GC_GREY)) { in gc_scan()
1103 GC_REF_SET_COLOR(ref, GC_WHITE); in gc_scan()
1110 ref = GC_STACK_POP(); in gc_scan()
1111 if (ref) { in gc_scan()
1122 if (GC_IS_ROOT(current->ref)) { in gc_scan_roots()
1123 if (GC_REF_CHECK_COLOR(current->ref, GC_GREY)) { in gc_scan_roots()
1124 GC_REF_SET_COLOR(current->ref, GC_WHITE); in gc_scan_roots()
1125 gc_scan(current->ref, stack); in gc_scan_roots()
1132 static void gc_add_garbage(zend_refcounted *ref) in gc_add_garbage() argument
1150 buf->ref = GC_MAKE_GARBAGE(ref); in gc_add_garbage()
1153 GC_REF_SET_INFO(ref, idx | GC_BLACK); in gc_add_garbage()
1157 static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_stack *stack) in gc_collect_white() argument
1167 if (GC_TYPE(ref) != IS_REFERENCE) { in gc_collect_white()
1171 if (GC_TYPE(ref) == IS_OBJECT) { in gc_collect_white()
1172 zend_object *obj = (zend_object*)ref; in gc_collect_white()
1174 if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { in gc_collect_white()
1179 if (!GC_INFO(ref)) { in gc_collect_white()
1180 gc_add_garbage(ref); in gc_collect_white()
1202 ref = Z_COUNTED_P(zv); in gc_collect_white()
1203 GC_ADDREF(ref); in gc_collect_white()
1204 if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { in gc_collect_white()
1205 GC_REF_SET_BLACK(ref); in gc_collect_white()
1206 GC_STACK_PUSH(ref); in gc_collect_white()
1212 ref = Z_COUNTED_P(zv); in gc_collect_white()
1213 GC_ADDREF(ref); in gc_collect_white()
1214 if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { in gc_collect_white()
1215 GC_REF_SET_BLACK(ref); in gc_collect_white()
1223 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_collect_white()
1225 if (!GC_INFO(ref)) { in gc_collect_white()
1226 gc_add_garbage(ref); in gc_collect_white()
1228 ht = (zend_array*)ref; in gc_collect_white()
1229 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_collect_white()
1230 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_collect_white()
1231 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_collect_white()
1232 GC_ADDREF(ref); in gc_collect_white()
1233 if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { in gc_collect_white()
1234 GC_REF_SET_BLACK(ref); in gc_collect_white()
1264 ref = Z_COUNTED_P(zv); in gc_collect_white()
1265 GC_ADDREF(ref); in gc_collect_white()
1266 if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { in gc_collect_white()
1267 GC_REF_SET_BLACK(ref); in gc_collect_white()
1268 GC_STACK_PUSH(ref); in gc_collect_white()
1277 ref = Z_COUNTED_P(zv); in gc_collect_white()
1278 GC_ADDREF(ref); in gc_collect_white()
1279 if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { in gc_collect_white()
1280 GC_REF_SET_BLACK(ref); in gc_collect_white()
1285 ref = GC_STACK_POP(); in gc_collect_white()
1286 } while (ref); in gc_collect_white()
1294 zend_refcounted *ref; in gc_collect_roots() local
1301 if (GC_IS_ROOT(current->ref)) { in gc_collect_roots()
1302 if (GC_REF_CHECK_COLOR(current->ref, GC_BLACK)) { in gc_collect_roots()
1303 GC_REF_SET_INFO(current->ref, 0); /* reset GC_ADDRESS() and keep GC_BLACK */ in gc_collect_roots()
1318 ref = current->ref; in gc_collect_roots()
1319 ZEND_ASSERT(GC_IS_ROOT(ref)); in gc_collect_roots()
1320 current->ref = GC_MAKE_GARBAGE(ref); in gc_collect_roots()
1321 if (GC_REF_CHECK_COLOR(ref, GC_WHITE)) { in gc_collect_roots()
1322 GC_REF_SET_BLACK(ref); in gc_collect_roots()
1323 count += gc_collect_white(ref, flags, stack); in gc_collect_roots()
1331 static int gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buffer *root, gc_stack *… in gc_remove_nested_data_from_buffer() argument
1343 } else if (GC_REF_ADDRESS(ref) != 0 in gc_remove_nested_data_from_buffer()
1344 && GC_REF_CHECK_COLOR(ref, GC_BLACK)) { in gc_remove_nested_data_from_buffer()
1345 GC_TRACE_REF(ref, "removing from buffer"); in gc_remove_nested_data_from_buffer()
1346 GC_REMOVE_FROM_BUFFER(ref); in gc_remove_nested_data_from_buffer()
1348 } else if (GC_TYPE(ref) == IS_REFERENCE) { in gc_remove_nested_data_from_buffer()
1349 if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { in gc_remove_nested_data_from_buffer()
1350 ref = Z_COUNTED(((zend_reference*)ref)->val); in gc_remove_nested_data_from_buffer()
1358 if (GC_TYPE(ref) == IS_OBJECT) { in gc_remove_nested_data_from_buffer()
1359 zend_object *obj = (zend_object*)ref; in gc_remove_nested_data_from_buffer()
1361 if (EXPECTED(!(OBJ_FLAGS(ref) & IS_OBJ_FREE_CALLED))) { in gc_remove_nested_data_from_buffer()
1378 ref = Z_COUNTED_P(zv); in gc_remove_nested_data_from_buffer()
1379 GC_STACK_PUSH(ref); in gc_remove_nested_data_from_buffer()
1384 ref = Z_COUNTED_P(zv); in gc_remove_nested_data_from_buffer()
1395 } else if (GC_TYPE(ref) == IS_ARRAY) { in gc_remove_nested_data_from_buffer()
1396 ht = (zend_array*)ref; in gc_remove_nested_data_from_buffer()
1421 ref = Z_COUNTED_P(zv); in gc_remove_nested_data_from_buffer()
1422 GC_STACK_PUSH(ref); in gc_remove_nested_data_from_buffer()
1430 ref = Z_COUNTED_P(zv); in gc_remove_nested_data_from_buffer()
1434 ref = GC_STACK_POP(); in gc_remove_nested_data_from_buffer()
1435 } while (ref); in gc_remove_nested_data_from_buffer()
1499 if (GC_IS_GARBAGE(current->ref)) { in zend_gc_collect_cycles()
1500 p = GC_GET_PTR(current->ref); in zend_gc_collect_cycles()
1505 current->ref = GC_MAKE_DTOR_GARBAGE(obj); in zend_gc_collect_cycles()
1522 if (GC_IS_DTOR_GARBAGE(current->ref)) { in zend_gc_collect_cycles()
1523 p = GC_GET_PTR(current->ref); in zend_gc_collect_cycles()
1537 if (GC_IS_DTOR_GARBAGE(current->ref)) { in zend_gc_collect_cycles()
1538 p = GC_GET_PTR(current->ref); in zend_gc_collect_cycles()
1541 current->ref = p; in zend_gc_collect_cycles()
1570 if (GC_IS_GARBAGE(current->ref)) { in zend_gc_collect_cycles()
1571 p = GC_GET_PTR(current->ref); in zend_gc_collect_cycles()
1580 current->ref = GC_MAKE_GARBAGE(((char*)obj) - obj->handlers->offset); in zend_gc_collect_cycles()
1608 if (GC_IS_GARBAGE(current->ref)) { in zend_gc_collect_cycles()
1609 p = GC_GET_PTR(current->ref); in zend_gc_collect_cycles()