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]

[sel-sched] Use alloc pools for list structures


Hello,

This short patch avoids most of malloc'ing by using alloc_pools for anything that sits in our list structures, that is, av sets, fences, and boundaries. Tested on ia64, committed to sel-sched branch.

Andrey
2007-10-02  Andrey Belevantsev  <abel@ispras.ru>

	* sel-sched-ir.c (sched_lists_pool): New global variable.
	* sel-sched-ir.h (sched_lists_pool): Export.
	(init_sched_pools, free_sched_pools): New inline functions.
	(_list_add): Allocate memory from pool.
	(_list_remove): Return memory to pool.
	* sel-sched.c (stage): Kill unused variable.
	(sel_global_init): Call init_sched_pools.
	(sel_global_finish): Call free_sched_pools.
Index: gcc/sel-sched.c
===================================================================
--- gcc/sel-sched.c	(revision 128953)
+++ gcc/sel-sched.c	(working copy)
@@ -171,10 +171,6 @@ int global_level;
 /* Current fences.  */
 flist_t fences;
 
-/* !!! Remove me: not used.
-   Stage of the loop pipelining process.  */
-static int stage;
-
 /* All newly emitted insns will have their uids greater than this value.  */
 static int first_emitted_uid;
 
@@ -5580,7 +5576,6 @@ sel_sched_region_1 (void)
     }
 
   global_level = 1;
-  stage = 1;
 
   sel_sched_region_2 (data);
 
@@ -5787,6 +5782,8 @@ sel_global_init (void)
 
   calculate_dominance_info (CDI_DOMINATORS);
 
+  init_sched_pools ();
+
   if (flag_sel_sched_pipelining_outer_loops)
     pipeline_outer_loops_init ();
 
@@ -5848,6 +5845,7 @@ sel_global_finish (void)
   if (flag_sel_sched_pipelining_outer_loops)
     pipeline_outer_loops_finish ();
 
+  free_sched_pools ();
   free_dominance_info (CDI_DOMINATORS);
 }
 
Index: gcc/sel-sched-ir.c
===================================================================
--- gcc/sel-sched-ir.c	(revision 128953)
+++ gcc/sel-sched-ir.c	(working copy)
@@ -65,6 +65,9 @@ VEC(sel_global_bb_info_def, heap) *sel_g
 /* A vector holding bb info.  */
 VEC(sel_region_bb_info_def, heap) *sel_region_bb_info = NULL;
 
+/* A pool for allocating all lists.  */
+alloc_pool sched_lists_pool;
+
 /* Data structure to describe interaction with the generic scheduler utils.  */
 static struct common_sched_info_def sel_common_sched_info;
 
Index: gcc/sel-sched-ir.h
===================================================================
--- gcc/sel-sched-ir.h	(revision 128953)
+++ gcc/sel-sched-ir.h	(working copy)
@@ -290,14 +290,29 @@ struct _list_node
 };
 
 
+extern alloc_pool sched_lists_pool;
+
 /* _list_t functions.
    All of _*list_* functions are used through accessor macros, thus
    we can't move them in sel-sched-ir.c.  */
 
 static inline void
+init_sched_pools (void)
+{
+  sched_lists_pool = create_alloc_pool ("sel-sched-lists", 
+                                        sizeof (struct _list_node), 500);
+}
+
+static inline void
+free_sched_pools (void)
+{
+  free_alloc_pool (sched_lists_pool);
+}
+
+static inline void
 _list_add (_list_t *lp)
 {
-  _list_t l = xmalloc (sizeof (*l));
+  _list_t l = (_list_t) pool_alloc (sched_lists_pool);
 
   _LIST_NEXT (l) = *lp;
   *lp = l;
@@ -309,7 +324,7 @@ _list_remove (_list_t *lp)
   _list_t n = *lp;
 
   *lp = _LIST_NEXT (n);
-  free (n);
+  pool_free (sched_lists_pool, n);
 }
 
 static inline void

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