hacking.txt 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. ,bench
  2. ,load-package linker
  3. ,new-package =link= linker debuginfo defpackage
  4. ,load scripts.scm
  5. (link-initial-system)
  6. To change between initial image starting in mini-command (MINI) and
  7. command (MAXI):
  8. 1. Definition of initial system's command module in comp-packages.scm:
  9. MINI: (make-mini-command scheme)
  10. MAXI: (make-command scheme)
  11. 2. Location of (define-module (make-command ...)...):
  12. MINI: more-packages.scm
  13. MAXI: comp-packages.scm
  14. 3. Location of (define-interface command-interface ...):
  15. MINI: more-interfaces.scm
  16. MAXI: interfaces.scm
  17. > ,new-package z architecture primitives packages table enumerated debug-data
  18. z> (let ((i 0))
  19. (table-walk (lambda (x y) (set! i (+ i 1)))
  20. location-name-table)
  21. i)
  22. 1385
  23. z> (vector-length (find-all-xs (name->enumerand 'location stob)))
  24. 1259
  25. (vector-length (find-all-xs (name->enumerand 'record stob)))
  26. 2150
  27. (find-all-xs (name->enumerand 'record stob))
  28. z> (do ((i 0 (+ i 1))
  29. (j 0 (if (package? (vector-ref rs i)) (+ j 1) j))) ((= i (vector-length rs)) j))
  30. 72
  31. z>
  32. > ,new-package z architecture primitives compiler table
  33. z> (vector-ref stob 10)
  34. 'template
  35. z> stob
  36. '#(pair symbol vector closure location port ratio record continuation extended-number template weak-pointer external unused-d-header1 unused-d-header2 string code-vector double bignum)
  37. z> (vector-ref stob 7)
  38. 'record
  39. z> (define rs (find-all-xs 7))
  40. z> (vector-length rs)
  41. 2178
  42. z> (define ls (find-all-xs 4))
  43. z> (vector-length ls)
  44. 1266
  45. z>
  46. To get a fresh config package:
  47. ,in config (define-structures ((config1 (export)))
  48. (open defpackage built-in-structures more-structures))
  49. ,config-package-is config1
  50. To load a linker with a fresh new compiler:
  51. x48 -i new-scheme48.image -h 10000000 <l.s48
  52. Then ,load scripts.scm or whatever.
  53. These are all files not belonging to any package description:
  54. boot-packages.scm
  55. comp-packages.scm
  56. flatload.scm
  57. more-packages.scm
  58. more-interfaces.scm
  59. rts-packages.scm
  60. scripts.scm
  61. interfaces.scm
  62. infix/
  63. debug/
  64. alt/
  65. link/p-features.scm
  66. link/p-record.scm
  67. link/t-features.scm
  68. link/t-record.scm
  69. misc/icon.scm
  70. misc/mail.scm -- related to more-thread.scm
  71. misc/more-thread.scm -- needs work
  72. misc/sicp.scm -- add to more-packages
  73. ,load-package rk-extensions
  74. ,new-package rk-user rk-extensions
  75. ,user-package-is rk-user
  76. # If initial images starts in mini-command instead of command, the
  77. # rule for $(IMAGE) becomes something like this:
  78. # (echo ,load more-interfaces.scm $(S48ROOT)/more-packages.scm; \
  79. # echo "(ensure-loaded command)"; \
  80. # echo ",go ((structure-ref command 'command-processor) batch)"; \
  81. ,in config (define-structures ((reification (export reify-structures)))
  82. (open scheme-level-2 table
  83. signals ;error
  84. packages
  85. features ;location-id location?
  86. scan) ;find-free-names-in-syntax-rules
  87. (files (link reify)))
  88. ,load-package reification
  89. debug-config> ,in reification reify-structures
  90. '#{Procedure 8447 reify-structures}
  91. debug-config> (define reify-structures ##)
  92. debug-config> make-simple-package
  93. Error: undefined variable
  94. make-simple-package
  95. (package debug-config)
  96. 1 debug-config>
  97. debug-config> (define-structures ((p (export start))) (open initial-system scheme-level-2 packages))
  98. debug-config> (define go (in p `(start ,(reify-structures (desirable-packages) (lambda (loc) `',loc)))))
  99. ### Small images for exercising the linker and/or runtime system
  100. debug/tiny.image: debug/tiny.scm $(LINKER_IMAGE)
  101. ($(START_LINKER_RUNNABLE) \
  102. echo "(load \"debug/tiny-packages.scm\")"; \
  103. echo "(link-simple-system '(debug tiny) 'start tiny-system)") \
  104. | $(LINKER_RUNNABLE) -i $(LINKER_IMAGE)
  105. debug/little.image: $(LINKER_IMAGE) $(CONFIG_FILES) $(little-files)
  106. ($(START_LINKER_RUNNABLE) \
  107. echo "(load \"scripts.scm\")"; \
  108. echo "(link-little-system)") \
  109. | $(LINKER_RUNNABLE) -i $(LINKER_IMAGE) $(BIG_HEAP)
  110. debug/medium.image: $(LINKER_IMAGE) $(CONFIG_FILES) $(medium-files)
  111. ($(START_LINKER_RUNNABLE) \
  112. echo "(load \"scripts.scm\")"; \
  113. echo "(link-medium-system)") \
  114. | $(LINKER_RUNNABLE) -i $(LINKER_IMAGE) $(BIG_HEAP)
  115. echo "(define l-f (package-all-filenames little-system))"; \
  116. echo "(define m-f (package-all-filenames medium-system))"; \
  117. 'little-files l-f 'medium-files m-f \
  118. [The following is from June 1992, and probably not quite compatible
  119. with the current compiler internals.]
  120. To eliminate use of the stack GC to implement tail recursion, change
  121. comp.scm as follows:
  122. (define (compile-unknown-call exp cenv depth cont)
  123. (note-source-code
  124. exp
  125. (maybe-push-continuation (sequentially
  126. (push-all (cdr exp) cenv 0)
  127. (compile (car exp)
  128. cenv
  129. (length (cdr exp))
  130. (fall-through-cont))
  131. (instruction (if (return-cont? cont)
  132. op/move-args-and-call
  133. op/call)
  134. (length (cdr exp))))
  135. depth
  136. cont)))
  137. --------------------
  138. Here's another cool thing. 6/28/93
  139. (define-interface evaluation-interface
  140. (export eval load eval-from-file))
  141. (define-structure run evaluation-interface
  142. (open scheme-level-2 syntactic packages scan
  143. environments
  144. signals
  145. locations
  146. features ;force-output
  147. table
  148. fluids)
  149. (files (debug run)))
  150. ,load-package run
  151. ,in run
  152. ,in package-commands (environment-for-syntax-promise)
  153. (define cool (make-simple-package (list scheme) eval ## 'cool))
  154. ,in command set-environment-for-commands!
  155. (## cool)
  156. cool> ,inspect (lambda (x) x)
  157. '#{Procedure 6394}
  158. [0: exp] '(lambda (x) x)
  159. [1: env] '#{Package 286 cool}
  160. inspect:
  161. inspect: q
  162. cool>
  163. (define (z s)
  164. (define (show-type name static)
  165. (write name)
  166. (display " : ")
  167. (write (static-type static))
  168. (newline))
  169. (if (package? s)
  170. (for-each-definition (lambda (name static loc)
  171. (show-type name static))
  172. s)
  173. (interface-walk (lambda (name type)
  174. (show-type name
  175. (car (structure-lookup
  176. s name #t))))
  177. (structure-interface s))))
  178. ; ,open expander syntactic packages reconstruction
  179. (define (e x)
  180. (let ((p (interaction-environment)))
  181. (let ((node (expand-form x p)))
  182. (write (node-type node (package->environment p)))
  183. (newline)
  184. (eval node p))))
  185. > (define hunk3 (lap hunk3
  186. 0 (check-nargs= 3)
  187. 2 (pop)
  188. 3 (make-stored-object 3 0)
  189. 6 (return)))
  190. > (hunk3 1 2 3)
  191. '(1 . 2)
  192. > (define cxr (lap cxr
  193. 0 (check-nargs= 2)
  194. 2 (pop)
  195. 3 (stored-object-indexed-ref 0)
  196. 5 (return)))
  197. > (cxr (hunk3 1 2 3) 2)
  198. 3
  199. >
  200. (define-syntax %cons
  201. (lambda (e r c)
  202. (let ((n (cadr e))
  203. (kind (caddr e)))
  204. `(,(r 'lap) (%cons ,n ,kind)
  205. (check-nargs= ,n)
  206. (pop)
  207. (make-stored-object ,n ,kind)
  208. (return)))))
  209. (define (& x)
  210. (or (node-ref x 'uid)
  211. (begin (set! *n* (+ *n* 1))
  212. (node-set! x 'uid *n*)
  213. *n*))
  214. x)
  215. (define (uid n) (node-ref (& n) 'uid))
  216. (define *n* 0)