]> git.eshelyaron.com Git - emacs.git/commitdiff
fix single function compilation
authorAndrea Corallo <akrl@sdf.org>
Sat, 23 Nov 2019 16:03:08 +0000 (17:03 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:38:09 +0000 (11:38 +0100)
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/comp.el

index 04c80c17577660ce5f4b183c4319f954b17f60d0..ebbee2a0c7c11d5a138872559ac2c8c82834c1aa 100644 (file)
@@ -3147,9 +3147,8 @@ for symbols generated by the byte compiler itself."
                        byte-compile-vector byte-compile-maxdepth)))
         (when byte-native-compiling
           ;; Spill LAP for the native compiler here
-          (when byte-compile-current-form
-            (push (cons byte-compile-current-form byte-compile-output)
-                  byte-to-native-lap)))
+          (push (cons byte-compile-current-form byte-compile-output)
+                byte-to-native-lap))
         out))
      ;; it's a trivial function
      ((cdr body) (cons 'progn (nreverse body)))
index 458c95a3227f684a93a131e81eeb28f30032f2b2..7358e8616cc1b15f013d6a2f57db41fd84d645a4 100644 (file)
@@ -102,7 +102,7 @@ Can be used by code that wants to expand differently in this case.")
                                  (* . number)
                                  (/ . number)
                                  (% . number)
-                                 ;; Type hint
+                                 ;; Type hints
                                  (comp-hint-fixnum . fixnum)
                                  (comp-hint-cons . cons))
   "Alist used for type propagation.")
@@ -412,31 +412,33 @@ Put PREFIX in front of it."
   ;; For the 1+ see bytecode.c:365 (finger crossed).
   (1+ (aref byte-compiled-func 3)))
 
-(defun comp-spill-lap-function (_function-name)
+(cl-defgeneric comp-spill-lap-function (input)
+  "Byte compile INPUT and spill lap for further stages.")
+
+(cl-defgeneric comp-spill-lap-function ((function-name symbol))
   "Byte compile FUNCTION-NAME spilling data from the byte compiler."
-  (signal 'native-ice "to be reimplemented")
-  ;; (let* ((f (symbol-function function-name))
-  ;;        (func (make-comp-func :symbol-name function-name
-  ;;                              :c-func-name (comp-c-func-name
-  ;;                                            function-name
-  ;;                                            "F"))))
-  ;;     (when (byte-code-function-p f)
-  ;;       (error "Can't native compile an already bytecompiled function"))
-  ;;     (setf (comp-func-byte-func func)
-  ;;           (byte-compile (comp-func-symbol-name func)))
-  ;;     (let ((lap (alist-get function-name (reverse byte-to-native-bytecode))))
-  ;;       (cl-assert lap)
-  ;;       (comp-log lap)
-  ;;       (let ((lambda-list (aref (comp-func-byte-func func) 0)))
-  ;;         (setf (comp-func-args func)
-  ;;               (comp-decrypt-lambda-list lambda-list)))
-  ;;       (setf (comp-func-lap func) lap)
-  ;;       (setf (comp-func-frame-size func)
-  ;;             (comp-byte-frame-size (comp-func-byte-func func)))
-  ;;       func))
-  )
-
-(defun comp-spill-lap-functions-file (filename)
+  (let* ((f (symbol-function function-name))
+         (func (make-comp-func :symbol-name function-name
+                               :c-func-name (comp-c-func-name
+                                             function-name
+                                             "F"))))
+      (when (byte-code-function-p f)
+        (signal 'native-compiler-error
+                "can't native compile an already bytecompiled function"))
+      (setf (comp-func-byte-func func)
+            (byte-compile (comp-func-symbol-name func)))
+      (let ((lap (alist-get nil byte-to-native-lap)))
+        (cl-assert lap)
+        (comp-log lap 1)
+        (let ((lambda-list (aref (comp-func-byte-func func) 0)))
+          (setf (comp-func-args func)
+                (comp-decrypt-lambda-list lambda-list)
+                (comp-func-lap func) lap
+                (comp-func-frame-size func)
+                (comp-byte-frame-size (comp-func-byte-func func))))
+        (list func))))
+
+(cl-defgeneric comp-spill-lap-function ((filename string))
   "Byte compile FILENAME spilling data from the byte compiler."
   (byte-compile-file filename)
   (unless byte-to-native-top-level-forms
@@ -472,9 +474,7 @@ If INPUT is a string this is the file path to be compiled."
   (let ((byte-native-compiling t)
         (byte-to-native-lap ())
         (byte-to-native-top-level-forms ()))
-    (cl-typecase input
-      (symbol (list (comp-spill-lap-function input)))
-      (string (comp-spill-lap-functions-file input)))))
+    (comp-spill-lap-function input)))
 
 \f
 ;;; Limplification pass specific code.
@@ -1860,7 +1860,7 @@ Return the compilation unit file name."
         (comp-native-compiling t)
         (comp-ctxt (make-comp-ctxt
                     :output (if (symbolp input)
-                                (symbol-name input)
+                                (make-temp-file (concat (symbol-name input) "-"))
                               (file-name-sans-extension (expand-file-name input))))))
     (comp-log "\n\f\n" 1)
     (condition-case err