aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2011-02-21 15:12:44 -0500
committerStefan Monnier2011-02-21 15:12:44 -0500
commit3e21b6a72b87787e2327513a44623b250054f77d (patch)
tree26831a9b700810d4f9cebe90afe2a090ae865604 /src
parente0f57e65692ed73a86926f737388b60faec92767 (diff)
downloademacs-3e21b6a72b87787e2327513a44623b250054f77d.tar.gz
emacs-3e21b6a72b87787e2327513a44623b250054f77d.zip
Use offsets relative to top rather than bottom for stack refs
* lisp/emacs-lisp/byte-opt.el (byte-compile-side-effect-and-error-free-ops): Remove interactive-p. (byte-optimize-lapcode): Update optimizations now that stack-refs are relative to the top rather than to the bottom. * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): Turn stack-ref-0 into dup. (byte-compile-form): Don't indirect-function since it can signal errors. (byte-compile-stack-ref, byte-compile-stack-set): Adjust to stack-refs being relative to top rather than to bottom in the byte-code. (with-output-to-temp-buffer): Remove. (byte-compile-with-output-to-temp-buffer): Remove. * lisp/emacs-lisp/cconv.el: Use lexical-binding. (cconv--lookup-let): Rename from cconv-lookup-let. (cconv-closure-convert-rec): Fix handling of captured+mutated arguments in defun/defmacro. * lisp/emacs-lisp/eieio-comp.el (eieio-byte-compile-file-form-defmethod): Rename from byte-compile-file-form-defmethod. Don't byte-compile-lambda. (eieio-byte-compile-defmethod-param-convert): Rename from byte-compile-defmethod-param-convert. * lisp/emacs-lisp/eieio.el (eieio-defgeneric-form-primary-only-one): Call byte-compile rather than byte-compile-lambda. * src/alloc.c (Fgarbage_collect): Don't mark the byte-stack redundantly. * src/bytecode.c (exec_byte_code): Change stack_ref and stack_set to use offsets relative to top rather than to bottom. * lisp/subr.el (with-output-to-temp-buffer): New macro. * lisp/simple.el (count-words-region): Don't use interactive-p.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/alloc.c2
-rw-r--r--src/bytecode.c52
-rw-r--r--src/print.c57
-rw-r--r--src/window.c12
5 files changed, 53 insertions, 77 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6bebce0abaa..d522b6c55dc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12011-02-21 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * bytecode.c (exec_byte_code): Change stack_ref and stack_set to use
4 offsets relative to top rather than to bottom.
5
6 * alloc.c (Fgarbage_collect): Don't mark the byte-stack redundantly.
7
12011-02-19 Stefan Monnier <monnier@iro.umontreal.ca> 82011-02-19 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * window.c (Fsave_window_excursion): Remove. Moved to Lisp. 10 * window.c (Fsave_window_excursion): Remove. Moved to Lisp.
diff --git a/src/alloc.c b/src/alloc.c
index 36c849418f3..4c29ce0b4ec 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5029,9 +5029,9 @@ returns nil, because real GC can't be done. */)
5029 for (i = 0; i < tail->nvars; i++) 5029 for (i = 0; i < tail->nvars; i++)
5030 mark_object (tail->var[i]); 5030 mark_object (tail->var[i]);
5031 } 5031 }
5032 mark_byte_stack ();
5032#endif 5033#endif
5033 5034
5034 mark_byte_stack ();
5035 for (catch = catchlist; catch; catch = catch->next) 5035 for (catch = catchlist; catch; catch = catch->next)
5036 { 5036 {
5037 mark_object (catch->tag); 5037 mark_object (catch->tag);
diff --git a/src/bytecode.c b/src/bytecode.c
index ad2f7d18ade..b2e9e3c5b56 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -51,7 +51,7 @@ by Hallvard:
51 * 51 *
52 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. 52 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
53 */ 53 */
54/* #define BYTE_CODE_SAFE */ 54#define BYTE_CODE_SAFE
55/* #define BYTE_CODE_METER */ 55/* #define BYTE_CODE_METER */
56 56
57 57
@@ -88,7 +88,7 @@ extern Lisp_Object Qand_optional, Qand_rest;
88 88
89/* Byte codes: */ 89/* Byte codes: */
90 90
91#define Bstack_ref 0 91#define Bstack_ref 0 /* Actually, Bstack_ref+0 is not implemented: use dup. */
92#define Bvarref 010 92#define Bvarref 010
93#define Bvarset 020 93#define Bvarset 020
94#define Bvarbind 030 94#define Bvarbind 030
@@ -189,8 +189,8 @@ extern Lisp_Object Qand_optional, Qand_rest;
189 189
190#define Bunwind_protect 0216 190#define Bunwind_protect 0216
191#define Bcondition_case 0217 191#define Bcondition_case 0217
192#define Btemp_output_buffer_setup 0220 192#define Btemp_output_buffer_setup 0220 /* Obsolete. */
193#define Btemp_output_buffer_show 0221 193#define Btemp_output_buffer_show 0221 /* Obsolete. */
194 194
195#define Bunbind_all 0222 /* Obsolete. */ 195#define Bunbind_all 0222 /* Obsolete. */
196 196
@@ -898,9 +898,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
898 898
899 case Bsave_window_excursion: /* Obsolete. */ 899 case Bsave_window_excursion: /* Obsolete. */
900 { 900 {
901 register Lisp_Object val;
902 register int count = SPECPDL_INDEX (); 901 register int count = SPECPDL_INDEX ();
903
904 record_unwind_protect (Fset_window_configuration, 902 record_unwind_protect (Fset_window_configuration,
905 Fcurrent_window_configuration (Qnil)); 903 Fcurrent_window_configuration (Qnil));
906 BEFORE_POTENTIAL_GC (); 904 BEFORE_POTENTIAL_GC ();
@@ -940,7 +938,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
940 break; 938 break;
941 } 939 }
942 940
943 case Btemp_output_buffer_setup: 941 case Btemp_output_buffer_setup: /* Obsolete. */
944 BEFORE_POTENTIAL_GC (); 942 BEFORE_POTENTIAL_GC ();
945 CHECK_STRING (TOP); 943 CHECK_STRING (TOP);
946 temp_output_buffer_setup (SSDATA (TOP)); 944 temp_output_buffer_setup (SSDATA (TOP));
@@ -948,7 +946,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
948 TOP = Vstandard_output; 946 TOP = Vstandard_output;
949 break; 947 break;
950 948
951 case Btemp_output_buffer_show: 949 case Btemp_output_buffer_show: /* Obsolete. */
952 { 950 {
953 Lisp_Object v1; 951 Lisp_Object v1;
954 BEFORE_POTENTIAL_GC (); 952 BEFORE_POTENTIAL_GC ();
@@ -1710,26 +1708,42 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1710#endif 1708#endif
1711 1709
1712 /* Handy byte-codes for lexical binding. */ 1710 /* Handy byte-codes for lexical binding. */
1713 case Bstack_ref: 1711 /* case Bstack_ref: */ /* Use `dup' instead. */
1714 case Bstack_ref+1: 1712 case Bstack_ref+1:
1715 case Bstack_ref+2: 1713 case Bstack_ref+2:
1716 case Bstack_ref+3: 1714 case Bstack_ref+3:
1717 case Bstack_ref+4: 1715 case Bstack_ref+4:
1718 case Bstack_ref+5: 1716 case Bstack_ref+5:
1719 PUSH (stack.bottom[op - Bstack_ref]); 1717 {
1720 break; 1718 Lisp_Object *ptr = top - (op - Bstack_ref);
1719 PUSH (*ptr);
1720 break;
1721 }
1721 case Bstack_ref+6: 1722 case Bstack_ref+6:
1722 PUSH (stack.bottom[FETCH]); 1723 {
1723 break; 1724 Lisp_Object *ptr = top - (FETCH);
1725 PUSH (*ptr);
1726 break;
1727 }
1724 case Bstack_ref+7: 1728 case Bstack_ref+7:
1725 PUSH (stack.bottom[FETCH2]); 1729 {
1726 break; 1730 Lisp_Object *ptr = top - (FETCH2);
1731 PUSH (*ptr);
1732 break;
1733 }
1734 /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */
1727 case Bstack_set: 1735 case Bstack_set:
1728 stack.bottom[FETCH] = POP; 1736 {
1729 break; 1737 Lisp_Object *ptr = top - (FETCH);
1738 *ptr = POP;
1739 break;
1740 }
1730 case Bstack_set2: 1741 case Bstack_set2:
1731 stack.bottom[FETCH2] = POP; 1742 {
1732 break; 1743 Lisp_Object *ptr = top - (FETCH2);
1744 *ptr = POP;
1745 break;
1746 }
1733 case BdiscardN: 1747 case BdiscardN:
1734 op = FETCH; 1748 op = FETCH;
1735 if (op & 0x80) 1749 if (op & 0x80)
diff --git a/src/print.c b/src/print.c
index 2c4762047ac..f48b618775d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -524,6 +524,7 @@ temp_output_buffer_setup (const char *bufname)
524 specbind (Qstandard_output, buf); 524 specbind (Qstandard_output, buf);
525} 525}
526 526
527/* FIXME: Use Lisp's with-output-to-temp-buffer instead! */
527Lisp_Object 528Lisp_Object
528internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args) 529internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function) (Lisp_Object), Lisp_Object args)
529{ 530{
@@ -545,60 +546,6 @@ internal_with_output_to_temp_buffer (const char *bufname, Lisp_Object (*function
545 546
546 return unbind_to (count, val); 547 return unbind_to (count, val);
547} 548}
548
549DEFUN ("with-output-to-temp-buffer",
550 Fwith_output_to_temp_buffer, Swith_output_to_temp_buffer,
551 1, UNEVALLED, 0,
552 doc: /* Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
553
554This construct makes buffer BUFNAME empty before running BODY.
555It does not make the buffer current for BODY.
556Instead it binds `standard-output' to that buffer, so that output
557generated with `prin1' and similar functions in BODY goes into
558the buffer.
559
560At the end of BODY, this marks buffer BUFNAME unmodifed and displays
561it in a window, but does not select it. The normal way to do this is
562by calling `display-buffer', then running `temp-buffer-show-hook'.
563However, if `temp-buffer-show-function' is non-nil, it calls that
564function instead (and does not run `temp-buffer-show-hook'). The
565function gets one argument, the buffer to display.
566
567The return value of `with-output-to-temp-buffer' is the value of the
568last form in BODY. If BODY does not finish normally, the buffer
569BUFNAME is not displayed.
570
571This runs the hook `temp-buffer-setup-hook' before BODY,
572with the buffer BUFNAME temporarily current. It runs the hook
573`temp-buffer-show-hook' after displaying buffer BUFNAME, with that
574buffer temporarily current, and the window that was used to display it
575temporarily selected. But it doesn't run `temp-buffer-show-hook'
576if it uses `temp-buffer-show-function'.
577
578usage: (with-output-to-temp-buffer BUFNAME BODY...) */)
579 (Lisp_Object args)
580{
581 struct gcpro gcpro1;
582 Lisp_Object name;
583 int count = SPECPDL_INDEX ();
584 Lisp_Object buf, val;
585
586 GCPRO1(args);
587 name = eval_sub (Fcar (args));
588 CHECK_STRING (name);
589 temp_output_buffer_setup (SSDATA (name));
590 buf = Vstandard_output;
591 UNGCPRO;
592
593 val = Fprogn (XCDR (args));
594
595 GCPRO1 (val);
596 temp_output_buffer_show (buf);
597 UNGCPRO;
598
599 return unbind_to (count, val);
600}
601
602 549
603static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag); 550static void print (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag);
604static void print_preprocess (Lisp_Object obj); 551static void print_preprocess (Lisp_Object obj);
@@ -2310,6 +2257,4 @@ priorities. */);
2310 2257
2311 print_prune_charset_plist = Qnil; 2258 print_prune_charset_plist = Qnil;
2312 staticpro (&print_prune_charset_plist); 2259 staticpro (&print_prune_charset_plist);
2313
2314 defsubr (&Swith_output_to_temp_buffer);
2315} 2260}
diff --git a/src/window.c b/src/window.c
index c90cc268a92..d21cbb164ea 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3655,7 +3655,6 @@ displaying that buffer. */)
3655 return Qnil; 3655 return Qnil;
3656} 3656}
3657 3657
3658
3659void 3658void
3660temp_output_buffer_show (register Lisp_Object buf) 3659temp_output_buffer_show (register Lisp_Object buf)
3661{ 3660{
@@ -3715,6 +3714,16 @@ temp_output_buffer_show (register Lisp_Object buf)
3715 } 3714 }
3716 } 3715 }
3717} 3716}
3717
3718DEFUN ("internal-temp-output-buffer-show",
3719 Ftemp_output_buffer_show, Stemp_output_buffer_show,
3720 1, 1, 0,
3721 doc: /* Internal function for `with-output-to-temp-buffer''. */)
3722 (Lisp_Object buf)
3723{
3724 temp_output_buffer_show (buf);
3725 return Qnil;
3726}
3718 3727
3719static void 3728static void
3720make_dummy_parent (Lisp_Object window) 3729make_dummy_parent (Lisp_Object window)
@@ -7155,6 +7164,7 @@ frame to be redrawn only if it is a tty frame. */);
7155 defsubr (&Sset_window_buffer); 7164 defsubr (&Sset_window_buffer);
7156 defsubr (&Sselect_window); 7165 defsubr (&Sselect_window);
7157 defsubr (&Sforce_window_update); 7166 defsubr (&Sforce_window_update);
7167 defsubr (&Stemp_output_buffer_show);
7158 defsubr (&Ssplit_window); 7168 defsubr (&Ssplit_window);
7159 defsubr (&Senlarge_window); 7169 defsubr (&Senlarge_window);
7160 defsubr (&Sshrink_window); 7170 defsubr (&Sshrink_window);