Mercurial > hg > xemacs-beta
comparison src/xgccache.c @ 3094:ad2f4ae9895b
[xemacs-hg @ 2005-11-26 11:45:47 by stephent]
Xft merge. <87k6ev4p8q.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Sat, 26 Nov 2005 11:46:25 +0000 |
parents | 1e2a3710564c |
children | ea87f3f1e3ff |
comparison
equal
deleted
inserted
replaced
3093:769dc945b085 | 3094:ad2f4ae9895b |
---|---|
156 gc_cache_lookup (struct gc_cache *cache, XGCValues *gcv, unsigned long mask) | 156 gc_cache_lookup (struct gc_cache *cache, XGCValues *gcv, unsigned long mask) |
157 { | 157 { |
158 struct gc_cache_cell *cell, *next, *prev; | 158 struct gc_cache_cell *cell, *next, *prev; |
159 struct gcv_and_mask gcvm; | 159 struct gcv_and_mask gcvm; |
160 | 160 |
161 #ifdef DEBUG_XEMACS | |
162 (void) describe_gc_cache (cache, DGCCFLAG_DISABLE); | |
163 #endif | |
164 | |
161 if ((!!cache->head) != (!!cache->tail)) ABORT (); | 165 if ((!!cache->head) != (!!cache->tail)) ABORT (); |
162 if (cache->head && (cache->head->prev || cache->tail->next)) ABORT (); | 166 if (cache->head && (cache->head->prev || cache->tail->next)) ABORT (); |
163 | 167 |
164 gcvm.mask = mask; | 168 gcvm.mask = mask; |
165 gcvm.gcv = *gcv; /* this copies... */ | 169 gcvm.gcv = *gcv; /* this copies... */ |
194 { | 198 { |
195 /* Found a cell. Move this cell to the end of the list, so that it | 199 /* Found a cell. Move this cell to the end of the list, so that it |
196 will be less likely to be collected than a cell that was accessed | 200 will be less likely to be collected than a cell that was accessed |
197 less recently. | 201 less recently. |
198 */ | 202 */ |
203 #if 0 | |
204 debug_out ("Returning cached GC: %08lx\n", XE_GCONTEXT(cell)); | |
205 #endif | |
199 if (cell == cache->tail) | 206 if (cell == cache->tail) |
200 return cell->gc; | 207 return cell->gc; |
201 | 208 |
202 next = cell->next; | 209 next = cell->next; |
203 prev = cell->prev; | 210 prev = cell->prev; |
224 { | 231 { |
225 cell = cache->head; | 232 cell = cache->head; |
226 cache->head = cell->next; | 233 cache->head = cell->next; |
227 cache->head->prev = 0; | 234 cache->head->prev = 0; |
228 if (cache->tail == cell) cache->tail = 0; /* only one */ | 235 if (cache->tail == cell) cache->tail = 0; /* only one */ |
236 debug_out ("Cache full, freeing GC: %08lx\n ", XE_GCONTEXT(cell)); | |
229 XFreeGC (cache->dpy, cell->gc); | 237 XFreeGC (cache->dpy, cell->gc); |
230 cache->delete_count++; | 238 cache->delete_count++; |
231 #ifdef GCCACHE_HASH | 239 #ifdef GCCACHE_HASH |
232 remhash (&cell->gcvm, cache->table); | 240 remhash (&cell->gcvm, cache->table); |
233 #endif | 241 #endif |
262 cell->gc = XCreateGC (cache->dpy, cache->window, mask, gcv); | 270 cell->gc = XCreateGC (cache->dpy, cache->window, mask, gcv); |
263 | 271 |
264 /* debug */ | 272 /* debug */ |
265 assert (cell->gc == gc_cache_lookup (cache, gcv, mask)); | 273 assert (cell->gc == gc_cache_lookup (cache, gcv, mask)); |
266 | 274 |
275 #if 0 | |
276 debug_out ("Returning new GC: %08lx\n ", XE_GCONTEXT(cell)); | |
277 #endif | |
267 return cell->gc; | 278 return cell->gc; |
268 } | 279 } |
269 | 280 |
270 | 281 |
271 #ifdef DEBUG_XEMACS | 282 #ifdef DEBUG_XEMACS |
272 | 283 |
273 void describe_gc_cache (struct gc_cache *cache); | 284 /* FLAGS |
285 The flags argument is a bitwise or of any of the following: | |
286 | |
287 DGCCFLAG_SUMMARY Summary statistics for cache | |
288 DGCCFLAG_LIST_CELLS If summary is being printed, print cell IDs too. | |
289 DGCCFLAG_CELL_DETAILS If cell IDs are being printed, additionally | |
290 print the internal fields used and values. | |
291 | |
292 DGCCFLAG_DEFAULT A predefined combination giving whatever the | |
293 maintainers are currently interested in seeing. | |
294 */ | |
274 void | 295 void |
275 describe_gc_cache (struct gc_cache *cache) | 296 describe_gc_cache (struct gc_cache *cache, int flags) |
276 { | 297 { |
277 int count = 0; | 298 int count = 0; |
278 struct gc_cache_cell *cell = cache->head; | 299 struct gc_cache_cell *cell = cache->head; |
300 | |
301 if (! flags & DGCCFLAG_SUMMARY) return; | |
302 | |
279 stderr_out ("\nsize: %d", cache->size); | 303 stderr_out ("\nsize: %d", cache->size); |
280 stderr_out ("\ncreated: %d", cache->create_count); | 304 stderr_out ("\ncreated: %d", cache->create_count); |
281 stderr_out ("\ndeleted: %d", cache->delete_count); | 305 stderr_out ("\ndeleted: %d", cache->delete_count); |
282 while (cell) | 306 |
283 { | 307 if (flags & DGCCFLAG_LIST_CELLS) |
284 struct gc_cache_cell *cell2; | 308 while (cell) |
285 int i = 0; | 309 { |
286 stderr_out ("\n%d:\t0x%lx GC: 0x%08lx hash: 0x%08lx\n", | 310 struct gc_cache_cell *cell2; |
287 count, (long) cell, (long) cell->gc, gc_cache_hash (&cell->gcvm)); | 311 int i = 0; |
288 for (cell2 = cache->head; cell2; cell2 = cell2->next, i++) | 312 stderr_out ("\n%d:\t0x%lx GC: 0x%08lx hash: 0x%08lx\n", |
289 if (count != i && | 313 count, (long) cell, (long) XE_GCONTEXT(cell), |
290 gc_cache_hash (&cell->gcvm) == gc_cache_hash (&cell2->gcvm)) | 314 gc_cache_hash (&cell->gcvm)); |
291 stderr_out ("\tHASH COLLISION with cell %d\n", i); | 315 |
292 stderr_out ("\tmask: %8lx\n", cell->gcvm.mask); | 316 for (cell2 = cache->head; cell2; cell2 = cell2->next, i++) |
293 | 317 if (count != i && |
318 gc_cache_hash (&cell->gcvm) == gc_cache_hash (&cell2->gcvm)) | |
319 stderr_out ("\tHASH COLLISION with cell %d\n", i); | |
320 stderr_out ("\tmask: %8lx\n", cell->gcvm.mask); | |
321 | |
322 if (flags & DGCCFLAG_CELL_DETAILS) | |
323 { | |
294 #define FROB(field) do { \ | 324 #define FROB(field) do { \ |
295 if ((int)cell->gcvm.gcv.field != (~0)) \ | 325 if ((int)cell->gcvm.gcv.field != (~0)) \ |
296 stderr_out ("\t%-12s%8x\n", #field ":", (int)cell->gcvm.gcv.field); \ | 326 stderr_out ("\t%-12s%8x\n", #field ":", (int)cell->gcvm.gcv.field); \ |
297 } while (0) | 327 } while (0) |
298 FROB (function); | 328 FROB (function); |
299 FROB (plane_mask); | 329 FROB (plane_mask); |
300 FROB (foreground); | 330 FROB (foreground); |
301 FROB (background); | 331 FROB (background); |
302 FROB (line_width); | 332 FROB (line_width); |
303 FROB (line_style); | 333 FROB (line_style); |
304 FROB (cap_style); | 334 FROB (cap_style); |
305 FROB (join_style); | 335 FROB (join_style); |
306 FROB (fill_style); | 336 FROB (fill_style); |
307 FROB (fill_rule); | 337 FROB (fill_rule); |
308 FROB (arc_mode); | 338 FROB (arc_mode); |
309 FROB (tile); | 339 FROB (tile); |
310 FROB (stipple); | 340 FROB (stipple); |
311 FROB (ts_x_origin); | 341 FROB (ts_x_origin); |
312 FROB (ts_y_origin); | 342 FROB (ts_y_origin); |
313 FROB (font); | 343 FROB (font); |
314 FROB (subwindow_mode); | 344 FROB (subwindow_mode); |
315 FROB (graphics_exposures); | 345 FROB (graphics_exposures); |
316 FROB (clip_x_origin); | 346 FROB (clip_x_origin); |
317 FROB (clip_y_origin); | 347 FROB (clip_y_origin); |
318 FROB (clip_mask); | 348 FROB (clip_mask); |
319 FROB (dash_offset); | 349 FROB (dash_offset); |
320 #undef FROB | 350 #undef FROB |
321 | 351 } |
322 count++; | 352 |
323 if (cell->next && cell == cache->tail) | 353 count++; |
324 stderr_out ("\nERROR! tail is here!\n\n"); | 354 if (cell->next && cell == cache->tail) |
325 else if (!cell->next && cell != cache->tail) | 355 stderr_out ("\nERROR! tail is here!\n\n"); |
326 stderr_out ("\nERROR! tail is not at the end\n\n"); | 356 else if (!cell->next && cell != cache->tail) |
327 cell = cell->next; | 357 stderr_out ("\nERROR! tail is not at the end\n\n"); |
328 } | 358 cell = cell->next; |
359 } /* while (cell) */ | |
360 | |
329 if (count != cache->size) | 361 if (count != cache->size) |
330 stderr_out ("\nERROR! count should be %d\n\n", cache->size); | 362 stderr_out ("\nERROR! count should be %d\n\n", cache->size); |
331 } | 363 } |
332 | 364 |
333 #endif /* DEBUG_XEMACS */ | 365 #endif /* DEBUG_XEMACS */ |