|
86 | 86 | #define GC_GREY 0x200000u
|
87 | 87 | #define GC_PURPLE 0x300000u
|
88 | 88 |
|
| 89 | +/* Debug tracing */ |
| 90 | +#if ZEND_GC_DEBUG > 1 |
| 91 | +# define GC_TRACE(format, ...) fprintf(stderr, format "\n", ##__VA_ARGS__); |
| 92 | +# define GC_TRACE_REF(ref, format, ...) \ |
| 93 | + do { \ |
| 94 | + gc_trace_ref((zend_refcounted *) ref); \ |
| 95 | + fprintf(stderr, format "\n", ##__VA_ARGS__); \ |
| 96 | + } while (0) |
| 97 | +# define GC_TRACE_SET_COLOR(ref, color) \ |
| 98 | + GC_TRACE_REF(ref, "->%s", gc_color_name(color)) |
| 99 | +#else |
| 100 | +# define GC_TRACE_REF(ref, format, ...) |
| 101 | +# define GC_TRACE_SET_COLOR(ref, new_color) |
| 102 | +# define GC_TRACE(str) |
| 103 | +#endif |
| 104 | + |
89 | 105 | /* GC_INFO access */
|
90 | 106 | #define GC_REF_ADDRESS(ref) \
|
91 | 107 | (((GC_TYPE_INFO(ref)) & (GC_ADDRESS << GC_INFO_SHIFT)) >> GC_INFO_SHIFT)
|
|
103 | 119 | } while (0)
|
104 | 120 |
|
105 | 121 | #define GC_REF_SET_COLOR(ref, c) do { \
|
| 122 | + GC_TRACE_SET_COLOR(ref, c); \ |
106 | 123 | GC_TYPE_INFO(ref) = \
|
107 | 124 | (GC_TYPE_INFO(ref) & ~(GC_COLOR << GC_INFO_SHIFT)) | \
|
108 | 125 | ((c) << GC_INFO_SHIFT); \
|
109 | 126 | } while (0)
|
110 | 127 |
|
111 | 128 | #define GC_REF_SET_BLACK(ref) do { \
|
| 129 | + GC_TRACE_SET_COLOR(ref, GC_BLACK); \ |
112 | 130 | GC_TYPE_INFO(ref) &= ~(GC_COLOR << GC_INFO_SHIFT); \
|
113 | 131 | } while (0)
|
114 | 132 |
|
115 | 133 | #define GC_REF_SET_PURPLE(ref) do { \
|
| 134 | + GC_TRACE_SET_COLOR(ref, GC_PURPLE); \ |
116 | 135 | GC_TYPE_INFO(ref) |= (GC_COLOR << GC_INFO_SHIFT); \
|
117 | 136 | } while (0)
|
118 | 137 |
|
@@ -232,21 +251,6 @@ static zend_gc_globals gc_globals;
|
232 | 251 | # define GC_BENCH_PEAK(peak, counter)
|
233 | 252 | #endif
|
234 | 253 |
|
235 |
| -#if ZEND_GC_DEBUG > 1 |
236 |
| -# define GC_TRACE(format, ...) fprintf(stderr, format "\n", ##__VA_ARGS__); |
237 |
| -# define GC_TRACE_REF(ref, format, ...) \ |
238 |
| - do { \ |
239 |
| - gc_trace_ref((zend_refcounted *) ref); \ |
240 |
| - fprintf(stderr, format "\n", ##__VA_ARGS__); \ |
241 |
| - } while (0) |
242 |
| -# define GC_TRACE_SET_COLOR(ref, color) \ |
243 |
| - GC_TRACE_REF(ref, "->%s", gc_color_name(color)) |
244 |
| -#else |
245 |
| -# define GC_TRACE_REF(ref, format, ...) |
246 |
| -# define GC_TRACE_SET_COLOR(ref, new_color) |
247 |
| -# define GC_TRACE(str) |
248 |
| -#endif |
249 |
| - |
250 | 254 |
|
251 | 255 | #define GC_STACK_SEGMENT_SIZE (((4096 - ZEND_MM_OVERHEAD) / sizeof(void*)) - 2)
|
252 | 256 |
|
|
0 commit comments