To be entirely fair, this problem with accessors mainly shows up when there are a large number of instances of the object and the accessor is being called as part of a traversal over the instances.
The typical solution is to allow direct access to the data member to avoid the stack frame setup/teardown overhead.
-- Rick Altherr kc8...@kc8apf.net"He said he hadn't had a byte in three days. I had a short, so I split it with him."
-- Unsigned On Jun 2, 2009, at 3:26 AM, Duane Ellis wrote:
You don't want to waste a lot of time in simple accessors if they are called frequently enoughReally? Sure - a few opcodes ... but in the grand scheme of things...For example the function target_write_memory() - with "-O2" is exactly these instructionspushl %ebp movl %esp, %ebp movl 8(%ebp), %edx popl %ebp movl (%edx), %ecx movl 64(%ecx), %ecx jmp *%ecx (A) 7 instructions, operating at 1ghz.(B) if they are called "frequently enough" they live in the cache and are faster!(C) And because the code is "more common/reused" - identical 7 instruction sequences in multiple places do not cause other identical 7 instruction sequences (at another address) to leave the cacheThe same argument can, to a degree, be made *against* 'static inline' functions in headers.-Duane.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development