Skip to content

Commit

Permalink
Coalesece FUN-INFO instances in save rather than only for self-build
Browse files Browse the repository at this point in the history
User code could add 1000 functions all with the 'foldable' attribute.

Also move the compilation of disassembler thingies into cold-init.
  • Loading branch information
snuglas committed Nov 16, 2017
1 parent d6351c3 commit 7ff79ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
17 changes: 0 additions & 17 deletions make-target-2-load.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,6 @@
(when (plusp count)
(format t "~&Removed ~D doc string~:P" count)))

;; Share identical FUN-INFOs
sb-int::
(let ((ht (make-hash-table :test 'equalp))
(old-count 0))
(sb-int:call-with-each-globaldb-name
(lambda (name)
(binding* ((info (info :function :info name) :exit-if-null)
(shared-info (gethash info ht info)))
(incf old-count)
(if (eq info shared-info)
(setf (gethash info ht) info)
(setf (info :function :info name) shared-info)))))
(format t "~&FUN-INFO: Collapsed ~D -> ~D~%"
old-count (hash-table-count ht)))

(sb-disassem::!compile-inst-printers)

;; Unintern no-longer-needed stuff before the possible PURIFY in
;; SAVE-LISP-AND-DIE.
#-sb-fluid (!unintern-init-only-stuff)
Expand Down
1 change: 1 addition & 0 deletions src/code/cold-init.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
(show-and-call float-cold-init-or-reinit)

(show-and-call !class-finalize)
(show-and-call sb!disassem::!compile-inst-printers)

;; Install closures as guards on some early PRINT-OBJECT methods so that
;; THREAD and RESTART print nicely prior to the real methods being installed.
Expand Down
10 changes: 10 additions & 0 deletions src/code/save.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ sufficiently motivated to do lengthy fixes."
(return-from save-lisp-and-die))))
(when (eql t compression)
(setf compression -1))

;; Share EQUALP FUN-INFOs
(let ((ht (make-hash-table :test 'equalp)))
(sb-int:call-with-each-globaldb-name
(lambda (name)
(binding* ((info (info :function :info name) :exit-if-null)
(shared-info (gethash info ht)))
(if shared-info
(setf (info :function :info name) shared-info)
(setf (gethash info ht) info))))))
;; Share similar simple-fun arglists and types
;; EQUALISH considers any two identically-spelled gensyms as EQ
(let ((arglist-hash (make-hash-table :hash-function 'equal-hash
Expand Down

0 comments on commit 7ff79ec

Please sign in to comment.