Patchwork Invoke ggc_free to free vec being released

login
register
mail settings
Submitter Teresa Johnson
Date July 11, 2013, 9:24 p.m.
Message ID <CAAe5K+XLDTKJBAwRq5_ynCcYmYcqW-CA-aKMspzyv+9wFDC=RA@mail.gmail.com>
Download mbox | patch
Permalink /patch/258622/
State New
Headers show

Comments

Teresa Johnson - July 11, 2013, 9:24 p.m.
This patch adds a call to ggc_free from va_gc::release, which is
called by vec_free. This was a regression from the old VEC_free
implementation and reduces the memory footprint during compilation.

Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?

2013-07-11  Teresa Johnson  <tejohnson@google.com>

        * vec.h (struct va_gc): Move release out-of-line.
        (va_gc::release): Call ggc_free on released vec.



--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
Diego Novillo - July 11, 2013, 9:32 p.m.
On Thu, Jul 11, 2013 at 2:24 PM, Teresa Johnson <tejohnson@google.com> wrote:

> 2013-07-11  Teresa Johnson  <tejohnson@google.com>
>
>         * vec.h (struct va_gc): Move release out-of-line.
>         (va_gc::release): Call ggc_free on released vec.

OK.  Thanks.


Diego.

Patch

Index: vec.h
===================================================================
--- vec.h (revision 200906)
+++ vec.h (working copy)
@@ -337,10 +337,22 @@  struct va_gc
        CXX_MEM_STAT_INFO);

   template<typename T, typename A>
-  static void release (vec<T, A, vl_embed> *&v) { v = NULL; }
+  static void release (vec<T, A, vl_embed> *&v);
 };


+/* Free GC memory used by V and reset V to NULL.  */
+
+template<typename T, typename A>
+inline void
+va_gc::release (vec<T, A, vl_embed> *&v)
+{
+  if (v)
+    ::ggc_free (v);
+  v = NULL;
+}
+
+
 /* Allocator for GC memory.  Ensure there are at least RESERVE free
    slots in V.  If EXACT is true, grow exactly, else grow
    exponentially.  As a special case, if the vector had not been