Subject: Re: Profiling Weirdness Solved.

From: Paul Kranenburg <[email-masked]>

> However, I am still confused by the fact that the %eax is not used by
> mcount(), and `gcc -pg' generated code emits .long 0's, but doesn't
> reference them at all.  
> 
> It's probably just an anachronism.  Probably gcc should be changed to
> stop emitting the .long 0's; and the ENTRY() macro in <machine/asm.h>
> should be changed to omit the .long 0 and the movl $1b,%eax.
> 

I removed the reference to it from the i386 tm.h's FUNCTION_PROFILER() macro.
The .long 0's itself are emitted from common (ie. non-i386 specific) code, in `final.c',
which I didn't want to touch at the time without inspecting other ports.

These .long's, someone told me some time ago, may have been in use in the days of prof(1).

-pk

---

From: [email-masked] (T. William Wells)

In article <[email-masked]>,
Paul Kranenburg  <[email-masked]> wrote:
: These .long's, someone told me some time ago, may have been in
: use in the days of prof(1).

Mcount was something along the lines of:

mcount(int location)
{
	if (*location == 0 && index < loctabsize) {
		loctab[index++] = location
	}
	++*location;
}

and "location" pointed to that .long.

---

From: [email-masked] (Ralph Campbell)

> From [email-masked] Tue Aug 30 18:06:55 1994
> Message-Id: <[email-masked]>
> To: der Mouse <[email-masked]>
> Cc: [email-masked]
> Subject: Re: Profiling Weirdness Solved. 
> In-Reply-To: Your message of "Mon, 29 Aug 1994 21:07:12 EDT."
>              <[email-masked]> 
> Date: Tue, 30 Aug 1994 10:20:22 -0700
> From: "J.T. Conklin" <[email-masked]>
> Sender: [email-masked]
> Precedence: bulk
> 
> > > I don't understand the "movl $1b,%eax" that I removed, or the .long 0
> > > in the data segement.  %eax is likely to be clobbered by mcount(),
> > > and the .long 0 doesn't look like it is ever referenced.
> > 
> > The "movl $1b,%eax" moves the address of local label 1b - ie, the
> > address of that .long 0 that was mystifying you - into %eax.
> > Presumably mcount uses this address for something.  (Many UNIX-derived
> > assemblers use $ to indicate an immediate operand, what many other
> > assemblers use # for.  Confusing, but that's history for you. 
> 
> Thanks,
> 
> I read the $1b has an immediate operand, and didn't realize it refered
> to the address of label 1.  
> 
> 	--jtc

I am guessing the address of the .long is the result of more history.
This was used by the *prof* command (remember cc -p before there was cc -pg?).
The compier produced code to support both most likely.

      -m-------  Ralph Campbell				[email-masked]
    ---mmm-----  Pyramid Technology Corporation		Tel: (408) 428-8639
  -----mmmmm---  3860 North First Street		Fax: (408) 428-8845
-------mmmmmmm-  San Jose, CA 95134