Re: What's this?

From: Dennis Ruffer <druffer_at_worldnet.att.net>
Date: Sat, 21 Feb 2009 09:23:02 -0600

Much better! This allows me to mark the problem, rather than the usage.

Thanks again! ;)

DaR

On Fri, Feb 20, 2009 at 8:51 PM, Rick VanNorman <rick_at_neverslow.com> wrote:
> Dennis,
>
> Try this extension to the optimizing compiler "notail.f"
>
> { ----------------------------------------------------------------------
> Selectively disable tail recursion in the optimizing compiler
>
> NO-TAIL-RECURSION is used just like IMMEDIATE, and disables the
> tail recursion behavior of the last defined word.
>
> The actual rule compiled for the optimizing compiler is
> equivalent to
>
> OPTIMIZE ANY foo WITH foo WITH /OPT
>
>
> Note that the same effect could have been obtained via a rule
> which triggered on "foo ;" instead of "ANY FOO" but this would
> require the optimizer to evaluate the rule on every ";" to see
> if it was preceeded by the reference to foo.
> ---------------------------------------------------------------------- }
>
> OPTIMIZING-COMPILER +ORDER
>
> : (NO-TAIL-RECURSION) ( -- )
> 0 RULE@ 3 CELLS + @ (COMPILE,) /OPT ;
>
> : NO-TAIL-RECURSION ( -- )
> LAST CELL+ CELL+ @ CODE> ['] ANY OVER OPTIMIZING >LINK ,
> ['] (NO-TAIL-RECURSION) , , ;
>
> OPTIMIZING-COMPILER -ORDER
>
> \ simple example:
>
> : EMBARK ( n n -- ) R> SWAP >R SWAP >R >R ; NO-TAIL-RECURSION
> : DEBARK ( -- n n ) R> R> SWAP R> SWAP >R ; NO-TAIL-RECURSION
>
> : TEST ( -- 3 4 )
> 1 2 3 4 EMBARK DROP DROP DEBARK ;
>
> On Fri, Feb 20, 2009 at 7:31 PM, Dennis Ruffer <druffer_at_worldnet.att.net> wrote:
>> Yep, I remembered to look at the VentureForth word recall to find the
>> -opt and +opt pair.
>>
>> Messy, but probably better than adding another call. ;)
>>
>> Thanks!
>>
>> DaR
>>
>> On Fri, Feb 20, 2009 at 7:23 PM, Rick VanNorman <rick_at_neverslow.com> wrote:
>>> The problem isn't that Dennis is trying to manipulate return addresses
>>> per se, but
>>> that he is trying to bury data under a subroutine's return address.
>>>
>>> The optimizer is replacing a nominal "CALL RESTORE RET" with "JUMP RESTORE"
>>>
>>> Try putting a NOOP in the sequence, as "... RESTORE NOOP ;" or turn
>>> off optimization
>>> with "-OPT"
>>>
>>> rick
>>>
>>>> On Fri, Feb 20, 2009 at 7:05 PM, Leon Wagner <leon_at_forth.com> wrote:
>>>>> It looks like you are trying to manipulate the return address in SAVE =
>>>>> and RESTORE. You can't do that in a Standard program. In both cases, =
>>>>> you begin with R> but you did not put anything on the return stack prior =
>>>>> to that.
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: sftalk-bounce_at_forth.com=20
>>>>>> [mailto:sftalk-bounce_at_forth.com] On Behalf Of Dennis Ruffer
>>>>>> Sent: Friday, February 20, 2009 4:59 PM
>>>>>> To: sftalk_at_forth.com
>>>>>> Subject: [sftalk] What's this?
>>>>>>=20
>>>>>> I'm finding a strange problem with the pfDatabase plug-in I published
>>>>>> at: http://vf-plugins.googlecode.com/files/pfDatabase.zip. It
>>>>>> involves code that saves and restores the file information to the
>>>>>> return stack. The code is defined like this:
>>>>>>=20
>>>>>> : SAVE ( -- ) ( R: -- f# db# r# ) R> R# @ >R DB# @ >R F# @ >R >R ;
>>>>>> : RESTORE ( -- ) ( R: f# db# r# -- ) R> R> F# ! R> DB# !=20
>>>>>> R> R# ! >R ;
>>>>>>=20
>>> ----------------------------------------------------------------------
>>> sftalk_at_forth.com The SwiftForth programming discussion email list
>>> To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
>>> For list command help, send subject "help" to sftalk-request_at_forth.com
>>> Message archives are located at http://www.forth.com/archive/sftalk
>>> ----------------------------------------------------------------------
>>> This list is a forum for SwiftForth users. For product support and
>>> bug reports, please send email to support_at_forth.com
>>> ----------------------------------------------------------------------
>>>
>>>
>> ----------------------------------------------------------------------
>> sftalk_at_forth.com The SwiftForth programming discussion email list
>> To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
>> For list command help, send subject "help" to sftalk-request_at_forth.com
>> Message archives are located at http://www.forth.com/archive/sftalk
>> ----------------------------------------------------------------------
>> This list is a forum for SwiftForth users. For product support and
>> bug reports, please send email to support_at_forth.com
>> ----------------------------------------------------------------------
>>
>>
> ----------------------------------------------------------------------
> sftalk_at_forth.com The SwiftForth programming discussion email list
> To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
> For list command help, send subject "help" to sftalk-request_at_forth.com
> Message archives are located at http://www.forth.com/archive/sftalk
> ----------------------------------------------------------------------
> This list is a forum for SwiftForth users. For product support and
> bug reports, please send email to support_at_forth.com
> ----------------------------------------------------------------------
>
>
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Sat Feb 21 2009 - 07:23:27 PST


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.