Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!ubc-cs!alberta!ncc!idacom!andrew From: andrew@idacom.uucp (Andrew Scott) Newsgroups: comp.lang.forth Subject: Re: Postfixer FORTH Message-ID: <1990Aug24.221345.14475@idacom.uucp> Date: 24 Aug 90 22:13:45 GMT References: <1599.UUL1.3#5129@willett.pgh.pa.us> Organization: IDACOM, a division of Hewlett-Packard Lines: 52 Doug Philips writes: > Oops. I forgot that. I guess the only difficulty might be if you were > using a subroutine threaded system with an optimizer in it, such as > Andrew Scott describes in the article "Extensible Optimizing Compiler" > (Forth Dimensions, Volume XII, Number 2). I'm not sure what would happen > to a label on an instruction that "disappeared". Maybe the label would > just inhibit optimization "across it"? Probably just an academic question. I hope I understand the issue, as I'm jumping into this discussion thread a bit late, but you *did* refer to my article. :-) The question of preventing optimizing across labels is not so academic. If you think of a branch destination like a label, the optimizer queue must be "flushed" before the branch is resolved. For example, suppose the phrase DUP >R was optimized to a single instruction. The following code illustrates the problem: : FOO ( x \ y -- ) HORIZ? IF OVER ELSE DUP THEN ( x coord for horiz., y for vertical ) >R ... ; THEN doesn't really compile any code - it only resolves a branch. There is no code between DUP and >R, but they must not be combined. My solution was to compile a "do nothing" word that has an optimization rule that "does nothing" (i.e. doesn't actually lay down code): : NOTHING ; SEQ: NOTHING IS: ( nothing ) ; The optimization rule does in fact complete any pending sequences, as NOTHING never appears in any other rule. The definition of THEN becomes: : THEN ' NOTHING COMPILE-TOKEN >RESOLVE ; IMMEDIATE (Our tick is state smart. Here's a vote for the proposal for COMPILE-TOKEN !) I force a "compilation" of NOTHING whenever I have to stop optimization. In your discussion, the same method could be used whenever internal labels need to be generated. I hope this all made some sense... -- Andrew Scott | mail: andrew@idacom.uucp | - or - {att, watmath, ubc-cs}!alberta!idacom!andrew | - or - uunet!myrias!aunro!idacom!andrew