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