Skip to content

Commit 429c9fa

Browse files
author
anton
committed
documentation changes: updated Changelog and NEWS, wrote sections on
pipes and updated the Performance section; updated timings.sc with gforth-0.5.9 numbers Changed name in bootmessage from GForth to Gforth.
1 parent 6826c51 commit 429c9fa

File tree

6 files changed

+184
-32
lines changed

6 files changed

+184
-32
lines changed

ChangeLog

+69-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1+
2003-02-25 Anton Ertl <[email protected]>
2+
3+
* kernel/int.fs, doc/gforth.ds, doc/vmgen.texi, Makefile.in, NEWS, compat/strcomp.fs, simp-see.fs:
4+
Documentation changes (new: The Input Stream (gforth), Stack growth
5+
direction (Vmgen)
6+
7+
2003-02-24 Anton Ertl <[email protected]>
8+
9+
* doc/gforth.ds: Documentation changes
10+
11+
2003-02-23 Anton Ertl <[email protected]>
12+
13+
* doc/vmgen.texi, NEWS, doc/gforth.ds:
14+
documented threaded code variations and dynamic superinstructions
15+
other documentation changes
16+
17+
2003-02-22 Anton Ertl <[email protected]>
18+
19+
* doc/gforth.ds: minor doc changes
20+
21+
2003-02-17 Anton Ertl <[email protected]>
22+
23+
* kernel/int.fs: minor change
24+
25+
* engine/forth.h, engine/io.h, engine/main.c, engine/signals.c, except.fs, kernel/int.fs, errors.fs:
26+
Gforth now works properly when its stdout is to a broken pipe (but not stderr)
27+
special SIGPIPE throw code (-2049)
28+
minor bugfix ("uncaught exception" is now printed on stderr)
29+
30+
2003-02-08 dvdkhlng <[email protected]>
31+
32+
* doc/gforth.ds:
33+
Updated the "Emacs and Gforth" chapter of the documentation.
34+
35+
* gforth.el: Updated docstrings.
36+
37+
Ripped out (unusable) forth-process code, replaced it with a
38+
comint-based implementation which is mostly copied from Emacs'
39+
`cmuscheme.el'. Tested with Emacs 21 and 20, XEmacs 21.
40+
41+
* gforth.el:
42+
Fixed `uncomment-region' (C-u C-x C-\) which didn't work, since
43+
regexp `comment-start-skip' was buggy.
44+
45+
2003-02-06 Anton Ertl <[email protected]>
46+
47+
* kernel/comp.fs, kernel/int.fs, kernel/vars.fs:
48+
>name now works for names of arbitrary length
49+
50+
* Makefile.in, configure.in: minor fixes
51+
52+
* kernel/int.fs, savesys.fs, search.fs:
53+
>name etc now works for names with up to 32 chars
54+
the search order is now preserved across savesystem
55+
56+
2003-02-03 Anton Ertl <[email protected]>
57+
58+
* Makefile.in, stuff.fs, BUGS, ChangeLog: updated ChangeLog and BUGS
59+
now gforth-itc is installed and uninstalled
60+
documentation changes
61+
62+
2003-02-02 Anton Ertl <[email protected]>
63+
64+
* vmgen-ex/support.c, vmgen-ex2/support.c, README, engine/signals.c, test/signals.fs:
65+
portability bugfixes
66+
use SA_ONSTACK for all program-generated signals
67+
updated README
68+
169
2003-02-02 Anton Ertl <[email protected]>
270

371
* vmgen-ex/support.c, vmgen-ex2/support.c, README, engine/signals.c, test/signals.fs:
@@ -5091,7 +5159,7 @@
50915159

50925160
* getopt1.c, getopt.h, getopt.c, forth.h, engine.c, ToDo, README, Makefile, INSTALL, COPYING, 386.h:
50935161
Updated ToDo and INSTALL; Wrote README; Lifted COPYING and getopt*
5094-
from other packages; removed $Id: ChangeLog,v 1.4 2003-02-03 08:59:28 anton Exp $ lines from some files
5162+
from other packages; removed $Id: ChangeLog,v 1.5 2003-02-28 10:59:10 anton Exp $ lines from some files
50955163

50965164
1994-09-28 Anton Ertl <[email protected]>
50975165

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ added words: EDIT-LINE ID. .ID CONST-DOES> K-PRIOR K-NEXT K-DELETE
88
Large file support on OSs that support them (i.e., files with more
99
than 2GB on 32-bit machines).
1010

11+
Gforth can now deal with well with broken pipes in most situations.
12+
1113
Default dictionary size is now 4MB.
1214

1315
vi tags files can be built with tags.fs (usage like etags.fs).

doc/gforth.ds

+104-23
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ Copyright @copyright{} 1995, 1996, 1997, 1998, 2000, 2003 Free Software Foundati
112112
@center Bernd Paysan
113113
@center Jens Wilke
114114
@sp 3
115-
@center This manual is permanently under construction and was last updated on 15-Mar-2000
116115

117116
@comment The following two commands start the copyright page.
118117
@page
@@ -179,6 +178,7 @@ Gforth Environment
179178
* Command-line editing::
180179
* Environment variables:: that affect how Gforth starts up
181180
* Gforth Files:: What gets installed and where
181+
* Gforth in pipes::
182182
* Startup speed:: When 35ms is not fast enough ...
183183

184184
Forth Tutorial
@@ -363,6 +363,7 @@ Other I/O
363363
* String Formats:: How Forth stores strings in memory
364364
* Displaying characters and strings:: Other stuff
365365
* Input:: Input
366+
* Pipes:: How to create your own pipes
366367

367368
Locals
368369

@@ -1027,6 +1028,7 @@ material in this chapter.
10271028
* Command-line editing::
10281029
* Environment variables:: that affect how Gforth starts up
10291030
* Gforth Files:: What gets installed and where
1031+
* Gforth in pipes::
10301032
* Startup speed:: When 35ms is not fast enough ...
10311033
@end menu
10321034

@@ -1353,7 +1355,7 @@ are not set.
13531355

13541356

13551357
@comment ----------------------------------------------
1356-
@node Gforth Files, Startup speed, Environment variables, Gforth Environment
1358+
@node Gforth Files, Gforth in pipes, Environment variables, Gforth Environment
13571359
@section Gforth files
13581360
@cindex Gforth files
13591361

@@ -1383,7 +1385,59 @@ You can select different places for installation by using
13831385
@code{configure} options (listed with @code{configure --help}).
13841386

13851387
@comment ----------------------------------------------
1386-
@node Startup speed, , Gforth Files, Gforth Environment
1388+
@node Gforth in pipes, Startup speed, Gforth Files, Gforth Environment
1389+
@section Gforth in pipes
1390+
@cindex pipes, Gforth as part of
1391+
1392+
Gforth can be used in pipes created elsewhere (described here). It can
1393+
also create pipes on its own (@pxref{Pipes}).
1394+
1395+
@cindex input from pipes
1396+
If you pipe into Gforth, your program should read with @code{read-file}
1397+
or @code{read-line} from @code{stdin} (@pxref{General files}).
1398+
@code{Key} does not recognize the end of input. Words like
1399+
@code{accept} echo the input and are therefore usually not useful for
1400+
reading from a pipe. You have to invoke the Forth program with an OS
1401+
command-line option, as you have no chance to use the Forth command line
1402+
(the text interpreter would try to interpret the pipe input).
1403+
1404+
@cindex output in pipes
1405+
You can output to a pipe with @code{type}, @code{emit}, @code{cr} etc.
1406+
1407+
@cindex silent exiting from Gforth
1408+
When you write to a pipe that has been closed at the other end, Gforth
1409+
receives a SIGPIPE signal (``pipe broken''). Gforth translates this
1410+
into the exception @code{broken-pipe-error}. If your application does
1411+
not catch that exception, the system catches it and exits, usually
1412+
silently (unless you were working on the Forth command line; then it
1413+
prints an error message and exits). This is usually the desired
1414+
behaviour.
1415+
1416+
If you do not like this behaviour, you have to catch the exception
1417+
yourself, and react to it.
1418+
1419+
Here's an example of an invocation of Gforth that is usable in a pipe:
1420+
1421+
@example
1422+
gforth -e ": foo begin pad dup 10 stdin read-file throw dup while \
1423+
type repeat ; foo bye"
1424+
@end example
1425+
1426+
This example just copies the input verbatim to the output. A very
1427+
simple pipe containing this example looks like this:
1428+
1429+
@example
1430+
cat startup.fs |
1431+
gforth -e ": foo begin pad dup 80 stdin read-file throw dup while \
1432+
type repeat ; foo bye"|
1433+
head
1434+
@end example
1435+
1436+
@cindex stderr and pipes
1437+
Pipes involving Gforth's @code{stderr} output do not work.
1438+
1439+
@comment ----------------------------------------------
1440+
@node Startup speed, , Gforth in pipes, Gforth Environment
13871441
@section Startup speed
13881442
@cindex Startup speed
13891443
@cindex speed, startup
@@ -1397,7 +1451,11 @@ If startup speed is a problem, you may consider the following ways to
13971451
improve it; or you may consider ways to reduce the number of startups
13981452
(for example, by using Fast-CGI).
13991453

1400-
The first step to improve startup speed is to statically link Gforth, by
1454+
An easy step that influences Gforth startup speed is the use of the
1455+
@option{--no-dynamic} option; this decreases image loading speed, but
1456+
increases compile-time and run-time.
1457+
1458+
Another step to improve startup speed is to statically link Gforth, by
14011459
building it with @code{XLDFLAGS=-static}. This requires more memory for
14021460
the code and will therefore slow down the first invocation, but
14031461
subsequent invocations avoid the dynamic linking overhead. Another
@@ -8550,6 +8608,9 @@ doc-resize-file
85508608

85518609
doc-slurp-file
85528610
doc-slurp-fid
8611+
doc-stdin
8612+
doc-stdout
8613+
doc-stderr
85538614

85548615
@c ---------------------------------------------------------
85558616
@node Search Paths, , General files, Files
@@ -8830,6 +8891,7 @@ doc-block-included
88308891
* String Formats:: How Forth stores strings in memory
88318892
* Displaying characters and strings:: Other stuff
88328893
* Input:: Input
8894+
* Pipes:: How to create your own pipes
88338895
@end menu
88348896

88358897
@node Simple numeric output, Formatted numeric output, Other I/O, Other I/O
@@ -9127,7 +9189,7 @@ definition of @code{my-char}.
91279189

91289190

91299191

9130-
@node Input, , Displaying characters and strings, Other I/O
9192+
@node Input, Pipes, Displaying characters and strings, Other I/O
91319193
@subsection Input
91329194
@cindex input
91339195
@cindex I/O - see input
@@ -9155,6 +9217,27 @@ doc-expect
91559217
doc-span
91569218

91579219

9220+
@node Pipes, , Input, Other I/O
9221+
@subsection Pipes
9222+
@cindex pipes, creating your own
9223+
9224+
In addition to using Gforth in pipes created by other processes
9225+
(@pxref{Gforth in pipes}), you can create your own pipe with
9226+
@code{open-pipe}, and read from or write to it.
9227+
9228+
doc-open-pipe
9229+
doc-close-pipe
9230+
9231+
If you write to a pipe, Gforth can throw a @code{broken-pipe-error}; if
9232+
you don't catch this exception, Gforth will catch it and exit, usually
9233+
silently (@pxref{Gforth in pipes}). Since you probably do not want
9234+
this, you should wrap a @code{catch} or @code{try} block around the code
9235+
from @code{open-pipe} to @code{close-pipe}, so you can deal with the
9236+
problem yourself, and then return to regular processing.
9237+
9238+
doc-broken-pipe-error
9239+
9240+
91589241
@c -------------------------------------------------------------
91599242
@node Locals, Structures, Other I/O, Words
91609243
@section Locals
@@ -11696,6 +11779,8 @@ in @file{compat/assert.fs}.
1169611779
@cindex singlestep Debugger
1169711780
@cindex debugging Singlestep
1169811781

11782+
The singlestep debugger does not work in this release.
11783+
1169911784
When you create a new word there's often the need to check whether it
1170011785
behaves correctly or not. You can do this by typing @code{dbg
1170111786
badword}. A debug session might look like this:
@@ -15078,7 +15163,7 @@ disassemble the code of primitives with @code{see} on some architectures.
1507815163
@cindex Gforth performance
1507915164

1508015165
On RISCs the Gforth engine is very close to optimal; i.e., it is usually
15081-
impossible to write a significantly faster engine.
15166+
impossible to write a significantly faster threaded-code engine.
1508215167

1508315168
On register-starved machines like the 386 architecture processors
1508415169
improvements are possible, because @code{gcc} does not utilize the
@@ -15090,7 +15175,8 @@ Sieve benchmark on a 486DX2/66 than Gforth compiled with
1509015175
with gcc-2.95 and gforth-0.4.9; now the most important virtual machine
1509115176
registers fit in real registers (and we can even afford to use the TOS
1509215177
optimization), resulting in a speedup of 1.14 on the sieve over the
15093-
earlier results.
15178+
earlier results. And dynamic superinstructions provide another speedup
15179+
(but only around a factor 1.2 on the 486).
1509415180

1509515181
@cindex Win32Forth performance
1509615182
@cindex NT Forth performance
@@ -15099,7 +15185,7 @@ earlier results.
1509915185
@cindex PFE performance
1510015186
@cindex TILE performance
1510115187
The potential advantage of assembly language implementations is not
15102-
necessarily realized in complete Forth systems: We compared Gforth-0.4.9
15188+
necessarily realized in complete Forth systems: We compared Gforth-0.5.9
1510315189
(direct threaded, compiled with @code{gcc-2.95.1} and
1510415190
@code{-DFORCE_REG}) with Win32Forth 1.2093 (newer versions are
1510515191
reportedly much faster), LMI's NT Forth (Beta, May 1994) and Eforth
@@ -15127,12 +15213,12 @@ scaled by the time taken by Gforth (in other words, it shows the speedup
1512715213
factor that Gforth achieved over the other systems).
1512815214

1512915215
@example
15130-
relative Win32- NT eforth This-
15131-
time Gforth Forth Forth eforth +opt PFE Forth TILE
15132-
sieve 1.00 1.60 1.32 1.60 0.98 1.82 3.67 9.91
15133-
bubble 1.00 1.55 1.66 1.75 1.04 1.78 4.58
15134-
matmul 1.00 1.71 1.57 1.69 0.86 1.83 4.74
15135-
fib 1.00 1.76 1.54 1.41 1.00 2.01 3.45 4.96
15216+
relative Win32- NT eforth This-
15217+
time Gforth Forth Forth eforth +opt PFE Forth TILE
15218+
sieve 1.00 2.16 1.78 2.16 1.32 2.46 4.96 13.37
15219+
bubble 1.00 1.93 2.07 2.18 1.29 2.21 5.70
15220+
matmul 1.00 1.92 1.76 1.90 0.96 2.06 5.32
15221+
fib 1.00 2.32 2.03 1.86 1.31 2.64 4.55 6.54
1513615222
@end example
1513715223

1513815224
You may be quite surprised by the good performance of Gforth when
@@ -15144,11 +15230,6 @@ but costly method for relocating the Forth image: like @code{cforth}, it
1514415230
computes the actual addresses at run time, resulting in two address
1514515231
computations per @code{NEXT} (@pxref{Image File Background}).
1514615232

15147-
Only Eforth with the peephole optimizer performs comparable to
15148-
Gforth. The speedups achieved with peephole optimization of threaded
15149-
code are quite remarkable. Adding a peephole optimizer to Gforth should
15150-
cause similar speedups.
15151-
1515215233
The speedup of Gforth over PFE, ThisForth and TILE can be easily
1515315234
explained with the self-imposed restriction of the latter systems to
1515415235
standard C, which makes efficient threading impossible (however, the
@@ -15161,8 +15242,8 @@ The performance of Gforth on 386 architecture processors varies widely
1516115242
with the version of @code{gcc} used. E.g., @code{gcc-2.5.8} failed to
1516215243
allocate any of the virtual machine registers into real machine
1516315244
registers by itself and would not work correctly with explicit register
15164-
declarations, giving a 1.5 times slower engine (on a 486DX2/66 running
15165-
the Sieve) than the one measured above.
15245+
declarations, giving a significantly slower engine (on a 486DX2/66
15246+
running the Sieve) than the one measured above.
1516615247

1516715248
Note that there have been several releases of Win32Forth since the
1516815249
release presented here, so the results presented above may have little
@@ -15176,8 +15257,8 @@ Translating Forth to Efficient C}} by M. Anton Ertl and Martin
1517615257
Maierhofer (presented at EuroForth '95), an indirect threaded version of
1517715258
Gforth is compared with Win32Forth, NT Forth, PFE, ThisForth, and
1517815259
several native code systems; that version of Gforth is slower on a 486
15179-
than the direct threaded version used here. You can find a newer version
15180-
of these measurements at
15260+
than the version used here. You can find a newer version of these
15261+
measurements at
1518115262
@uref{http://www.complang.tuwien.ac.at/forth/performance.html}. You can
1518215263
find numbers for Gforth on various machines in @file{Benchres}.
1518315264

errors.fs

+2
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ variable next-exception -2050 next-exception !
103103
next-exception @
104104
-1 next-exception +! ;
105105

106+
-2049 constant broken-pipe-error ( -- n ) \ gforth
107+
\G the error number for a broken pipe
106108

kernel/int.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,9 @@ Defer dobacktrace ( -- )
895895
\ \ Cold Boot 13feb93py
896896

897897
: (bootmessage)
898-
." GForth " version-string type
898+
." Gforth " version-string type
899899
." , Copyright (C) 1995-2003 Free Software Foundation, Inc." cr
900-
." GForth comes with ABSOLUTELY NO WARRANTY; for details type `license'"
900+
." Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'"
901901
[ has? os [IF] ]
902902
cr ." Type `bye' to exit"
903903
[ [THEN] ] ;

0 commit comments

Comments
 (0)