This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix --enable-detailed-mem-stats


Hi,
--enable-gather-detailed-mem-stats broke with the merge of zone collector (that
is quite unforutunate as the memory tester stopped for a while and memory
consumption is up considerably).
The problem is the trick of passing location info only when declaration is
enabled like this:
    t = ggc_alloc_zone_stat (length, &tree_id_zone PASS_MEM_STAT);
When ggc_alloc_zone_stat is a macro, the call still has two arguments so we
can't throw away the redundant &tree_id_zone while calling ggc_alloc_zone.

Only way to fix it I see is to turn this inline.  Problem is that then without
optimization we end up referencing zone pointers even for non-zone garbage
collector so we need placeholders.

Does this look resonable?  Bootstrapped/regtested i686-pc-gnu-linux
Honza
2005-04-15  Jan Hubicka  <jh@suse.cz>
	* ggc-none.c (alloc_zone): New struct.
	(tree_zone, rtl_zone, tree_id_zone): Define.
	* ggc-page.c (alloc_zone): New struct.
	(tree_zone, rtl_zone, tree_id_zone): Define.
	* ggc.h (tree_zone, rtl_zone, tree_id_zone): Declare uncondtionally.
	(ggc_alloc_zone_stat): Make inline for non-zone collectors
	(ggc_alloc_zone): Define unconditionally.
Index: ggc-none.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-none.c,v
retrieving revision 1.22
diff -c -3 -p -r1.22 ggc-none.c
*** ggc-none.c	13 Mar 2005 18:09:54 -0000	1.22
--- ggc-none.c	14 Apr 2005 19:40:18 -0000
***************
*** 33,38 ****
--- 33,44 ----
  #include "coretypes.h"
  #include "ggc.h"
  
+ struct alloc_zone {char nothing;};
+ /* Some default zones.  */
+ struct alloc_zone rtl_zone;
+ struct alloc_zone tree_zone;
+ struct alloc_zone tree_id_zone;
+ 
  void *
  ggc_alloc_typed_stat (enum gt_types_enum ARG_UNUSED (gte), size_t size
  		      MEM_STAT_DECL)
Index: ggc-page.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-page.c,v
retrieving revision 1.100
diff -c -3 -p -r1.100 ggc-page.c
*** ggc-page.c	13 Mar 2005 18:09:54 -0000	1.100
--- ggc-page.c	14 Apr 2005 19:40:18 -0000
*************** Software Foundation, 59 Temple Place - S
*** 74,79 ****
--- 74,84 ----
  #ifndef USING_MMAP
  #define USING_MALLOC_PAGE_GROUPS
  #endif
+ struct alloc_zone {char nothing;};
+ /* Some default zones.  */
+ struct alloc_zone rtl_zone;
+ struct alloc_zone tree_zone;
+ struct alloc_zone tree_id_zone;
  
  /* Stategy:
  
Index: ggc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc.h,v
retrieving revision 1.71
diff -c -3 -p -r1.71 ggc.h
*** ggc.h	14 Mar 2005 13:10:51 -0000	1.71
--- ggc.h	14 Apr 2005 19:40:18 -0000
*************** extern int ggc_min_expand_heuristic (voi
*** 300,308 ****
  extern int ggc_min_heapsize_heuristic (void);
  extern void init_ggc_heuristics (void);
  
- /* Zone collection.  */
- #if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
- 
  /* For regular rtl allocations.  */
  extern struct alloc_zone rtl_zone;
  /* For regular tree allocations.  */
--- 300,305 ----
*************** extern struct alloc_zone tree_zone;
*** 310,328 ****
  /* For IDENTIFIER_NODE allocations.  */
  extern struct alloc_zone tree_id_zone;
  
  /* Allocate an object into the specified allocation zone.  */
  extern void *ggc_alloc_zone_stat (size_t, struct alloc_zone * MEM_STAT_DECL);
- # define ggc_alloc_zone(s,z) ggc_alloc_zone_stat (s,z MEM_STAT_INFO)
  
  #else
  
! # define ggc_alloc_zone(s, z) ggc_alloc (s)
! # ifdef GATHER_STATISTICS
! #  define ggc_alloc_zone_stat(s, z, n, l, f) ggc_alloc_stat (s, n, l, f)
! # else
! #  define ggc_alloc_zone_stat(s, z) ggc_alloc_stat (s)
! # endif
  
  #endif
  
  #endif
--- 307,328 ----
  /* For IDENTIFIER_NODE allocations.  */
  extern struct alloc_zone tree_id_zone;
  
+ /* Zone collection.  */
+ #if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
+ 
  /* Allocate an object into the specified allocation zone.  */
  extern void *ggc_alloc_zone_stat (size_t, struct alloc_zone * MEM_STAT_DECL);
  
  #else
  
! static inline void *
! ggc_alloc_zone_stat (size_t s, struct alloc_zone *z ATTRIBUTE_UNUSED MEM_STAT_DECL)
! {
!    return ggc_alloc_stat (s PASS_MEM_STAT);
! }
  
  #endif
  
+ #define ggc_alloc_zone(s,z) ggc_alloc_zone_stat (s,z MEM_STAT_INFO)
+ 
  #endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]