Commit bba752f8 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* lisp/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.
parent 6c075cd7
2011-03-10 Stefan Monnier <monnier@iro.umontreal.ca> 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 * emacs-lisp/cconv.el (cconv--convert-function): Rename from
cconv-closure-convert-function. cconv-closure-convert-function.
(cconv-convert): Rename from cconv-closure-convert-rec. (cconv-convert): Rename from cconv-closure-convert-rec.
...@@ -7,7 +14,6 @@ ...@@ -7,7 +14,6 @@
(cconv--analyse-function): Rename from cconv-analyse-function. (cconv--analyse-function): Rename from cconv-analyse-function.
(cconv--analyse-use): Change some patterns to silence compiler. (cconv--analyse-use): Change some patterns to silence compiler.
(cconv-convert, cconv--convert-function): Rewrite. (cconv-convert, cconv--convert-function): Rewrite.
* emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust check for * emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust check for
new byte-code representation. 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. ;; Copyright (C) 1991, 1994, 2000-2011 Free Software Foundation, Inc.
...@@ -378,7 +378,9 @@ ...@@ -378,7 +378,9 @@
;;; implementing source-level optimizers ;;; 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 ;; 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 ;; we need to have special knowledge of the syntax of the special forms
...@@ -386,7 +388,8 @@ ...@@ -386,7 +388,8 @@
;; the important aspect is that they are subrs that don't evaluate all of ;; the important aspect is that they are subrs that don't evaluate all of
;; their args.) ;; their args.)
;; ;;
(let ((fn (car-safe form)) (let ((for-effect for-effect-arg)
(fn (car-safe form))
tmp) tmp)
(cond ((not (consp form)) (cond ((not (consp form))
(if (not (and for-effect (if (not (and for-effect
...@@ -586,18 +589,19 @@ ...@@ -586,18 +589,19 @@
(setq list (cdr list))) (setq list (cdr list)))
constant)) 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." "The source-level pass of the optimizer."
;; ;;
;; First, optimize all sub-forms of this one. ;; 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 ;; after optimizing all subforms, optimize this form until it doesn't
;; optimize any further. This means that some forms will be passed through ;; 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 ;; the optimizer many times, but that's necessary to make the for-effect
;; processing do as much as possible. ;; processing do as much as possible.
;; ;;
(let (opt new) (let ((for-effect for-effect-arg)
opt new)
(if (and (consp form) (if (and (consp form)
(symbolp (car form)) (symbolp (car form))
(or (and for-effect (or (and for-effect
...@@ -1355,6 +1359,7 @@ ...@@ -1355,6 +1359,7 @@
(setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;offset in next byte (setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;offset in next byte
(aref bytedecomp-bytes bytedecomp-ptr)))) (aref bytedecomp-bytes bytedecomp-ptr))))
(defvar byte-compile-tag-number)
;; This de-compiler is used for inline expansion of compiled functions, ;; This de-compiler is used for inline expansion of compiled functions,
;; and by the disassembler. ;; and by the disassembler.
...@@ -1376,9 +1381,9 @@ ...@@ -1376,9 +1381,9 @@
;; If MAKE-SPLICEABLE is nil, we are being called for 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 ;; In that case, we put a pc value into the list
;; before each insn (or its label). ;; before each insn (or its label).
(defun byte-decompile-bytecode-1 (bytedecomp-bytes constvec (defun byte-decompile-bytecode-1 (bytes constvec &optional make-spliceable)
&optional make-spliceable) (let ((bytedecomp-bytes bytes)
(let ((length (length bytedecomp-bytes)) (length (length bytes))
(bytedecomp-ptr 0) optr tags bytedecomp-op offset (bytedecomp-ptr 0) optr tags bytedecomp-op offset
lap tmp lap tmp
endtag) endtag)
...@@ -1522,7 +1527,7 @@ ...@@ -1522,7 +1527,7 @@
;; The variable `byte-boolean-vars' is now primitive and updated ;; The variable `byte-boolean-vars' is now primitive and updated
;; automatically by DEFVAR_BOOL. ;; 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. "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." If FOR-EFFECT is non-nil, the return value is assumed to be of no importance."
(let (lap0 (let (lap0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment