home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / compiler / documentation / INSTALL < prev    next >
Text File  |  1993-10-29  |  17KB  |  367 lines

  1. -*-Text-*-
  2.  
  3.            Installation Notes for Liar version 4.9
  4.  
  5.  
  6. Liar, the CScheme compiler, is available for the following computers:
  7.  
  8.     Sun 3
  9.     HP 9000 series 300 (except model 310)
  10.  
  11. These are 68020 based machines.  Ports for 68000/68010 machines and
  12. the Vax will be available in the future.
  13.  
  14. For bug reports send computer mail to
  15.  
  16.     BUG-LIAR@ZURICH.AI.MIT.EDU (on the Arpanet/Internet)
  17.  
  18. or US Snail to
  19.  
  20.     Scheme Team
  21.     c/o Prof. Hal Abelson
  22.     545 Technology Sq. rm 410
  23.     Cambridge MA 02139
  24.  
  25. * The compiler is distributed as four compressed tar files, as
  26. follows:
  27.  
  28. ** "dist6.2.1-tar.Z" is release 6.2.1 of CScheme.  This is required
  29. for using the compiler.  It is installed in the usual way except for
  30. one small change to the microcode needed to support compiled code.
  31. This tar file contains about 5.1 Mbyte of data when unloaded.
  32.  
  33. ** "liar4.9b-tar.Z" contains the binary files for the compiler.  This
  34. includes a ".bin" file (SCode binary, for the interpreter) and a
  35. ".com" file (native code compiler output) for each source file in the
  36. compiler.  It also contains a few other files used to construct the
  37. compiler from the binary files.  This tar file contains about 3 Mbyte
  38. of data when unloaded.
  39.  
  40. ** "liar4.9s-tar.Z" contains the source files for the compiler.  It
  41. also includes a TAGS table.  This tar file contains about 1.2 Mbyte of
  42. data when unloaded.
  43.  
  44. ** "liar4.9d-tar.Z" contains some debugging files.  There is one
  45. ".binf" file corresponding to each ".com" file in the compiler.  Given
  46. both of these files, the compiler can generate a symbolic assembly
  47. language listing of the compiled code.  In future releases, these
  48. debugging files will also support debugging tools for parsing the
  49. stack and examining compiled code environment structures.  This tar
  50. file contains about 4.5 Mbyte of data when unloaded.
  51.  
  52. * Installation of the compiler.  Installation requires about 17-20
  53. Mbyte of disk space.  This is conservative and could be reduced with
  54. some knowledge of what is needed and what is not.
  55.  
  56. ** The first step in installation is building CScheme.  Follow the
  57. instructions included in the release, except that the file
  58. "makefiles/sun" or "makefiles/hp200" (as appropriate) must be edited
  59. as follows.  Look for the following lines in that file:
  60.  
  61.     # Compiled code interface files.
  62.     # These defaults are just stubs.
  63.  
  64.     CSRC  = compiler.c
  65.     CFILE = compiler.oo
  66.     D_CFILE = compiler.do
  67.     F_CFILE = compiler.fo
  68.     CFLAG =
  69.     GC_HEAD_FILES= gccode.h
  70.  
  71. edit these lines to read as follows:
  72.  
  73.     # Compiled code interface files.
  74.  
  75.     CSRC  = cmp68020.s
  76.     CFILE = cmp68020.o
  77.     D_CFILE = cmp68020.o
  78.     F_CFILE = cmp68020.o
  79.     CFLAG = -DCMPGCFILE=\"cmp68kgc.h\"
  80.     GC_HEAD_FILES= gccode.h cmp68kgc.h
  81.  
  82.     .s.o: ; as -o $*.o $*.s
  83.  
  84. After this is done, connect to the microcode subdirectory and execute
  85. the following
  86.  
  87.     cp cmp68020.s-<sys> cmp68020.s
  88.  
  89. where <sys> is "sun" if you are running on a Sun 3, or "hp" if you are
  90. running on an HP 9000 series 300.  NOTE: the file "cmp68020.s-src" is
  91. the source file from which the other two were built.  It was processed
  92. by m4 on an HP machine to create "cmp68020.s-hp", then that file was
  93. processed by a custom conversion program (courtesy of the
  94. butterfly-lisp hackers at BBN) to produce "cmp68020.s-sun".
  95.  
  96. Once these changes have been made, finish the installation process in
  97. the normal way.
  98.  
  99. **** Note that on Sun workstations, assembling "cmp68020.s" will
  100. produce the following harmless warning messages:
  101.  
  102. as: error (cmp68020.s:1432): Unqualified forward reference
  103. as: error (cmp68020.s:1435): Unqualified forward reference
  104. as: error (cmp68020.s:1444): Unqualified forward reference
  105.  
  106. Also, on older versions of Sun software (before release 3.4) you may
  107. not be able to assemble this file at all.  For that case, we have
  108. included the file "cmp68020.o-sun" which is the output of the
  109. assembler on a 3.4 system.  Copy that file to "cmp68020.o" and touch
  110. it to make sure it is newer than the source file.
  111.  
  112. ** The next step in installation is unloading the Liar tar files.  The
  113. tar files may be unloaded wherever you like.  When unloaded, they will
  114. create a directory "liar4.9" under the directory to which you are
  115. connected.
  116.  
  117. Note that only "liar4.9b-tar.Z" need be unloaded in order to perform
  118. the rest of the installation.
  119.  
  120. In what follows, let $LIAR stand for the name of the directory in
  121. which the compiler is loaded, and let $SCHEME stand for the name of
  122. the directory in which the interpreter is loaded.
  123.  
  124. ** After having unloaded the files, and after CScheme has been built
  125. and installed, do the following:
  126.  
  127.     cd $SCHEME
  128.     mv $LIAR/runtime/* runtime
  129.     mv $LIAR/sf/* sf
  130.     cd runtime
  131.     scheme -fasl cmp-runmd.bin < $LIAR/etc/mkrun.scm
  132.  
  133. This transfers a number of compiled files to the Scheme runtime system
  134. directory, and constructs a new version of the runtime system, named
  135. "scheme.com", which is partially compiled.  After this has been done,
  136. you may discard all of the ".com" files in the runtime system
  137. directory.  If you want the new runtime system to be the default,
  138. rename it to "scheme.bin".
  139.  
  140. **** Note: because this is a beta release, the compiled runtime system
  141. "scheme.com" is likely to have bugs.  If you intend to use it by
  142. default, we suggest you retain the original (interpreted) runtime
  143. system "scheme.bin" by renaming it to something else.
  144.  
  145. ** Next, do the following:
  146.  
  147.     scheme -constant 510 -heap 500 -band $SCHEME/runtime/scheme.com
  148.  
  149. This starts up the scheme interpreter with a large constant space and
  150. heap, using the partially compiled runtime system.  After the
  151. interpreter has started, type the following expression at it:
  152.  
  153.     (begin (%cd "$LIAR")
  154.        (load "machines/bobcat/make" system-global-environment)
  155.        (disk-save "$SCHEME/runtime/compiler.com"))
  156.  
  157. it will load two files, then ask the question "Load compiled?".  Type
  158. Y, which means to build the compiler using compiled code.  If you type
  159. N, the compiler will be run interpretively, which is about a factor of
  160. 10 slower than the compiled version.
  161.  
  162. After you answer the question, it will load and evaluate approximately
  163. 100 files.  This will take several minutes.  When it is done, you are
  164. returned to the interpreter.  At this point, a new band will have been
  165. created, called "$SCHEME/runtime/compiler.com", which contains the
  166. compiler.  All the other files in the $LIAR directory may be
  167. discarded, if you wish, since only "compiler.com" is needed to run the
  168. compiler.
  169.  
  170. * Using the compiler.
  171.  
  172. ** Loading.  The compiler band, "compiler.com", is used by starting
  173. Scheme and specifying that file using the "-band" option.  You must
  174. also use the "-constant" option to specify that the constant space is
  175. at least 510, and it is recommended that the "-heap" be specified at
  176. least 500.  For medium to large compilations, a heap size of 700 or
  177. more may be needed; at MIT we typically use 1000 to be safe.
  178.  
  179. Alternatively, the switch "-compiler" specifies constant 510, heap
  180. 500, and the compiler band.
  181.  
  182. ** Memory usage.  Note that the total memory used by Scheme in this
  183. configuration is substantial!  With a heap of 1000 and a constant
  184. space of 510, the memory used is (* 4 (+ 510 (* 2 1000))), or about 10
  185. Mbyte.  For many computers this is a ridiculous figure, and Scheme
  186. will die a slow death due to paging.  Using a heap of 500 reduces this
  187. to about 6 Mbytes, but that is still quite alot.
  188.  
  189. For machines with small memories, using the `bchscheme' version of the
  190. microcode will be helpful.  This program, which is made by connecting
  191. to "$SCHEME/microcode" and typing "make bchscheme", does its garbage
  192. collection to a disk file, thus requiring only one heap in the virtual
  193. address space.  This reduces the overall memory requirements for the
  194. above examples to 6 Mbyte and 4 Mbyte, respectively.  The savings of 4
  195. and 2 Mbytes (respective) will be allocated in the file system rather
  196. than in virtual memory.
  197.  
  198. This may seem like a complicated way of doing virtual memory
  199. management, but in fact it performs significantly better than paging
  200. on machines with small amounts of RAM.  This is because the GC
  201. algorithm uses the disk much more efficiently than the paging system
  202. will be able to.
  203.  
  204. ** Compilation.  The following global definitions are available for
  205. calling the compiler:
  206.  
  207.  
  208. (COMPILE-BIN-FILE FILENAME #!OPTIONAL OUTPUT-FILENAME)
  209.  
  210. Compiles a binary SCode file, producing a native code file.  FILENAME
  211. should refer to a file which is the output of the SF program (see
  212. "$SCHEME/documentation/user.txt" for a description of SF).  The type
  213. of the input file defaults to ".bin".
  214.  
  215. OUTPUT-FILENAME, if given, is where to put the output file.  If no
  216. output filename is given, the output filename defaults to the input
  217. filename, except with type ".com".  If it is a directory specification
  218. (on unix, this means if it has a trailing "/"), then the output
  219. filename defaults as usual, except that it goes in that directory.
  220.  
  221. This is similar to the operation of SF.  Also, like SF, the input
  222. filename may be a list of filenames, in which case they are all
  223. compiled in order.
  224.  
  225.  
  226. (COMPILE-PROCEDURE PROCEDURE)
  227.  
  228. Compiles a compound procedure, given as its argument, and returns a
  229. new procedure which is the compiled form.  This does not perform side
  230. effects on the environment, so if one wished to compile MAP, for
  231. example, and install the compiled form, it would be necessary to say
  232.  
  233.     (set! map (compile-procedure map))
  234.  
  235.  
  236. (COMPILER:WRITE-LAP-FILE FILENAME)
  237.  
  238. This procedure generates a "LAP" disassembly file (LAP stands for Lisp
  239. Assembly Program, a traditional name for assembly language written in
  240. a list notation) from the output of COMPILE-BIN-FILE.  If filename is
  241. "foo", then it looks for "foo.com" and disassembles that, producing a
  242. file "foo.lap".  If, in addition, the file "foo.binf" exists, it will
  243. use that information to produce a disassembly which contains symbolic
  244. names for all of the labels.  This second form is extremely useful for
  245. debugging.
  246.  
  247.  
  248. (COMPILE-DIRECTORY DIRECTORY #!OPTIONAL OUTPUT-DIRECTORY FORCE?)
  249.  
  250. Finds all of the ".bin" files in DIRECTORY whose corresponding ".com"
  251. files either do not exist or are older, and recompiles them.
  252. OUTPUT-DIRECTORY, if given, specifies a different directory to look in
  253. for the ".com" files.  FORCE?, if given and not #F, means recompile
  254. even if the output files appear up to date.
  255.  
  256. * Debugging compiled code.  At present the debugging tools are
  257. practically nonexistent.  What follows is a description of the lowest
  258. level support, which is clumsy to use but which is adequate if you
  259. have a moderate understanding of the compiled code.  This is one of
  260. the prices of beta test!  Before release we will have user-level
  261. debugging tools.
  262.  
  263. There are two basic kinds of errors: fatal and non-fatal.  Fatal
  264. errors are things like segmentation violations and bus errors, and
  265. when these occur the only method of debugging is to use an assembly
  266. language debugger such as `adb' or `gdb'.  Debugging these errors is
  267. complicated and will not be described here.
  268.  
  269. ** Non-fatal errors can be debugged from Scheme.  Here is the method:
  270. the file "$LIAR/etc/stackp.bin" contains a simple stack parser that
  271. will allow you to display the Scheme stack, and refer to any of the
  272. items in the stack by offset number.  Loading this file (into the
  273. global environment, for example), defines two useful procedures:
  274.  
  275. (RCD FILENAME) writes a file containing a description of the current
  276. stack.  When an error has occurred, the current stack contains the
  277. continuation of the error, which is the information you want to see.
  278. Each line of the file contains an offset number and the printed
  279. representation of an object (the latter is truncated to fit on one
  280. line).
  281.  
  282. (RCR OFFSET) returns the object corresponding to OFFSET from the
  283. current stack.  Thus, after using RCD to see the stack, RCR will get
  284. you pointers to any of the objects.
  285.  
  286. Given these procedures, you can look at the compiled code stack
  287. frames, and possibly (with some skill) figure out what is happening.
  288.  
  289. ** Compiled code objects manipulators.  Another set of useful
  290. procedures, built into the runtime system and defined in the file
  291. "$SCHEME/runtime/ustruc.scm", will allow you to manipulate various
  292. compiled code objects:
  293.  
  294. (COMPILED-PROCEDURE-ENTRY PROCEDURE) returns the entry point of the
  295. compiled procedure PROCEDURE.  This entry point is an object whose
  296. type is COMPILED-EXPRESSION.
  297.  
  298. (COMPILED-CODE-ADDRESS? OBJECT) is true of both COMPILED-EXPRESSION
  299. objects as well as COMPILER-RETURN-ADDRESS objects.
  300.  
  301. (COMPILED-CODE-ADDRESS->BLOCK COMPILED-CODE-ADDRESS) returns the
  302. compiled code block to which that address refers.  The procedure
  303. COMPILED-CODE-BLOCK/DEBUGGING-INFO will tell you the name of the
  304. ".binf" file corresponding to that compiled code block, if the
  305. compiled code was generated by COMPILE-BIN-FILE.
  306.  
  307. (COMPILED-CODE-ADDRESS->OFFSET COMPILED-CODE-ADDRESS) returns the
  308. offset, in bytes, of that address from the beginning of the compiled
  309. code block.  NOTE: this offset is the SAME offset as that shown in the
  310. disassembly listing!  Thus, given any compiled code address, you can
  311. figure out both what file it corresponds to, plus what label in the
  312. disassembly file it points at.  This is the basic information you need
  313. to understand the stack.
  314.  
  315. There are several other procedures defined for manipulating these
  316. objects -- see the source code for details.  What follows is a brief
  317. description of the object formats to aid debugging.
  318.  
  319. ** Compiled Code Blocks.  Compiled code blocks are "partially marked"
  320. vectors.  The first part of a compiled code block is "non-marked",
  321. which means that the GC copies it but does not look through it for
  322. pointers.  This part is used to hold the compiled code.  The second
  323. part is "marked", and contains constants that are referred to by the
  324. compiled code.  These constants are ordinary Scheme objects and must
  325. be traced by the GC in the usual way.
  326.  
  327. The disassembly listing shows the compiled code block in the same
  328. format that it is laid out in memory, with offsets in bytes from the
  329. beginning of the block.  The header of the block is 8 bytes, so the
  330. disassembly listing starts at offset 8.  The code and constants
  331. sections are displayed separately, in slightly different formats.
  332.  
  333. ** Procedure Entry Points.  The entry point of a procedure can be
  334. found in the LAP file by looking for a label with the same name as the
  335. procedure, concatenated with some positive integer.  Unnamed lambda
  336. expressions will be lambda-<n> for some <n>.  Closed procedures (i.e.
  337. those procedures which have an external representation) have two entry
  338. points, whose labels differ only in the concatenated integer.  The
  339. first entry point is responsible for checking the number of arguments,
  340. and transfers control to the second entry point if that is correct.
  341.  
  342. ** Stack Frames.  The normal stack frame for a closed procedure is
  343. constructed by pushing the return address, then all the arguments
  344. right to left, then the procedure.  If the procedure has internal
  345. definitions, then these are pushed on the stack on top of that in some
  346. unspecified order.  Internal procedures, when invoked, may either
  347. extend the closure's frame or create new frames.  The rules for this
  348. are complicated and far beyond the scope of this document.  However,
  349. two special types of stack pointers may be used when the closure's
  350. frame is extended.
  351.  
  352. The first of these is a "static link".  This is a pointer into the
  353. stack which is used when a sub-frame needs to refer to bindings in
  354. some parent frame, but the compiler was unable to determine where that
  355. parent frame was at compile time.  The other type is a "dynamic link",
  356. which points to where the return address for the current procedure is
  357. located in the stack.  Because of tail recursion considerations, the
  358. compiler cannot always determine this at compile time, and in those
  359. cases dynamic links are used.  The dynamic link is normally kept in
  360. register A4, and pushed and popped off the stack at appropriate times.
  361.  
  362. Note that internal procedures evaluate and push their arguments in a
  363. completely unspecified order.  Thus if your program depends on the
  364. fact that the interpreter evaluates arguments from right to left, you
  365. might be screwed, since the compiler chooses whatever order seems most
  366. efficient or convenient.
  367.