Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #26543

Re: A problem with gforth-fast

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: A problem with gforth-fast
Date 2013-10-15 09:50 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2013Oct15.115028@mips.complang.tuwien.ac.at> (permalink)
References (2 earlier) <xeednaA0e5SbvcXPnZ2dnUVZ_sSdnZ2d@supernews.com> <l39a61$so1$1@online.de> <MImdnXkWs-Frn8TPnZ2dnUVZ8iadnZ2d@supernews.com> <2013Oct14.191716@mips.complang.tuwien.ac.at> <w--dnRhMSaYys8HPnZ2dnUVZ_rKdnZ2d@supernews.com>

Show all headers | View raw


Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>Bernd Paysan <bernd.paysan@gmx.de> wrote:
>>>> Andrew Haley wrote:
>>>> 
>>>>> Bernd Paysan <bernd.paysan@gmx.de> wrote:
>>>>> Fascinating.  Is it simply that cos() leaves the stack pointer
>>>>> depressed?  And no-one noticed!  I guess as long as you don't call it
>>>>> too many times in a loop, no-one ever would.  :-)
>>>> 
>>>> It clobbers ECX.  As long as you don't keep anything of value in ECX, it 
>>>> works fine.
>>>
>>>So what?  It's allowed to clobber ECX:
>>>
>>>%ecx and %edx
>>>
>>>Scratch registers have no specified role in the standard calling
>>>sequence. Functions do not have to preserve their values for the
>>>caller.
>> 
>> If it's a caller-saved register (those that do not have to be
>> preserved by the callee), then gcc should save it before the call and
>> restore it after the call.  Apparently it doesn't.
>
>Why?  ECX is known to be call-clobbered, and you're using it.

spTOS is a local variable, and these are not clobbered by calls.  If
it's in a caller-saved register (whether allocated automatically or
explicitly), it's the compiler's job to save them before the call and
restore them after the call.  That's why they are called "caller-saved
registers".

And given that spTOS is not clobbered by calls in general, but only by
a few transcendental functions, it seems that gcc mostly gets this
right.  But not always.  I'll look into that later.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2013: http://www.euroforth.org/ef13/

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A problem with gforth-fast humptydumpty <ouatubi@gmail.com> - 2013-10-11 02:51 -0700
  Re: A problem with gforth-fast Bernd Paysan <bernd.paysan@gmx.de> - 2013-10-11 17:00 +0200
    Re: A problem with gforth-fast humptydumpty <ouatubi@gmail.com> - 2013-10-11 08:54 -0700
    Re: A problem with gforth-fast Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-10-11 10:57 -0500
      Re: A problem with gforth-fast Bernd Paysan <bernd.paysan@gmx.de> - 2013-10-11 18:49 +0200
        Re: A problem with gforth-fast Bernd Paysan <bernd.paysan@gmx.de> - 2013-10-11 21:08 +0200
          Re: A problem with gforth-fast humptydumpty <ouatubi@gmail.com> - 2013-10-11 12:54 -0700
            Re: A problem with gforth-fast Bernd Paysan <bernd.paysan@gmx.de> - 2013-10-11 23:21 +0200
              Re: A problem with gforth-fast humptydumpty <ouatubi@gmail.com> - 2013-10-11 23:58 -0700
        Re: A problem with gforth-fast Bernd Paysan <bernd.paysan@gmx.de> - 2013-10-11 21:30 +0200
        Re: A problem with gforth-fast Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-10-12 03:06 -0500
          Re: A problem with gforth-fast Bernd Paysan <bernd.paysan@gmx.de> - 2013-10-12 15:50 +0200
          Re: A problem with gforth-fast anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-14 17:17 +0000
            Re: A problem with gforth-fast Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-10-14 12:49 -0500
              Re: A problem with gforth-fast anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-15 09:50 +0000
                Re: A problem with gforth-fast Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-10-15 07:48 -0500
                Re: A problem with gforth-fast anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-15 13:35 +0000
                Re: A problem with gforth-fast Bernd Paysan <bernd.paysan@gmx.de> - 2013-10-15 17:09 +0200
                Re: A problem with gforth-fast anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-16 16:36 +0000

csiph-web