Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!news.cs.indiana.edu!purdue!bouma From: bouma@cs.purdue.EDU (William J. Bouma) Newsgroups: comp.lang.forth Subject: Re: Metacompiling and C Forth 83 Message-ID: <12740@medusa.cs.purdue.edu> Date: 12 Dec 90 22:11:19 GMT References: <9012121624.AA00871@ucbvax.Berkeley.EDU> Organization: Department of Computer Science, Purdue University Lines: 21 In article <9012121624.AA00871@ucbvax.Berkeley.EDU> wmb%MITCH.ENG.SUN.COM@SCFVM.GSFC.NASA.GOV writes: >> How slow would [C Forth 83] be, compared to a FORTH compiler written >> for any particular processor? > >On SPARC, C Forth 83 runs about 50% slower than my direct-threaded >native SPARC Forth (i.e. the time ratio is 3:2), using the Sun optimizing >C compiler at high optimization levels. This is probably close to >the best case. Given any decent compiler, the difference comes down to an indexed- indirect jump plus a jump for the C 'switch' as opposed to an indirect jump for the direct-thread. I too have found the ratio in speed to be under 1:2 on several different processors. If you compile the C-switch code into assembler instead of machine code and then spend about 30 seconds on it in an editor, you can direct thread it. The switch statement already builds a table of all the code addresses so it can do the indexed jump. My plan is to write sed scripts for various architectures that will do that optimization. -- Bill