comparison src/gc.c @ 4934:714f7c9fabb1

make it easier to debug staticpro crashes. Add functions to print out the variable names saved during calls to staticpro(), and change the order of enumerating staticpros to start from 0 to make it easier to get a count to pass to the new functions.
author Ben Wing <ben@xemacs.org>
date Tue, 19 Jan 2010 01:21:39 -0600
parents 8748a3f7ceb4
children 19a72041c5ed
comparison
equal deleted inserted replaced
4933:77e3b19bd245 4934:714f7c9fabb1
1 /* New incremental garbage collector for XEmacs. 1 /* New incremental garbage collector for XEmacs.
2 Copyright (C) 2005 Marcus Crestani. 2 Copyright (C) 2005 Marcus Crestani.
3 Copyright (C) 2010 Ben Wing.
3 4
4 This file is part of XEmacs. 5 This file is part of XEmacs.
5 6
6 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
1622 # define mark_object(obj) kkcc_gc_stack_push_lisp_object (obj, 0, -1) 1623 # define mark_object(obj) kkcc_gc_stack_push_lisp_object (obj, 0, -1)
1623 #endif /* USE_KKCC */ 1624 #endif /* USE_KKCC */
1624 1625
1625 { /* staticpro() */ 1626 { /* staticpro() */
1626 Lisp_Object **p = Dynarr_begin (staticpros); 1627 Lisp_Object **p = Dynarr_begin (staticpros);
1628 Elemcount len = Dynarr_length (staticpros);
1627 Elemcount count; 1629 Elemcount count;
1628 for (count = Dynarr_length (staticpros); count; count--, p++) 1630 for (count = 0; count < len; count++, p++)
1629 /* Need to check if the pointer in the staticpro array is not 1631 /* Need to check if the pointer in the staticpro array is not
1630 NULL. A gc can occur after variable is added to the staticpro 1632 NULL. A gc can occur after variable is added to the staticpro
1631 array and _before_ it is correctly initialized. In this case 1633 array and _before_ it is correctly initialized. In this case
1632 its value is NULL, which we have to catch here. */ 1634 its value is NULL, which we have to catch here. */
1633 if (*p) 1635 if (*p)
1634 mark_object (**p); 1636 mark_object (**p);
1635 } 1637 }
1636 1638
1637 { /* staticpro_nodump() */ 1639 { /* staticpro_nodump() */
1638 Lisp_Object **p = Dynarr_begin (staticpros_nodump); 1640 Lisp_Object **p = Dynarr_begin (staticpros_nodump);
1641 Elemcount len = Dynarr_length (staticpros_nodump);
1639 Elemcount count; 1642 Elemcount count;
1640 for (count = Dynarr_length (staticpros_nodump); count; count--, p++) 1643 for (count = 0; count < len; count++, p++)
1641 /* Need to check if the pointer in the staticpro array is not 1644 /* Need to check if the pointer in the staticpro array is not
1642 NULL. A gc can occur after variable is added to the staticpro 1645 NULL. A gc can occur after variable is added to the staticpro
1643 array and _before_ it is correctly initialized. In this case 1646 array and _before_ it is correctly initialized. In this case
1644 its value is NULL, which we have to catch here. */ 1647 its value is NULL, which we have to catch here. */
1645 if (*p) 1648 if (*p)
1647 } 1650 }
1648 1651
1649 #ifdef NEW_GC 1652 #ifdef NEW_GC
1650 { /* mcpro () */ 1653 { /* mcpro () */
1651 Lisp_Object *p = Dynarr_begin (mcpros); 1654 Lisp_Object *p = Dynarr_begin (mcpros);
1655 Elemcount len = Dynarr_length (mcpros);
1652 Elemcount count; 1656 Elemcount count;
1653 for (count = Dynarr_length (mcpros); count; count--) 1657 for (count = 0; count < len; count++, p++)
1654 mark_object (*p++); 1658 mark_object (*p);
1655 } 1659 }
1656 #endif /* NEW_GC */ 1660 #endif /* NEW_GC */
1657 1661
1658 { /* GCPRO() */ 1662 { /* GCPRO() */
1659 struct gcpro *tail; 1663 struct gcpro *tail;