2011-03-10 Stefan Monnier <monnier@iro.umontreal.ca>
+ * emacs-lisp/byte-opt.el: Use lexical binding.
+ (for-effectm byte-compile-tag-number): Declare dynamic.
+ (byte-optimize-form-code-walker, byte-optimize-form): Move dynamic
+ binding of for-effect from function argument to let binding.
+ (byte-decompile-bytecode-1): Move dynamic binding of bytedecomp-bytes
+ from function argument to let binding.
+
* emacs-lisp/cconv.el (cconv--convert-function): Rename from
cconv-closure-convert-function.
(cconv-convert): Rename from cconv-closure-convert-rec.
(cconv--analyse-function): Rename from cconv-analyse-function.
(cconv--analyse-use): Change some patterns to silence compiler.
(cconv-convert, cconv--convert-function): Rewrite.
-
* emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust check for
new byte-code representation.
-;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler
+;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler -*- lexical-binding: t -*-
;; Copyright (C) 1991, 1994, 2000-2011 Free Software Foundation, Inc.
\f
;;; implementing source-level optimizers
-(defun byte-optimize-form-code-walker (form for-effect)
+(defvar for-effect)
+
+(defun byte-optimize-form-code-walker (form for-effect-arg)
;;
;; For normal function calls, We can just mapcar the optimizer the cdr. But
;; we need to have special knowledge of the syntax of the special forms
;; the important aspect is that they are subrs that don't evaluate all of
;; their args.)
;;
- (let ((fn (car-safe form))
+ (let ((for-effect for-effect-arg)
+ (fn (car-safe form))
tmp)
(cond ((not (consp form))
(if (not (and for-effect
(setq list (cdr list)))
constant))
-(defun byte-optimize-form (form &optional for-effect)
+(defun byte-optimize-form (form &optional for-effect-arg)
"The source-level pass of the optimizer."
;;
;; First, optimize all sub-forms of this one.
- (setq form (byte-optimize-form-code-walker form for-effect))
+ (setq form (byte-optimize-form-code-walker form for-effect-arg))
;;
;; after optimizing all subforms, optimize this form until it doesn't
;; optimize any further. This means that some forms will be passed through
;; the optimizer many times, but that's necessary to make the for-effect
;; processing do as much as possible.
;;
- (let (opt new)
+ (let ((for-effect for-effect-arg)
+ opt new)
(if (and (consp form)
(symbolp (car form))
(or (and for-effect
(setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;offset in next byte
(aref bytedecomp-bytes bytedecomp-ptr))))
+(defvar byte-compile-tag-number)
;; This de-compiler is used for inline expansion of compiled functions,
;; and by the disassembler.
;; If MAKE-SPLICEABLE is nil, we are being called for the disassembler.
;; In that case, we put a pc value into the list
;; before each insn (or its label).
-(defun byte-decompile-bytecode-1 (bytedecomp-bytes constvec
- &optional make-spliceable)
- (let ((length (length bytedecomp-bytes))
+(defun byte-decompile-bytecode-1 (bytes constvec &optional make-spliceable)
+ (let ((bytedecomp-bytes bytes)
+ (length (length bytes))
(bytedecomp-ptr 0) optr tags bytedecomp-op offset
lap tmp
endtag)
;; The variable `byte-boolean-vars' is now primitive and updated
;; automatically by DEFVAR_BOOL.
-(defun byte-optimize-lapcode (lap &optional for-effect)
+(defun byte-optimize-lapcode (lap &optional _for-effect)
"Simple peephole optimizer. LAP is both modified and returned.
If FOR-EFFECT is non-nil, the return value is assumed to be of no importance."
(let (lap0