Better calls to static functions on x86-64.
authorStas Boukarev <stassats@gmail.com>
Sun, 2 Jun 2013 17:25:21 +0000 (21:25 +0400)
committerStas Boukarev <stassats@gmail.com>
Sun, 2 Jun 2013 17:25:21 +0000 (21:25 +0400)
Encode the calls to static functions as an immediate argument to the
CALL instruction when possible.

NEWS
src/compiler/srctran.lisp

diff --git a/NEWS b/NEWS
index d84fd52..b42f0ec 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ 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. 
   
 changes in sbcl-1.1.8 relative to sbcl-1.1.7:
   * notice: The implementation of MAP-ALLOCATED-OBJECTS (the heart of
index 80338ea..c90ca44 100644 (file)
                (policy-quality-name-p (lvar-value quality-name)))
     (give-up-ir1-transform))
   '(%policy-quality policy quality-name))
+\f
+(deftransform encode-universal-time
+    ((second minute hour date month year &optional time-zone)
+     ((constant-arg (mod 60)) (constant-arg (mod 60))
+      (constant-arg (mod 24))
+      (constant-arg (integer 1 31))
+      (constant-arg (integer 1 12))
+      (constant-arg (integer 1899))
+      (constant-arg (rational -24 24))))
+  (let ((second (lvar-value second))
+        (minute (lvar-value minute))
+        (hour (lvar-value hour))
+        (date (lvar-value date))
+        (month (lvar-value month))
+        (year (lvar-value year))
+        (time-zone (lvar-value time-zone)))
+    (if (zerop (rem time-zone 1/3600))
+        (encode-universal-time second minute hour date month year time-zone)
+        (give-up-ir1-transform))))