From: Christophe R. <cr...@us...> - 2009-04-24 14:26:35
|
Update of /cvsroot/sbcl/sbcl/src/compiler In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19946/src/compiler Modified Files: dump.lisp ir1util.lisp Log Message: 1.0.27.40: host-invariant string constant coalescing It took a little time to get right, but here's (I hope) invariant constant string coalescing in the cross-file-compiler. 3 commit messages follow: more invariant constant string coalescing When dumping strings in cross-compilation, we always end up dumping as base-string. That means we need to compare all strings of whatever underlying array type for content equality, not just strings of the same type. This shows up when dumping in the same file "BLOCK" and the value of (symbol-name 'block) under CLISP, which dumps two separate values. dumping string constants, the other half Not only do we have to enter entries into the hash table with a known element-type, we also have to retrieve them... bogosity finally picked up by use of a CL symbol name (AND) in src/compiler/x86/insts.lisp... further refinement on constant coalescing Not only must we coalesce all kinds of strings at fasl dump time, we must coalesce the constants in our TN representation while we're compiling, otherwise we will get different lengths of constant vectors for the same function depending on how many different string representations there are in the host compiler. Index: dump.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/dump.lisp,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- dump.lisp 24 Apr 2009 12:46:38 -0000 1.66 +++ dump.lisp 24 Apr 2009 14:26:30 -0000 1.67 @@ -208,7 +208,8 @@ (type string x)) (unless *cold-load-dump* (let ((handle (cdr (assoc - (array-element-type x) + #+sb-xc-host 'base-char ; for repeatable xc fasls + #-sb-xc-host (array-element-type x) (gethash x (fasl-output-equal-table fasl-output)))))) (cond (handle (dump-push handle fasl-output) t) @@ -238,7 +239,9 @@ (type string x)) (unless *cold-load-dump* (let ((handle (dump-pop fasl-output))) - (push (cons (array-element-type x) handle) + (push (cons #+sb-xc-host 'base-char ; repeatable xc fasls + #-sb-xc-host (array-element-type x) + handle) (gethash x (fasl-output-equal-table fasl-output))) (setf (gethash x (fasl-output-eq-table fasl-output)) handle) (dump-push handle fasl-output))) Index: ir1util.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/src/compiler/ir1util.lisp,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -r1.122 -r1.123 --- ir1util.lisp 14 Jan 2009 18:37:20 -0000 1.122 +++ ir1util.lisp 24 Apr 2009 14:26:30 -0000 1.123 @@ -1685,10 +1685,26 @@ ((atom y) (file-coalesce-p y)) (unless (file-coalesce-p (car y)) (return nil))))) - ;; We *could* coalesce base-strings as well, but we'd need - ;; a separate hash-table for that, since we are not allowed to - ;; coalesce base-strings with non-base-strings. - (typep x '(or (vector character) bit-vector))))) + ;; We *could* coalesce base-strings as well, + ;; but we'd need a separate hash-table for + ;; that, since we are not allowed to coalesce + ;; base-strings with non-base-strings. + (typep x + '(or bit-vector + ;; in the cross-compiler, we coalesce + ;; all strings with the same contents, + ;; because we will end up dumping them + ;; as base-strings anyway. In the + ;; real compiler, we're not allowed to + ;; coalesce regardless of string + ;; specialized element type, so we + ;; KLUDGE by coalescing only character + ;; strings (the common case) and + ;; punting on the other types. + #+sb-xc-host + string + #-sb-xc-host + (vector character)))))) (coalescep (x) (if faslp (file-coalesce-p x) (core-coalesce-p x)))) (if (and (boundp '*constants*) (coalescep object)) |