* lisp/emacs-lisp/cconv.el (cconv-closure-convert-rec): Let the byte
[emacs.git] / lisp / ChangeLog
blobf7a62bc8385d0f9e0731ec619403c4f96063974d
1 2011-02-21  Stefan Monnier  <monnier@iro.umontreal.ca>
3         * emacs-lisp/cconv.el (cconv-closure-convert-rec): Let the byte
4         compiler choose the representation of closures.
5         (cconv--env-var): Remove.
6         * emacs-lisp/bytecomp.el (byte-compile--env-var): New var.
7         (byte-compile-make-closure, byte-compile-get-closed-var):
8         New functions.
10 2011-02-21  Stefan Monnier  <monnier@iro.umontreal.ca>
12         * subr.el (with-output-to-temp-buffer): New macro.
14         * simple.el (count-words-region): Don't use interactive-p.
16         * minibuffer.el: Use lexical-binding.  Replace all uses of lexical-let.
18         * emacs-lisp/eieio.el (eieio-defgeneric-form-primary-only-one):
19         Call byte-compile rather than byte-compile-lambda.
21         * emacs-lisp/eieio-comp.el (eieio-byte-compile-file-form-defmethod):
22         Rename from byte-compile-file-form-defmethod.
23         Don't byte-compile-lambda.
24         (eieio-byte-compile-defmethod-param-convert): Rename from
25         byte-compile-defmethod-param-convert.
27         * emacs-lisp/cl-extra.el (cl-macroexpand-all): Don't assume that the
28         value of (function (lambda ...)) is self-quoting.
30         * emacs-lisp/cconv.el: Use lexical-binding.
31         (cconv--lookup-let): Rename from cconv-lookup-let.
32         (cconv-closure-convert-rec): Fix handling of captured+mutated
33         arguments in defun/defmacro.
35         * emacs-lisp/bytecomp.el (byte-compile-lapcode):
36         Turn stack-ref-0 into dup.
37         (byte-compile-form): Don't indirect-function since it can signal
38         errors.
39         (byte-compile-stack-ref, byte-compile-stack-set): Adjust to stack-refs
40         being relative to top rather than to bottom in the byte-code.
41         (with-output-to-temp-buffer): Remove.
42         (byte-compile-with-output-to-temp-buffer): Remove.
44         * emacs-lisp/byte-opt.el (byte-compile-side-effect-and-error-free-ops):
45         Remove interactive-p.
46         (byte-optimize-lapcode): Update optimizations now that stack-refs are
47         relative to the top rather than to the bottom.
49 2011-02-19  Stefan Monnier  <monnier@iro.umontreal.ca>
51         * subr.el (save-window-excursion): New macro, moved from C.
52         * emacs-lisp/lisp-mode.el (save-window-excursion): Don't touch.
53         * emacs-lisp/cconv.el (cconv-closure-convert-rec, cconv-analyse-form):
54         Don't handle save-window-excursion any more.
55         * emacs-lisp/bytecomp.el (interactive-p, save-window-excursion):
56         Don't use the byte-code any more.
57         (byte-compile-form): Check macro expansion was done.
58         (byte-compile-save-window-excursion): Remove.
59         * emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
60         Ignore save-window-excursion.  Don't macroepand any more.
62 2011-02-18  Stefan Monnier  <monnier@iro.umontreal.ca>
64         * emacs-lisp/pcase.el (pcase--expand, pcase--u, pcase--u1, pcase--q1):
65         Avoid destructuring-bind which results in poorer code.
67 2011-02-17  Stefan Monnier  <monnier@iro.umontreal.ca>
69         * files.el (lexical-binding): Add a safe-local-variable property.
71         * emacs-lisp/cl-macs.el (cl-byte-compile-block): Disable optimization
72         in lexbind, because it needs a different implementation.
74         * emacs-lisp/cconv.el (cconv--set-diff, cconv--set-diff-map)
75         (cconv--map-diff, cconv--map-diff-elem, cconv--map-diff-set): New funs.
76         (cconv--env-var): New constant.
77         (cconv-closure-convert-rec): Use it and use them.  Fix a typo that
78         ended up forgetting to remove entries from lmenvs in `let'.
79         For `lambda' use the outer `fvrs' when building the closure and don't
80         forget to remove `vars' from the `emvrs' and `lmenvs' of the body.
82         * emacs-lisp/bytecomp.el (byte-compile-arglist-warn):
83         Correctly extract arglist from `closure's.
84         (byte-compile-cl-warn): Compiler-macros are run earlier now.
85         (byte-compile-top-level): Bind byte-compile-lexical-environment to nil,
86         except for lambdas.
87         (byte-compile-form): Don't run the compiler-macro expander here.
88         (byte-compile-let): Merge with byte-compile-let*.
89         Don't preserve-body-value if the body's value was discarded.
91         * emacs-lisp/byte-opt.el (byte-inline-lapcode): Check how many elements
92         are added to the stack.
93         (byte-compile-splice-in-already-compiled-code): Don't touch lexical nor
94         byte-compile-depth now that byte-inline-lapcode does it for us.
95         (byte-compile-inline-expand): Don't inline dynbind byte code into
96         lexbind code, since it has to be done differently.
98 2011-02-12  Stefan Monnier  <monnier@iro.umontreal.ca>
100         * emacs-lisp/byte-lexbind.el: Delete.
102         * emacs-lisp/bytecomp.el (byte-compile-current-heap-environment)
103         (byte-compile-current-num-closures): Remove vars.
104         (byte-vec-ref, byte-vec-set): Remove byte codes.
105         (byte-compile-arglist-vars, byte-compile-make-lambda-lexenv): Move from
106         byte-lexbind.el.
107         (byte-compile-lambda): Never build a closure.
108         (byte-compile-closure-code-p, byte-compile-make-closure): Remove.
109         (byte-compile-closure): Simplify.
110         (byte-compile-top-level): Don't mess with heap environments.
111         (byte-compile-dynamic-variable-bind): Always maintain
112         byte-compile-bound-variables.
113         (byte-compile-variable-ref, byte-compile-variable-set): Always just use
114         the stack for lexical vars.
115         (byte-compile-push-binding-init): Simplify.
116         (byte-compile-not-lexical-var-p): New function, moved from cconv.el.
117         (byte-compile-bind, byte-compile-unbind): New functions, moved and
118         simplified from byte-lexbind.el.
119         (byte-compile-let, byte-compile-let*): Simplify.
120         (byte-compile-condition-case): Don't add :fun-body to the bound vars.
121         (byte-compile-defmacro): Simplify.
123         * emacs-lisp/cconv.el (cconv-not-lexical-var-p): Remove.
124         (cconv-freevars, cconv-analyse-function, cconv-analyse-form):
125         Use byte-compile-not-lexical-var-p instead.
127         * help-fns.el (describe-function-1): Fix paren typo.
129         * emacs-lisp/byte-opt.el (byte-compile-side-effect-free-ops)
130         (byte-optimize-lapcode): Remove byte-vec-ref and byte-vec-set.
132 2011-02-11  Stefan Monnier  <monnier@iro.umontreal.ca>
134         * emacs-lisp/cconv.el (cconv-closure-convert): Drop `toplevel' arg.
135         (cconv-closure-convert-toplevel): Remove.
136         (cconv-lookup-let): New fun.
137         (cconv-closure-convert-rec): Don't bother with defs-are-legal.
138         Use :fun-body to handle special forms that require closing their forms.
140         * emacs-lisp/bytecomp.el (byte-compile-file-form, byte-compile):
141         Use cconv-closure-convert instead of cconv-closure-convert-toplevel.
142         (byte-compile-lambda, byte-compile-make-closure):
143         * emacs-lisp/byte-lexbind.el (byte-compile-maybe-push-heap-environment):
144         Make sure cconv did its job.
146         * emacs-lisp/byte-opt.el (byte-optimize-lapcode): Check stack-depth
147         before using it.
149         * dired.el (dired-desktop-buffer-misc-data): Don't use a dynamic var as
150         function argument.
152 2011-02-11  Stefan Monnier  <monnier@iro.umontreal.ca>
154         * emacs-lisp/bytecomp.el (byte-compile-lambda): Fix `fun' that was not
155         renamed to `bytecomp-fun'.
157         * emacs-lisp/byte-lexbind.el (byte-compile-lforminfo-analyze):
158         Understand the :fun-body case for catch, save-window-excursion, and
159         condition-case.
160         (byte-compile-maybe-push-heap-environment): No need when nclosures is
161         zero and byte-compile-current-num-closures is -1.
163         * emacs-lisp/cconv.el (cconv-not-lexical-var-p): New function.
164         (cconv-freevars): Use it.
165         (cconv-closure-convert-rec): Avoid `position'.
166         (cconv-analyse-function): New function.
167         (cconv-analyse-form): Use it.  `inclosure' can't be nil any more.
168         Check lexical vars at let-binding time rather than when referenced.
169         For defuns to be in an empty environment and lambdas to take lexical args.
170         Pay attention to the need to build closures in catch, unwind-protect,
171         save-window-excursion, condition-case, and track-mouse.
172         Fix defconst/defvar handling.
174 2011-02-10  Stefan Monnier  <monnier@iro.umontreal.ca>
176         * emacs-lisp/cconv.el (cconv-mutated, cconv-captured)
177         (cconv-captured+mutated, cconv-lambda-candidates): Fix up declaration.
178         (cconv-freevars): Minor cleanup.  Fix handling of the error var in
179         condition-case.
181         * emacs-lisp/bytecomp.el (byte-compile-catch)
182         (byte-compile-unwind-protect, byte-compile-track-mouse)
183         (byte-compile-condition-case, byte-compile-save-window-excursion):
184         Provide a :fun-body alternative, so that info can be propagated from the
185         surrounding context, as is the case for lexical scoping.
187 2011-02-10  Igor Kuzmin  <kuzminig@iro.umontreal.ca>
189         * emacs-lisp/cconv.el: New file.
190         * emacs-lisp/bytecomp.el: Use cconv.
191         (byte-compile-file-form, byte-compile):
192         Call cconv-closure-convert-toplevel when requested.
193         * server.el:
194         * mpc.el:
195         * emacs-lisp/pcase.el:
196         * doc-view.el:
197         * dired.el: Use lexical-binding.
199 2010-12-27  Stefan Monnier  <monnier@iro.umontreal.ca>
201         * emacs-lisp/bytecomp.el (byte-compile-track-mouse): Don't use #'.
203 2010-12-15  Stefan Monnier  <monnier@iro.umontreal.ca>
205         * emacs-lisp/edebug.el (edebug-eval-defun, edebug-eval):
206         * emacs-lisp/lisp-mode.el (eval-last-sexp-1, eval-defun-1):
207         * ielm.el (ielm-eval-input):
208         * simple.el (eval-expression): Use new eval arg to obey lexical-binding.
210 2010-12-14  Stefan Monnier  <monnier@iro.umontreal.ca>
212         * emacs-lisp/bytecomp.el (byte-compile-condition-case): Use push.
214 2010-12-13  Stefan Monnier  <monnier@iro.umontreal.ca>
216         * subr.el (with-lexical-binding): Remove.
218 2010-06-18  Stefan Monnier  <monnier@iro.umontreal.ca>
220         * emacs-lisp/byte-lexbind.el (byte-compile-compute-lforminfo):
221         specialp -> special-variable-p.
223 2010-06-15  Stefan Monnier  <monnier@iro.umontreal.ca>
225         * emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment):
226         Don't macroexpand before evaluating in eval-and-compile, in case
227         `body's macro expansion uses macros and functions defined in itself.
229 2010-06-14  Stefan Monnier  <monnier@iro.umontreal.ca>
231         * emacs-lisp/bytecomp.el (byte-compile-check-variable):
232         Update byte-compile-not-obsolete-var to byte-compile-not-obsolete-vars.
234         * Makefile.in (.el.elc): Increase max-lisp-eval-depth.
236 2006-12-04  Miles Bader  <miles@gnu.org>
238         * Makefile.in (COMPILE_FIRST_STACK_DEPTH): New variable.
239         (compile, compile-always): Use it.
241 2005-10-24  Miles Bader  <miles@gnu.org>
243         * subr.el (functionp): Re-remove.
245         * emacs-lisp/bytecomp.el (byte-compile-closure): Add optional
246         ADD-LAMBDA argument, which we just pass to `byte-compile-lambda'.
247         (byte-compile-defun): Use ADD-LAMBDA arg to `byte-compile-closure'
248         instead of adding lambda ourselves.
250 2004-08-09  Miles Bader  <miles@gnu.org>
252         Changes from merging the funvec patch:
254         * emacs-lisp/bytecomp.el (byte-compile-make-closure): Use `curry'
255         instead of `vector' to create compiled closures.
257         Merge funvec patch.
259 2004-04-29  Miles Bader  <miles@gnu.org>
261         * emacs-lisp/bytecomp.el (byte-compile-top-level): Add new entries
262         to `byte-compile-lexical-environment' at the start, not end.
263         (byte-compile-delay-out): Correctly default STACK-ADJUST to zero.
265         * emacs-lisp/byte-opt.el (byte-opt-update-stack-params):
266         Don't crash on no-op lapcode entries (car is nil).
268         * emacs-lisp/byte-lexbind.el (byte-compile-make-lambda-lexenv):
269         Push a lexvar onto lexenv, not a vinfo!
271 2004-04-11  Miles Bader  <miles@gnu.org>
273         * emacs-lisp/bytecomp.el (byte-compile-top-level):
274         Correctly analyze lexically-bound arguments.
276         * emacs-lisp/byte-lexbind.el (byte-compile-lforminfo-analyze):
277         Use `append' instead of `nconc'.
279         * emacs-lisp/byte-lexbind.el (byte-compile-make-lvarinfo):
280         Don't use backquote to make a mutable data-structure.
281         (byte-compile-lvarinfo-num-refs, byte-compile-lvarinfo-num-sets):
282         Rename to use `num-' instead of `num'.
283         (byte-compile-make-lambda-lexenv): Adjust accordingly.
285 2004-04-10  Miles Bader  <miles@gnu.org>
287         * emacs-lisp/byte-lexbind.el (byte-compile-compute-lforminfo):
288         Look at variable's global specialp state too.
290 2004-04-09  Miles Bader  <miles@gnu.org>
292         * emacs-lisp/byte-opt.el (byte-optimize-lapcode):
293         Default initial-stack-depth to 0.
294         (byte-optimize-lapcode): Discard the right number of values in
295         the stack-set+discard-->discard optimization.
297 2004-04-02  Miles Bader  <miles@gnu.org>
299         * emacs-lisp/lisp-mode.el (eval-last-sexp-1): Setup the lexical
300         environment if lexical-binding is enabled.
302 2003-10-14  Miles Bader  <miles@gnu.org>
304         * emacs-lisp/macroexp.el (macroexpand-all-1): Special-case
305         `backquote-list*' to avoid stack overflows.
307 2003-04-04  Miles Bader  <miles@gnu.org>
309         * help-fns.el (help-function-arglist): Handle interpreted closures.
311 2002-11-20  Miles Bader  <miles@gnu.org>
313         * emacs-lisp/bytecomp.el (byte-compile-stack-adjustment):
314         Correctly handle discardN* operators.
315         * emacs-lisp/byte-opt.el (byte-optimize-lapcode): Fix stack-depth
316         tracking errors.
318 2002-08-26  Miles Bader  <miles@gnu.org>
320         * international/mule.el (make-char): Macroexpand call to
321         charset-id constructed by `byte-compile' hook.
323         * emacs-lisp/macroexp.el (macroexpand-all-1): Expand defconst value.
325         * emacs-lisp/byte-opt.el (byte-opt-update-stack-params): New macro.
326         (byte-optimize-lapcode): Keep track of stack-depth in final pass too.
327         Add more optimizations for lexical binding.
328         (byte-compile-inline-expand): Macroexpand result of inlining.
330         * emacs-lisp/bytecomp.el (byte-compile-lambda): Update call to
331         byte-compile-closure-initial-lexenv-p.
332         (byte-discardN-preserve-tos): Alias to byte-discardN.
333         (byte-compile-push-binding-init): Don't push unused variables on
334         init-lexenv.
335         (byte-compile-push-binding-init): Don't use LFORMINFO if it's nil.
336         (byte-compile-lambda): Don't look at lexical environment unless
337         we're using lexical binding.
338         (byte-compile-defmacro): Correctly generate macros.
340         * emacs-lisp/byte-lexbind.el (byte-compile-unbind): Optimize the
341         dynamic-bindings-only case.
342         (byte-compile-bind): Don't special-case unused lexical variables.
344         * emacs-lisp/disass.el (disassemble-1): Print arg for discardN ops.
346 2002-08-19  Miles Bader  <miles@gnu.org>
348         * emacs-lisp/byte-opt.el (byte-decompile-bytecode-1):
349         Handle `byte-discardN-preserve-tos' pseudo-op.
350         (byte-compile-side-effect-and-error-free-ops): Add `byte-stack-ref'.
351         (byte-compile-side-effect-free-ops): Add `byte-vec-ref'.
352         (byte-optimize-lapcode): Add some cases for stack-set/ref ops.
353         Add tracking of stack-depth.  Unfinished code to collapse
354         lexical-unbinding sequences.
356         * emacs-lisp/bytecomp.el (byte-compile-lapcode):
357         Handle `byte-discardN-preserve-tos' pseudo-op.
358         (byte-compile-top-level): If there are lexical args, output a TAG
359         op to record the initial stack-depth for the optimizer.
361 2002-08-17  Miles Bader  <miles@gnu.org>
363         * emacs-lisp/bytecomp.el (byte-discardN): Add byte-defop.
364         (byte-compile-lapcode): Include byte-discardN.
365         (byte-compile-lambda): Fixup closure detection.
366         (byte-compile-top-level): Handle arguments for a lexical lambda.
367         (byte-compile-lexical-variable-ref, byte-compile-variable-ref)
368         (byte-compile-variable-set): Use byte-compile-stack-set/ref.
369         (byte-compile-discard): Add new parameters NUM and PRESERVE-TOS.
370         (byte-compile-stack-ref, byte-compile-stack-set): New functions.
371         (byte-compile-push-binding-init): Get the variable list properly
372         from LFORMINFO.
374         * emacs-lisp/byte-lexbind.el (byte-compile-lforminfo-analyze):
375         Ignore setq'd variables we're not interested in.
376         (byte-compile-make-lambda-lexenv): Add assertion that closed-over
377         variables be heap allocated.
378         (byte-compile-closure-initial-lexenv-p): Rename from
379         byte-compile-closure-lexenv-p.
380         (byte-compile-non-stack-bindings-p): Get the variable list
381         properly from LFORMINFO.
382         (byte-compile-maybe-push-heap-environment): Handle the
383         no-closed-over-variables case correctly.
384         (byte-compile-bind): Use byte-compile-stack-set/ref.
385         Don't bother modifying INIT-LEXENV as no one will see the changes.
386         (byte-compile-unbind): Call `byte-compile-discard' to handle
387         unbinding lexical bindings.
389         * emacs-lisp/disass.el (disassemble-internal): Handle closures.
390         (disassemble-1): Handle new bytecodes.
391         * emacs-lisp/byte-opt.el (disassemble-offset): Handle new bytecodes.
393 2002-06-16  Miles Bader  <miles@gnu.org>
395         * emacs-lisp/macroexp.el (macroexp-accumulate): New macro.
396         (macroexpand-all-forms, macroexpand-all-clauses): Use it.
397         * Makefile.in (compile): Undo previous change.
399 2002-06-14  Miles Bader  <miles@gnu.org>
401         * Makefile.in (COMPILE_FIRST): Add `emacs-lisp/macroexp.el'.
402         (compile): Add a special case that compiles `emacs-lisp/macroexp.el'
403         with an increased max-lisp-eval-depth.
405         * emacs-lisp/bytecomp.el: Provide `bytecomp-preload', at the
406         beginning of the file.  Require `byte-lexbind' at compile time.
407         Add a few doc string.
408         (byte-compile-push-bytecodes)
409         (byte-compile-push-bytecode-const2): New macros.
410         (byte-compile-lapcode): Use them.  Do general code cleanup.
411         (byte-compile-initial-macro-environment): Expand macros in
412         byte-compile-eval before passing to byte-compile-top-level.
413         (byte-compile): Use the `byte-compile-initial-macro-environment'.
415         * emacs-lisp/byte-lexbind.el: Require `bytecomp-preload' instead of
416         `bytecomp'.
417         (byte-compile-bind): Use `byte-compile-dynamic-variable-bind' to bind
418         dynamic variables.
419         (byte-compile-maybe-push-heap-environment): Fix function name typo.
421 2002-06-13  Miles Bader  <miles@gnu.org>
423         Byte compiler lexical binding support (not finished yet):
424         * emacs-lisp/bytecomp.el: Require `macroexp'.
425         (byte-compile-lexical-environment)
426         (byte-compile-current-heap-environment)
427         (byte-compile-current-num-closures): New variables.
428         (0, 178, 179, 180, 181): New byte-opcodes.
429         (byte-compile-lapcode): Handle stack-ref/set opcodes.  Signal an
430         error if a delay-output placeholder is not filled in yet.
431         (byte-compile-file-form, byte-compile): Expand all macros with
432         `macroexpand-all'.
433         (byte-compile-file-form-defsubst, byte-compile-form): Don't expand
434         macros here.
435         (byte-compile-make-lambda-lexenv): Autoload.
436         (byte-compile-lambda): Initial code for handling lexically-bound
437         arguments and closures; doesn't work yet.
438         (byte-compile-closure-code-p, byte-compile-make-closure)
439         (byte-compile-closure): New functions.
440         (byte-compile-check-variable, byte-compile-dynamic-variable-op)
441         (byte-compile-dynamic-variable-bind)
442         (byte-compile-lexical-variable-ref, byte-compile-variable-set):
443         New functions.
444         (byte-compile-variable-ref): Remove second argument.  Now only
445         handles real variable references (not setting or binding).
446         (byte-compile-push-unknown-constant)
447         (byte-compile-resolve-unknown-constant): New functions.
448         (byte-compile-funarg, byte-compile-funarg-2): Functions removed.
449         (byte-compile-function-form): Use either `byte-compile-constant'
450         or `byte-compile-closure'.
451         (byte-compile-setq): Use `byte-compile-variable-set' instead of
452         `byte-compile-variable-ref'.
453         (apply, mapcar, mapatoms, mapconcat, mapc, sort):
454         `byte-defop-compiler-1's removed.
455         (byte-compile-while): Make sure lexically-bound variables inside
456         the loop don't get stored in an environment outside the loop.
457         (byte-compile-compute-lforminfo): Autoload.
458         (byte-compile-push-binding-init): New function.
459         (byte-compile-let, byte-compile-let*): Handle lexical binding.
460         (byte-compile-defun): Use `byte-compile-closure' to do the work.
461         (byte-compile-defmacro): Use `byte-compile-make-closure'.
462         (byte-compile-defvar): Expand the generated call to `push' since
463         we're past macroexpansion already.
464         (byte-compile-stack-adjustment): New function.
465         (byte-compile-out): Make second arg optional.  Rewrite for clarity.
466         (byte-compile-delay-out, byte-compile-delayed-out): New functions.
468         * emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
469         Don't expand macros here.
471         * emacs-lisp/macroexp.el (macroexpand-all-1): Expand defmacro forms.
473         * emacs-lisp/byte-lexbind.el (byte-compile-make-lvarinfo)
474         (byte-compile-lforminfo-add-var)
475         (byte-compile-lforminfo-note-closure)
476         (byte-compile-compute-lforminfo)
477         (byte-compile-lforminfo-from-lambda)
478         (byte-compile-lforminfo-analyze)
479         (byte-compile-heapenv-add-accessible-env)
480         (byte-compile-heapenv-ensure-access)
481         (byte-compile-rearrange-let-clauses, byte-compile-bind)
482         (byte-compile-unbind): Fix a bunch of typos.
484 2002-06-12  Miles Bader  <miles@gnu.org>
486         * emacs-lisp/byte-lexbind.el, emacs-lisp/macroexp.el: New files.
488         * subr.el (functionp): Function removed (now a subr).
489         * help-fns.el (describe-function-1): Handle interpreted closures.
491 ;; arch-tag: bd1b5b8b-fdb2-425d-9ac2-20689fb0ee70