Re: [PATCH 07/35] Change use to type-based pool allocator in var-tracking.c.

2015-05-29 Thread Martin Liška

On 05/27/2015 03:56 PM, mliska wrote:

gcc/ChangeLog:

2015-04-30  Martin Liska  

* var-tracking.c (variable_htab_free):Use new type-based pool allocator.
(attrs_list_clear) Likewise.
(attrs_list_insert) Likewise.
(attrs_list_copy) Likewise.
(shared_hash_unshare) Likewise.
(shared_hash_destroy) Likewise.
(unshare_variable) Likewise.
(var_reg_delete_and_set) Likewise.
(var_reg_delete) Likewise.
(var_regno_delete) Likewise.
(drop_overlapping_mem_locs) Likewise.
(variable_union) Likewise.
(insert_into_intersection) Likewise.
(canonicalize_values_star) Likewise.
(variable_merge_over_cur) Likewise.
(dataflow_set_merge) Likewise.
(remove_duplicate_values) Likewise.
(variable_post_merge_new_vals) Likewise.
(dataflow_set_preserve_mem_locs) Likewise.
(dataflow_set_remove_mem_locs) Likewise.
(variable_from_dropped) Likewise.
(variable_was_changed) Likewise.
(set_slot_part) Likewise.
(clobber_slot_part) Likewise.
(delete_slot_part) Likewise.
(loc_exp_insert_dep) Likewise.
(notify_dependents_of_changed_value) Likewise.
(emit_notes_for_differences_1) Likewise.
(vt_emit_notes) Likewise.
(vt_initialize) Likewise.
(vt_finalize) Likewise.
---
  gcc/var-tracking.c | 201 -
  1 file changed, 122 insertions(+), 79 deletions(-)

diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 0db4358..f7afed1 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -282,6 +282,21 @@ typedef struct attrs_def

