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]

libgo patch committed: Don't explicitly free tiny blocks


This patch fixes libgo to not explicitly free tiny blocks when deleting
an entry from a map.  The memory allocator now has a special case for
tiny objects (less than 16 bytes), and they can not be explicitly freed,
only garbage collected.  This is PR go/61620.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r a45b1aa17901 libgo/runtime/go-map-delete.c
--- a/libgo/runtime/go-map-delete.c	Tue Jul 01 16:18:58 2014 -0700
+++ b/libgo/runtime/go-map-delete.c	Wed Jul 02 07:20:02 2014 -0700
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 
 #include "runtime.h"
+#include "malloc.h"
 #include "go-alloc.h"
 #include "go-assert.h"
 #include "map.h"
@@ -47,7 +48,8 @@
       if (equalfn (key, entry + key_offset, key_size))
 	{
 	  *pentry = *(void **) entry;
-	  __go_free (entry);
+	  if (descriptor->__entry_size >= TinySize)
+	    __go_free (entry);
 	  map->__element_count -= 1;
 	  break;
 	}

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