diff options
| author | Andrea Corallo | 2021-01-14 23:54:52 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2021-01-17 22:33:02 +0100 |
| commit | 339b4a754b0abe8e376c96ff3ca9624d8942cab2 (patch) | |
| tree | ef5a8a511dff4f6070168d1822269480abdcccac | |
| parent | 883d937320a8be2bdc6d0ab7b5dd9551cbfeebd4 (diff) | |
| download | emacs-339b4a754b0abe8e376c96ff3ca9624d8942cab2.tar.gz emacs-339b4a754b0abe8e376c96ff3ca9624d8942cab2.zip | |
* Introduce `comp-fwprop-max-insns-scan' as heuristic threshold
* lisp/emacs-lisp/comp.el (comp-fwprop-max-insns-scan): New
constant.
(comp-fwprop*): Give-up when `comp-fwprop-max-insns-scan' is
exceeded.
| -rw-r--r-- | lisp/emacs-lisp/comp.el | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 238d86f7d51..d4faa207b5d 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el | |||
| @@ -2926,6 +2926,11 @@ Return t when one or more block was removed, nil otherwise." | |||
| 2926 | ;; This is also responsible for removing function calls to pure functions if | 2926 | ;; This is also responsible for removing function calls to pure functions if |
| 2927 | ;; possible. | 2927 | ;; possible. |
| 2928 | 2928 | ||
| 2929 | (defconst comp-fwprop-max-insns-scan 4500 | ||
| 2930 | ;; Choosen as ~ the greatest required value for full convergence | ||
| 2931 | ;; native compiling all Emacs codebase. | ||
| 2932 | "Max number of scanned insn before giving-up.") | ||
| 2933 | |||
| 2929 | (defun comp-copy-insn (insn) | 2934 | (defun comp-copy-insn (insn) |
| 2930 | "Deep copy INSN." | 2935 | "Deep copy INSN." |
| 2931 | ;; Adapted from `copy-tree'. | 2936 | ;; Adapted from `copy-tree'. |
| @@ -3086,7 +3091,9 @@ Fold the call in case." | |||
| 3086 | (defun comp-fwprop* () | 3091 | (defun comp-fwprop* () |
| 3087 | "Propagate for set* and phi operands. | 3092 | "Propagate for set* and phi operands. |
| 3088 | Return t if something was changed." | 3093 | Return t if something was changed." |
| 3089 | (cl-loop with modified = nil | 3094 | (cl-loop named outer |
| 3095 | with modified = nil | ||
| 3096 | with i = 0 | ||
| 3090 | for b being each hash-value of (comp-func-blocks comp-func) | 3097 | for b being each hash-value of (comp-func-blocks comp-func) |
| 3091 | do (cl-loop | 3098 | do (cl-loop |
| 3092 | with comp-block = b | 3099 | with comp-block = b |
| @@ -3094,9 +3101,13 @@ Return t if something was changed." | |||
| 3094 | for orig-insn = (unless modified | 3101 | for orig-insn = (unless modified |
| 3095 | ;; Save consing after 1th change. | 3102 | ;; Save consing after 1th change. |
| 3096 | (comp-copy-insn insn)) | 3103 | (comp-copy-insn insn)) |
| 3097 | do (comp-fwprop-insn insn) | 3104 | do |
| 3105 | (comp-fwprop-insn insn) | ||
| 3106 | (cl-incf i) | ||
| 3098 | when (and (null modified) (not (equal insn orig-insn))) | 3107 | when (and (null modified) (not (equal insn orig-insn))) |
| 3099 | do (setf modified t)) | 3108 | do (setf modified t)) |
| 3109 | when (> i comp-fwprop-max-insns-scan) | ||
| 3110 | do (cl-return-from outer nil) | ||
| 3100 | finally return modified)) | 3111 | finally return modified)) |
| 3101 | 3112 | ||
| 3102 | (defun comp-rewrite-non-locals () | 3113 | (defun comp-rewrite-non-locals () |