diff options
| author | Stefan Monnier | 2011-03-10 09:52:33 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-03-10 09:52:33 -0500 |
| commit | bba752f83152f36bfc2a24b212fb5cba3aad9188 (patch) | |
| tree | 99438c0d54c0a70f7db5b7b6b9adfdb57983ccc2 | |
| parent | 6c075cd7c07d8f7f2ae52ab4369e709d7664043e (diff) | |
| download | emacs-bba752f83152f36bfc2a24b212fb5cba3aad9188.tar.gz emacs-bba752f83152f36bfc2a24b212fb5cba3aad9188.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 25 |
2 files changed, 22 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5e38629461b..26661bf6df7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2011-03-10 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2011-03-10 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/byte-opt.el: Use lexical binding. | ||
| 4 | (for-effectm byte-compile-tag-number): Declare dynamic. | ||
| 5 | (byte-optimize-form-code-walker, byte-optimize-form): Move dynamic | ||
| 6 | binding of for-effect from function argument to let binding. | ||
| 7 | (byte-decompile-bytecode-1): Move dynamic binding of bytedecomp-bytes | ||
| 8 | from function argument to let binding. | ||
| 9 | |||
| 3 | * emacs-lisp/cconv.el (cconv--convert-function): Rename from | 10 | * emacs-lisp/cconv.el (cconv--convert-function): Rename from |
| 4 | cconv-closure-convert-function. | 11 | cconv-closure-convert-function. |
| 5 | (cconv-convert): Rename from cconv-closure-convert-rec. | 12 | (cconv-convert): Rename from cconv-closure-convert-rec. |
| @@ -7,7 +14,6 @@ | |||
| 7 | (cconv--analyse-function): Rename from cconv-analyse-function. | 14 | (cconv--analyse-function): Rename from cconv-analyse-function. |
| 8 | (cconv--analyse-use): Change some patterns to silence compiler. | 15 | (cconv--analyse-use): Change some patterns to silence compiler. |
| 9 | (cconv-convert, cconv--convert-function): Rewrite. | 16 | (cconv-convert, cconv--convert-function): Rewrite. |
| 10 | |||
| 11 | * emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust check for | 17 | * emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust check for |
| 12 | new byte-code representation. | 18 | new byte-code representation. |
| 13 | 19 | ||
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index a49218fe02d..68ec2144dae 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler | 1 | ;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1991, 1994, 2000-2011 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1991, 1994, 2000-2011 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -378,7 +378,9 @@ | |||
| 378 | 378 | ||
| 379 | ;;; implementing source-level optimizers | 379 | ;;; implementing source-level optimizers |
| 380 | 380 | ||
| 381 | (defun byte-optimize-form-code-walker (form for-effect) | 381 | (defvar for-effect) |
| 382 | |||
| 383 | (defun byte-optimize-form-code-walker (form for-effect-arg) | ||
| 382 | ;; | 384 | ;; |
| 383 | ;; For normal function calls, We can just mapcar the optimizer the cdr. But | 385 | ;; For normal function calls, We can just mapcar the optimizer the cdr. But |
| 384 | ;; we need to have special knowledge of the syntax of the special forms | 386 | ;; we need to have special knowledge of the syntax of the special forms |
| @@ -386,7 +388,8 @@ | |||
| 386 | ;; the important aspect is that they are subrs that don't evaluate all of | 388 | ;; the important aspect is that they are subrs that don't evaluate all of |
| 387 | ;; their args.) | 389 | ;; their args.) |
| 388 | ;; | 390 | ;; |
| 389 | (let ((fn (car-safe form)) | 391 | (let ((for-effect for-effect-arg) |
| 392 | (fn (car-safe form)) | ||
| 390 | tmp) | 393 | tmp) |
| 391 | (cond ((not (consp form)) | 394 | (cond ((not (consp form)) |
| 392 | (if (not (and for-effect | 395 | (if (not (and for-effect |
| @@ -586,18 +589,19 @@ | |||
| 586 | (setq list (cdr list))) | 589 | (setq list (cdr list))) |
| 587 | constant)) | 590 | constant)) |
| 588 | 591 | ||
| 589 | (defun byte-optimize-form (form &optional for-effect) | 592 | (defun byte-optimize-form (form &optional for-effect-arg) |
| 590 | "The source-level pass of the optimizer." | 593 | "The source-level pass of the optimizer." |
| 591 | ;; | 594 | ;; |
| 592 | ;; First, optimize all sub-forms of this one. | 595 | ;; First, optimize all sub-forms of this one. |
| 593 | (setq form (byte-optimize-form-code-walker form for-effect)) | 596 | (setq form (byte-optimize-form-code-walker form for-effect-arg)) |
| 594 | ;; | 597 | ;; |
| 595 | ;; after optimizing all subforms, optimize this form until it doesn't | 598 | ;; after optimizing all subforms, optimize this form until it doesn't |
| 596 | ;; optimize any further. This means that some forms will be passed through | 599 | ;; optimize any further. This means that some forms will be passed through |
| 597 | ;; the optimizer many times, but that's necessary to make the for-effect | 600 | ;; the optimizer many times, but that's necessary to make the for-effect |
| 598 | ;; processing do as much as possible. | 601 | ;; processing do as much as possible. |
| 599 | ;; | 602 | ;; |
| 600 | (let (opt new) | 603 | (let ((for-effect for-effect-arg) |
| 604 | opt new) | ||
| 601 | (if (and (consp form) | 605 | (if (and (consp form) |
| 602 | (symbolp (car form)) | 606 | (symbolp (car form)) |
| 603 | (or (and for-effect | 607 | (or (and for-effect |
| @@ -1355,6 +1359,7 @@ | |||
| 1355 | (setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;offset in next byte | 1359 | (setq bytedecomp-ptr (1+ bytedecomp-ptr)) ;offset in next byte |
| 1356 | (aref bytedecomp-bytes bytedecomp-ptr)))) | 1360 | (aref bytedecomp-bytes bytedecomp-ptr)))) |
| 1357 | 1361 | ||
| 1362 | (defvar byte-compile-tag-number) | ||
| 1358 | 1363 | ||
| 1359 | ;; This de-compiler is used for inline expansion of compiled functions, | 1364 | ;; This de-compiler is used for inline expansion of compiled functions, |
| 1360 | ;; and by the disassembler. | 1365 | ;; and by the disassembler. |
| @@ -1376,9 +1381,9 @@ | |||
| 1376 | ;; If MAKE-SPLICEABLE is nil, we are being called for the disassembler. | 1381 | ;; If MAKE-SPLICEABLE is nil, we are being called for the disassembler. |
| 1377 | ;; In that case, we put a pc value into the list | 1382 | ;; In that case, we put a pc value into the list |
| 1378 | ;; before each insn (or its label). | 1383 | ;; before each insn (or its label). |
| 1379 | (defun byte-decompile-bytecode-1 (bytedecomp-bytes constvec | 1384 | (defun byte-decompile-bytecode-1 (bytes constvec &optional make-spliceable) |
| 1380 | &optional make-spliceable) | 1385 | (let ((bytedecomp-bytes bytes) |
| 1381 | (let ((length (length bytedecomp-bytes)) | 1386 | (length (length bytes)) |
| 1382 | (bytedecomp-ptr 0) optr tags bytedecomp-op offset | 1387 | (bytedecomp-ptr 0) optr tags bytedecomp-op offset |
| 1383 | lap tmp | 1388 | lap tmp |
| 1384 | endtag) | 1389 | endtag) |
| @@ -1522,7 +1527,7 @@ | |||
| 1522 | ;; The variable `byte-boolean-vars' is now primitive and updated | 1527 | ;; The variable `byte-boolean-vars' is now primitive and updated |
| 1523 | ;; automatically by DEFVAR_BOOL. | 1528 | ;; automatically by DEFVAR_BOOL. |
| 1524 | 1529 | ||
| 1525 | (defun byte-optimize-lapcode (lap &optional for-effect) | 1530 | (defun byte-optimize-lapcode (lap &optional _for-effect) |
| 1526 | "Simple peephole optimizer. LAP is both modified and returned. | 1531 | "Simple peephole optimizer. LAP is both modified and returned. |
| 1527 | If FOR-EFFECT is non-nil, the return value is assumed to be of no importance." | 1532 | If FOR-EFFECT is non-nil, the return value is assumed to be of no importance." |
| 1528 | (let (lap0 | 1533 | (let (lap0 |