Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #55930
| From | Alex <alex@rivadpm.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: When to use !name vs. name! ? |
| Date | 2017-03-19 17:42 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <oamfnv$rrb$1@dont-email.me> (permalink) |
| References | (7 earlier) <oakpjr$lf6$1@dont-email.me> <bJmdndkW2_YCc1DFnZ2dnUU7-U_NnZ2d@supernews.com> <oakv5o$qc1$2@dont-email.me> <L_6dnTsdnMh9olPFnZ2dnUU7-QXNnZ2d@supernews.com> <2017Mar19.170308@mips.complang.tuwien.ac.at> |
On 3/19/2017 16:03, Anton Ertl wrote: > "Elizabeth D. Rather" <erather@forth.com> writes: > >> In most ITC Forths, the stack pointer is in a register, and an increment >> or shift is one instruction (possibly indirect). There is no read or >> write. I don't remember any instruction sets in which it is not possible >> to increment or shift left the TOS in one instruction. A C >> implementation, of course, may be much less efficient. > > Just to illustrate this, here's what you get in gforth-fast: > > : foo 1+ 2* ; ok > : bar 1 + 2 * ; ok > see-code foo > $7F2CA4B88390 1+ > 7F2CA4AF6505: add rbx,$08 \ update ip (of threaded code) > 7F2CA4AF6509: add r14,$01 \ tos = tos + 1 > $7F2CA4B88398 2* > 7F2CA4AF650D: add rbx,$08 \ update ip (of threaded code) > 7F2CA4AF6511: add r14,r14 \ tos = tos + tos > $7F2CA4B883A0 ;s > see-code bar > $7F2CA4B883E0 lit > $7F2CA4B883E8 <$1> > $7F2CA4B883F0 <$0> \ actually +, but combined with LIT > 7F2CA4AF6529: add r14,[rbx] \ tos = tos + *ip > 7F2CA4AF652C: add rbx,$18 \ update ip (of threaded code) > $7F2CA4B883F8 noop \ actually LIT, decompiler acting up > $7F2CA4B88400 <$2> > 7F2CA4AF6530: mov [r15],r14 > 7F2CA4AF6533: sub r15,$08 > 7F2CA4AF6537: mov rax,rbx > 7F2CA4AF653A: lea rbx,$10[rbx] > 7F2CA4AF653E: mov r14,[rax] > $7F2CA4B88408 * > 7F2CA4AF6541: mov rax,r15 > 7F2CA4AF6544: lea r15,$08[r15] > 7F2CA4AF6548: add rbx,$08 > 7F2CA4AF654C: imul r14,$08[rax] > $7F2CA4B88410 ;s ok > > In the BAR example you see that Gforth-fast has a static > superinstruction for "lit <num> +", but none for "lit <num> *". So > for the "2 *" you see all the stack access overhead. You don't see > threaded-code overhead apart from the ip updates thanks to dynamic > superinstructions. And it looks like we are now using Intel assembler > syntax in the disassembler. STC Experimental 32bit: 0.06.08 Build: 781 : foo 1+ 2* ; ok : bar 1 + 2 * ; ok see foo : foo ( ? -- ? ) \ foo is defined in (console) \ call compiled \ code=$41C550 len=5 type=130 ( $0 ) add eax $1 \ 83C001 ( $3 ) add eax eax \ 03C0 ( $5 ) ret \ C3 ( end ) ok see bar : bar ( ? -- ? ) \ bar is defined in (console) \ call compiled \ code=$41C55B len=5 type=130 ( $0 ) add eax $1 \ 83C001 ( $3 ) add eax eax \ 03C0 ( $5 ) ret \ C3 ( end ) ok I'm still working on a full optimizer (using SSA) but this one is not hard to optimize. -- Alex
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-14 11:15 +1100
Re: When to use !name vs. name! ? hughaguilar96@gmail.com - 2017-03-13 18:27 -0700
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-14 01:33 -0700
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-14 01:30 -0700
When to use !name vs. name! ? NN <november.nihal@gmail.com> - 2017-03-14 02:56 -0700
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-16 08:59 +1100
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-16 02:11 -0700
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-17 11:19 +1100
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-16 20:46 -0400
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-16 21:34 -1000
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-18 09:49 +1100
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-17 13:08 -1000
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-17 19:35 -0400
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-18 00:51 -0700
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-19 10:47 +1100
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-18 22:18 -0400
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-18 16:36 -1000
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-18 23:53 -0400
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-18 22:22 -1000
Re: When to use !name vs. name! ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-19 16:03 +0000
Re: When to use !name vs. name! ? Alex <alex@rivadpm.com> - 2017-03-19 17:42 +0000
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-19 13:10 -1000
Re: When to use !name vs. name! ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-03-19 13:34 +0100
Re: When to use !name vs. name! ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-19 16:23 +0000
Re: When to use !name vs. name! ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-03-19 20:47 +0100
Re: When to use !name vs. name! ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-20 03:47 -0500
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-20 09:41 +1100
Re: When to use !name vs. name! ? Coos Haak <htrofhc@gmail.com> - 2017-03-20 01:24 +0100
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-21 12:10 +1100
Re: When to use !name vs. name! ? hughaguilar96@gmail.com - 2017-03-20 18:45 -0700
Re: When to use !name vs. name! ? Coos Haak <htrofhc@gmail.com> - 2017-03-21 14:58 +0100
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-22 19:49 +1100
Re: When to use !name vs. name! ? hughaguilar96@gmail.com - 2017-03-17 16:46 -0700
Re: When to use !name vs. name! ? Lars Brinkhoff <lars.spam@nocrew.org> - 2017-04-12 08:13 +0200
csiph-web