Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #30129
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | SEE (was: Umm...help?) |
| Date | 2014-05-06 16:30 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2014May6.183038@mips.complang.tuwien.ac.at> (permalink) |
| References | (2 earlier) <7u6dncZmC6vqXvvOnZ2dnUVZ_rOdnZ2d@supernews.com> <lk6k8l$ubm$1@online.de> <XPydnTnVmKp0fvvOnZ2dnUVZ_sSdnZ2d@supernews.com> <lk7rck$13n$1@online.de> <E7udnYO809nlTvrOnZ2dnUVZ_smdnZ2d@supernews.com> |
"Elizabeth D. Rather" <erather@forth.com> writes:
>On 5/5/14 1:06 AM, Bernd Paysan wrote:
>> Elizabeth D. Rather wrote:
>>> It's harder than you might think. There are different sequences of
>>> high-level words that can compile the same few machine instructions, and
>>> how would you know whence they came?
>>
>> Search and display the most likely result. SEE in bigForth is not always
>> 100% accurate, either. Example: If you have DUP +, you can optimize that to
>> 2*. A SEE that reports 2* would be fine for me. Or when you do constant
>> folding, just display the results (e.g. 1 2 + would result in 3).
>>
>> How easy that is depends on how many optimizations you do.
>
>We do a lot more than that.
Is there a paper on it? The last I heard about SwiftForth compilation
technique is that it combines sequences of primitives into optimized
primitives. That is relatively straightforward to decompile, even if
you get synonymous code sometimes.
>If you want to see source, why not see it? Actual source is surely more
>useful than an attempted reconstruction, which is almost certainly flawed.
Decompiled code (to the Forth level) is useful for seeing whether,
e.g., macros worked as intended.
And with enough effort, it is certainly not flawed. The question is
whether the benefit justifies the effort. For SwiftForth customers,
apparently not. For gforth-fast other things are also higher on the
to-do list.
>The Forth200x definition of SEE is pretty opaque, IMO: "Display a
>human-readable representation of the named word’s definition. The source
>of the representation (object-code decompilation, source block, etc.)
>and the particular form of the display is implementation defined."
>
>It would be much more useful if it clarified whether it shows what has
>been compiled (which to me is most useful) vs. an attempted reconstruction.
Your proposal on that will be welcome. BTW, IIRC this wording came
unchanged from Forth-94.
In Gforth we have a number of code inspection words:
SEE tries to reconstruct something close to source.
SIMPLE-SEE tries to reconstruct the primitives and their arguments.
SEE-CODE is like SIMPLE-SEE, but shows the native code for the
primitives that has been copied into dynamic superinstructions.
Sure, one might rename SEE into SEE-FORTH and SEE-CODE into SEE, but
does it really matter? Portable programs don't depend on it, and what
the programmers want depends on the occasion.
Here's an example of input and output (for a somewhat extreme example):
: foo ." hello" ; ok
see foo
: foo
.\" hello" ; ok
simple-see foo
$F7255F10 branch
$F7255F14 <-148545760>
$F7255F18 <1819043176>
$F7255F1C <538976367>
$F7255F20 lit
$F7255F24 <-148545768>
$F7255F28 lit
$F7255F2C <5>
$F7255F30 lit-perform
$F7255F34 <type>
$F7255F38 ;s ok
see-code foo
$F7255F10 branch
$F7255F14 <-148545760>
$F7255F18 <1819043176>
$F7255F1C <538976367>
( $F7213306 ) mov dword ptr 806256C , ebx \ $89 $1D $6C $25 $6 $8
( $F721330C ) mov ebx , dword ptr [ebx] \ $8B $1B
( $F721330E ) add ebx , # 4 \ $83 $C3 $4
( $F7213311 ) mov eax , dword ptr FC [ebx] \ $8B $43 $FC
( $F7213314 ) jmp eax \ $FF $E0
$F7255F20 lit
$F7255F24 <-148545768>
( $F7213316 ) mov dword ptr 806256C , ebx \ $89 $1D $6C $25 $6 $8
( $F721331C ) mov eax , dword ptr [ebx] \ $8B $3
( $F721331E ) add ebx , # 4 \ $83 $C3 $4
( $F7213321 ) add esi , # -4 \ $83 $C6 $FC
( $F7213324 ) add ebx , # 4 \ $83 $C3 $4
( $F7213327 ) mov dword ptr [esi] , eax \ $89 $6
$F7255F28 lit
$F7255F2C <5>
( $F7213329 ) mov dword ptr 806256C , ebx \ $89 $1D $6C $25 $6 $8
( $F721332F ) mov eax , dword ptr [ebx] \ $8B $3
( $F7213331 ) add ebx , # 4 \ $83 $C3 $4
( $F7213334 ) add esi , # -4 \ $83 $C6 $FC
( $F7213337 ) add ebx , # 4 \ $83 $C3 $4
( $F721333A ) mov dword ptr [esi] , eax \ $89 $6
$F7255F30 lit-perform
$F7255F34 <type>
( $F721333C ) mov dword ptr 806256C , ebx \ $89 $1D $6C $25 $6 $8
( $F7213342 ) mov eax , dword ptr [ebx] \ $8B $3
( $F7213344 ) add ebx , # 4 \ $83 $C3 $4
( $F7213347 ) mov edx , dword ptr [eax] \ $8B $10
( $F7213349 ) mov eax , dword ptr [edx] \ $8B $2
( $F721334B ) xchg eax, eax \ $90
( $F721334C ) jmp eax \ $FF $E0
( $F721334E ) d16: \ $66
( $F721334F ) xchg eax, ax \ $90
$F7255F38 ;s ok
- 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 2014: http://www.euroforth.org/ef14/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Umm...help? David J <skamolex@gmail.com> - 2014-04-29 18:46 -0700
Re: Umm...help? Julian Fondren <ayrnieu@gmail.com> - 2014-04-29 19:32 -0700
Re: Umm...help? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-04-30 10:21 +0000
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-01 15:39 -0700
Re: Umm...help? Coos Haak <chforth@hccnet.nl> - 2014-05-02 10:13 +0200
Re: Umm...help? Mark Wills <markwills1970@gmail.com> - 2014-05-02 02:06 -0700
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-08 16:04 -0700
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-08 16:10 -0700
Re: Umm...help? rickman <gnuarm@gmail.com> - 2014-05-09 14:18 -0400
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-19 14:20 -0700
Re: Umm...help? "Elizabeth D. Rather" <erather@forth.com> - 2014-04-29 16:51 -1000
Re: Umm...help? David J <skamolex@gmail.com> - 2014-04-29 20:03 -0700
Re: Umm...help? "Elizabeth D. Rather" <erather@forth.com> - 2014-04-29 17:41 -1000
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-01 15:29 -0700
Re: Umm...help? David J <skamolex@gmail.com> - 2014-04-29 19:51 -0700
Re: Umm...help? stephenXXX@mpeforth.com (Stephen Pelc) - 2014-04-30 08:49 +0000
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-01 15:32 -0700
Re: Umm...help? stephenXXX@mpeforth.com (Stephen Pelc) - 2014-05-02 09:03 +0000
Re: Umm...help? Torfinn Ingolfsen <tingo@home.no> - 2014-05-02 13:33 +0200
Re: Umm...help? rickman <gnuarm@gmail.com> - 2014-05-04 15:11 -0400
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-08 16:15 -0700
Re: Umm...help? David J <skamolex@gmail.com> - 2014-05-08 16:11 -0700
Re: Umm...help? David Hume <David.Hume@example.com> - 2014-05-04 20:35 +0100
Re: Umm...help? "Elizabeth D. Rather" <erather@forth.com> - 2014-05-04 12:47 -1000
Re: Umm...help? Bernd Paysan <bernd.paysan@gmx.de> - 2014-05-05 01:59 +0200
Re: Umm...help? "Elizabeth D. Rather" <erather@forth.com> - 2014-05-04 15:05 -1000
Re: Umm...help? Bernd Paysan <bernd.paysan@gmx.de> - 2014-05-05 13:06 +0200
Re: Umm...help? "Elizabeth D. Rather" <erather@forth.com> - 2014-05-05 08:07 -1000
SEE (was: Umm...help?) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-05-06 16:30 +0000
Re: SEE "Elizabeth D. Rather" <erather@forth.com> - 2014-05-06 09:24 -1000
Re: SEE Bernd Paysan <bernd.paysan@gmx.de> - 2014-05-06 21:53 +0200
no more ASS cracks? (was Re: SEE) all2001@spambog.com (Wolfgang Allinger) - 2014-05-06 19:48 -0400
Re: SEE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-05-10 17:11 +0000
Re: Umm...help? Assad Ebrahim <assad.ebrahim@alum.swarthmore.edu> - 2014-05-10 15:47 +0100
Re: Umm...help? Assad Ebrahim <assad.ebrahim@alum.swarthmore.edu> - 2014-05-10 16:06 +0100
csiph-web