Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E7wSu-0005uG-UK for qemu-devel@nongnu.org; Wed, 24 Aug 2005 10:42:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E7wSq-0005s2-Ff for qemu-devel@nongnu.org; Wed, 24 Aug 2005 10:42:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E7wSq-0005qN-8d for qemu-devel@nongnu.org; Wed, 24 Aug 2005 10:42:52 -0400 Received: from [129.143.116.10] (helo=rhlx01.fht-esslingen.de) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1E7wQ3-0005qt-2b for qemu-devel@nongnu.org; Wed, 24 Aug 2005 10:39:59 -0400 Date: Wed, 24 Aug 2005 16:38:51 +0200 From: Andreas Mohr Subject: Re: [Qemu-devel] [PATCH] const / static (against current CVS) Message-ID: <20050824143851.GA24595@rhlx01.fht-esslingen.de> References: <20050823174026.GA27203@rhlx01.fht-esslingen.de> <23bcb8700508240554653c7ff0@mail.gmail.com> <200508241441.45656.paul@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200508241441.45656.paul@codesourcery.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, On Wed, Aug 24, 2005 at 02:41:44PM +0100, Paul Brook wrote: > > Probably more important is to make sure none constant data structures > > are done on the stack. There is no good reason why any code page > > should be read-write. > > Huh? this is nonsense. Uhoh, I seem to have managed to stir up a veritable hornet's net with my patch... > Making global data readonly is a small win because it means it can be shared > by multiple instances of the same application. Yup. > Moving global RW data onto the stack isn't neccly a win. Most systems have a > relatively small limit on stack size, so putting large objects on the stack > is a bad idea. Indeed. Witness e.g. Linux's optional kernel stack reduction to 4k and the problems that ensued. > Contrary to popular belief the "const" qualifier on pointers has absolutely no > effect on optimization. It's simply a debugging aid so the compiler will > generate an error if you accidentally assign to it. It's perfectly legal to > cast a (const char *) to a (char *) then dereference and write to it, > provided the object the object it points to is modifiable. I was thinking just that: that constifying stuff at most gives a very small compiler gain, but most probably just nothing (some people reported some rather weak 1.4% performance gain somewhere!? Statistical noise...). Since you say it's nothing I'm strongly inclined to believe it... Well, it's not only a compiler debugging aid, but also a runtime debugging aid, since random (attempted) .rodata page corruption should SEGV in that case. Andreas Mohr