Re: hi-res profiling

From: Andres Kroonmaa <andre@dont-contact.us>
Date: Wed, 2 Oct 2002 17:29:28 +0300

On 2 Oct 2002, at 15:43, Henrik Nordstrom <hno@marasystems.com> wrote:

> Robert Collins wrote:
> > On Wed, 2002-10-02 at 21:36, Henrik Nordstrom wrote:
> >
> > > A staticall defined array with constant indexes (inlined functions) will
> > > translate to direct memory accesses.
> > >
> > > A dynamically allocated array with dynamic indexes (not inlined
> > > functions) translates to a indirect loopup via the pointer address plus
> > > calculated entry offset plus field offset.
> >
> > Ok, can't argue with that :}.
> > What about a dynamically allocated array with constant indexes?
>
> Semi-ok. It at most gets into two instructions
> 1. Load pointer value
> 2. load/store/modify value at constant offset from pointer
>
> a4[12].v[2] = 24;
> 8048435: a1 c4 9b 04 08 mov 0x8049bc4,%eax
> 804843a: c7 80 78 02 00 00 18 movl $0x18,0x278(%eax)
> 8048441: 00 00 00
>
> The pointer may be cached in a register if you are accessing the same array
> multiple times in the same function.

 This may hold only if all code is inlined. If we use call with probe type as
 argument, func has to load array pointer, mult index by struct size, and
 then reference with offset into struct.

 I wonder how does gcc compile stuff if array is across lib boundary, will
 it at all even attempt to use direct access, or will it just load pointer
 to it from some place where "relocation" has been done?
 gcc would never inline public exported funcs, and so I wonder, how it
 handles public exported arrays?

 We could also pass as argument pointer to the struct of array, which could
 be calculated in macro. Would make probe code even more simple.

------------------------------------
 Andres Kroonmaa <andre@online.ee>
 CTO, Microlink Online
 Tel: 6501 731, Fax: 6501 725
 Pärnu mnt. 158, Tallinn,
 11317 Estonia
Received on Wed Oct 02 2002 - 08:38:35 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:16:51 MST