From 11f6bc8c710bfa83e8cddbc9a389be02ae6ee7ef Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Sun, 2 Jun 2013 22:58:27 +0400 Subject: [PATCH] Don't go through fdefn when referencing #'known-functions. Known functions are know to be always present, save on indirection by using them directly. --- NEWS | 4 +++- src/code/fop.lisp | 3 +++ src/compiler/dump.lisp | 5 ++++- src/compiler/generic/target-core.lisp | 5 ++++- src/compiler/ir2tran.lisp | 16 ++++++++++++---- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index b42f0ec..b6e2d99 100644 --- 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 diff --git a/src/code/fop.lisp b/src/code/fop.lisp index 1161239..02dcf61 100644 --- a/src/code/fop.lisp +++ b/src/code/fop.lisp @@ -600,6 +600,9 @@ (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) diff --git a/src/compiler/dump.lisp b/src/compiler/dump.lisp index f2152f0..02774c9 100644 --- a/src/compiler/dump.lisp +++ b/src/compiler/dump.lisp @@ -1147,7 +1147,10 @@ (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))))) diff --git a/src/compiler/generic/target-core.lisp b/src/compiler/generic/target-core.lisp index 55808d8..3174ae5 100644 --- a/src/compiler/generic/target-core.lisp +++ b/src/compiler/generic/target-core.lisp @@ -112,5 +112,8 @@ (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)) diff --git a/src/compiler/ir2tran.lisp b/src/compiler/ir2tran.lisp index b10661d..f37fde5 100644 --- a/src/compiler/ir2tran.lisp +++ b/src/compiler/ir2tran.lisp @@ -178,10 +178,18 @@ (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) -- 1.7.10.4