mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
basic file compilation working
This commit is contained in:
parent
37a794ce21
commit
29fcb6ca12
3 changed files with 45 additions and 17 deletions
|
|
@ -563,8 +563,9 @@ Each element is (INDEX . VALUE)")
|
|||
(defvar byte-compile-depth 0 "Current depth of execution stack.")
|
||||
(defvar byte-compile-maxdepth 0 "Maximum depth of execution stack.")
|
||||
|
||||
;; These are use by comp.el to spill
|
||||
;; These are use by comp.el to spill data out of here
|
||||
(defvar byte-native-compiling nil)
|
||||
(defvar byte-to-native-names nil)
|
||||
(defvar byte-to-native-lap-output nil)
|
||||
(defvar byte-to-native-bytecode-output nil)
|
||||
|
||||
|
|
@ -2271,6 +2272,10 @@ we output that argument and the following argument
|
|||
QUOTED says that we have to put a quote before the
|
||||
list that represents a doc string reference.
|
||||
`defvaralias', `autoload' and `custom-declare-variable' need that."
|
||||
(when byte-native-compiling
|
||||
;; Spill output for the native compiler here
|
||||
(push name byte-to-native-names)
|
||||
(push (apply #'vector form) byte-to-native-bytecode-output))
|
||||
;; We need to examine byte-compile-dynamic-docstrings
|
||||
;; in the input buffer (now current), not in the output buffer.
|
||||
(let ((dynamic-docstrings byte-compile-dynamic-docstrings))
|
||||
|
|
@ -3122,8 +3127,7 @@ for symbols generated by the byte compiler itself."
|
|||
byte-compile-vector byte-compile-maxdepth)))
|
||||
(when byte-native-compiling
|
||||
;; Spill output for the native compiler here
|
||||
(push byte-compile-output byte-to-native-lap-output)
|
||||
(push out byte-to-native-bytecode-output))
|
||||
(push byte-compile-output byte-to-native-lap-output))
|
||||
out))
|
||||
;; it's a trivial function
|
||||
((cdr body) (cons 'progn (nreverse body)))
|
||||
|
|
|
|||
|
|
@ -243,6 +243,8 @@ Put PREFIX in front of it."
|
|||
|
||||
(defun comp-decrypt-lambda-list (x)
|
||||
"Decript lambda list X."
|
||||
(unless (fixnump x)
|
||||
(error "Can't native compile a non lexical scoped function"))
|
||||
(let ((rest (not (= (logand x 128) 0)))
|
||||
(mandatory (logand x 127))
|
||||
(nonrest (ash x -8)))
|
||||
|
|
@ -254,7 +256,7 @@ Put PREFIX in front of it."
|
|||
:nonrest nonrest))))
|
||||
|
||||
(defun comp-spill-lap-function (function-name)
|
||||
"Spill LAP for FUNCTION-NAME."
|
||||
"Byte compile FUNCTION-NAME spilling data from the byte compiler."
|
||||
(let* ((f (symbol-function function-name))
|
||||
(func (make-comp-func :symbol-name function-name
|
||||
:func f
|
||||
|
|
@ -268,23 +270,45 @@ Put PREFIX in front of it."
|
|||
(comp-within-log-buff
|
||||
(cl-prettyprint byte-to-native-lap-output))
|
||||
(let ((lambda-list (aref (comp-func-byte-func func) 0)))
|
||||
(if (fixnump lambda-list)
|
||||
(setf (comp-func-args func)
|
||||
(comp-decrypt-lambda-list lambda-list))
|
||||
(error "Can't native compile a non lexical scoped function")))
|
||||
(comp-decrypt-lambda-list lambda-list)))
|
||||
(setf (comp-func-lap func) (car byte-to-native-lap-output))
|
||||
(setf (comp-func-frame-size func) (aref (comp-func-byte-func func) 3))
|
||||
func))
|
||||
|
||||
(defun comp-spill-lap-functions-file (filename)
|
||||
"Byte compile FILENAME spilling data from the byte compiler."
|
||||
(byte-compile-file filename)
|
||||
(cl-assert (= (length byte-to-native-names)
|
||||
(length byte-to-native-lap-output)
|
||||
(length byte-to-native-bytecode-output)))
|
||||
(cl-loop for function-name in byte-to-native-names
|
||||
for lap in byte-to-native-lap-output
|
||||
for bytecode in byte-to-native-bytecode-output
|
||||
for lambda-list = (aref bytecode 0)
|
||||
for func = (make-comp-func :symbol-name function-name
|
||||
:byte-func bytecode
|
||||
:c-func-name (comp-c-func-name
|
||||
function-name
|
||||
"F")
|
||||
:args (comp-decrypt-lambda-list lambda-list)
|
||||
:lap lap
|
||||
:frame-size (aref bytecode 3))
|
||||
do (comp-within-log-buff
|
||||
(cl-prettyprint lap))
|
||||
collect func))
|
||||
|
||||
(defun comp-spill-lap (input)
|
||||
"Byte compile and spill the LAP rapresentation for INPUT.
|
||||
If INPUT is a symbol this is the function-name to be compiled.
|
||||
If INPUT is a string this is the file path to be compiled."
|
||||
(let ((byte-native-compiling t)
|
||||
(byte-to-native-lap-output ()))
|
||||
(byte-to-native-names ())
|
||||
(byte-to-native-lap-output ())
|
||||
(byte-to-native-bytecode-output ()))
|
||||
(cl-typecase input
|
||||
(symbol (list (comp-spill-lap-function input)))
|
||||
(string (error "To be implemented")))))
|
||||
(string (comp-spill-lap-functions-file input)))))
|
||||
|
||||
|
||||
;;; Limplification pass specific code.
|
||||
|
|
@ -905,11 +929,11 @@ Prepare every functions for final compilation and drive the C side."
|
|||
(defun native-compile (input)
|
||||
"Compile INPUT into native code.
|
||||
This is the entrypoint for the Emacs Lisp native compiler.
|
||||
If INPUT is a symbol this is the function-name to be compiled.
|
||||
If INPUT is a string this is the file path to be compiled."
|
||||
If INPUT is a symbol, native-compile its function definition.
|
||||
If INPUT is a string, use it as the file path to be native compiled."
|
||||
(unless (or (symbolp input)
|
||||
(stringp input))
|
||||
(error "Trying to native compile something not a function or file"))
|
||||
(error "Trying to native compile something not a symbol function or file"))
|
||||
(let ((data input)
|
||||
(comp-ctxt (make-comp-ctxt :output (if (symbolp input)
|
||||
(symbol-name input)
|
||||
|
|
|
|||
|
|
@ -3057,9 +3057,9 @@ helper_PSEUDOVECTOR_TYPEP_XUNTAG (const union vectorlike_header *a,
|
|||
}
|
||||
|
||||
|
||||
/*********************************/
|
||||
/* Native elisp load functions. */
|
||||
/*********************************/
|
||||
/**************************************/
|
||||
/* Functions used to load eln files. */
|
||||
/**************************************/
|
||||
|
||||
static Lisp_Object Vnative_elisp_refs_hash;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue