changeset 1297:6c21360a544b

[xemacs-hg @ 2003-02-14 11:50:36 by ben] bytecomp patch commit byte-optimize.el: Review carefully and sync up to 20.7 except for areas as noted. Fixes problem with JDE compilation.
author ben
date Fri, 14 Feb 2003 11:50:36 +0000
parents 87084e8445a7
children 1b4bc72f433e
files lisp/ChangeLog lisp/byte-optimize.el
diffstat 2 files changed, 114 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Feb 14 09:50:17 2003 +0000
+++ b/lisp/ChangeLog	Fri Feb 14 11:50:36 2003 +0000
@@ -1,3 +1,73 @@
+2003-02-14  Ben Wing  <ben@xemacs.org>
+
+	* byte-optimize.el:
+	* byte-optimize.el (byte-compile-inline-expand):
+	* byte-optimize.el (byte-compile-unfold-lambda):
+	* byte-optimize.el (byte-optimize-form-code-walker):
+	* byte-optimize.el (byte-optimize-form):
+	* byte-optimize.el (byte-decompile-bytecode-1):
+	* byte-optimize.el (byte-optimize-lapcode):
+	Review carefully and sync up to 20.7 except for areas as noted.
+	Fixes problem with JDE compilation.
+
+2003-02-14  Ben Wing  <ben@xemacs.org>
+
+	* autoload.el:
+	* autoload.el (generate-file-autoloads):
+	* autoload.el (generate-autoload-ish-1):
+	* autoload.el (generate-file-autoloads-1):
+	* autoload.el (generate-c-file-autoloads-1):
+	* byte-optimize.el:
+	* byte-optimize.el (byte-compile-inline-expand):
+	* byte-optimize.el (byte-compile-unfold-lambda):
+	* byte-optimize.el (byte-optimize-form-code-walker):
+	* byte-optimize.el (byte-optimize-form):
+	* byte-optimize.el (byte-decompile-bytecode-1):
+	* byte-optimize.el (byte-optimize-lapcode):
+	* cus-dep.el:
+	* cus-dep.el (cusload-hash-table-marker): New.
+	* cus-dep.el (Custom-make-dependencies-1):
+	* update-elc-2.el:
+	* update-elc-2.el (dirfiles-table): New.
+	* update-elc-2.el (do-update-elc-2):
+	* update-elc-2.el (batch-update-elc-2):
+	* update-elc.el:
+	* update-elc.el (dumped-exe): Removed.
+	* update-elc.el (dumped-exe-out-of-date-wrt-undumped-exe): Removed.
+	* update-elc.el (lisp-files-ignored-when-checking-for-autoload-updating): New.
+	* update-elc.el ((preloaded-file-list site-load-packages files-to-process)):
+
+2003-02-11  Ben Wing  <ben@xemacs.org>
+
+	* byte-optimize.el:
+	* byte-optimize.el (byte-compile-inline-expand):
+	* byte-optimize.el (byte-compile-unfold-lambda):
+	* byte-optimize.el (byte-optimize-form-code-walker):
+	* byte-optimize.el (byte-optimize-form):
+	* byte-optimize.el (byte-decompile-bytecode-1):
+	* byte-optimize.el (byte-optimize-lapcode):
+	
+	* update-elc-2.el:
+	* update-elc-2.el (dirfiles-table): New.
+	* update-elc-2.el (dolist): New.
+	* update-elc-2.el (do-update-elc-2):
+	* update-elc-2.el (batch-update-elc-2):
+	Rewrite algorithm to be much faster -- cache calls to
+	directory-files and don't make needless calls to file-exists-p,
+	file-directory-p because they're way way slow.
+
+	Autoload early and only when update-elc has told us to.
+	
+	* update-elc.el:
+	* update-elc.el (dumped-exe-exists): New.
+	* update-elc.el (lisp-files-ignored-when-checking-for-autoload-updating): New.
+	* update-elc.el ((preloaded-file-list site-load-packages files-to-process)):
+	If no files need byte compilation, signal to update-elc-2 to do
+	any necessary autoload updating rather than doing it ourselves,
+	which would be way slow.  Ignore updates to custom-load.el and
+	auto-autoloads.el when checking to see whether autoloads need
+	updating.
+
 2003-02-12  Jerry James  <james@xemacs.org>
 
 	* about.el (about-url-alist): Add my home page.
