Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!dwp From: dwp@willett.pgh.pa.us (Doug Philips) Newsgroups: comp.lang.forth Subject: Re: Forth optimization (was Re: Postfixer Forth) Message-ID: <1676.UUL1.3#5129@willett.pgh.pa.us> Date: 6 Sep 90 03:33:15 GMT References: <1990Aug29.171704.15174@idacom.uucp> Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 35 In <1990Aug29.171704.15174@idacom.uucp>, andrew@idacom.uucp (Andrew Scott) writes: > I would have to save all the compilation tokens in the entire IF > construct before the decision could be made. Currently, the optimizer is > quite small because I only have to queue up 4 tokens at most (the longest > sequence in the optimization rules set is 4 words). And you could always do the code motion by hand, or recode assembler if it were really critical. > There are many more optimizations that my compiler could tackle, but I don't > want to end up with a mammoth system. I get decent results from the sequence > optimizations I perform now. The first 90% takes 90%, the last 10% takes the other 90% > I was going to experiment with an optimizer that worked at the assembly > language level. Each Forth primitive (like DUP) could be coded in "machine" > primitives (like POP and PUSH). Redundant POPs and PUSHes could be eliminated > and values could remain in registers over a long span of code. Movement > to the stack in memory would only take place when necessary. This approach > might yield big speed improvements on non-Forth processors. Do you mean that you'll have another virtual machine with PUSH POP etc. or do you mean the real machine level instructions. I think you could probably do a good machine code peephole optimizer that way. Of course, if you do automatic inlining (instead of having a special word :: ) you would want to delay "optimization" until the end. Maybe with a multiple cfa scheme you could have both the optimized and unoptimized code, depending on what you need to use at the time. -Doug --- Preferred: ( dwp@willett.pgh.pa.us OR ...!{sei,pitt}!willett!dwp ) Daily: ...!{uunet,nfsun}!willett!dwp [last resort: dwp@vega.fac.cs.cmu.edu]