/* Offset from start of DECL.  */
HOST_WIDE_INT offset;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((attrs_def *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
  } *attrs;

  /* Structure for chaining the locations.  */
@@ -298,6 +313,21 @@ typedef struct location_chain_def

/* Initialized? */
enum var_init_status init;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((location_chain_def *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
  } *location_chain;

  /* A vector of loc_exp_dep holds the active dependencies of a one-part
@@ -315,6 +345,21 @@ typedef struct loc_exp_dep_s
/* A pointer to the pointer to this entry (head or prev's next) in
   the doubly-linked list.  */
struct loc_exp_dep_s **pprev;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((loc_exp_dep_s *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
  } loc_exp_dep;


@@ -554,6 +599,21 @@ typedef struct shared_hash_def

/* Actual hash table.  */
variable_table_type *htab;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((shared_hash_def *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
  } *shared_hash;

  /* Structure holding the IN or OUT set for a basic block.  */
@@ -598,22 +658,28 @@ typedef struct variable_tracking_info_def
  } *variable_tracking_info;

  /* Alloc pool for struct attrs_def.  */
-static alloc_pool attrs_pool;
+pool_allocator attrs_def::pool ("attrs_def pool", 1024);

  /* Alloc pool for struct variable_def with MAX_VAR_PARTS entries.  */
-static alloc_pool var_pool;
+
+static pool_allocator var_pool
+  ("variable_def pool", 64,
+   (MAX_VAR_PARTS - 1) * sizeof (((variable)NULL)->var_part[0]));

  /* Alloc pool for struct variable_def with a single var_part entry.  */
-static alloc_pool valvar_pool;
+static pool_allocator valvar_pool
+  ("small variable_def pool", 256);

  /* Alloc pool for struct location_chain_def.  */
-static alloc_pool loc_chain_pool;
+pool_allocator location_chain_def::pool
+  ("location_chain_def pool", 1024);

  /* Alloc pool for struct shared_hash_def.  */
-static alloc_pool shared_hash_pool;
+pool_allocator shared_hash_def::pool
+  ("shared_hash_def pool", 256);

  /* Alloc pool for struct loc_exp_dep_s for NOT_ONEPART variables.  */
-static alloc_pool loc_exp_dep_pool;
+pool_allocator loc_exp_dep::pool ("loc_exp_dep pool", 64);

  /* Changed variables, notes will be emitted for them.  */
  static variable

[PATCH 07/35] Change use to type-based pool allocator in var-tracking.c.

2015-05-27 Thread mliska
gcc/ChangeLog:

2015-04-30  Martin Liska  

* var-tracking.c (variable_htab_free):Use new type-based pool allocator.
(attrs_list_clear) Likewise.
(attrs_list_insert) Likewise.
(attrs_list_copy) Likewise.
(shared_hash_unshare) Likewise.
(shared_hash_destroy) Likewise.
(unshare_variable) Likewise.
(var_reg_delete_and_set) Likewise.
(var_reg_delete) Likewise.
(var_regno_delete) Likewise.
(drop_overlapping_mem_locs) Likewise.
(variable_union) Likewise.
(insert_into_intersection) Likewise.
(canonicalize_values_star) Likewise.
(variable_merge_over_cur) Likewise.
(dataflow_set_merge) Likewise.
(remove_duplicate_values) Likewise.
(variable_post_merge_new_vals) Likewise.
(dataflow_set_preserve_mem_locs) Likewise.
(dataflow_set_remove_mem_locs) Likewise.
(variable_from_dropped) Likewise.
(variable_was_changed) Likewise.
(set_slot_part) Likewise.
(clobber_slot_part) Likewise.
(delete_slot_part) Likewise.
(loc_exp_insert_dep) Likewise.
(notify_dependents_of_changed_value) Likewise.
(emit_notes_for_differences_1) Likewise.
(vt_emit_notes) Likewise.
(vt_initialize) Likewise.
(vt_finalize) Likewise.
---
 gcc/var-tracking.c | 201 -
 1 file changed, 122 insertions(+), 79 deletions(-)

diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 0db4358..f7afed1 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -282,6 +282,21 @@ typedef struct attrs_def
 
   /* Offset from start of DECL.  */
   HOST_WIDE_INT offset;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((attrs_def *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
 } *attrs;
 
 /* Structure for chaining the locations.  */
@@ -298,6 +313,21 @@ typedef struct location_chain_def
 
   /* Initialized? */
   enum var_init_status init;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((location_chain_def *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
 } *location_chain;
 
 /* A vector of loc_exp_dep holds the active dependencies of a one-part
@@ -315,6 +345,21 @@ typedef struct loc_exp_dep_s
   /* A pointer to the pointer to this entry (head or prev's next) in
  the doubly-linked list.  */
   struct loc_exp_dep_s **pprev;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((loc_exp_dep_s *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
 } loc_exp_dep;
 
 
@@ -554,6 +599,21 @@ typedef struct shared_hash_def
 
   /* Actual hash table.  */
   variable_table_type *htab;
+
+  /* Pool allocation new operator.  */
+  inline void *operator new (size_t)
+  {
+return pool.allocate ();
+  }
+
+  /* Delete operator utilizing pool allocation.  */
+  inline void operator delete (void *ptr)
+  {
+pool.remove((shared_hash_def *) ptr);
+  }
+
+  /* Memory allocation pool.  */
+  static pool_allocator pool;
 } *shared_hash;
 
 /* Structure holding the IN or OUT set for a basic block.  */
@@ -598,22 +658,28 @@ typedef struct variable_tracking_info_def
 } *variable_tracking_info;
 
 /* Alloc pool for struct attrs_def.  */
-static alloc_pool attrs_pool;
+pool_allocator attrs_def::pool ("attrs_def pool", 1024);
 
 /* Alloc pool for struct variable_def with MAX_VAR_PARTS entries.  */
-static alloc_pool var_pool;
+
+static pool_allocator var_pool
+  ("variable_def pool", 64,
+   (MAX_VAR_PARTS - 1) * sizeof (((variable)NULL)->var_part[0]));
 
 /* Alloc pool for struct variable_def with a single var_part entry.  */
-static alloc_pool valvar_pool;
+static pool_allocator valvar_pool
+  ("small variable_def pool", 256);
 
 /* Alloc pool for struct location_chain_def.  */
-static alloc_pool loc_chain_pool;
+pool_allocator location_chain_def::pool
+  ("location_chain_def pool", 1024);
 
 /* Alloc pool for struct shared_hash_def.  */
-static alloc_pool shared_hash_pool;
+pool_allocator shared_hash_def::pool
+  ("shared_hash_def pool", 256);
 
 /* Alloc pool for struct loc_exp_dep_s for NOT_ONEPART variables.  */
-static alloc_pool loc_exp_dep_pool;
+pool_allocator loc_exp_dep::pool ("loc_exp_dep pool", 64);
 
 /* Changed variables, notes will be emitted for them.  */
 static variable_table_type *changed_variables;
@@ -784,7 +850,7 @@