hacking.txt 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. debug/
  63. alt/
  64. link/p-features.scm
  65. link/p-record.scm
  66. link/t-features.scm
  67. link/t-record.scm
  68. misc/icon.scm
  69. misc/mail.scm -- related to more-thread.scm
  70. misc/more-thread.scm -- needs work
  71. misc/sicp.scm -- add to more-packages
  72. ,load-package rk-extensions
  73. ,new-package rk-user rk-extensions
  74. ,user-package-is rk-user
  75. # If initial images starts in mini-command instead of command, the
  76. # rule for $(IMAGE) becomes something like this:
  77. # (echo ,load more-interfaces.scm $(S48ROOT)/more-packages.scm; \
  78. # echo "(ensure-loaded command)"; \
  79. # echo ",go ((structure-ref command 'command-processor) batch)"; \
  80. ,in config (define-structures ((reification (export reify-structures)))
  81. (open scheme-level-2 table
  82. signals ;error
  83. packages
  84. features ;location-id location?
  85. scan) ;find-free-names-in-syntax-rules
  86. (files (link reify)))
  87. ,load-package reification
  88. debug-config> ,in reification reify-structures
  89. '#{Procedure 8447 reify-structures}
  90. debug-config> (define reify-structures ##)
  91. debug-config> make-simple-package
  92. Error: undefined variable
  93. make-simple-package
  94. (package debug-config)
  95. 1 debug-config>
  96. debug-config> (define-structures ((p (export start))) (open initial-system scheme-level-2 packages))
  97. debug-config> (define go (in p `(start ,(reify-structures (desirable-packages) (lambda (loc) `',loc)))))
  98. ### Small images for exercising the linker and/or runtime system
  99. debug/tiny.image: debug/tiny.scm $(LINKER_IMAGE)
  100. ($(START_LINKER_RUNNABLE) \
  101. echo "(load \"debug/tiny-packages.scm\")"; \
  102. echo "(link-simple-system '(debug tiny) 'start tiny-system)") \
  103. | $(LINKER_RUNNABLE) -i $(LINKER_IMAGE)
  104. debug/little.image: $(LINKER_IMAGE) $(CONFIG_FILES) $(little-files)
  105. ($(START_LINKER_RUNNABLE) \
  106. echo "(load \"scripts.scm\")"; \
  107. echo "(link-little-system)") \
  108. | $(LINKER_RUNNABLE) -i $(LINKER_IMAGE) $(BIG_HEAP)
  109. debug/medium.image: $(LINKER_IMAGE) $(CONFIG_FILES) $(medium-files)
  110. ($(START_LINKER_RUNNABLE) \
  111. echo "(load \"scripts.scm\")"; \
  112. echo "(link-medium-system)") \
  113. | $(LINKER_RUNNABLE) -i $(LINKER_IMAGE) $(BIG_HEAP)
  114. echo "(define l-f (package-all-filenames little-system))"; \
  115. echo "(define m-f (package-all-filenames medium-system))"; \
  116. 'little-files l-f 'medium-files m-f \
  117. [The following is from June 1992, and probably not quite compatible
  118. with the current compiler internals.]
  119. To eliminate use of the stack GC to implement tail recursion, change
  120. comp.scm as follows:
  121. (define (compile-unknown-call exp cenv depth cont)
  122. (note-source-code
  123. exp
  124. (maybe-push-continuation (sequentially
  125. (push-all (cdr exp) cenv 0)
  126. (compile (car exp)
  127. cenv
  128. (length (cdr exp))
  129. (fall-through-cont))
  130. (instruction (if (return-cont? cont)
  131. op/move-args-and-call
  132. op/call)
  133. (length (cdr exp))))
  134. depth
  135. cont)))
  136. --------------------
  137. Here's another cool thing. 6/28/93
  138. (define-interface evaluation-interface
  139. (export eval load eval-from-file))
  140. (define-structure run evaluation-interface
  141. (open scheme-level-2 syntactic packages scan
  142. environments
  143. signals
  144. locations
  145. features ;force-output
  146. table
  147. fluids)
  148. (files (debug run)))
  149. ,load-package run
  150. ,in run
  151. ,in package-commands (environment-for-syntax-promise)
  152. (define cool (make-simple-package (list scheme) eval ## 'cool))
  153. ,in command set-environment-for-commands!
  154. (## cool)
  155. cool> ,inspect (lambda (x) x)
  156. '#{Procedure 6394}
  157. [0: exp] '(lambda (x) x)
  158. [1: env] '#{Package 286 cool}
  159. inspect:
  160. inspect: q
  161. cool>
  162. (define (z s)
  163. (define (show-type name static)
  164. (write name)
  165. (display " : ")
  166. (write (static-type static))
  167. (newline))
  168. (if (package? s)
  169. (for-each-definition (lambda (name static loc)
  170. (show-type name static))
  171. s)
  172. (interface-walk (lambda (name type)
  173. (show-type name
  174. (car (structure-lookup
  175. s name #t))))
  176. (structure-interface s))))
  177. ; ,open expander syntactic packages reconstruction
  178. (define (e x)
  179. (let ((p (interaction-environment)))
  180. (let ((node (expand-form x p)))
  181. (write (node-type node (package->environment p)))
  182. (newline)
  183. (eval node p))))
  184. > (define hunk3 (lap hunk3
  185. 0 (check-nargs= 3)
  186. 2 (pop)
  187. 3 (make-stored-object 3 0)
  188. 6 (return)))
  189. > (hunk3 1 2 3)
  190. '(1 . 2)
  191. > (define cxr (lap cxr
  192. 0 (check-nargs= 2)
  193. 2 (pop)
  194. 3 (stored-object-indexed-ref 0)
  195. 5 (return)))
  196. > (cxr (hunk3 1 2 3) 2)
  197. 3
  198. >
  199. (define-syntax %cons
  200. (lambda (e r c)
  201. (let ((n (cadr e))
  202. (kind (caddr e)))
  203. `(,(r 'lap) (%cons ,n ,kind)
  204. (check-nargs= ,n)
  205. (pop)
  206. (make-stored-object ,n ,kind)
  207. (return)))))
  208. (define (& x)
  209. (or (node-ref x 'uid)
  210. (begin (set! *n* (+ *n* 1))
  211. (node-set! x 'uid *n*)
  212. *n*))
  213. x)
  214. (define (uid n) (node-ref (& n) 'uid))
  215. (define *n* 0)