Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #5344
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Subject | return address manipulation (was: A Minimal Extended Control Wordset) |
| Newsgroups | comp.lang.forth |
| References | <110432aa-3c94-46ba-9b04-a3868f4c8dbf@s20g2000yql.googlegroups.com> <j3etmd$mg1$1@news-01.bur.connect.com.au> <lMydnRfHlK9Lj8bTnZ2dnUVZ_tudnZ2d@supernews.com> |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Date | 2011-08-29 09:14 +0000 |
| Message-ID | <2011Aug29.111402@mips.complang.tuwien.ac.at> (permalink) |
"Elizabeth D. Rather" <erather@forth.com> writes:
[Return address manipulation]
>The standards teams so far have not felt that guaranteeing this
>particular functionality is sufficiently valuable to limit
>implementations that could achieve significant performance benefits by
>doing things differently.
That argument leads down a slippery slope, and C has slidden down this
slope quite far:
Some Features were originally not standardized
because there was some system that did not implement it, typically
because it would have required contortions on the hardware that system
ran on. These features were used by many programs that were never
intended to be ported to that hardware, and they worked on a lot of
hardware and systems.
Then some C compiler writers decided to take advantage of the absence
of these features to get ahead of the others in the benchmarketing
game (the benchmark programs don't use the features because the ones
using the feature were excluded from the benchmark suites or because
they were rewritten to not use the features). They started
miscompiling the programs that use these features, but the C compiler
writers did not care; after all, these features were non-standard.
And now the claim is not that these features are not standardized
because of portability to some hardware platforms, but because of
"significant performance benefits". Of course, many application
programmers simply experience that the compiler miscompiles their
program with optimization on and compiles it as intended with
optimization off, so they just turn optimization off. As a result,
the applications run slower after this optimization was built into the
compiler than before (when the optimizer did not "achieve significant
performance benefits" by miscompiling the application).
Wrt return address manipulations, the more convincing arguments for
not standardizing it are implementation approaches like the one used
by F-PC (where a return address has two cells) and the PIC (where the
return address stack cannot be used for holding data, so the stack
used by R> etc. has to be separate from the return address stack).
What should we do about programs using return address manipulations
vs. tail-call optimization and inlining in compilers?
One suggestion was that the compiler should analyze the program and
turn off these optimizations if they cannot guarantee that they don't
manipulate the return stack. One problem with this approach is that
any word that calls EXECUTE would always be excluded from the
optimization, because nothing is known about the called word. Also,
this amount of analysis is not quite fitting with the Forth spirit of
having a relatively simple compiler, and offloading complicated stuff
to the programmer.
Another suggestion is to turn off optimization explicitly for the
affected words and turn it back on afterwards. The problem with this
approach is that it is quite implementation-specific and it turns off
other optimizations as well.
There are two approaches I am considering:
1) We might support a general declaration that the program performs
return-address manipulation. That would be simple to use.
Why not the other way round (i.e., declare that the program uses no
return-address manipulation)? Because that property can be easily
broken anywhere (e.g., by upgrading some library), so it's better
to declare return-address manipulation in all the files where it
occurs.
One technical problem here is: Consider a program that includes one
libarary that contains an EXECUTE and another that contains
return-address manipulation. If the EXECUTEing library is included
first, the system might perform tail-call optimization or somesuch
there before it knows that the program as a whole uses
return-address manipulation. So if we take this approach, the
declaration should not include return-address manipulations across
EXECUTE (probably not a frequent usage anyway).
2) Indicate the specific words whose return address might be
manipulated, e.g. ": foo r-a-m ... ;" (I'll leave it to you to
suggest a cute name instead of R-A-M). The compiler would then not
use tail-call optimization or inlining when compiling these words.
Advantage: The optimizations could be applied to more words.
Disadvantage: More work for the programmer, error-prone on
maintenance.
3) Indicate the specific words that might manipulate return addresses,
along with the number of return levels that is affected. Words
that call this word would inherit this property with one level
lower, eliminating the need to add a declaration to these words.
Advantage: Good for optimization, and an intermediate amount of
work for the programmer; especially better in maintenance.
Disadvantage: Restricts the usage to known callers (not through
EXECUTE) and known number of levels.
Of course, one can also combine these approaches.
- 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 2011: http://www.euroforth.org/ef11/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 07:01 -0700
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 07:50 -0700
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-08-24 08:04 -0700
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 08:59 -0700
Re: A Minimal Extended Control Wordset coos haak <chforth@hccnet.nl> - 2011-08-24 20:00 +0200
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 14:03 -0700
Re: A Minimal Extended Control Wordset coos haak <chforth@hccnet.nl> - 2011-08-26 20:36 +0200
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-24 07:54 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-12 09:43 -0700
Re: A Minimal Extended Control Wordset "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-08-24 18:52 -0400
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-25 06:52 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-26 12:23 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-25 21:03 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-26 20:02 +1000
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-26 04:36 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-26 10:42 -0700
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-27 14:45 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-27 17:13 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-26 10:16 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-25 09:46 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-25 20:54 -0700
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-26 10:24 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-26 11:04 -0700
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-08-31 04:14 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-31 15:25 -0700
Re: A Minimal Extended Control Wordset JennyB <jennybrien@googlemail.com> - 2011-09-01 04:00 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 12:47 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-27 13:18 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-27 04:41 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-28 13:28 +1000
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-27 18:32 -1000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-29 12:32 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-28 09:22 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-29 12:30 +1000
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-28 18:17 -1000
return address manipulation (was: A Minimal Extended Control Wordset) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-08-29 09:14 +0000
Re: return address manipulation Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-29 05:53 -0500
Re: return address manipulation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-08-29 11:45 +0000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-30 14:08 +1000
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-29 18:28 -1000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-31 13:52 +1000
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-30 21:42 -1000
Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-08-31 00:47 -0700
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-08-30 21:55 -1000
Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-01 00:44 -0700
Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-01 03:37 -0500
Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-01 02:19 -0700
Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-01 05:05 -0500
min-max-sum (was: A Minimal Extended Control Wordset) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-01 14:32 +0000
Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-01 10:43 -0500
Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-01 15:59 +0000
Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-01 13:13 -0700
Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-02 04:12 -0500
Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-02 04:31 -0500
Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-02 10:41 +0000
Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-02 06:31 -0500
Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-04 13:18 +0000
Re: min-max-sum mhx@iae.nl (Marcel Hendrix) - 2011-09-04 22:42 +0200
Re: min-max-sum anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-05 08:16 +0000
Re: min-max-sum Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-05 02:58 -0500
Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-02 08:43 -0700
Re: min-max-sum coos haak <chforth@hccnet.nl> - 2011-09-02 20:35 +0200
Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-03 11:48 -0700
Re: min-max-sum BruceMcF <agila61@netscape.net> - 2011-09-04 18:31 -0700
Re: min-max-sum Alex McDonald <blog@rivadpm.com> - 2011-09-02 05:37 -0700
Re: min-max-sum mhx@iae.nl (Marcel Hendrix) - 2011-09-03 12:06 +0200
Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-04 22:07 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-04 22:56 -0700
Re: A Minimal Extended Control Wordset C G Montgomery <cgm@physics.utoledo.edu> - 2011-09-05 17:44 -0400
Re: A Minimal Extended Control Wordset Paul Rubin <no.email@nospam.invalid> - 2011-09-05 18:10 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 11:01 -0700
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-01 09:17 -1000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-01 13:39 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 10:21 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-05 12:24 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-04 21:11 -0700
Re: A Minimal Extended Control Wordset Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-09-06 18:13 +0000
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-06 12:15 -0700
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-06 09:53 -1000
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-06 14:18 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-06 17:32 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-07 19:43 +1000
Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-07 06:02 -0500
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-07 05:41 -0700
Re: A Minimal Extended Control Wordset anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-07 16:00 +0000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-09 08:52 +1000
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-08 16:08 -0700
Re: A Minimal Extended Control Wordset George Hubert <georgeahubert@yahoo.co.uk> - 2011-09-09 04:12 -0700
Re: A Minimal Extended Control Wordset Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-09-10 09:09 +0000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-11 18:29 +1000
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-11 09:04 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-15 19:25 +1000
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-15 03:30 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-18 15:43 +1000
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-17 20:42 -1000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-19 05:14 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-18 19:31 -0700
Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-18 01:49 -0500
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-08 14:56 -1000
Re: A Minimal Extended Control Wordset anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-09-09 08:20 +0000
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-11 16:22 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-11 03:06 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-08 19:29 -0700
Re: A Minimal Extended Control Wordset Brad <hwfwguy@gmail.com> - 2011-09-08 08:58 -0700
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-08 10:00 -0700
Re: A Minimal Extended Control Wordset coos haak <chforth@hccnet.nl> - 2011-09-08 22:00 +0200
Re: A Minimal Extended Control Wordset Alex McDonald <blog@rivadpm.com> - 2011-09-08 16:02 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-09 09:16 +1000
Re: A Minimal Extended Control Wordset "Elizabeth D. Rather" <erather@forth.com> - 2011-09-08 15:04 -1000
Re: A Minimal Extended Control Wordset Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-09-09 04:13 -0500
Re: A Minimal Extended Control Wordset Brad <hwfwguy@gmail.com> - 2011-08-31 09:20 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-28 21:31 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-08-31 13:53 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-08-31 04:11 -0700
Re: A Minimal Extended Control Wordset "Ed" <nospam@invalid.com> - 2011-09-01 14:47 +1000
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 10:32 -0700
Re: A Minimal Extended Control Wordset BruceMcF <agila61@netscape.net> - 2011-09-01 10:33 -0700
csiph-web