Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #20814
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Difficulty with Brad Rodriguez' screenful |
| Date | 2013-03-19 03:29 +0100 |
| Organization | 1&1 Internet AG |
| Message-ID | <ki8ihj$8af$1@online.de> (permalink) |
| References | <8ea2fd45-14b0-45ba-b49d-e3144b9f06ab@googlegroups.com> <05170318008434@frunobulax.edu> <ki35b7$jnn$1@online.de> <5147093c.396277031@news.demon.co.uk> <2013Mar18.191720@mips.complang.tuwien.ac.at> |
Anton Ertl wrote:
> As long as the calls are direct, and the return stack is manipulated
> with R> etc., it's possible. But if your words contains EXECUTE or
> calls a DEFERred word, you would have to turn off optimization of
> calls in this word an all it's callers. I think that this would
> affect a large part of the code.
You think EXECUTE and DEFERred words are used quite often? In normal code,
I doubt that. In OOP code, yes. But then, OOP code does not benefit from
inliners. You have a set of small methods, which gets called through
virtual method tables.
If we use our higher-level functions and quotations, EXECUTE would be more
frequent. But then, an optimizing compiler could first inline the higher-
level function, and then - as it is called with a quotation, turn the
<const> EXECUTE into a CALL, and inline - as next step - the quotation into
the higher order function. Woops, full knowledge of what's happening is
suddenly possible. If the quotation uses return stack tricks to do an early
exit from the higher order function, you can fold all those constants you
have created (the return address is a constant), and thus convert that early
exit into a direct branch.
For an analytical compiler, EXECUTE is a stack normalizer point. You don't
know what the called word does with the stack, so you have to put the stack
into canonical form. That's somewhat costly. If you go further, and give
return stack entitlements, EXECUTE is also a return stack normalizer. You
have to push and create the relevant return stack entries. This does not
mean you aren't allowed to inline stuff, you just must keep track of the
return stack effect the inlined code has.
Andrew Haley suggested using CATCH/THROW instead of return stack
manipulations. CATCH/THROW are pretty hard to optimize. We are discussing
about optimization here, and IMHO we make some sort of clever optimizations
impossible. Is that really a good idea?
VFX's inliner started out as source inliner. That did a lot of things
wrong. Then MPE rewrote it to the token inliner, which did a lot of things
right, and was simpler. Maybe doing the return stack entitlement right
within the inliner could give benefits instead of being something negative
you'd rather avoid. Especially when it comes to higher-level functions.
Example:
: looper ( ... xt -- ... ) 0 ?DO i swap dup >r execute r> LOOP drop ;
: test ( -- 4950 ) 0 ['] + 100 looper ;
At the moment, VFX inlines looper, but does not do the constant folding of
['] + exeucte. If you place a ['] + execute side-by-side, it does constant
folding, and converts that to a call. It doesn't realize that + can be
optimized even further. And it doesn't realize that all inputs of the loop
are constant, so you can let it run at compile time. SEE TEST should give
: test 4950 ;
Then the compiler did his job. Bonus points if it does not actually execute
the loop, but compute 100 99 * 2/ ;-).
Test with a "real" bloated compiler, GCC:
int looper(int(*foo)(int a, int b), int n, int start)
{
int i;
for(i=0; i<n; i++) {
start=foo(i, start);
}
return start;
}
int plus(int a, int b)
{
return a + b;
}
int test()
{
return looper(plus, 100, 0);
}
gcc -S -O2 looper.c
test:
.LFB2:
.cfi_startproc
movl $4950, %eax
ret
.cfi_endproc
Yes!
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-15 07:10 -0700
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-15 17:06 +0000
Re: Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-15 11:27 -0700
Re: Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-15 13:06 -0700
Re: Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-15 13:43 -0700
Re: Difficulty with Brad Rodriguez' screenful "Elizabeth D. Rather" <erather@forth.com> - 2013-03-15 12:17 -1000
Re: Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-16 13:25 -0700
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-17 00:18 +0200
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-17 02:13 +0100
Re: Difficulty with Brad Rodriguez' screenful "Elizabeth D. Rather" <erather@forth.com> - 2013-03-16 15:29 -1000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-18 02:03 +0100
Re: Difficulty with Brad Rodriguez' screenful "Elizabeth D. Rather" <erather@forth.com> - 2013-03-17 15:23 -1000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-18 04:16 +0100
Re: Difficulty with Brad Rodriguez' screenful "Elizabeth D. Rather" <erather@forth.com> - 2013-03-17 18:20 -1000
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-18 13:07 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-18 21:45 +0100
Re: Difficulty with Brad Rodriguez' screenful Elizabeth D Rather <erather@forth.com> - 2013-03-18 12:13 -1000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 03:46 +0100
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-19 09:42 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 17:04 +0100
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-19 17:54 +0000
Re: Difficulty with Brad Rodriguez' screenful Brad Eckert <hwfwguy@gmail.com> - 2013-03-19 13:30 -0700
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 22:33 +0100
Re: Difficulty with Brad Rodriguez' screenful albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-03-19 13:03 +0000
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-19 14:56 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 21:55 +0100
Re: Difficulty with Brad Rodriguez' screenful Alex McDonald <blog@rivadpm.com> - 2013-03-19 14:16 -0700
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-20 02:09 +0100
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-02 16:44 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 20:35 +0100
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-19 09:52 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 18:56 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-19 13:18 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 22:37 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-20 03:33 -0500
Re: Difficulty with Brad Rodriguez' screenful "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-03-20 05:30 -0400
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-18 11:28 -0500
Re: Difficulty with Brad Rodriguez' screenful Alex McDonald <blog@rivadpm.com> - 2013-03-18 15:39 -0700
Re: Difficulty with Brad Rodriguez' screenful albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-03-19 13:07 +0000
Re: Difficulty with Brad Rodriguez' screenful m.a.m.hendrix@tue.nl - 2013-03-19 06:58 -0700
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 03:05 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-19 05:27 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 19:24 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-20 03:42 -0500
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-20 03:54 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-20 17:49 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-20 12:51 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-20 20:25 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-21 04:31 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-21 16:31 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-21 14:48 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-21 18:07 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-21 14:49 -0500
Re: Difficulty with Brad Rodriguez' screenful Coos Haak <chforth@hccnet.nl> - 2013-03-22 00:07 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-21 18:31 -0500
Re: Difficulty with Brad Rodriguez' screenful Coos Haak <chforth@hccnet.nl> - 2013-03-22 00:48 +0100
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-22 01:49 +0100
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-27 17:30 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-22 03:57 -0500
Re: Difficulty with Brad Rodriguez' screenful Alex McDonald <blog@rivadpm.com> - 2013-03-22 03:39 -0700
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-22 09:03 -0500
Re: Difficulty with Brad Rodriguez' screenful Alex McDonald <blog@rivadpm.com> - 2013-03-23 08:13 -0700
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-23 12:39 -0500
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-23 14:19 -0500
Re: Difficulty with Brad Rodriguez' screenful Alex McDonald <blog@rivadpm.com> - 2013-03-23 13:01 -0700
Re: Difficulty with Brad Rodriguez' screenful Brad Eckert <hwfwguy@gmail.com> - 2013-03-22 08:13 -0700
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-22 14:44 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-22 10:34 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-22 15:39 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-22 20:38 +0100
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-22 20:54 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-22 12:27 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-22 17:38 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-22 13:48 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-23 11:53 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-24 01:46 +0100
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-27 17:04 +0000
Re: Difficulty with Brad Rodriguez' screenful Brad Eckert <hwfwguy@gmail.com> - 2013-03-25 10:06 -0700
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-19 16:05 +0000
Re: Difficulty with Brad Rodriguez' screenful Alex McDonald <blog@rivadpm.com> - 2013-03-19 12:32 -0700
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-18 18:28 +0000
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-18 12:40 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-18 17:23 +0100
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-18 17:35 +0000
Re: Difficulty with Brad Rodriguez' screenful Brad Eckert <hwfwguy@gmail.com> - 2013-03-18 11:02 -0700
Re: Difficulty with Brad Rodriguez' screenful "WJ" <w_a_x_man@yahoo.com> - 2013-03-19 03:25 +0000
Re: Difficulty with Brad Rodriguez' screenful albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-03-18 19:35 +0000
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-18 18:17 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 03:29 +0100
Re: Difficulty with Brad Rodriguez' screenful Paul Rubin <no.email@nospam.invalid> - 2013-03-19 00:06 -0700
Re: Difficulty with Brad Rodriguez' screenful Paul Rubin <no.email@nospam.invalid> - 2013-03-19 00:11 -0700
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 16:16 +0100
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-19 15:06 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-19 22:27 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-20 03:49 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-20 11:09 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-20 10:25 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-20 18:08 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-20 13:04 -0500
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-20 20:12 +0100
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-21 04:39 -0500
Re: Difficulty with Brad Rodriguez' screenful albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-03-20 19:22 +0000
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-30 17:35 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-31 08:51 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-02 15:50 +0000
Re: Difficulty with Brad Rodriguez' screenful Alex McDonald <blog@rivadpm.com> - 2013-03-20 10:27 -0700
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-20 12:03 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-20 18:47 +0100
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-30 16:40 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-01 02:12 +0200
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-01 16:58 +0000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-02 04:20 +0200
Re: Difficulty with Brad Rodriguez' screenful "Elizabeth D. Rather" <erather@forth.com> - 2013-04-01 16:39 -1000
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-02 14:15 +0000
Re: Difficulty with Brad Rodriguez' screenful Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-04-02 04:17 -0500
Re: Difficulty with Brad Rodriguez' screenful anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-04-02 15:35 +0000
Re: Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-16 22:27 -0700
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-17 10:10 +0200
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-17 18:15 +0200
Re: Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-17 13:00 -0700
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-17 23:34 +0200
Re: Difficulty with Brad Rodriguez' screenful Eduardo Costa <edu500ac@gmail.com> - 2013-03-17 16:44 -0700
Re: Difficulty with Brad Rodriguez' screenful "WJ" <w_a_x_man@yahoo.com> - 2013-03-17 23:53 +0000
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-18 23:32 +0200
Re: Difficulty with Brad Rodriguez' screenful Lars Brinkhoff <lars.spam@nocrew.org> - 2013-03-19 08:12 +0100
Re: Difficulty with Brad Rodriguez' screenful m.a.m.hendrix@tue.nl - 2013-03-19 00:33 -0700
Re: Difficulty with Brad Rodriguez' screenful Lars Brinkhoff <lars.spam@nocrew.org> - 2013-03-19 09:39 +0100
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-19 21:11 +0200
Re: Difficulty with Brad Rodriguez' screenful Elizabeth D Rather <erather@forth.com> - 2013-03-19 10:30 -1000
Re: Difficulty with Brad Rodriguez' screenful Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-03-19 22:31 +0100
Re: Difficulty with Brad Rodriguez' screenful Elizabeth D Rather <erather@forth.com> - 2013-03-19 12:09 -1000
Re: Difficulty with Brad Rodriguez' screenful Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-18 19:23 +0100
Re: Difficulty with Brad Rodriguez' screenful stephenXXX@mpeforth.com (Stephen Pelc) - 2013-03-16 06:34 +0000
Re: Difficulty with Brad Rodriguez' screenful junnia@gmail.com - 2013-03-19 07:45 -0700
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-19 21:38 +0200
Re: Difficulty with Brad Rodriguez' screenful mhx@iae.nl (Marcel Hendrix) - 2013-03-23 01:31 +0200
csiph-web