@@ -16,17 +86,6 @@
 	sync to them because (a) it conses (bad for lazy-lock), (b) it
 	calls select-window.
 
-2003-02-09  Ben Wing  <ben@xemacs.org>
-
-	* byte-optimize.el:
-	* byte-optimize.el (byte-compile-inline-expand):
-	* byte-optimize.el (byte-compile-unfold-lambda):
-	* byte-optimize.el (byte-optimize-form-code-walker):
-	* byte-optimize.el (byte-optimize-form):
-	* byte-optimize.el (byte-decompile-bytecode-1):
-	* byte-optimize.el (byte-optimize-lapcode):
-	Review carefully and sync up to 20.7 except for areas as noted.
-
 2003-02-07  Ben Wing  <ben@xemacs.org>
 
 	* hyper-apropos.el:
--- a/lisp/byte-optimize.el	Fri Feb 14 09:50:17 2003 +0000
+++ b/lisp/byte-optimize.el	Fri Feb 14 11:50:36 2003 +0000
@@ -24,7 +24,11 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.7.
+;;; Synched up with: FSF 20.7 except where marked.
+;;; [[ Synched up with: FSF 20.7. ]]
+;;; DO NOT PUT IN AN INVALID SYNC MESSAGE WHEN YOU DO A PARTIAL SYNC. --ben
+
+;; BEGIN SYNC WITH 20.7.
 
 ;;; Commentary:
 
@@ -292,8 +296,10 @@
 				(compiled-function-constants fn)
 				(compiled-function-stack-depth fn)))
 		    (cdr form)))
-	  (if (not (eq (car fn) 'lambda)) (error "%s is not a lambda" name))
-	  (cons fn (cdr form)))))))
+	  (if (eq (car-safe fn) 'lambda)
+	      (cons fn (cdr form))
+	    ;; Give up on inlining.
+	    form))))))
 
 ;;; ((lambda ...) ...)
 ;;;
@@ -351,6 +357,7 @@
 		(byte-compile-warn
 		 "attempt to open-code %s with too many arguments" name))
 	    form)
+	(setq body (mapcar 'byte-optimize-form body))
 	(let ((newform
 	       (if bindings
 		   (cons 'let (cons (nreverse bindings) body))
@@ -520,6 +527,14 @@
 					    byte-compile-macro-environment))))
 	   (byte-optimize-form form for-effect))
 
+	  ;; Support compiler macros as in cl.el.
+	  ((and (fboundp 'compiler-macroexpand)
+		(symbolp (car-safe form))
+		(get (car-safe form) 'cl-compiler-macro)
+	        (not (eq form
+		         (setq form (compiler-macroexpand form)))))
+	   (byte-optimize-form form for-effect))
+
 	  ((not (symbolp fn))
 	   (or (eq 'mocklisp (car-safe fn)) ; ha!
 	       (byte-compile-warn "%s is a malformed function"
@@ -567,7 +582,8 @@
 	(progn
 ;;	  (if (equal form new) (error "bogus optimizer -- %s" opt))
 	  (byte-compile-log "  %s\t==>\t%s" form new)
-	  (byte-optimize-form new for-effect))
+	  (setq new (byte-optimize-form new for-effect))
+	  new)
       form)))
 
 
@@ -699,6 +715,8 @@
 				(list (apply fun (nreverse constants)))))))))
     form))
 
+;; END SYNC WITH 20.7.
+
 ;;; It is not safe to optimize calls to arithmetic ops with one arg
 ;;; away entirely (actually, it would be safe if we know the sole arg
 ;;; is not a marker or if it appears in other arithmetic).
@@ -762,6 +780,8 @@
      ;; We don't have to check for divide-by-zero because `/' does.
      (t (byte-optimize-predicate form)))))
 
+;; BEGIN SYNC WITH 20.7.
+
 (defun byte-optimize-logmumble (form)
   (setq form (byte-optimize-delay-constants-math form 1 (car form)))
   (byte-optimize-predicate
@@ -945,6 +965,8 @@
 	(byte-optimize-predicate form)
       (nth 1 form))))
 
+;; END SYNC WITH 20.7.
+
 ;;; For the byte optimizer, `cond' is just overly sweet syntactic sugar.
 ;;; So we rewrite (cond ...) in terms of `if' and `or',
 ;;; which are easier to optimize.
@@ -963,6 +985,8 @@
      (when (cdr clauses) (list (byte-optimize-cond-1 (cdr clauses))))))
    (t (error "malformed cond clause %s" (car clauses)))))
 
