From e5560ff7d28c684003ed598a9390e17f9fb92d34 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sat, 16 Jun 2012 14:24:15 +0200 Subject: * buffer.h (FETCH_MULTIBYTE_CHAR): Define as inline. (BUF_FETCH_MULTIBYTE_CHAR): Likewise. * character.c (_fetch_multibyte_char_p): Remove. * alloc.c: Include "character.h" before "buffer.h". * bidi.c: Likewise. * buffer.c: Likewise. * bytecode.c: Likewise. * callint.c: Likewise. * callproc.c: Likewise. * casefiddle.c: Likewise. * casetab.c: Likewise. * category.c: Likewise. * cmds.c: Likewise. * coding.c: Likewise. * composite.c: Likewise. * dired.c: Likewise. * dispnew.c: Likewise. * doc.c: Likewise. * dosfns.c: Likewise. * editfns.c: Likewise. * emacs.c: Likewise. * fileio.c: Likewise. * filelock.c: Likewise. * font.c: Likewise. * fontset.c: Likewise. * fringe.c: Likewise. * indent.c: Likewise. * insdel.c: Likewise. * intervals.c: Likewise. * keyboard.c: Likewise. * keymap.c: Likewise. * lread.c: Likewise. * macros.c: Likewise. * marker.c: Likewise. * minibuf.c: Likewise. * nsfns.m: Likewise. * nsmenu.m: Likewise. * print.c: Likewise. * process.c: Likewise. * regex.c: Likewise. * region-cache.c: Likewise. * search.c: Likewise. * syntax.c: Likewise. * term.c: Likewise. * textprop.c: Likewise. * undo.c: Likewise. * unexsol.c: Likewise. * w16select.c: Likewise. * w32fns.c: Likewise. * w32menu.c: Likewise. * window.c: Likewise. * xdisp.c: Likewise. * xfns.c: Likewise. * xmenu.c: Likewise. * xml.c: Likewise. * xselect.c: Likewise. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index e2370254f36..2e6ee3d4445 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -35,8 +35,8 @@ by Hallvard: #include #include #include "lisp.h" -#include "buffer.h" #include "character.h" +#include "buffer.h" #include "syntax.h" #include "window.h" -- cgit v1.2.1 From defd4196e7acc24a9c5a10799e960a2f3c8c50d3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 18 Jun 2012 15:53:53 -0700 Subject: Port byte-code-meter to modern targets. * bytecode.c (METER_CODE) [BYTE_CODE_METER]: Don't assume !CHECK_LISP_OBJECT_TYPE && !USE_LSB_TAG. Problem with CHECK_LISP_OBJECT_TYPE reported by Dmitry Andropov in . (METER_1, METER_2): Simplify. --- src/bytecode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 2e6ee3d4445..9c7a3fa30cf 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -58,21 +58,21 @@ by Hallvard: #ifdef BYTE_CODE_METER Lisp_Object Qbyte_code_meter; -#define METER_2(code1, code2) \ - XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \ - ->contents[(code2)]) - -#define METER_1(code) METER_2 (0, (code)) +#define METER_2(code1, code2) AREF (AREF (Vbyte_code_meter, code1), code2) +#define METER_1(code) METER_2 (0, code) #define METER_CODE(last_code, this_code) \ { \ if (byte_metering_on) \ { \ - if (METER_1 (this_code) < MOST_POSITIVE_FIXNUM) \ - METER_1 (this_code)++; \ + if (XFASTINT (METER_1 (this_code)) < MOST_POSITIVE_FIXNUM) \ + XSETFASTINT (METER_1 (this_code), \ + XFASTINT (METER_1 (this_code)) + 1); \ if (last_code \ - && METER_2 (last_code, this_code) < MOST_POSITIVE_FIXNUM) \ - METER_2 (last_code, this_code)++; \ + && (XFASTINT (METER_2 (last_code, this_code)) \ + < MOST_POSITIVE_FIXNUM)) \ + XSETFASTINT (METER_2 (last_code, this_code), \ + XFASTINT (METER_2 (last_code, this_code)) + 1); \ } \ } -- cgit v1.2.1 From 28be1ada0fb9a4b51cf361dc45208e764bd34143 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 19 Jun 2012 20:56:28 +0400 Subject: * alloc.c, bytecode.c, ccl.c, coding.c, composite.c, data.c, dosfns.c: * font.c, image.c, keyboard.c, lread.c, menu.c, minibuf.c, msdos.c: * print.c, syntax.c, window.c, xmenu.c, xselect.c: Replace direct access to `contents' member of Lisp_Vector objects with AREF and ASET where appropriate. --- src/bytecode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 9c7a3fa30cf..08a02ea921d 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1867,8 +1867,8 @@ integer, it is incremented each time that symbol's function is called. */); { int i = 256; while (i--) - XVECTOR (Vbyte_code_meter)->contents[i] = - Fmake_vector (make_number (256), make_number (0)); + ASET (Vbyte_code_meter, i, + Fmake_vector (make_number (256), make_number (0))); } #endif } -- cgit v1.2.1 From 38182d901d030c7d65f4aa7a49b583afb30eb9b7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 5 Jul 2012 11:35:48 -0700 Subject: More xmalloc and related cleanup. * alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c: * callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c: * font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c: * gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c: * nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c: * regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c: * sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c: * xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c: * xterm.c: Omit needless casts involving void * pointers and allocation. Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))", as the former is more robust if P's type is changed. Prefer xzalloc to xmalloc + memset 0. Simplify malloc-or-realloc to realloc. Don't worry about xmalloc returning a null pointer. Prefer xstrdup to xmalloc + strcpy. * editfns.c (Fmessage_box): Grow message_text by at least 80 when growing it. * keyboard.c (apply_modifiers_uncached): Prefer local array to alloca of a constant. --- src/bytecode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 08a02ea921d..e1363d390e8 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -488,8 +488,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.constants = vector; if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth)) memory_full (SIZE_MAX); - top = (Lisp_Object *) alloca ((XFASTINT (maxdepth) + 1) - * sizeof (Lisp_Object)); + top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); #if BYTE_MAINTAIN_TOP stack.bottom = top + 1; stack.top = NULL; -- cgit v1.2.1 From 3a4c8000fba422ac9d005d29ad0c5d8becc58167 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 10 Jul 2012 08:25:22 -0600 Subject: Implement token threading * bytecode.c (BYTE_CODE_THREADED): New macro. (BYTE_CODES): New macro. Replaces all old byte-code defines. (enum byte_code_op): New type. (CASE, NEXT, FIRST, CASE_DEFAULT, CASE_ABORT): New macros. (exec_byte_code): Use them. Use token threading when applicable. --- src/bytecode.c | 1016 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 565 insertions(+), 451 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index e1363d390e8..4d3a35ee24d 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -54,6 +54,14 @@ by Hallvard: /* #define BYTE_CODE_SAFE */ /* #define BYTE_CODE_METER */ +/* If BYTE_CODE_THREADED is defined, then the interpreter will be + indirect threaded, using GCC's computed goto extension. This code, + as currently implemented, is incompatible with BYTE_CODE_SAFE and + BYTE_CODE_METER. */ +#if defined (__GNUC__) && !defined (BYTE_CODE_SAFE) && !defined (BYTE_CODE_METER) +#define BYTE_CODE_THREADED +#endif + #ifdef BYTE_CODE_METER @@ -83,158 +91,204 @@ Lisp_Object Qbytecode; /* Byte codes: */ -#define Bstack_ref 0 /* Actually, Bstack_ref+0 is not implemented: use dup. */ -#define Bvarref 010 -#define Bvarset 020 -#define Bvarbind 030 -#define Bcall 040 -#define Bunbind 050 - -#define Bnth 070 -#define Bsymbolp 071 -#define Bconsp 072 -#define Bstringp 073 -#define Blistp 074 -#define Beq 075 -#define Bmemq 076 -#define Bnot 077 -#define Bcar 0100 -#define Bcdr 0101 -#define Bcons 0102 -#define Blist1 0103 -#define Blist2 0104 -#define Blist3 0105 -#define Blist4 0106 -#define Blength 0107 -#define Baref 0110 -#define Baset 0111 -#define Bsymbol_value 0112 -#define Bsymbol_function 0113 -#define Bset 0114 -#define Bfset 0115 -#define Bget 0116 -#define Bsubstring 0117 -#define Bconcat2 0120 -#define Bconcat3 0121 -#define Bconcat4 0122 -#define Bsub1 0123 -#define Badd1 0124 -#define Beqlsign 0125 -#define Bgtr 0126 -#define Blss 0127 -#define Bleq 0130 -#define Bgeq 0131 -#define Bdiff 0132 -#define Bnegate 0133 -#define Bplus 0134 -#define Bmax 0135 -#define Bmin 0136 -#define Bmult 0137 - -#define Bpoint 0140 -/* Was Bmark in v17. */ -#define Bsave_current_buffer 0141 /* Obsolete. */ -#define Bgoto_char 0142 -#define Binsert 0143 -#define Bpoint_max 0144 -#define Bpoint_min 0145 -#define Bchar_after 0146 -#define Bfollowing_char 0147 -#define Bpreceding_char 0150 -#define Bcurrent_column 0151 -#define Bindent_to 0152 -#ifdef BYTE_CODE_SAFE -#define Bscan_buffer 0153 /* No longer generated as of v18. */ -#endif -#define Beolp 0154 -#define Beobp 0155 -#define Bbolp 0156 -#define Bbobp 0157 -#define Bcurrent_buffer 0160 -#define Bset_buffer 0161 -#define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */ -#if 0 -#define Bread_char 0162 /* No longer generated as of v19 */ -#endif +#define BYTE_CODES \ +DEFINE (Bstack_ref, 0) /* Actually, Bstack_ref+0 is not implemented: use dup. */ \ +DEFINE (Bstack_ref1, 1) \ +DEFINE (Bstack_ref2, 2) \ +DEFINE (Bstack_ref3, 3) \ +DEFINE (Bstack_ref4, 4) \ +DEFINE (Bstack_ref5, 5) \ +DEFINE (Bstack_ref6, 6) \ +DEFINE (Bstack_ref7, 7) \ +DEFINE (Bvarref, 010) \ +DEFINE (Bvarref1, 011) \ +DEFINE (Bvarref2, 012) \ +DEFINE (Bvarref3, 013) \ +DEFINE (Bvarref4, 014) \ +DEFINE (Bvarref5, 015) \ +DEFINE (Bvarref6, 016) \ +DEFINE (Bvarref7, 017) \ +DEFINE (Bvarset, 020) \ +DEFINE (Bvarset1, 021) \ +DEFINE (Bvarset2, 022) \ +DEFINE (Bvarset3, 023) \ +DEFINE (Bvarset4, 024) \ +DEFINE (Bvarset5, 025) \ +DEFINE (Bvarset6, 026) \ +DEFINE (Bvarset7, 027) \ +DEFINE (Bvarbind, 030) \ +DEFINE (Bvarbind1, 031) \ +DEFINE (Bvarbind2, 032) \ +DEFINE (Bvarbind3, 033) \ +DEFINE (Bvarbind4, 034) \ +DEFINE (Bvarbind5, 035) \ +DEFINE (Bvarbind6, 036) \ +DEFINE (Bvarbind7, 037) \ +DEFINE (Bcall, 040) \ +DEFINE (Bcall1, 041) \ +DEFINE (Bcall2, 042) \ +DEFINE (Bcall3, 043) \ +DEFINE (Bcall4, 044) \ +DEFINE (Bcall5, 045) \ +DEFINE (Bcall6, 046) \ +DEFINE (Bcall7, 047) \ +DEFINE (Bunbind, 050) \ +DEFINE (Bunbind1, 051) \ +DEFINE (Bunbind2, 052) \ +DEFINE (Bunbind3, 053) \ +DEFINE (Bunbind4, 054) \ +DEFINE (Bunbind5, 055) \ +DEFINE (Bunbind6, 056) \ +DEFINE (Bunbind7, 057) \ + \ +DEFINE (Bnth, 070) \ +DEFINE (Bsymbolp, 071) \ +DEFINE (Bconsp, 072) \ +DEFINE (Bstringp, 073) \ +DEFINE (Blistp, 074) \ +DEFINE (Beq, 075) \ +DEFINE (Bmemq, 076) \ +DEFINE (Bnot, 077) \ +DEFINE (Bcar, 0100) \ +DEFINE (Bcdr, 0101) \ +DEFINE (Bcons, 0102) \ +DEFINE (Blist1, 0103) \ +DEFINE (Blist2, 0104) \ +DEFINE (Blist3, 0105) \ +DEFINE (Blist4, 0106) \ +DEFINE (Blength, 0107) \ +DEFINE (Baref, 0110) \ +DEFINE (Baset, 0111) \ +DEFINE (Bsymbol_value, 0112) \ +DEFINE (Bsymbol_function, 0113) \ +DEFINE (Bset, 0114) \ +DEFINE (Bfset, 0115) \ +DEFINE (Bget, 0116) \ +DEFINE (Bsubstring, 0117) \ +DEFINE (Bconcat2, 0120) \ +DEFINE (Bconcat3, 0121) \ +DEFINE (Bconcat4, 0122) \ +DEFINE (Bsub1, 0123) \ +DEFINE (Badd1, 0124) \ +DEFINE (Beqlsign, 0125) \ +DEFINE (Bgtr, 0126) \ +DEFINE (Blss, 0127) \ +DEFINE (Bleq, 0130) \ +DEFINE (Bgeq, 0131) \ +DEFINE (Bdiff, 0132) \ +DEFINE (Bnegate, 0133) \ +DEFINE (Bplus, 0134) \ +DEFINE (Bmax, 0135) \ +DEFINE (Bmin, 0136) \ +DEFINE (Bmult, 0137) \ + \ +DEFINE (Bpoint, 0140) \ +/* Was Bmark in v17. */ \ +DEFINE (Bsave_current_buffer, 0141) /* Obsolete. */ \ +DEFINE (Bgoto_char, 0142) \ +DEFINE (Binsert, 0143) \ +DEFINE (Bpoint_max, 0144) \ +DEFINE (Bpoint_min, 0145) \ +DEFINE (Bchar_after, 0146) \ +DEFINE (Bfollowing_char, 0147) \ +DEFINE (Bpreceding_char, 0150) \ +DEFINE (Bcurrent_column, 0151) \ +DEFINE (Bindent_to, 0152) \ +DEFINE (Beolp, 0154) \ +DEFINE (Beobp, 0155) \ +DEFINE (Bbolp, 0156) \ +DEFINE (Bbobp, 0157) \ +DEFINE (Bcurrent_buffer, 0160) \ +DEFINE (Bset_buffer, 0161) \ +DEFINE (Bsave_current_buffer_1, 0162) /* Replacing Bsave_current_buffer. */ \ +DEFINE (Binteractive_p, 0164) /* Obsolete since Emacs-24.1. */ \ + \ +DEFINE (Bforward_char, 0165) \ +DEFINE (Bforward_word, 0166) \ +DEFINE (Bskip_chars_forward, 0167) \ +DEFINE (Bskip_chars_backward, 0170) \ +DEFINE (Bforward_line, 0171) \ +DEFINE (Bchar_syntax, 0172) \ +DEFINE (Bbuffer_substring, 0173) \ +DEFINE (Bdelete_region, 0174) \ +DEFINE (Bnarrow_to_region, 0175) \ +DEFINE (Bwiden, 0176) \ +DEFINE (Bend_of_line, 0177) \ + \ +DEFINE (Bconstant2, 0201) \ +DEFINE (Bgoto, 0202) \ +DEFINE (Bgotoifnil, 0203) \ +DEFINE (Bgotoifnonnil, 0204) \ +DEFINE (Bgotoifnilelsepop, 0205) \ +DEFINE (Bgotoifnonnilelsepop, 0206) \ +DEFINE (Breturn, 0207) \ +DEFINE (Bdiscard, 0210) \ +DEFINE (Bdup, 0211) \ + \ +DEFINE (Bsave_excursion, 0212) \ +DEFINE (Bsave_window_excursion, 0213) /* Obsolete since Emacs-24.1. */ \ +DEFINE (Bsave_restriction, 0214) \ +DEFINE (Bcatch, 0215) \ + \ +DEFINE (Bunwind_protect, 0216) \ +DEFINE (Bcondition_case, 0217) \ +DEFINE (Btemp_output_buffer_setup, 0220) /* Obsolete since Emacs-24.1. */ \ +DEFINE (Btemp_output_buffer_show, 0221) /* Obsolete since Emacs-24.1. */ \ + \ +DEFINE (Bunbind_all, 0222) /* Obsolete. Never used. */ \ + \ +DEFINE (Bset_marker, 0223) \ +DEFINE (Bmatch_beginning, 0224) \ +DEFINE (Bmatch_end, 0225) \ +DEFINE (Bupcase, 0226) \ +DEFINE (Bdowncase, 0227) \ + \ +DEFINE (Bstringeqlsign, 0230) \ +DEFINE (Bstringlss, 0231) \ +DEFINE (Bequal, 0232) \ +DEFINE (Bnthcdr, 0233) \ +DEFINE (Belt, 0234) \ +DEFINE (Bmember, 0235) \ +DEFINE (Bassq, 0236) \ +DEFINE (Bnreverse, 0237) \ +DEFINE (Bsetcar, 0240) \ +DEFINE (Bsetcdr, 0241) \ +DEFINE (Bcar_safe, 0242) \ +DEFINE (Bcdr_safe, 0243) \ +DEFINE (Bnconc, 0244) \ +DEFINE (Bquo, 0245) \ +DEFINE (Brem, 0246) \ +DEFINE (Bnumberp, 0247) \ +DEFINE (Bintegerp, 0250) \ + \ +DEFINE (BRgoto, 0252) \ +DEFINE (BRgotoifnil, 0253) \ +DEFINE (BRgotoifnonnil, 0254) \ +DEFINE (BRgotoifnilelsepop, 0255) \ +DEFINE (BRgotoifnonnilelsepop, 0256) \ + \ +DEFINE (BlistN, 0257) \ +DEFINE (BconcatN, 0260) \ +DEFINE (BinsertN, 0261) \ + \ +/* Bstack_ref is code 0. */ \ +DEFINE (Bstack_set, 0262) \ +DEFINE (Bstack_set2, 0263) \ +DEFINE (BdiscardN, 0266) \ + \ +DEFINE (Bconstant, 0300) + +enum byte_code_op +{ +#define DEFINE(name, value) name = value, + BYTE_CODES +#undef DEFINE + #ifdef BYTE_CODE_SAFE -#define Bset_mark 0163 /* this loser is no longer generated as of v18 */ + Bscan_buffer = 0153, /* No longer generated as of v18. */ + Bset_mark = 0163 /* this loser is no longer generated as of v18 */ #endif -#define Binteractive_p 0164 /* Obsolete since Emacs-24.1. */ - -#define Bforward_char 0165 -#define Bforward_word 0166 -#define Bskip_chars_forward 0167 -#define Bskip_chars_backward 0170 -#define Bforward_line 0171 -#define Bchar_syntax 0172 -#define Bbuffer_substring 0173 -#define Bdelete_region 0174 -#define Bnarrow_to_region 0175 -#define Bwiden 0176 -#define Bend_of_line 0177 - -#define Bconstant2 0201 -#define Bgoto 0202 -#define Bgotoifnil 0203 -#define Bgotoifnonnil 0204 -#define Bgotoifnilelsepop 0205 -#define Bgotoifnonnilelsepop 0206 -#define Breturn 0207 -#define Bdiscard 0210 -#define Bdup 0211 - -#define Bsave_excursion 0212 -#define Bsave_window_excursion 0213 /* Obsolete since Emacs-24.1. */ -#define Bsave_restriction 0214 -#define Bcatch 0215 - -#define Bunwind_protect 0216 -#define Bcondition_case 0217 -#define Btemp_output_buffer_setup 0220 /* Obsolete since Emacs-24.1. */ -#define Btemp_output_buffer_show 0221 /* Obsolete since Emacs-24.1. */ - -#define Bunbind_all 0222 /* Obsolete. Never used. */ - -#define Bset_marker 0223 -#define Bmatch_beginning 0224 -#define Bmatch_end 0225 -#define Bupcase 0226 -#define Bdowncase 0227 - -#define Bstringeqlsign 0230 -#define Bstringlss 0231 -#define Bequal 0232 -#define Bnthcdr 0233 -#define Belt 0234 -#define Bmember 0235 -#define Bassq 0236 -#define Bnreverse 0237 -#define Bsetcar 0240 -#define Bsetcdr 0241 -#define Bcar_safe 0242 -#define Bcdr_safe 0243 -#define Bnconc 0244 -#define Bquo 0245 -#define Brem 0246 -#define Bnumberp 0247 -#define Bintegerp 0250 - -#define BRgoto 0252 -#define BRgotoifnil 0253 -#define BRgotoifnonnil 0254 -#define BRgotoifnilelsepop 0255 -#define BRgotoifnonnilelsepop 0256 - -#define BlistN 0257 -#define BconcatN 0260 -#define BinsertN 0261 - -/* Bstack_ref is code 0. */ -#define Bstack_set 0262 -#define Bstack_set2 0263 -#define BdiscardN 0266 - -#define Bconstant 0300 +}; /* Whether to maintain a `top' and `bottom' field in the stack frame. */ #define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK) @@ -560,27 +614,83 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, this_op = op = FETCH; METER_CODE (prev_op, op); #else +#ifndef BYTE_CODE_THREADED op = FETCH; #endif +#endif + + /* The interpreter can be compiled one of two ways: as an + ordinary switch-based interpreter, or as a threaded + interpreter. The threaded interpreter relies on GCC's + computed goto extension, so it is not available everywhere. + Threading provides a performance boost. These macros are how + we allow the code to be compiled both ways. */ +#ifdef BYTE_CODE_THREADED + /* The CASE macro introduces an instruction's body. It is + either a label or a case label. */ +#define CASE(OP) insn_ ## OP + /* NEXT is invoked at the end of an instruction to go to the + next instruction. It is either a computed goto, or a + plain break. */ +#define NEXT goto *(targets[op = FETCH]) + /* FIRST is like NEXT, but is only used at the start of the + interpreter body. In the switch-based interpreter it is the + switch, so the threaded definition must include a semicolon. */ +#define FIRST NEXT; + /* Most cases are labeled with the CASE macro, above. + CASE_DEFAULT is one exception; it is used if the interpreter + being built requires a default case. The threaded + interpreter does not, because the dispatch table is + completely filled. */ +#define CASE_DEFAULT + /* This introduces an instruction that is known to call abort. */ +#define CASE_ABORT CASE (Bstack_ref): CASE (default) +#else + /* See above for the meaning of the various defines. */ +#define CASE(OP) case OP +#define NEXT break +#define FIRST switch (op) +#define CASE_DEFAULT case 255: default: +#define CASE_ABORT case 0 +#endif + +#ifdef BYTE_CODE_THREADED + + /* A convenience define that saves us a lot of typing and makes + the table clearer. */ +#define LABEL(OP) [OP] = &&insn_ ## OP - switch (op) + /* This is the dispatch table for the threaded interpreter. */ + static const void *const targets[256] = { - case Bvarref + 7: + [0 ... (Bconstant - 1)] = &&insn_default, + [Bconstant ... 255] = &&insn_Bconstant, + +#define DEFINE(name, value) LABEL (name) , + BYTE_CODES +#undef DEFINE + }; +#endif + + + FIRST + { + CASE (Bvarref7): op = FETCH2; goto varref; - case Bvarref: - case Bvarref + 1: - case Bvarref + 2: - case Bvarref + 3: - case Bvarref + 4: - case Bvarref + 5: + CASE (Bvarref): + CASE (Bvarref1): + CASE (Bvarref2): + CASE (Bvarref3): + CASE (Bvarref4): + CASE (Bvarref5): op = op - Bvarref; goto varref; /* This seems to be the most frequently executed byte-code among the Bvarref's, so avoid a goto here. */ - case Bvarref+6: + CASE (Bvarref6): op = FETCH; varref: { @@ -605,10 +715,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, AFTER_POTENTIAL_GC (); } PUSH (v2); - break; + NEXT; } - case Bgotoifnil: + CASE (Bgotoifnil): { Lisp_Object v1; MAYBE_GC (); @@ -620,10 +730,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CHECK_RANGE (op); stack.pc = stack.byte_string_start + op; } - break; + NEXT; } - case Bcar: + CASE (Bcar): { Lisp_Object v1; v1 = TOP; @@ -637,28 +747,28 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, wrong_type_argument (Qlistp, v1); AFTER_POTENTIAL_GC (); } - break; + NEXT; } - case Beq: + CASE (Beq): { Lisp_Object v1; v1 = POP; TOP = EQ (v1, TOP) ? Qt : Qnil; - break; + NEXT; } - case Bmemq: + CASE (Bmemq): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fmemq (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bcdr: + CASE (Bcdr): { Lisp_Object v1; v1 = TOP; @@ -672,24 +782,23 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, wrong_type_argument (Qlistp, v1); AFTER_POTENTIAL_GC (); } - break; - break; + NEXT; } - case Bvarset: - case Bvarset+1: - case Bvarset+2: - case Bvarset+3: - case Bvarset+4: - case Bvarset+5: + CASE (Bvarset): + CASE (Bvarset1): + CASE (Bvarset2): + CASE (Bvarset3): + CASE (Bvarset4): + CASE (Bvarset5): op -= Bvarset; goto varset; - case Bvarset+7: + CASE (Bvarset7): op = FETCH2; goto varset; - case Bvarset+6: + CASE (Bvarset6): op = FETCH; varset: { @@ -712,54 +821,54 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, } } (void) POP; - break; + NEXT; - case Bdup: + CASE (Bdup): { Lisp_Object v1; v1 = TOP; PUSH (v1); - break; + NEXT; } /* ------------------ */ - case Bvarbind+6: + CASE (Bvarbind6): op = FETCH; goto varbind; - case Bvarbind+7: + CASE (Bvarbind7): op = FETCH2; goto varbind; - case Bvarbind: - case Bvarbind+1: - case Bvarbind+2: - case Bvarbind+3: - case Bvarbind+4: - case Bvarbind+5: + CASE (Bvarbind): + CASE (Bvarbind1): + CASE (Bvarbind2): + CASE (Bvarbind3): + CASE (Bvarbind4): + CASE (Bvarbind5): op -= Bvarbind; varbind: /* Specbind can signal and thus GC. */ BEFORE_POTENTIAL_GC (); specbind (vectorp[op], POP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bcall+6: + CASE (Bcall6): op = FETCH; goto docall; - case Bcall+7: + CASE (Bcall7): op = FETCH2; goto docall; - case Bcall: - case Bcall+1: - case Bcall+2: - case Bcall+3: - case Bcall+4: - case Bcall+5: + CASE (Bcall): + CASE (Bcall1): + CASE (Bcall2): + CASE (Bcall3): + CASE (Bcall4): + CASE (Bcall5): op -= Bcall; docall: { @@ -782,47 +891,47 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #endif TOP = Ffuncall (op + 1, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bunbind+6: + CASE (Bunbind6): op = FETCH; goto dounbind; - case Bunbind+7: + CASE (Bunbind7): op = FETCH2; goto dounbind; - case Bunbind: - case Bunbind+1: - case Bunbind+2: - case Bunbind+3: - case Bunbind+4: - case Bunbind+5: + CASE (Bunbind): + CASE (Bunbind1): + CASE (Bunbind2): + CASE (Bunbind3): + CASE (Bunbind4): + CASE (Bunbind5): op -= Bunbind; dounbind: BEFORE_POTENTIAL_GC (); unbind_to (SPECPDL_INDEX () - op, Qnil); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bunbind_all: /* Obsolete. Never used. */ + CASE (Bunbind_all): /* Obsolete. Never used. */ /* To unbind back to the beginning of this frame. Not used yet, but will be needed for tail-recursion elimination. */ BEFORE_POTENTIAL_GC (); unbind_to (count, Qnil); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bgoto: + CASE (Bgoto): MAYBE_GC (); BYTE_CODE_QUIT; op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ CHECK_RANGE (op); stack.pc = stack.byte_string_start + op; - break; + NEXT; - case Bgotoifnonnil: + CASE (Bgotoifnonnil): { Lisp_Object v1; MAYBE_GC (); @@ -834,10 +943,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CHECK_RANGE (op); stack.pc = stack.byte_string_start + op; } - break; + NEXT; } - case Bgotoifnilelsepop: + CASE (Bgotoifnilelsepop): MAYBE_GC (); op = FETCH2; if (NILP (TOP)) @@ -847,9 +956,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.pc = stack.byte_string_start + op; } else DISCARD (1); - break; + NEXT; - case Bgotoifnonnilelsepop: + CASE (Bgotoifnonnilelsepop): MAYBE_GC (); op = FETCH2; if (!NILP (TOP)) @@ -859,15 +968,15 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.pc = stack.byte_string_start + op; } else DISCARD (1); - break; + NEXT; - case BRgoto: + CASE (BRgoto): MAYBE_GC (); BYTE_CODE_QUIT; stack.pc += (int) *stack.pc - 127; - break; + NEXT; - case BRgotoifnil: + CASE (BRgotoifnil): { Lisp_Object v1; MAYBE_GC (); @@ -878,10 +987,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.pc += (int) *stack.pc - 128; } stack.pc++; - break; + NEXT; } - case BRgotoifnonnil: + CASE (BRgotoifnonnil): { Lisp_Object v1; MAYBE_GC (); @@ -892,10 +1001,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.pc += (int) *stack.pc - 128; } stack.pc++; - break; + NEXT; } - case BRgotoifnilelsepop: + CASE (BRgotoifnilelsepop): MAYBE_GC (); op = *stack.pc++; if (NILP (TOP)) @@ -904,9 +1013,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.pc += op - 128; } else DISCARD (1); - break; + NEXT; - case BRgotoifnonnilelsepop: + CASE (BRgotoifnonnilelsepop): MAYBE_GC (); op = *stack.pc++; if (!NILP (TOP)) @@ -915,31 +1024,31 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.pc += op - 128; } else DISCARD (1); - break; + NEXT; - case Breturn: + CASE (Breturn): result = POP; goto exit; - case Bdiscard: + CASE (Bdiscard): DISCARD (1); - break; + NEXT; - case Bconstant2: + CASE (Bconstant2): PUSH (vectorp[FETCH2]); - break; + NEXT; - case Bsave_excursion: + CASE (Bsave_excursion): record_unwind_protect (save_excursion_restore, save_excursion_save ()); - break; + NEXT; - case Bsave_current_buffer: /* Obsolete since ??. */ - case Bsave_current_buffer_1: + CASE (Bsave_current_buffer): /* Obsolete since ??. */ + CASE (Bsave_current_buffer_1): record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); - break; + NEXT; - case Bsave_window_excursion: /* Obsolete since 24.1. */ + CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ { register ptrdiff_t count1 = SPECPDL_INDEX (); record_unwind_protect (Fset_window_configuration, @@ -948,29 +1057,29 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, TOP = Fprogn (TOP); unbind_to (count1, TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bsave_restriction: + CASE (Bsave_restriction): record_unwind_protect (save_restriction_restore, save_restriction_save ()); - break; + NEXT; - case Bcatch: /* FIXME: ill-suited for lexbind. */ + CASE (Bcatch): /* FIXME: ill-suited for lexbind. */ { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = internal_catch (TOP, eval_sub, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bunwind_protect: /* FIXME: avoid closure for lexbind. */ + CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */ record_unwind_protect (Fprogn, POP); - break; + NEXT; - case Bcondition_case: /* FIXME: ill-suited for lexbind. */ + CASE (Bcondition_case): /* FIXME: ill-suited for lexbind. */ { Lisp_Object handlers, body; handlers = POP; @@ -978,18 +1087,18 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, BEFORE_POTENTIAL_GC (); TOP = internal_lisp_condition_case (TOP, body, handlers); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Btemp_output_buffer_setup: /* Obsolete since 24.1. */ + CASE (Btemp_output_buffer_setup): /* Obsolete since 24.1. */ BEFORE_POTENTIAL_GC (); CHECK_STRING (TOP); temp_output_buffer_setup (SSDATA (TOP)); AFTER_POTENTIAL_GC (); TOP = Vstandard_output; - break; + NEXT; - case Btemp_output_buffer_show: /* Obsolete since 24.1. */ + CASE (Btemp_output_buffer_show): /* Obsolete since 24.1. */ { Lisp_Object v1; BEFORE_POTENTIAL_GC (); @@ -999,10 +1108,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, /* pop binding of standard-output */ unbind_to (SPECPDL_INDEX () - 1, Qnil); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bnth: + CASE (Bnth): { Lisp_Object v1, v2; EMACS_INT n; @@ -1017,173 +1126,173 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, immediate_quit = 0; TOP = CAR (v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bsymbolp: + CASE (Bsymbolp): TOP = SYMBOLP (TOP) ? Qt : Qnil; - break; + NEXT; - case Bconsp: + CASE (Bconsp): TOP = CONSP (TOP) ? Qt : Qnil; - break; + NEXT; - case Bstringp: + CASE (Bstringp): TOP = STRINGP (TOP) ? Qt : Qnil; - break; + NEXT; - case Blistp: + CASE (Blistp): TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil; - break; + NEXT; - case Bnot: + CASE (Bnot): TOP = NILP (TOP) ? Qt : Qnil; - break; + NEXT; - case Bcons: + CASE (Bcons): { Lisp_Object v1; v1 = POP; TOP = Fcons (TOP, v1); - break; + NEXT; } - case Blist1: + CASE (Blist1): TOP = Fcons (TOP, Qnil); - break; + NEXT; - case Blist2: + CASE (Blist2): { Lisp_Object v1; v1 = POP; TOP = Fcons (TOP, Fcons (v1, Qnil)); - break; + NEXT; } - case Blist3: + CASE (Blist3): DISCARD (2); TOP = Flist (3, &TOP); - break; + NEXT; - case Blist4: + CASE (Blist4): DISCARD (3); TOP = Flist (4, &TOP); - break; + NEXT; - case BlistN: + CASE (BlistN): op = FETCH; DISCARD (op - 1); TOP = Flist (op, &TOP); - break; + NEXT; - case Blength: + CASE (Blength): BEFORE_POTENTIAL_GC (); TOP = Flength (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Baref: + CASE (Baref): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Faref (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Baset: + CASE (Baset): { Lisp_Object v1, v2; BEFORE_POTENTIAL_GC (); v2 = POP; v1 = POP; TOP = Faset (TOP, v1, v2); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bsymbol_value: + CASE (Bsymbol_value): BEFORE_POTENTIAL_GC (); TOP = Fsymbol_value (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bsymbol_function: + CASE (Bsymbol_function): BEFORE_POTENTIAL_GC (); TOP = Fsymbol_function (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bset: + CASE (Bset): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fset (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bfset: + CASE (Bfset): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Ffset (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bget: + CASE (Bget): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fget (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bsubstring: + CASE (Bsubstring): { Lisp_Object v1, v2; BEFORE_POTENTIAL_GC (); v2 = POP; v1 = POP; TOP = Fsubstring (TOP, v1, v2); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bconcat2: + CASE (Bconcat2): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Fconcat (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bconcat3: + CASE (Bconcat3): BEFORE_POTENTIAL_GC (); DISCARD (2); TOP = Fconcat (3, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bconcat4: + CASE (Bconcat4): BEFORE_POTENTIAL_GC (); DISCARD (3); TOP = Fconcat (4, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case BconcatN: + CASE (BconcatN): op = FETCH; BEFORE_POTENTIAL_GC (); DISCARD (op - 1); TOP = Fconcat (op, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bsub1: + CASE (Bsub1): { Lisp_Object v1; v1 = TOP; @@ -1198,10 +1307,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, TOP = Fsub1 (v1); AFTER_POTENTIAL_GC (); } - break; + NEXT; } - case Badd1: + CASE (Badd1): { Lisp_Object v1; v1 = TOP; @@ -1216,10 +1325,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, TOP = Fadd1 (v1); AFTER_POTENTIAL_GC (); } - break; + NEXT; } - case Beqlsign: + CASE (Beqlsign): { Lisp_Object v1, v2; BEFORE_POTENTIAL_GC (); @@ -1237,57 +1346,57 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, } else TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil); - break; + NEXT; } - case Bgtr: + CASE (Bgtr): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fgtr (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Blss: + CASE (Blss): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Flss (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bleq: + CASE (Bleq): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fleq (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bgeq: + CASE (Bgeq): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fgeq (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bdiff: + CASE (Bdiff): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Fminus (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bnegate: + CASE (Bnegate): { Lisp_Object v1; v1 = TOP; @@ -1302,209 +1411,209 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, TOP = Fminus (1, &TOP); AFTER_POTENTIAL_GC (); } - break; + NEXT; } - case Bplus: + CASE (Bplus): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Fplus (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bmax: + CASE (Bmax): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Fmax (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bmin: + CASE (Bmin): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Fmin (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bmult: + CASE (Bmult): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Ftimes (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bquo: + CASE (Bquo): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Fquo (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Brem: + CASE (Brem): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Frem (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bpoint: + CASE (Bpoint): { Lisp_Object v1; XSETFASTINT (v1, PT); PUSH (v1); - break; + NEXT; } - case Bgoto_char: + CASE (Bgoto_char): BEFORE_POTENTIAL_GC (); TOP = Fgoto_char (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Binsert: + CASE (Binsert): BEFORE_POTENTIAL_GC (); TOP = Finsert (1, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case BinsertN: + CASE (BinsertN): op = FETCH; BEFORE_POTENTIAL_GC (); DISCARD (op - 1); TOP = Finsert (op, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bpoint_max: + CASE (Bpoint_max): { Lisp_Object v1; XSETFASTINT (v1, ZV); PUSH (v1); - break; + NEXT; } - case Bpoint_min: + CASE (Bpoint_min): { Lisp_Object v1; XSETFASTINT (v1, BEGV); PUSH (v1); - break; + NEXT; } - case Bchar_after: + CASE (Bchar_after): BEFORE_POTENTIAL_GC (); TOP = Fchar_after (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bfollowing_char: + CASE (Bfollowing_char): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = Ffollowing_char (); AFTER_POTENTIAL_GC (); PUSH (v1); - break; + NEXT; } - case Bpreceding_char: + CASE (Bpreceding_char): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = Fprevious_char (); AFTER_POTENTIAL_GC (); PUSH (v1); - break; + NEXT; } - case Bcurrent_column: + CASE (Bcurrent_column): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); XSETFASTINT (v1, current_column ()); AFTER_POTENTIAL_GC (); PUSH (v1); - break; + NEXT; } - case Bindent_to: + CASE (Bindent_to): BEFORE_POTENTIAL_GC (); TOP = Findent_to (TOP, Qnil); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Beolp: + CASE (Beolp): PUSH (Feolp ()); - break; + NEXT; - case Beobp: + CASE (Beobp): PUSH (Feobp ()); - break; + NEXT; - case Bbolp: + CASE (Bbolp): PUSH (Fbolp ()); - break; + NEXT; - case Bbobp: + CASE (Bbobp): PUSH (Fbobp ()); - break; + NEXT; - case Bcurrent_buffer: + CASE (Bcurrent_buffer): PUSH (Fcurrent_buffer ()); - break; + NEXT; - case Bset_buffer: + CASE (Bset_buffer): BEFORE_POTENTIAL_GC (); TOP = Fset_buffer (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Binteractive_p: /* Obsolete since 24.1. */ + CASE (Binteractive_p): /* Obsolete since 24.1. */ PUSH (Finteractive_p ()); - break; + NEXT; - case Bforward_char: + CASE (Bforward_char): BEFORE_POTENTIAL_GC (); TOP = Fforward_char (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bforward_word: + CASE (Bforward_word): BEFORE_POTENTIAL_GC (); TOP = Fforward_word (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bskip_chars_forward: + CASE (Bskip_chars_forward): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fskip_chars_forward (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bskip_chars_backward: + CASE (Bskip_chars_backward): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fskip_chars_backward (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bforward_line: + CASE (Bforward_line): BEFORE_POTENTIAL_GC (); TOP = Fforward_line (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bchar_syntax: + CASE (Bchar_syntax): { int c; @@ -1516,51 +1625,51 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, MAKE_CHAR_MULTIBYTE (c); XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]); } - break; + NEXT; - case Bbuffer_substring: + CASE (Bbuffer_substring): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fbuffer_substring (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bdelete_region: + CASE (Bdelete_region): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fdelete_region (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bnarrow_to_region: + CASE (Bnarrow_to_region): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fnarrow_to_region (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bwiden: + CASE (Bwiden): BEFORE_POTENTIAL_GC (); PUSH (Fwiden ()); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bend_of_line: + CASE (Bend_of_line): BEFORE_POTENTIAL_GC (); TOP = Fend_of_line (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bset_marker: + CASE (Bset_marker): { Lisp_Object v1, v2; BEFORE_POTENTIAL_GC (); @@ -1568,72 +1677,72 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, v2 = POP; TOP = Fset_marker (TOP, v2, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bmatch_beginning: + CASE (Bmatch_beginning): BEFORE_POTENTIAL_GC (); TOP = Fmatch_beginning (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bmatch_end: + CASE (Bmatch_end): BEFORE_POTENTIAL_GC (); TOP = Fmatch_end (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bupcase: + CASE (Bupcase): BEFORE_POTENTIAL_GC (); TOP = Fupcase (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bdowncase: + CASE (Bdowncase): BEFORE_POTENTIAL_GC (); TOP = Fdowncase (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bstringeqlsign: + CASE (Bstringeqlsign): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fstring_equal (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bstringlss: + CASE (Bstringlss): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fstring_lessp (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bequal: + CASE (Bequal): { Lisp_Object v1; v1 = POP; TOP = Fequal (TOP, v1); - break; + NEXT; } - case Bnthcdr: + CASE (Bnthcdr): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fnthcdr (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Belt: + CASE (Belt): { Lisp_Object v1, v2; if (CONSP (TOP)) @@ -1659,87 +1768,91 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, TOP = Felt (TOP, v1); AFTER_POTENTIAL_GC (); } - break; + NEXT; } - case Bmember: + CASE (Bmember): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fmember (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bassq: + CASE (Bassq): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fassq (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bnreverse: + CASE (Bnreverse): BEFORE_POTENTIAL_GC (); TOP = Fnreverse (TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bsetcar: + CASE (Bsetcar): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fsetcar (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bsetcdr: + CASE (Bsetcdr): { Lisp_Object v1; BEFORE_POTENTIAL_GC (); v1 = POP; TOP = Fsetcdr (TOP, v1); AFTER_POTENTIAL_GC (); - break; + NEXT; } - case Bcar_safe: + CASE (Bcar_safe): { Lisp_Object v1; v1 = TOP; TOP = CAR_SAFE (v1); - break; + NEXT; } - case Bcdr_safe: + CASE (Bcdr_safe): { Lisp_Object v1; v1 = TOP; TOP = CDR_SAFE (v1); - break; + NEXT; } - case Bnconc: + CASE (Bnconc): BEFORE_POTENTIAL_GC (); DISCARD (1); TOP = Fnconc (2, &TOP); AFTER_POTENTIAL_GC (); - break; + NEXT; - case Bnumberp: + CASE (Bnumberp): TOP = (NUMBERP (TOP) ? Qt : Qnil); - break; + NEXT; - case Bintegerp: + CASE (Bintegerp): TOP = INTEGERP (TOP) ? Qt : Qnil; - break; + NEXT; #ifdef BYTE_CODE_SAFE + /* These are intentionally written using 'case' syntax, + because they are incompatible with the threaded + interpreter. */ + case Bset_mark: BEFORE_POTENTIAL_GC (); error ("set-mark is an obsolete bytecode"); @@ -1752,49 +1865,49 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, break; #endif - case 0: + CASE_ABORT: /* Actually this is Bstack_ref with offset 0, but we use Bdup for that instead. */ - /* case Bstack_ref: */ + /* CASE (Bstack_ref): */ abort (); /* Handy byte-codes for lexical binding. */ - case Bstack_ref+1: - case Bstack_ref+2: - case Bstack_ref+3: - case Bstack_ref+4: - case Bstack_ref+5: + CASE (Bstack_ref1): + CASE (Bstack_ref2): + CASE (Bstack_ref3): + CASE (Bstack_ref4): + CASE (Bstack_ref5): { Lisp_Object *ptr = top - (op - Bstack_ref); PUSH (*ptr); - break; + NEXT; } - case Bstack_ref+6: + CASE (Bstack_ref6): { Lisp_Object *ptr = top - (FETCH); PUSH (*ptr); - break; + NEXT; } - case Bstack_ref+7: + CASE (Bstack_ref7): { Lisp_Object *ptr = top - (FETCH2); PUSH (*ptr); - break; + NEXT; } - case Bstack_set: + CASE (Bstack_set): /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */ { Lisp_Object *ptr = top - (FETCH); *ptr = POP; - break; + NEXT; } - case Bstack_set2: + CASE (Bstack_set2): { Lisp_Object *ptr = top - (FETCH2); *ptr = POP; - break; + NEXT; } - case BdiscardN: + CASE (BdiscardN): op = FETCH; if (op & 0x80) { @@ -1802,10 +1915,10 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, top[-op] = TOP; } DISCARD (op); - break; + NEXT; - case 255: - default: + CASE_DEFAULT + CASE (Bconstant): #ifdef BYTE_CODE_SAFE if (op < Bconstant) { @@ -1819,6 +1932,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #else PUSH (vectorp[op - Bconstant]); #endif + NEXT; } } -- cgit v1.2.1 From ffacb12679a1e001981c2e0f690b327eda652d04 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 10 Jul 2012 15:40:34 -0700 Subject: * bytecode.c (targets): Suppress -Woverride-init warnings. --- src/bytecode.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 4d3a35ee24d..acdf809971f 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -660,6 +660,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, the table clearer. */ #define LABEL(OP) [OP] = &&insn_ ## OP +#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Woverride-init" +#endif + /* This is the dispatch table for the threaded interpreter. */ static const void *const targets[256] = { @@ -670,6 +675,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, BYTE_CODES #undef DEFINE }; + +#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +# pragma GCC diagnostic pop +#endif + #endif -- cgit v1.2.1 From 765e61e391ee0937ff6b30510b6c4651064fe38e Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 20 Jul 2012 09:28:00 +0400 Subject: Cleanup calls to Fgarbage_collect. * lisp.h (maybe_gc): New prototype. (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold): Remove declarations. * alloc.c (maybe_gc): New function. (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold): Make them static. * bytecode.c (MAYBE_GC): Use maybe_gc. * eval.c (eval_sub, Ffuncall): Likewise. * keyboard.c (read_char): Likewise. Adjust call to maybe_gc to avoid dependency from auto-save feature. --- src/bytecode.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index acdf809971f..dca1e552dd0 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -423,15 +423,11 @@ unmark_byte_stack (void) /* Garbage collect if we have consed enough since the last time. We do this at every branch, to avoid loops that never GC. */ -#define MAYBE_GC() \ - do { \ - if (consing_since_gc > gc_cons_threshold \ - && consing_since_gc > gc_relative_threshold) \ - { \ - BEFORE_POTENTIAL_GC (); \ - Fgarbage_collect (); \ - AFTER_POTENTIAL_GC (); \ - } \ +#define MAYBE_GC() \ + do { \ + BEFORE_POTENTIAL_GC (); \ + maybe_gc (); \ + AFTER_POTENTIAL_GC (); \ } while (0) /* Check for jumping out of range. */ -- cgit v1.2.1 From 8271d59040b3d83fb3fc8cb23723538183b12ad4 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 1 Aug 2012 11:57:09 +0400 Subject: Use INTERNAL_FIELD for symbols. * src/lisp.h (SVAR): New macro. Adjust users. * src/alloc.c, src/bytecode.c, src/cmds.c, src/data.c, src/doc.c, src/eval.c: * src/fns.c, src/keyboard.c, src/lread.c, src/xterm.c: Users changed. * admin/coccinelle/symbol.cocci: Semantic patch to replace direct access to Lisp_Object members of struct Lisp_Symbol to SVAR. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index dca1e552dd0..523d56bc97b 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -818,7 +818,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, && !EQ (val, Qunbound) && !XSYMBOL (sym)->redirect && !SYMBOL_CONSTANT_P (sym)) - XSYMBOL (sym)->val.value = val; + SVAR (XSYMBOL (sym), val.value) = val; else { BEFORE_POTENTIAL_GC (); -- cgit v1.2.1 From 663e2b3f88f9be61399e06dfc0b76700f90c6ca6 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Sun, 5 Aug 2012 19:47:28 +0400 Subject: Generalize common compile-time constants. * lisp.h (header_size, bool_header_size, word_size): Now here. (struct Lisp_Vector): Add comment. (struct Lisp_Bool_Vector): Move up to define handy constants. (VECSIZE, PSEUDOVECSIZE): Simplify. (SAFE_ALLOCA_LISP): Use new constant. Adjust indentation. * buffer.c, buffer.h, bytecode.c, callint.c, eval.c, fns.c: * font.c, fontset.c, keyboard.c, keymap.c, macros.c, menu.c: * msdos.c, w32menu.c, w32term.h, window.c, xdisp.c, xfaces.c: * xfont.c, xmenu.c: Use word_size where appropriate. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 523d56bc97b..49369de33e9 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -536,7 +536,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.byte_string = bytestr; stack.pc = stack.byte_string_start = SDATA (bytestr); stack.constants = vector; - if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth)) + if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) memory_full (SIZE_MAX); top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); #if BYTE_MAINTAIN_TOP -- cgit v1.2.1 From c644523bd8a23e518c91b61a1b8520e866b715b9 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 7 Aug 2012 17:37:21 +0400 Subject: Revert and cleanup Lisp_Cons, Lisp_Misc and Lisp_Symbol things. * src/lisp.h (struct Lisp_Symbol): Change xname to meaningful name since all xname users are fixed long time ago. Do not use INTERNAL_FIELD. (set_symbol_name, set_symbol_function, set_symbol_plist): (set_symbol_next, set_overlay_plist): New function. (struct Lisp_Cons): Do not use INTERNAL_FIELD. (struct Lisp_Overlay): Likewise. (CVAR, MVAR, SVAR): Remove. * src/alloc.c, src/buffer.c, src/buffer.h, src/bytecode.c: * src/cmds.c, src/data.c, src/doc.c, src/eval.c, src/fns.c: * src/keyboard.c, src/lread.c, src/nsselect.m, src/xterm.c: Adjust users. * src/.gdbinit: Change to use name field of struct Lisp_Symbol where appropriate. * admin/coccinelle/overlay.cocci, admin/coccinelle/symbol.cocci: Remove. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 49369de33e9..5ac8b4fa2bd 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -818,7 +818,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, && !EQ (val, Qunbound) && !XSYMBOL (sym)->redirect && !SYMBOL_CONSTANT_P (sym)) - SVAR (XSYMBOL (sym), val.value) = val; + SET_SYMBOL_VAL (XSYMBOL (sym), val); else { BEFORE_POTENTIAL_GC (); -- cgit v1.2.1 From 2f221583cf4a4b412c16260d148b59931b12455a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 24 Aug 2012 20:11:12 -0700 Subject: * bytecode.c, callint.c, callproc.c: Use bool for boolean. * bytecode.c (exec_byte_code): * callint.c (check_mark, Fcall_interactively): * callproc.c (Fcall_process, add_env, child_setup, getenv_internal_1) (getenv_internal, sync_process_alive, call_process_exited): * lisp.h (USE_SAFE_ALLOCA): Use bool for booleans, instead of int. * lisp.h, process.h: Adjust prototypes to match above changes. * callint.c (Fcall_interactively): Don't assume the mark's offset fits in 'int'. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 5ac8b4fa2bd..753f149ae01 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -553,7 +553,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, if (INTEGERP (args_template)) { ptrdiff_t at = XINT (args_template); - int rest = at & 128; + bool rest = (at & 128) != 0; int mandatory = at & 127; ptrdiff_t nonrest = at >> 8; eassert (mandatory <= nonrest); -- cgit v1.2.1 From 66322887059e1f2711e07def5eff661281cee855 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 28 Aug 2012 10:20:08 +0400 Subject: Always use set_buffer_if_live to restore original buffer at unwind. * buffer.h (record_unwind_current_buffer): New function. * bytecode.c, dispnew.c, editfns.c, fileio.c, fns.c, insdel.c: * keyboard.c, keymap.c, minibuf.c, print.c, process.c, textprop.c: * undo.c, window.c: Adjust users. * buffer.c (set_buffer_if_live): Fix comment. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 753f149ae01..40729cbd453 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1051,7 +1051,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CASE (Bsave_current_buffer): /* Obsolete since ??. */ CASE (Bsave_current_buffer_1): - record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); + record_unwind_current_buffer (); NEXT; CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ -- cgit v1.2.1 From 1088b9226e7dac7314dab52ef0696a5f540900cd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 4 Sep 2012 10:34:54 -0700 Subject: Simplify redefinition of 'abort' (Bug#12316). Do not try to redefine the 'abort' function. Instead, redo the code so that it calls 'emacs_abort' rather than 'abort'. This removes the need for the NO_ABORT configure-time macro and makes it easier to change the abort code to do a backtrace. * configure.ac (NO_ABRT): Remove. * admin/CPP-DEFINES (NO_ABORT): Remove. * nt/inc/ms-w32.h (w32_abort) [HAVE_NTGUI]: Remove. * src/.gdbinit: Just stop at emacs_abort, not at w32_abort or abort. * src/emacs.c (abort) [!DOS_NT && !NO_ABORT]: Remove; sysdep.c's emacs_abort now takes its place. * src/lisp.h (emacs_abort): New decl. All calls from Emacs code to 'abort' changed to use 'emacs_abort'. * src/msdos.c (dos_abort) [defined abort]: Remove; not used. (abort) [!defined abort]: Rename to ... (emacs_abort): ... new name. * src/sysdep.c (emacs_abort) [!HAVE_NTGUI]: New function, taking the place of the old 'abort' in emacs.c. * src/w32.c, src/w32fns.c (abort): Do not #undef. * src/w32.c (emacs_abort): Rename from w32_abort. --- src/bytecode.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 40729cbd453..97730636d0e 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -435,7 +435,7 @@ unmark_byte_stack (void) #ifdef BYTE_CODE_SAFE #define CHECK_RANGE(ARG) \ - if (ARG >= bytestr_length) abort () + if (ARG >= bytestr_length) emacs_abort () #else /* not BYTE_CODE_SAFE */ @@ -508,7 +508,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, if (FRAME_X_P (f) && FRAME_FONT (f)->direction != 0 && FRAME_FONT (f)->direction != 1) - abort (); + emacs_abort (); } #endif @@ -600,9 +600,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, { #ifdef BYTE_CODE_SAFE if (top > stacke) - abort (); + emacs_abort (); else if (top < stack.bottom - 1) - abort (); + emacs_abort (); #endif #ifdef BYTE_CODE_METER @@ -1875,7 +1875,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, /* Actually this is Bstack_ref with offset 0, but we use Bdup for that instead. */ /* CASE (Bstack_ref): */ - abort (); + emacs_abort (); /* Handy byte-codes for lexical binding. */ CASE (Bstack_ref1): @@ -1928,11 +1928,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #ifdef BYTE_CODE_SAFE if (op < Bconstant) { - abort (); + emacs_abort (); } if ((op -= Bconstant) >= const_length) { - abort (); + emacs_abort (); } PUSH (vectorp[op]); #else @@ -1951,7 +1951,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #ifdef BYTE_CODE_SAFE error ("binding stack not balanced (serious byte compiler bug)"); #else - abort (); + emacs_abort (); #endif return result; -- cgit v1.2.1 From 0328b6de4a92676b4ad4616095ce19a4f51d1c4d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 15 Sep 2012 00:06:56 -0700 Subject: Port better to POSIX hosts lacking _setjmp. * configure.ac (HAVE__SETJMP, HAVE_SIGSETJMP): New symbols. (_setjmp, _longjmp): Remove. * src/lisp.h: Include here, since we use its symbols here. All instances of '#include ' removed, if the only reason for the instance was because "lisp.h" was included. (sys_jmp_buf, sys_setjmp, sys_longjmp): New symbols. Unless otherwise specified, replace all uses of jmp_buf, _setjmp, and _longjmp with the new symbols. Emacs already uses _setjmp if available, so this change affects only POSIXish hosts that have sigsetjmp but not _setjmp, such as some versions of Solaris and Unixware. (Also, POSIX-2008 marks _setjmp as obsolescent.) * src/image.c (_setjmp, _longjmp) [HAVE_PNG && !HAVE__SETJMP]: New macros. (png_load_body) [HAVE_PNG]: (PNG_LONGJMP) [HAVE_PNG && PNG_LIBPNG_VER < 10500]: (PNG_JMPBUF) [HAVE_PNG && PNG_LIBPNG_VER >= 10500]: Use _setjmp and _longjmp rather than sys_setjmp and sys_longjmp, since PNG requires jmp_buf. This is the only exception to the general rule that we now use sys_setjmp and sys_longjmp. This exception is OK since this code does not change the signal mask or longjmp out of a signal handler. Fixes: debbugs:12446 --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 97730636d0e..b151078f60f 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -33,7 +33,7 @@ by Hallvard: */ #include -#include + #include "lisp.h" #include "character.h" #include "buffer.h" -- cgit v1.2.1 From 0caaedb1c3c9c48980144e41d2a95329d39c399a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 16 Sep 2012 14:43:55 -0700 Subject: Remove configure's --without-sync-input option. When auditing signal-handling in preparation for cleaning it up, I found that SYNC_INPUT has race conditions and would be a real pain to fix. Since it's an undocumented and deprecated configure-time option, now seems like a good time to remove it. Also see . * configure.ac (SYNC_INPUT, BROKEN_SA_RESTART): Remove. * admin/CPP-DEFINES (BROKEN_SA_RESTART, SA_RESTART): Remove. * etc/TODO (Make SYNC_INPUT the default): Remove, as the code now behaves as if SYNC_INPUT is always true. * src/alloc.c (_bytes_used, __malloc_extra_blocks, _malloc_internal) (_free_internal) [!DOUG_LEA_MALLOC]: Remove decls. (alloc_mutex) [!SYSTEM_MALLOC && !SYNC_INPUT && HAVE_PTHREAD]: (malloc_hysteresis): (check_depth) [XMALLOC_OVERRUN_CHECK]: (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): (__malloc_hook, __realloc_hook, __free_hook, BYTES_USED) (dont_register_blocks, bytes_used_when_reconsidered) (bytes_used_when_full, emacs_blocked_free, emacs_blocked_malloc) (emacs_blocked_realloc, reset_malloc_hooks, uninterrupt_malloc): [!SYSTEM_MALLOC && !SYNC_INPUT]: Remove. All uses removed. (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): Use a different implementation, one that depends on whether the new macro XMALLOC_BLOCK_INPUT_CHECK is defined, not on whether SYNC_INPUT is defined. * src/atimer.c (run_timers, handle_alarm_signal): * src/keyboard.c (pending_signal, poll_for_input_1, poll_for_input) (handle_async_input, process_pending_signals) (handle_input_available_signal, init_keyboard): * src/nsterm.m (ns_read_socket): * src/process.c (wait_reading_process_output): * src/regex.c (immediate_quit, IMMEDIATE_QUIT_CHECK): * src/sysdep.c (emacs_sigaction_init) [SA_RESTART]: (emacs_write): * src/xterm.c (XTread_socket): Assume SYNC_INPUT. * src/conf_post.h (SA_RESTART) [IRIX6_5]: Do not #undef. * src/eval.c (handling_signal): Remove. All uses removed. * src/lisp.h (ELSE_PENDING_SIGNALS): Remove. All uses replaced with the SYNC_INPUT version. (reset_malloc_hooks, uninterrupt_malloc, handling_signal): Remove decls. * src/sysdep.c, src/syssignal.h (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]: Now static. Fixes: debbugs:12450 --- src/bytecode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index b151078f60f..5f4fdcc5eff 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -458,7 +458,8 @@ unmark_byte_stack (void) Fsignal (Qquit, Qnil); \ AFTER_POTENTIAL_GC (); \ } \ - ELSE_PENDING_SIGNALS \ + else if (pending_signals) \ + process_pending_signals (); \ } while (0) -- cgit v1.2.1 From 22e8cf4a89aeb9f0a31f8676f0ab177c28ab473f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 24 Sep 2012 18:47:51 -0400 Subject: * src/bytecode.c (exec_byte_code): Signal an error instead of aborting, when encountering an unknown bytecode. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 5f4fdcc5eff..648813aed86 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1876,7 +1876,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, /* Actually this is Bstack_ref with offset 0, but we use Bdup for that instead. */ /* CASE (Bstack_ref): */ - emacs_abort (); + error ("Invalid byte opcode"); /* Handy byte-codes for lexical binding. */ CASE (Bstack_ref1): -- cgit v1.2.1 From 23ba2705e22b89154ef7cbb0595419732080b94c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 19 Nov 2012 23:24:09 -0500 Subject: Make called-interactively-p work for edebug or advised code. * lisp/subr.el (called-interactively-p-functions): New var. (internal--called-interactively-p--get-frame): New macro. (called-interactively-p, interactive-p): Rewrite in Lisp. * lisp/emacs-lisp/nadvice.el (advice--called-interactively-skip): New fun. (called-interactively-p-functions): Use it. * lisp/emacs-lisp/edebug.el (edebug--called-interactively-skip): New fun. (called-interactively-p-functions): Use it. * lisp/allout.el (allout-called-interactively-p): Don't assume called-interactively-p is a subr. * src/eval.c (Finteractive_p, Fcalled_interactively_p, interactive_p): Remove. (syms_of_eval): Remove corresponding defsubr. * src/bytecode.c (exec_byte_code): `interactive-p' is now a Lisp function. * test/automated/advice-tests.el (advice-tests--data): Remove. (advice-tests): Move the tests directly here instead. Add called-interactively-p tests. --- src/bytecode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 648813aed86..3267c7c8c76 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1579,7 +1579,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, NEXT; CASE (Binteractive_p): /* Obsolete since 24.1. */ - PUSH (Finteractive_p ()); + BEFORE_POTENTIAL_GC (); + PUSH (call0 (intern ("interactive-p"))); + AFTER_POTENTIAL_GC (); NEXT; CASE (Bforward_char): -- cgit v1.2.1 From bc9dbce6ee527ded152682c98f5f82e42c33dde9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 3 Dec 2012 13:07:47 -0800 Subject: * bytecode.c, lisp.h (Qbytecode): Remove. No longer needed after 2012-11-20 interactive-p changes. --- src/bytecode.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 3267c7c8c76..4c5ac151de1 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -87,8 +87,6 @@ Lisp_Object Qbyte_code_meter; #endif /* BYTE_CODE_METER */ -Lisp_Object Qbytecode; - /* Byte codes: */ #define BYTE_CODES \ @@ -1963,8 +1961,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, void syms_of_bytecode (void) { - DEFSYM (Qbytecode, "byte-code"); - defsubr (&Sbyte_code); #ifdef BYTE_CODE_METER -- cgit v1.2.1 From ab422c4d6899b1442cb6954c1829c1fb656b006c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 1 Jan 2013 09:11:05 +0000 Subject: Update copyright notices for 2013. --- src/bytecode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 648813aed86..843a12a0e33 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1,5 +1,6 @@ /* Execution of byte code produced by bytecomp.el. - Copyright (C) 1985-1988, 1993, 2000-2012 Free Software Foundation, Inc. + Copyright (C) 1985-1988, 1993, 2000-2013 Free Software Foundation, + Inc. This file is part of GNU Emacs. -- cgit v1.2.1 From 99ec16475a6d1bbe3b308f89e45afb0096e02f0e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 10 Mar 2013 17:46:55 -0400 Subject: * src/bytecode.c (struct byte_stack): Remove `constants' when unused. --- src/bytecode.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index bd8abe85e04..628c4d90cf3 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -313,9 +313,11 @@ struct byte_stack Lisp_Object byte_string; const unsigned char *byte_string_start; +#if BYTE_MARK_STACK /* The vector of constants used during byte-code execution. Storing this here protects it from GC because mark_byte_stack marks it. */ Lisp_Object constants; +#endif /* Next entry in byte_stack_list. */ struct byte_stack *next; @@ -379,12 +381,12 @@ unmark_byte_stack (void) } -/* Fetch the next byte from the bytecode stream */ +/* Fetch the next byte from the bytecode stream. */ #define FETCH *stack.pc++ /* Fetch two bytes from the bytecode stream and make a 16-bit number - out of them */ + out of them. */ #define FETCH2 (op = FETCH, op + (FETCH << 8)) @@ -404,7 +406,7 @@ unmark_byte_stack (void) #define DISCARD(n) (top -= (n)) /* Get the value which is at the top of the execution stack, but don't - pop it. */ + pop it. */ #define TOP (*top) @@ -535,7 +537,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.byte_string = bytestr; stack.pc = stack.byte_string_start = SDATA (bytestr); +#if BYTE_MARK_STACK stack.constants = vector; +#endif if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) memory_full (SIZE_MAX); top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); -- cgit v1.2.1 From d9df6f40e326f3f5487b7c50b99bf5112262badc Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Mar 2013 00:27:34 -0700 Subject: Static checking by Sun C 5.12. * lib-src/etags.c (analyse_regex): Omit unreachable code. * src/alloc.c (buffer_memory_full) [REL_ALLOC]: * src/bytecode.c (exec_byte_code): * src/dispnew.c (init_display): * src/eval.c (error): * src/fileio.c (Fsubstitute_in_file_name): * src/keyboard.c (Fevent_convert_list): * src/keymap.c (Fsingle_key_description): * src/term.c (maybe_fatal, fatal): * src/xfns.c (Fx_display_backing_store, Fx_display_visual_class): * src/xsmfns.c (Fhandle_save_session): Omit unreachable code. * src/keymap.c (map_keymap_char_table_item): Cast void * to a function pointer type; the C Standard requires this. --- src/bytecode.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 628c4d90cf3..acb96c1e61b 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -755,7 +755,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, { BEFORE_POTENTIAL_GC (); wrong_type_argument (Qlistp, v1); - AFTER_POTENTIAL_GC (); } NEXT; } @@ -790,7 +789,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, { BEFORE_POTENTIAL_GC (); wrong_type_argument (Qlistp, v1); - AFTER_POTENTIAL_GC (); } NEXT; } -- cgit v1.2.1 From 908589fd28437a9b0995b103e22ce5e4d421eb8a Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 24 Mar 2013 13:59:45 +0100 Subject: Reorder conditions that are written backwards * alloc.c (xpalloc, Fgarbage_collect): Reorder conditions that are written backwards. * blockinput.h (input_blocked_p): Likewise. * bytecode.c (exec_byte_code): Likewise. * callproc.c (call_process_kill, call_process_cleanup) (Fcall_process): Likewise. * ccl.c (ccl_driver, resolve_symbol_ccl_program) (Fccl_execute_on_string): Likewise. * character.c (string_escape_byte8): Likewise. * charset.c (read_hex): Likewise. * cm.c (calccost): Likewise. * data.c (cons_to_unsigned): Likewise. * dired.c (directory_files_internal, file_name_completion): Likewise. * dispnew.c (scrolling_window, update_frame_1, Fsleep_for) (sit_for): Likewise. * doc.c (Fsubstitute_command_keys): Likewise. * doprnt.c (doprnt): Likewise. * editfns.c (hi_time, decode_time_components, Fformat): Likewise. * emacsgtkfixed.c: Likewise. * fileio.c (file_offset, Fwrite_region): Likewise. * floatfns.c (Fexpt, fmod_float): Likewise. * fns.c (larger_vector, make_hash_table, Fmake_hash_table): Likewise. * font.c (font_intern_prop): Likewise. * frame.c (x_set_alpha): Likewise. * gtkutil.c (get_utf8_string): Likewise. * indent.c (check_display_width): Likewise. * intervals.c (create_root_interval, rotate_right, rotate_left) (split_interval_right, split_interval_left) (adjust_intervals_for_insertion, delete_node) (interval_deletion_adjustment, adjust_intervals_for_deletion) (merge_interval_right, merge_interval_left, copy_intervals) (set_intervals_multibyte_1): Likewise. * keyboard.c (gobble_input, append_tool_bar_item): Likewise. * keymap.c (Fkey_description): Likewise. * lisp.h (FIXNUM_OVERFLOW_P, vcopy): Likewise. * lread.c (openp, read_integer, read1, string_to_number): Likewise. * menu.c (ensure_menu_items): Likewise. * minibuf.c (read_minibuf_noninteractive): Likewise. * print.c (printchar, strout): Likewise. * process.c (create_process, Faccept_process_output) (wait_reading_process_output, read_process_output, send_process) (wait_reading_process_output): Likewise. * profiler.c (make_log, handle_profiler_signal): Likewise. * regex.c (re_exec): Likewise. * regex.h: Likewise. * search.c (looking_at_1, Freplace_match): Likewise. * sysdep.c (get_child_status, procfs_ttyname) (procfs_get_total_memory): Likewise. * systime.h (EMACS_TIME_VALID_P): Likewise. * term.c (dissociate_if_controlling_tty): Likewise. * window.c (get_phys_cursor_glyph): Likewise. * xdisp.c (init_iterator, redisplay_internal, redisplay_window) (try_window_reusing_current_matrix, try_window_id, pint2hrstr): Likewise. * xfns.c (Fx_window_property): Likewise. * xmenu.c (set_frame_menubar): Likewise. * xselect.c (x_get_window_property, x_handle_dnd_message): Likewise. * xsmfns.c (smc_save_yourself_CB): Likewise. * xterm.c (x_scroll_bar_set_handle): Likewise. --- src/bytecode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index acb96c1e61b..7676c8550a4 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -660,7 +660,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, the table clearer. */ #define LABEL(OP) [OP] = &&insn_ ## OP -#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Woverride-init" #endif @@ -676,7 +676,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #undef DEFINE }; -#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) # pragma GCC diagnostic pop #endif -- cgit v1.2.1 From 31ff141c226d00ce8c85562e7812ff1178cb45ed Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 17 May 2013 22:32:17 -0700 Subject: Port --enable-gcc-warnings to clang. * configure.ac (nw): Remove obsolescent warnings. These aren't needed for clang, or for gcc for that matter. (emacs_cv_clang): New var, which tests for clang. Omit warnings that clang is too picky about. (GLIB_DISABLE_DEPRECATION_WARNINGS): Define this; needed for Ubuntu 13.04 + clang + --enable-gcc-warnings. * lib-src/etags.c: Omit unnecessary forward decls. (print_version, print_help): Declare _Noreturn. * lib-src/pop.c (socket_connection) [HAVE_GETADDRINFO]: Simplify. * src/bytecode.c (exec_byte_code): * src/regex.c: Redo diagnostic pragmas to pacify clang, too. * src/dbusbind.c (xd_retrieve_arg): Do not use uninitialized variable. * src/editfns.c (Fencode_time): * src/fileio.c (file_accessible_directory_p): * src/font.c (font_unparse_xlfd): Use '&"string"[index]' instead of '"string" + (index)'. * src/undo.c (user_error): Remove; unused. --- src/bytecode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 7676c8550a4..4940fd5c182 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -660,9 +660,12 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, the table clearer. */ #define LABEL(OP) [OP] = &&insn_ ## OP -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Woverride-init" +#elif defined __clang__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Winitializer-overrides" #endif /* This is the dispatch table for the threaded interpreter. */ @@ -676,7 +679,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #undef DEFINE }; -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__ # pragma GCC diagnostic pop #endif -- cgit v1.2.1 From 1fc7100890ced39f81a822661439b1f7030df5a1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 20 Jun 2013 11:59:08 -0700 Subject: * syntax.c: Integer cleanups. (SYNTAX_FLAGS_COMMENT_STYLEC): Return a boolean, not 0-or-2. All uses that need 0-or-2 changed to: (SYNTAX_FLAGS_COMMENT_STYLEC2): New macro, with the same semantics as the old SYNTAX_FLAGS_COMMENT_STYLEC. (struct lisp_parse_state, syntax_prefix_flag_p, update_syntax_table) (char_quoted, prev_char_comend_first, back_comment) (Finternal_describe_syntax_value, skip_chars, skip_syntaxes) (in_classes, forw_comment, scan_lists, scan_sexps_forward): Use bool for boolean. (update_syntax_table, skip_chars, skip_syntaxes): Prefer int to unsigned when either will do. (back_comment): Return boolean success flag, like forw_comment, instead of positive-or-minus-1 (which might have overflowed int anyway). Don't stuff ptrdiff_t into int. (syntax_spec_code, syntax_code_spec): Now const. (Fmatching_paren, scan_lists, scan_sexps_forward): Use enum syntaxcode for syntax code. (Fmatching_paren): Check that arg is a character, not just an integer. (Fstring_to_syntax): Don't assume 0377 fits in enum syntaxcode. (Finternal_describe_syntax_value): Omit no-longer-needed comparison to 0. (skip_chars): Use char, not unsigned char, when the distinction doesn't matter. (forw_comment, scan_lists): Prefer A |= B to A = A || B when B's cheap. * bytecode.c (exec_byte_code): * syntax.c (syntax_spec_code, Fchar_syntax) (Finternal_describe_syntax_value, skip_chars, skip_syntaxes) (init_syntax_once): * syntax.h (SYNTAX_WITH_FLAGS): Omit unnecessary casts. --- src/bytecode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index 4940fd5c182..d95c53bf055 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1636,7 +1636,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, c = XFASTINT (TOP); if (NILP (BVAR (current_buffer, enable_multibyte_characters))) MAKE_CHAR_MULTIBYTE (c); - XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]); + XSETFASTINT (TOP, syntax_code_spec[SYNTAX (c)]); } NEXT; -- cgit v1.2.1 From 29abe551a0d9137718cd21732c9dc383d6493d71 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 10 Jul 2013 16:23:57 -0700 Subject: Port to C89. * lib-src/ebrowse.c (USAGE): Remove macro with too-long string literal ... (usage_message): ... and replace it with this new static constant containing multiple literals. All uses changed. * lib-src/emacsclient.c (print_help_and_exit): Rewrite to avoid string literals longer than the C89 limits. (start_daemon_and_retry_set_socket): Rewrite to avoid non-constant array initializer. * lib-src/make-docfile.c (enum global_type): Omit trailing comma. * src/bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__. (B__dummy__): New dummy symbol, to pacify C89. * src/dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since they can't grok varargs macros. * src/dispnew.c (add_window_display_history) (add_frame_display_history): * src/print.c (print_object): * src/xdisp.c (debug_method_add): Use %p printf format only for void pointers. * src/emacs.c (usage_message): New constant, replacing ... (USAGE1, USAGE2, USAGE3): Remove; they were too long for C89. (main): Adjust to usage reorg. * src/fns.c (syms_of_fns): * src/profiler.c (syms_of_profiler): Don't use non-constant struct initializers. * src/gnutls.h (gnutls_initstage_t): * src/lisp.h (enum Lisp_Fwd_Type): * src/lread.c (lisp_file_lexically_bound_p): * src/xsettings.c (anonymous enum): Remove trailing comma. * src/xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism. * src/lisp.h (ENUM_BF): Use unsigned if pedantic. (DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99. (DEFUN): Use it. * src/regex.c (const_re_char): New type, to pacify strict C89. All uses of 'const re_char' replaced to use it. * src/regex.h (_Restrict_): Rename from __restrict, to avoid clash with glibc when strict C89. This change is imported from gnulib. All uses changed. (_Restrict_arr_): Rename from __restrict_arr, similarly. * src/sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]: Omit GNU_LINUX implementation, since it requires long long. * src/xterm.c (x_draw_underwave): Do not assume the traditional order of struct's members. (x_term_init): Rewrite to avoid the need for non-constant structure initializers. --- src/bytecode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index d95c53bf055..c79027597f8 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -59,7 +59,8 @@ by Hallvard: indirect threaded, using GCC's computed goto extension. This code, as currently implemented, is incompatible with BYTE_CODE_SAFE and BYTE_CODE_METER. */ -#if defined (__GNUC__) && !defined (BYTE_CODE_SAFE) && !defined (BYTE_CODE_METER) +#if (defined __GNUC__ && !defined __STRICT_ANSI__ \ + && !defined BYTE_CODE_SAFE && !defined BYTE_CODE_METER) #define BYTE_CODE_THREADED #endif @@ -285,8 +286,10 @@ enum byte_code_op #ifdef BYTE_CODE_SAFE Bscan_buffer = 0153, /* No longer generated as of v18. */ - Bset_mark = 0163 /* this loser is no longer generated as of v18 */ + Bset_mark = 0163, /* this loser is no longer generated as of v18 */ #endif + + B__dummy__ = 0 /* Pacify C89. */ }; /* Whether to maintain a `top' and `bottom' field in the stack frame. */ -- cgit v1.2.1 From 6c6f1994bf684f510d600bd18023fa01b4b06500 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 15 Jul 2013 23:39:49 -0700 Subject: Prefer list1 (X) to Fcons (X, Qnil) when building lists. This makes the code easier to read and the executable a bit smaller. Do not replace all calls to Fcons that happen to create lists, just calls that are intended to create lists. For example, when creating an alist that maps FOO to nil, use list1 (Fcons (FOO, Qnil)) rather than list1 (list1 (FOO)) or Fcons (Fcons (FOO, Qnil), Qnil). Similarly for list2 through list5. * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): * bytecode.c (exec_byte_code): * callint.c (quotify_arg, Fcall_interactively): * callproc.c (Fcall_process, create_temp_file): * charset.c (load_charset_map_from_file) (Fdefine_charset_internal, init_charset): * coding.c (get_translation_table, detect_coding_system) (Fcheck_coding_systems_region) (Fset_terminal_coding_system_internal) (Fdefine_coding_system_internal, Fdefine_coding_system_alias): * composite.c (update_compositions, Ffind_composition_internal): * dired.c (directory_files_internal, file_name_completion) (Fsystem_users): * dispnew.c (Fopen_termscript, bitch_at_user, init_display): * doc.c (Fsnarf_documentation): * editfns.c (Fmessage_box): * emacs.c (main): * eval.c (do_debug_on_call, signal_error, maybe_call_debugger) (Feval, eval_sub, Ffuncall, apply_lambda): * fileio.c (make_temp_name, Fcopy_file, Faccess_file) (Fset_file_selinux_context, Fset_file_acl, Fset_file_modes) (Fset_file_times, Finsert_file_contents) (Fchoose_write_coding_system, Fwrite_region): * fns.c (Flax_plist_put, Fyes_or_no_p, syms_of_fns): * font.c (font_registry_charsets, font_parse_fcname) (font_prepare_cache, font_update_drivers, Flist_fonts): * fontset.c (Fset_fontset_font, Ffontset_info, syms_of_fontset): * frame.c (make_frame, Fmake_terminal_frame) (x_set_frame_parameters, x_report_frame_params) (x_default_parameter, Fx_parse_geometry): * ftfont.c (syms_of_ftfont): * image.c (gif_load): * keyboard.c (command_loop_1): * keymap.c (Fmake_keymap, Fmake_sparse_keymap, access_keymap_1) (Fcopy_keymap, append_key, Fcurrent_active_maps) (Fminor_mode_key_binding, accessible_keymaps_1) (Faccessible_keymaps, Fwhere_is_internal): * lread.c (read_emacs_mule_char): * menu.c (find_and_return_menu_selection): * minibuf.c (get_minibuffer): * nsfns.m (Fns_perform_service): * nsfont.m (ns_script_to_charset): * nsmenu.m (ns_popup_dialog): * nsselect.m (ns_get_local_selection, ns_string_from_pasteboard) (Fx_own_selection_internal): * nsterm.m (append2): * print.c (Fredirect_debugging_output) (print_prune_string_charset): * process.c (Fdelete_process, Fprocess_contact) (Fformat_network_address, set_socket_option) (read_and_dispose_of_process_output, write_queue_push) (send_process, exec_sentinel): * sound.c (Fplay_sound_internal): * textprop.c (validate_plist, add_properties) (Fput_text_property, Fadd_face_text_property) (copy_text_properties, text_property_list, syms_of_textprop): * unexaix.c (report_error): * unexcoff.c (report_error): * unexsol.c (unexec): * xdisp.c (redisplay_tool_bar, store_mode_line_string) (Fformat_mode_line, syms_of_xdisp): * xfaces.c (set_font_frame_param) (Finternal_lisp_face_attribute_values) (Finternal_merge_in_global_face, syms_of_xfaces): * xfns.c (x_default_scroll_bar_color_parameter) (x_default_font_parameter, x_create_tip_frame): * xfont.c (xfont_supported_scripts): * xmenu.c (Fx_popup_dialog, xmenu_show, xdialog_show) (menu_help_callback, xmenu_show): * xml.c (make_dom): * xterm.c (set_wm_state): Prefer list1 (FOO) to Fcons (FOO, Qnil) when creating a list, and similarly for list2 through list5. --- src/bytecode.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index c79027597f8..be4fab4a536 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -572,9 +572,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, if (nargs < mandatory) /* Too few arguments. */ Fsignal (Qwrong_number_of_arguments, - Fcons (Fcons (make_number (mandatory), + list2 (Fcons (make_number (mandatory), rest ? Qand_rest : make_number (nonrest)), - Fcons (make_number (nargs), Qnil))); + make_number (nargs))); else { for (; i < nonrest; i++) @@ -593,9 +593,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, else /* Too many arguments. */ Fsignal (Qwrong_number_of_arguments, - Fcons (Fcons (make_number (mandatory), - make_number (nonrest)), - Fcons (make_number (nargs), Qnil))); + list2 (Fcons (make_number (mandatory), make_number (nonrest)), + make_number (nargs))); } else if (! NILP (args_template)) /* We should push some arguments on the stack. */ @@ -1172,14 +1171,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, } CASE (Blist1): - TOP = Fcons (TOP, Qnil); + TOP = list1 (TOP); NEXT; CASE (Blist2): { Lisp_Object v1; v1 = POP; - TOP = Fcons (TOP, Fcons (v1, Qnil)); + TOP = list2 (TOP, v1); NEXT; } -- cgit v1.2.1 From 27e498e6e5fea8ac64c90ac13678b537b7b12302 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 16 Jul 2013 14:35:45 -0700 Subject: New unwind-protect flavors to better type-check C callbacks. This also lessens the need to write wrappers for callbacks, and the need for make_save_pointer. * alloca.c (free_save_value): * atimer.c (run_all_atimers): Now extern. * alloc.c (safe_alloca_unwind): * atimer.c (unwind_stop_other_atimers): * keyboard.c (cancel_hourglass_unwind) [HAVE_WINDOW_SYSTEM]: * menu.c (cleanup_popup_menu) [HAVE_NS]: * minibuf.c (choose_minibuf_frame_1): * process.c (make_serial_process_unwind): * xdisp.h (pop_message_unwind): * xselect.c (queue_selection_requests_unwind): Remove no-longer-needed wrapper. All uses replaced by the wrappee. * alloca.c (record_xmalloc): Prefer record_unwind_protect_ptr to record_unwind_protect with make_save_pointer. * alloca.c (Fgarbage_collect): Prefer record_unwind_protect_void to passing a dummy. * buffer.c (restore_buffer): * window.c (restore_window_configuration): * xfns.c, w32fns.c (do_unwind_create_frame) New wrapper. All record-unwind uses of wrappee changed. * buffer.c (set_buffer_if_live): * callproc.c (call_process_cleanup, delete_temp_file): * coding.c (code_conversion_restore): * dired.c (directory_files_internal_w32_unwind) [WINDOWSNT]: * editfns.c (save_excursion_restore) (subst_char_in_region_unwind, subst_char_in_region_unwind_1) (save_restriction_restore): * eval.c (restore_stack_limits, un_autoload): * fns.c (require_unwind): * keyboard.c (recursive_edit_unwind, tracking_off): * lread.c (record_load_unwind, load_warn_old_style_backquotes): * macros.c (pop_kbd_macro, restore_menu_items): * nsfns.m (unwind_create_frame): * print.c (print_unwind): * process.c (start_process_unwind): * search.c (unwind_set_match_data): * window.c (select_window_norecord, select_frame_norecord): * xdisp.c (unwind_with_echo_area_buffer, unwind_format_mode_line) (fast_set_selected_frame): * xfns.c, w32fns.c (unwind_create_tip_frame): Return void, not a dummy Lisp_Object. All uses changed. * buffer.h (set_buffer_if_live): Move decl here from lisp.h. * callproc.c (call_process_kill): * fileio.c (restore_point_unwind, decide_coding_unwind) (build_annotations_unwind): * insdel.c (Fcombine_after_change_execute_1): * keyboard.c (read_char_help_form_unwind): * menu.c (unuse_menu_items): * minibuf.c (run_exit_minibuf_hook, read_minibuf_unwind): * sound.c (sound_cleanup): * xdisp.c (unwind_redisplay): * xfns.c (clean_up_dialog): * xselect.c (x_selection_request_lisp_error, x_catch_errors_unwind): Accept no args and return void, instead of accepting and returning a dummy Lisp_Object. All uses changed. * cygw32.c (fchdir_unwind): * fileio.c (close_file_unwind): * keyboard.c (restore_kboard_configuration): * lread.c (readevalllop_1): * process.c (wait_reading_process_output_unwind): Accept int and return void, rather than accepting an Emacs integer and returning a dummy object. In some cases this fixes an unlikely bug when the corresponding int is outside Emacs integer range. All uses changed. * dired.c (directory_files_internal_unwind): * fileio.c (do_auto_save_unwind): * gtkutil.c (pop_down_dialog): * insdel.c (reset_var_on_error): * lread.c (load_unwind): * xfns.c (clean_up_file_dialog): * xmenu.c, nsmenu.m (pop_down_menu): * xmenu.c (cleanup_widget_value_tree): * xselect.c (wait_for_property_change_unwind): Accept pointer and return void, rather than accepting an Emacs save value encapsulating the pointer and returning a dummy object. All uses changed. * editfns.c (Fformat): Update the saved pointer directly via set_unwind_protect_ptr rather than indirectly via make_save_pointer. * eval.c (specpdl_func): Remove. All uses replaced by definiens. (unwind_body): New function. (record_unwind_protect): First arg is now a function returning void, not a dummy Lisp_Object. (record_unwind_protect_ptr, record_unwind_protect_int) (record_unwind_protect_void): New functions. (unbind_to): Support SPECPDL_UNWIND_PTR etc. * fileio.c (struct auto_save_unwind): New type. (do_auto_save_unwind): Use it. (do_auto_save_unwind_1): Remove; subsumed by new do_auto_save_unwind. * insdel.c (struct rvoe_arg): New type. (reset_var_on_error): Use it. * lisp.h (SPECPDL_UNWIND_PTR, SPECPDL_UNWIND_INT, SPECPDL_UNWIND_VOID): New constants. (specbinding_func): Remove; there are now several such functions. (union specbinding): New members unwind_ptr, unwind_int, unwind_void. (set_unwind_protect_ptr): New function. * xselect.c: Remove unnecessary forward decls, to simplify maintenance. --- src/bytecode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/bytecode.c') diff --git a/src/bytecode.c b/src/bytecode.c index be4fab4a536..e0e7b22ea13 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -1063,8 +1063,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ { - register ptrdiff_t count1 = SPECPDL_INDEX (); - record_unwind_protect (Fset_window_configuration, + ptrdiff_t count1 = SPECPDL_INDEX (); + record_unwind_protect (restore_window_configuration, Fcurrent_window_configuration (Qnil)); BEFORE_POTENTIAL_GC (); TOP = Fprogn (TOP); @@ -1089,7 +1089,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, } CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */ - record_unwind_protect (Fprogn, POP); + record_unwind_protect (unwind_body, POP); NEXT; CASE (Bcondition_case): /* FIXME: ill-suited for lexbind. */ -- cgit v1.2.1