svn commit: r184605 - head/sys/dev/usb

Christoph Mallon christoph.mallon at gmx.de
Tue Nov 4 01:28:15 PST 2008


Joerg Sonnenberger wrote:
> On Mon, Nov 03, 2008 at 11:49:50PM +0100, Christoph Mallon wrote:
>> You may want to make cmd[] static and/or const, so the compiler really  
>> just puts the bytes in the data section instead of generating code,  
>> which pretty much is the same as the assignments you just removed.
> 
> I didn't make it const originally as I am not sure if the USB stack will
> never modify the buffer.

GCC generates 31 movb instructions to initialise the array on entry of 
the function. Every movb is 5 Bytes long (opcode + mod r/m + sib + 
offset + immediate). 31 * 5 = 155 Bytes. It is only sensible to use 
static initialisation for a local array, which contains lots of zeroes, 
if it can be made static or const (GCC is clever enough to turn a const 
array into a static one). Yes, GCC could be more clever and use movl 
instead of movb, but it isn't.

	Christoph


More information about the svn-src-all mailing list