+;; BEGIN SYNC WITH 20.7.
+
 (defun byte-optimize-if (form)
   ;; (if <true-constant> <then> <else...>) ==> <then>
   ;; (if <false-constant> <then> <else...>) ==> (progn <else...>)
@@ -1355,7 +1379,9 @@
 					     tags)))))))
 	    ((cond ((eq op 'byte-constant2) (setq op 'byte-constant) t)
 		   ((memq op byte-constref-ops)))
-	     (setq tmp (aref constvec offset)
+	     (setq tmp (if (>= offset (length constvec))
+			   (list 'out-of-range offset)
+			 (aref constvec offset))
 		   offset (if (eq op 'byte-constant)
 			      (byte-compile-get-constant tmp)
 			    (or (assq tmp byte-compile-variables)
@@ -1467,33 +1493,7 @@
 ;;; variables.
 
 ;(defconst byte-boolean-vars
-;  '(abbrev-all-caps purify-flag find-file-compare-truenames
-;    find-file-use-truenames delete-auto-save-files byte-metering-on
-;    x-seppuku-on-epipe zmacs-regions zmacs-region-active-p
-;    zmacs-region-stays atomic-extent-goto-char-p
-;    suppress-early-error-handler-backtrace noninteractive
-;    inhibit-early-packages inhibit-autoloads debug-paths
-;    inhibit-site-lisp debug-on-quit debug-on-next-call
-;    modifier-keys-are-sticky x-allow-sendevents
-;    mswindows-dynamic-frame-resize focus-follows-mouse
-;    inhibit-input-event-recording enable-multibyte-characters
-;    disable-auto-save-when-buffer-shrinks
-;    allow-deletion-of-last-visible-frame indent-tabs-mode
-;    load-in-progress load-warn-when-source-newer
-;    load-warn-when-source-only load-ignore-elc-files
-;    load-force-doc-strings fail-on-bucky-bit-character-escapes
-;    popup-menu-titles menubar-show-keybindings completion-ignore-case
-;    canna-empty-info canna-through-info canna-underline
-;    canna-inhibit-hankakukana enable-multibyte-characters
-;    re-short-flag x-handle-non-fully-specified-fonts
-;    print-escape-newlines print-readably delete-exited-processes
-;    windowed-process-io visible-bell no-redraw-on-reenter
-;    cursor-in-echo-area inhibit-warning-display
-;    column-number-start-at-one parse-sexp-ignore-comments
-;    words-include-escapes scroll-on-clipped-lines)
-;  "DEFVAR_BOOL variables.  Giving these any non-nil value sets them to t.
-;If this does not enumerate all DEFVAR_BOOL variables, the byte-optimizer
-;may generate incorrect code.")
+;   ...)
 
 (defun byte-optimize-lapcode (lap &optional for-effect)
   "Simple peephole optimizer.  LAP is both modified and returned."
@@ -1954,14 +1954,16 @@
     (while rest
       (setq lap0 (car rest)
 	    lap1 (nth 1 rest))
-      (case (car lap0)
-	((byte-varref byte-varset byte-varbind)
-	 (incf (gethash (cdr lap0) variable-frequency 0))
-	 (unless (memq (cdr lap0) byte-compile-variables)
-	   (push (cdr lap0) byte-compile-variables)))
-	((byte-constant)
-	 (unless (memq (cdr lap0) byte-compile-constants)
-	   (push (cdr lap0) byte-compile-constants))))
+      (if (memq (car lap0) byte-constref-ops)
+	  (if (not (eq (car lap0) 'byte-constant))
+	      (progn 
+		(incf (gethash (cdr lap0) variable-frequency 0))
+		(or (memq (cdr lap0) byte-compile-variables)
+		    (setq byte-compile-variables
+			  (cons (cdr lap0) byte-compile-variables))))
+	    (or (memq (cdr lap0) byte-compile-constants)
+		(setq byte-compile-constants (cons (cdr lap0)
+						   byte-compile-constants)))))
       (cond (;;
 	     ;; const-C varset-X  const-C  -->  const-C dup varset-X
 	     ;; const-C varbind-X const-C  -->  const-C dup varbind-X
@@ -2047,4 +2049,6 @@
 	  byte-optimize-lapcode))))
  nil)
 
+;; END SYNC WITH 20.7.
+
 ;;; byte-optimize.el ends here