Don't go through fdefn when referencing #'known-functions.
authorStas Boukarev <stassats@gmail.com>
Sun, 2 Jun 2013 18:58:27 +0000 (22:58 +0400)
committerStas Boukarev <stassats@gmail.com>
Sun, 2 Jun 2013 18:58:27 +0000 (22:58 +0400)
Known functions are know to be always present, save on indirection by
using them directly.

NEWS
src/code/fop.lisp
src/compiler/dump.lisp
src/compiler/generic/target-core.lisp
src/compiler/ir2tran.lisp

diff --git a/NEWS b/NEWS
index b42f0ec..b6e2d99 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,9 @@ changes relative to sbcl-1.1.8:
   * enchancement: disassemble now annotates some previously missing static
     functions, like LENGTH.
   * optimization: calls to static functions on x86-64 use less instructions.
-  * optimization: compute encode-universal-time at compile time when possible. 
+  * optimization: compute encode-universal-time at compile time when possible.
+  * optimization: when referencing internal functions as #'x, don't go through
+    an indirect fdefn structure.
   
 changes in sbcl-1.1.8 relative to sbcl-1.1.7:
   * notice: The implementation of MAP-ALLOCATED-OBJECTS (the heart of
index 1161239..02dcf61 100644 (file)
 (define-fop (fop-fdefinition 60)
   (fdefinition-object (pop-stack) t))
 
+(define-fop (fop-known-fun 65)
+  (%coerce-name-to-fun (pop-stack)))
+
 (define-fop (fop-sanctify-for-execution 61)
   (let ((component (pop-stack)))
     (sb!vm:sanctify-for-execution component)
index f2152f0..02774c9 100644 (file)
                 (dump-push (cdr entry) fasl-output))
                (:fdefinition
                 (dump-object (cdr entry) fasl-output)
-                (dump-fop 'fop-fdefinition fasl-output))))
+                (dump-fop 'fop-fdefinition fasl-output))
+               (:known-fun
+                (dump-object (cdr entry) fasl-output)
+                (dump-fop 'fop-known-fun fasl-output))))
             (null
              (dump-fop 'fop-misc-trap fasl-output)))))
 
index 55808d8..3174ae5 100644 (file)
                 (reference-core-fun code-obj index (cdr const) object))
                (:fdefinition
                 (setf (code-header-ref code-obj index)
-                      (fdefinition-object (cdr const) t))))))))))
+                      (fdefinition-object (cdr const) t)))
+               (:known-fun
+                (setf (code-header-ref code-obj index)
+                      (%coerce-name-to-fun (cdr const)))))))))))
   (values))
index b10661d..f37fde5 100644 (file)
              (vop fast-symbol-global-value node block name-tn res)
              (vop symbol-global-value node block name-tn res))))
       (:global-function
-       (let ((fdefn-tn (make-load-time-constant-tn :fdefinition name)))
-         (if unsafe
-             (vop fdefn-fun node block fdefn-tn res)
-             (vop safe-fdefn-fun node block fdefn-tn res)))))))
+       (cond #-sb-xc-host
+             ((and (info :function :definition name)
+                   (info :function :info name))
+              ;; Known functions can be saved without going through fdefns,
+              ;; except during cross-compilation
+              (emit-move node block (make-load-time-constant-tn :known-fun name)
+                         res))
+             (t
+              (let ((fdefn-tn (make-load-time-constant-tn :fdefinition name)))
+                (if unsafe
+                    (vop fdefn-fun node block fdefn-tn res)
+                    (vop safe-fdefn-fun node block fdefn-tn res)))))))))
 
 ;;; some sanity checks for a CLAMBDA passed to IR2-CONVERT-CLOSURE
 (defun assertions-on-ir2-converted-clambda (clambda)