This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
libgo patch committed: Don't explicitly free tiny blocks
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Wed, 02 Jul 2014 07:23:47 -0700
- Subject: libgo patch committed: Don't explicitly free tiny blocks
- Authentication-results: sourceware.org; auth=none
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;
}