[m-dev.] for discussion: Proposed change to label handling

Tyson Dowd trd at cs.mu.oz.au
Fri Dec 19 01:21:40 AEDT 1997


On 18-Dec-1997, Fergus Henderson <fjh at cs.mu.oz.au> wrote:
> I had a look at the code to see why you got a speedup,
> and I noticed that the fixup_gp stuff in the call() macro
> seems to be unnecessary.
> 
> So, I propose committing the following change:
> 
> mercury_calls.h:
> 	Delete (actually just `#if 0' out) the code to fixup
> 	the GP register in call macros; that should not be
> 	necessary, since restoration of the GP register
> 	is done in the Define_label() macro.
> 
> 	This might break the non-asm `jump' and `fast' grades,
> 	because the non-asm labels don't restore the GP register,
> 	but those grades don't work on the Alpha anyway, and the
> 	fact that they ever worked on other architectures is probably
> 	just coincidence -- restoring the GP register only on returns
> 	would work most of the time, but I can imagine situations where
> 	it wouldn't work.  We could fix these grades, but the fixed
> 	grades would be similar enough to the asm_jump and asm_fast
> 	grades that I don't think there is any point.
> 
> Then, I think you should benchmark your change relative
> to the compiler after this change, rather than relative to
> the current compiler.  Probably you will get no speedup,
> and the size increases will be worse.

Yes - no speedup is really possible, because apart from some static
data and initialization code that doesn't get run until needed,
the code is exactly the same.

Also, because this change causes the compiler to be smaller, the size
increases are comparatively worse. 

But the good news is, after doing all this work, my original change is now
fairly trivial (so easier to maintain even if it isn't the default),
neater, and we got a compiler speedup as a bonus.
> 
> Index: mercury_calls.h
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_calls.h,v
> retrieving revision 1.3
> diff -u -u -r1.3 mercury_calls.h
> --- mercury_calls.h	1997/12/03 07:26:11	1.3
> +++ mercury_calls.h	1997/12/18 10:49:26
> @@ -26,15 +26,10 @@
>  ** On some systems [basically those using PIC (Position Independent Code)],
>  ** if we're using gcc non-local gotos to jump between functions then
>  ** we need to do ASM_FIXUP_REGS after each return from a procedure call.
> -**
> -** We *don't* need to do this if we are using NATIVE_GC, because all
> -** labels are defined as entry labels anyway. Entry labels do 
> -** ASM_FIXUP_REGS immediately. Also, for NATIVE_GC we need the succip
> -** set to the address of the continuation label, not the fixup_gp:
> -** label.
> +** This is currently done in the Define_label(), Define_static(),
> +** or Define_Entry() macros, however, so there's no need to do it here.
>  */

If you're not going to delete this code, you need to put a bigger
skull and crossbones here to warn people away. Mentioning that it's
potentially buggy and slower would be enough. 

Otherwise, this is a good idea.

-- 
       Tyson Dowd           # If I'm unusually agressive in this email, it's
                            # probably because USENET has been down here for
     trd at cs.mu.oz.au        # over a week, and I'm missing my usual dosage
http://www.cs.mu.oz.au/~trd # of flamewars. My apologies in advance.



More information about the developers mailing list