[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp cfb871a 08/12: * Handle correctly pure delaration sp
From: |
Andrea Corallo |
Subject: |
feature/native-comp cfb871a 08/12: * Handle correctly pure delaration specifier. |
Date: |
Sun, 21 Jun 2020 18:37:17 -0400 (EDT) |
branch: feature/native-comp
commit cfb871add49096f38c5a8ff0882a7e111943ee52
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Handle correctly pure delaration specifier.
* lisp/emacs-lisp/comp.el (comp-func): New slot 'pure'.
(comp-spill-decl-spec): New function.
(comp-spill-speed): Rework to use the later.
(comp-spill-lap-function, comp-intern-func-in-ctxt): Spill pure
decl value.
(comp-function-optimizable-p): Check in the compiler env too if
pure.
---
lisp/emacs-lisp/comp.el | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 3372400..e5674cc 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -372,7 +372,9 @@ structure.")
(array-h (make-hash-table) :type hash-table
:documentation "array idx -> array length.")
(speed nil :type number
- :documentation "Optimization level (see `comp-speed')."))
+ :documentation "Optimization level (see `comp-speed').")
+ (pure nil :type boolean
+ :documentation "t if declared pure nil otherwise."))
(cl-defstruct (comp-func-l (:include comp-func))
"Lexical scoped function."
@@ -549,10 +551,14 @@ instruction."
(and (byte-code-function-p f)
(fixnump (aref f 0))))
-(defun comp-spill-speed (fuction-name)
- "Return the speed for SYMBOL-FUNCTION."
- (or (plist-get (cdr (assq fuction-name byte-to-native-plist-environment))
- 'speed)
+(defun comp-spill-decl-spec (function-name spec)
+ "Return the declared specifier SPEC for FUNCTION-NAME."
+ (plist-get (cdr (assq function-name byte-to-native-plist-environment))
+ spec))
+
+(defun comp-spill-speed (function-name)
+ "Return the speed for FUNCTION-NAME."
+ (or (comp-spill-decl-spec function-name 'speed)
comp-speed))
(defun comp-c-func-name (name prefix)
@@ -622,7 +628,9 @@ Put PREFIX in front of it."
:c-name c-name
:doc (documentation f)
:int-spec (interactive-form f)
- :speed (comp-spill-speed function-name))))
+ :speed (comp-spill-speed function-name)
+ :pure (comp-spill-decl-spec function-name
+ 'pure))))
(when (byte-code-function-p f)
(signal 'native-compiler-error
"can't native compile an already bytecompiled function"))
@@ -672,7 +680,8 @@ Put PREFIX in front of it."
(comp-func-c-name func) c-name
(comp-func-lap func) lap
(comp-func-frame-size func) (comp-byte-frame-size byte-func)
- (comp-func-speed func) (comp-spill-speed name))
+ (comp-func-speed func) (comp-spill-speed name)
+ (comp-func-pure func) (comp-spill-decl-spec name 'pure))
;; Store the c-name to have it retrivable from
;; `comp-ctxt-top-level-forms'.
@@ -1960,7 +1969,12 @@ Here goes everything that can be done not iteratively
(read once).
(defsubst comp-function-optimizable-p (f args)
"Given function F called with ARGS return non nil when optimizable."
(when (cl-every #'comp-mvar-const-vld args)
- (or (get f 'pure)
+ (or (when-let ((func (gethash (gethash f
+ (comp-ctxt-sym-to-c-name-h
+ comp-ctxt))
+ (comp-ctxt-funcs-h comp-ctxt))))
+ (comp-func-pure func))
+ (get f 'pure)
(memq (get f 'byte-optimizer) comp-propagate-classes)
(let ((values (mapcar #'comp-mvar-constant args)))
(pcase f
- feature/native-comp updated (5a55a84 -> c324e02), Andrea Corallo, 2020/06/21
- feature/native-comp c37b544 01/12: Add native compiler dynamic scope support, Andrea Corallo, 2020/06/21
- feature/native-comp 47ab6c2 02/12: Add some testing for dynamic scope, Andrea Corallo, 2020/06/21
- feature/native-comp 29b2a08 03/12: Execute top level forms in the right lex/dyn scope., Andrea Corallo, 2020/06/21
- feature/native-comp decced8 04/12: Allow per function speed declaration, Andrea Corallo, 2020/06/21
- feature/native-comp 34117de 05/12: Add a test for speed -1, Andrea Corallo, 2020/06/21
- feature/native-comp 51df0ab 06/12: Do not native compile two functions to allow cc-mode hack, Andrea Corallo, 2020/06/21
- feature/native-comp 1179a1c 07/12: * Add a func-arity test for dynamic functions, Andrea Corallo, 2020/06/21
- feature/native-comp 89b6f56 09/12: * src/comp.c (Fcomp__compile_ctxt_to_file): Confine gcc optim level in [0, 3]., Andrea Corallo, 2020/06/21
- feature/native-comp cfb871a 08/12: * Handle correctly pure delaration specifier.,
Andrea Corallo <=
- feature/native-comp 0a70ed9 10/12: ; * src/comp.c (define_maybe_gc_or_quit): Fix a comment., Andrea Corallo, 2020/06/21
- feature/native-comp c324e02 12/12: Merge remote-tracking branch 'savahnna/master' into dev, Andrea Corallo, 2020/06/21
- feature/native-comp f0e9fdd 11/12: Two `load-history' eln related fixes., Andrea Corallo, 2020/06/21