don't consider an interpreted->compiled function change interesting
[sbcl.git] / src / compiler / x86-64 / static-fn.lisp
index e0b76ca..1f0c370 100644 (file)
     (error "either too many args (~W) or too many results (~W); max = ~W"
            num-args num-results register-arg-count))
   (let ((num-temps (max num-args num-results))
-        (node (gensym "NODE-")))
+        (node (sb!xc:gensym "NODE-"))
+        (new-rbp-ea
+         '(make-ea :qword
+           :disp (frame-byte-offset (+ sp->fp-offset -3 ocfp-save-offset))
+           :base rsp-tn)))
     (collect ((temp-names) (temps) (arg-names) (args) (result-names) (results))
       (dotimes (i num-results)
         (let ((result-name (intern (format nil "RESULT-~D" i))))
@@ -69,7 +73,6 @@
                     static-fun-template)
         (:args ,@(args))
         ,@(temps)
-        (:temporary (:sc unsigned-reg) call-target)
         (:results ,@(results))
         (:node-var ,node)
         (:generator ,(+ 50 num-args num-results)
          ;; effect of the ENTER with discrete instructions. Takes
          ;; 3+4+4=11 bytes as opposed to 1+4=5 bytes.
          (cond ((policy ,node (>= speed space))
-                (inst sub rsp-tn (fixnumize 3))
-                (inst mov (make-ea :qword :base rsp-tn
-                                   :disp (frame-byte-offset
-                                          (+ sp->fp-offset
-                                             -3
-                                             ocfp-save-offset)))
-                      rbp-tn)
-                (inst lea rbp-tn (make-ea :qword :base rsp-tn
-                                          :disp (frame-byte-offset
-                                                 (+ sp->fp-offset
-                                                    -3
-                                                    ocfp-save-offset)))))
+                (inst sub rsp-tn (* 3 n-word-bytes))
+                (inst mov ,new-rbp-ea rbp-tn)
+                (inst lea rbp-tn ,new-rbp-ea))
                (t
                 ;; Dummy for return address.
                 (inst push rbp-tn)
-                (inst enter (fixnumize 1))))
+                (inst enter n-word-bytes)))
 
          ,(if (zerop num-args)
-              '(inst xor ecx ecx)
-              `(inst mov ecx (fixnumize ,num-args)))
+              '(zeroize ecx)
+              `(inst mov ecx ,(fixnumize num-args)))
 
          (note-this-location vop :call-site)
          ;; Old CMU CL comment:
          ;; longer executed? Does it not depend on the
          ;; 1+3=4=fdefn_raw_address_offset relationship above?
          ;; Is something else going on?)
-
-         ;; Need to load the target address into a register, since
-         ;; immediate call arguments are just a 32-bit displacement,
-         ;; which obviously can't work with >4G spaces.
-         (inst mov call-target
-               (make-ea :qword
-                        :disp (+ nil-value (static-fun-offset function))))
-         (inst call call-target)
+         (call-indirect (+ nil-value (static-fun-offset function)))
          ,(collect ((bindings) (links))
                    (do ((temp (temp-names) (cdr temp))
                         (name 'values (gensym))
                      (default-unknown-values
                          vop
                          ,(if (zerop num-results) nil 'values)
-                       ,num-results)))
+                       ,num-results
+                       ,node)))
          ,@(moves (result-names) (temp-names)))))))
 
 ) ; EVAL-WHEN