Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: use xcalloc for zalloc.
@ 2009-03-18 19:40 Joern Rennecke
  2009-03-19  7:17 ` Doug Evans
  2009-03-19 14:54 ` Joel Brobecker
  0 siblings, 2 replies; 5+ messages in thread
From: Joern Rennecke @ 2009-03-18 19:40 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]

This patch speeds up simulators that use the sim/common infrastructure
to allocate their memory.

[-- Attachment #2: zalloc-diff-cvs --]
[-- Type: text/plain, Size: 1633 bytes --]

regression tested for m32r-elf with check-gcc and check-gdb on gcc11 in
gcc svn & sourceware cvs from 20090317.
A simple test shows that speed for allocating large memory areas is indeed
improved on gcc11:
amylaar@gcc11:~/20090317-z$ uname -a
Linux gcc11 2.6.18-6-vserver-amd64 #1 SMP Fri Jun 6 05:50:26 UTC 2008 x86_64 GNU/Linux
amylaar@gcc11:~/20090317/bld-m32r/gcc/testsuite/gcc$ time ~/20090317/bld-m32r/sim/m32r/run  --memory-region 0,0x80000000  big.x

real    0m3.180s
user    0m1.488s
sys     0m1.692s
amylaar@gcc11:~/20090317/bld-m32r/gcc/testsuite/gcc$ time ~/20090317-z/bld-m32r/sim/m32r/run  --memory-region 0,0x80000000  big.x

real    0m0.069s
user    0m0.060s
sys     0m0.012s

2007-04-30  J"orn Rennecke  <joern.rennecke@arc.com>

	Speed up simulator startup:
	* sim-utils.c (zalloc): Use xcalloc.

Index: sim/common/sim-utils.c
===================================================================
RCS file: /cvs/src/src/sim/common/sim-utils.c,v
retrieving revision 1.9
diff -p -u -r1.9 sim-utils.c
--- sim/common/sim-utils.c	14 Jan 2009 10:53:06 -0000	1.9
+++ sim/common/sim-utils.c	18 Mar 2009 18:42:18 -0000
@@ -52,15 +52,13 @@ along with this program.  If not, see <h
    Set by sim_resume.  */
 struct sim_state *current_state;
 
-/* Allocate zero filled memory with xmalloc - xmalloc aborts of the
+/* Allocate zero filled memory with xcalloc - xcalloc aborts if the
    allocation fails.  */
 
 void *
 zalloc (unsigned long size)
 {
-  void *memory = (void *) xmalloc (size);
-  memset (memory, 0, size);
-  return memory;
+  return xcalloc (1, size);
 }
 
 void

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-19 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-18 19:40 RFA: use xcalloc for zalloc Joern Rennecke
2009-03-19  7:17 ` Doug Evans
2009-03-19 14:54 ` Joel Brobecker
2009-03-19 15:08   ` Joern Rennecke
2009-03-19 17:39     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox