| 1 | /* Execution of byte code produced by bytecomp.el. |
| 2 | Copyright (C) 1985-1988, 1993, 2000-2014 Free Software Foundation, |
| 3 | Inc. |
| 4 | |
| 5 | This file is part of GNU Emacs. |
| 6 | |
| 7 | GNU Emacs is free software: you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation, either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | GNU Emacs is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | /* |
| 21 | hacked on by jwz@lucid.com 17-jun-91 |
| 22 | o added a compile-time switch to turn on simple sanity checking; |
| 23 | o put back the obsolete byte-codes for error-detection; |
| 24 | o added a new instruction, unbind_all, which I will use for |
| 25 | tail-recursion elimination; |
| 26 | o made temp_output_buffer_show be called with the right number |
| 27 | of args; |
| 28 | o made the new bytecodes be called with args in the right order; |
| 29 | o added metering support. |
| 30 | |
| 31 | by Hallvard: |
| 32 | o added relative jump instructions; |
| 33 | o all conditionals now only do QUIT if they jump. |
| 34 | */ |
| 35 | |
| 36 | #include <config.h> |
| 37 | |
| 38 | #include "lisp.h" |
| 39 | #include "character.h" |
| 40 | #include "buffer.h" |
| 41 | #include "syntax.h" |
| 42 | #include "window.h" |
| 43 | |
| 44 | #ifdef CHECK_FRAME_FONT |
| 45 | #include "frame.h" |
| 46 | #include "xterm.h" |
| 47 | #endif |
| 48 | |
| 49 | /* |
| 50 | * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for |
| 51 | * debugging the byte compiler...) |
| 52 | * |
| 53 | * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. |
| 54 | */ |
| 55 | /* #define BYTE_CODE_SAFE */ |
| 56 | /* #define BYTE_CODE_METER */ |
| 57 | |
| 58 | /* If BYTE_CODE_THREADED is defined, then the interpreter will be |
| 59 | indirect threaded, using GCC's computed goto extension. This code, |
| 60 | as currently implemented, is incompatible with BYTE_CODE_SAFE and |
| 61 | BYTE_CODE_METER. */ |
| 62 | #if (defined __GNUC__ && !defined __STRICT_ANSI__ \ |
| 63 | && !defined BYTE_CODE_SAFE && !defined BYTE_CODE_METER) |
| 64 | #define BYTE_CODE_THREADED |
| 65 | #endif |
| 66 | |
| 67 | \f |
| 68 | #ifdef BYTE_CODE_METER |
| 69 | |
| 70 | Lisp_Object Qbyte_code_meter; |
| 71 | #define METER_2(code1, code2) AREF (AREF (Vbyte_code_meter, code1), code2) |
| 72 | #define METER_1(code) METER_2 (0, code) |
| 73 | |
| 74 | #define METER_CODE(last_code, this_code) \ |
| 75 | { \ |
| 76 | if (byte_metering_on) \ |
| 77 | { \ |
| 78 | if (XFASTINT (METER_1 (this_code)) < MOST_POSITIVE_FIXNUM) \ |
| 79 | XSETFASTINT (METER_1 (this_code), \ |
| 80 | XFASTINT (METER_1 (this_code)) + 1); \ |
| 81 | if (last_code \ |
| 82 | && (XFASTINT (METER_2 (last_code, this_code)) \ |
| 83 | < MOST_POSITIVE_FIXNUM)) \ |
| 84 | XSETFASTINT (METER_2 (last_code, this_code), \ |
| 85 | XFASTINT (METER_2 (last_code, this_code)) + 1); \ |
| 86 | } \ |
| 87 | } |
| 88 | |
| 89 | #endif /* BYTE_CODE_METER */ |
| 90 | \f |
| 91 | |
| 92 | /* Byte codes: */ |
| 93 | |
| 94 | #define BYTE_CODES \ |
| 95 | DEFINE (Bstack_ref, 0) /* Actually, Bstack_ref+0 is not implemented: use dup. */ \ |
| 96 | DEFINE (Bstack_ref1, 1) \ |
| 97 | DEFINE (Bstack_ref2, 2) \ |
| 98 | DEFINE (Bstack_ref3, 3) \ |
| 99 | DEFINE (Bstack_ref4, 4) \ |
| 100 | DEFINE (Bstack_ref5, 5) \ |
| 101 | DEFINE (Bstack_ref6, 6) \ |
| 102 | DEFINE (Bstack_ref7, 7) \ |
| 103 | DEFINE (Bvarref, 010) \ |
| 104 | DEFINE (Bvarref1, 011) \ |
| 105 | DEFINE (Bvarref2, 012) \ |
| 106 | DEFINE (Bvarref3, 013) \ |
| 107 | DEFINE (Bvarref4, 014) \ |
| 108 | DEFINE (Bvarref5, 015) \ |
| 109 | DEFINE (Bvarref6, 016) \ |
| 110 | DEFINE (Bvarref7, 017) \ |
| 111 | DEFINE (Bvarset, 020) \ |
| 112 | DEFINE (Bvarset1, 021) \ |
| 113 | DEFINE (Bvarset2, 022) \ |
| 114 | DEFINE (Bvarset3, 023) \ |
| 115 | DEFINE (Bvarset4, 024) \ |
| 116 | DEFINE (Bvarset5, 025) \ |
| 117 | DEFINE (Bvarset6, 026) \ |
| 118 | DEFINE (Bvarset7, 027) \ |
| 119 | DEFINE (Bvarbind, 030) \ |
| 120 | DEFINE (Bvarbind1, 031) \ |
| 121 | DEFINE (Bvarbind2, 032) \ |
| 122 | DEFINE (Bvarbind3, 033) \ |
| 123 | DEFINE (Bvarbind4, 034) \ |
| 124 | DEFINE (Bvarbind5, 035) \ |
| 125 | DEFINE (Bvarbind6, 036) \ |
| 126 | DEFINE (Bvarbind7, 037) \ |
| 127 | DEFINE (Bcall, 040) \ |
| 128 | DEFINE (Bcall1, 041) \ |
| 129 | DEFINE (Bcall2, 042) \ |
| 130 | DEFINE (Bcall3, 043) \ |
| 131 | DEFINE (Bcall4, 044) \ |
| 132 | DEFINE (Bcall5, 045) \ |
| 133 | DEFINE (Bcall6, 046) \ |
| 134 | DEFINE (Bcall7, 047) \ |
| 135 | DEFINE (Bunbind, 050) \ |
| 136 | DEFINE (Bunbind1, 051) \ |
| 137 | DEFINE (Bunbind2, 052) \ |
| 138 | DEFINE (Bunbind3, 053) \ |
| 139 | DEFINE (Bunbind4, 054) \ |
| 140 | DEFINE (Bunbind5, 055) \ |
| 141 | DEFINE (Bunbind6, 056) \ |
| 142 | DEFINE (Bunbind7, 057) \ |
| 143 | \ |
| 144 | DEFINE (Bpophandler, 060) \ |
| 145 | DEFINE (Bpushconditioncase, 061) \ |
| 146 | DEFINE (Bpushcatch, 062) \ |
| 147 | \ |
| 148 | DEFINE (Bnth, 070) \ |
| 149 | DEFINE (Bsymbolp, 071) \ |
| 150 | DEFINE (Bconsp, 072) \ |
| 151 | DEFINE (Bstringp, 073) \ |
| 152 | DEFINE (Blistp, 074) \ |
| 153 | DEFINE (Beq, 075) \ |
| 154 | DEFINE (Bmemq, 076) \ |
| 155 | DEFINE (Bnot, 077) \ |
| 156 | DEFINE (Bcar, 0100) \ |
| 157 | DEFINE (Bcdr, 0101) \ |
| 158 | DEFINE (Bcons, 0102) \ |
| 159 | DEFINE (Blist1, 0103) \ |
| 160 | DEFINE (Blist2, 0104) \ |
| 161 | DEFINE (Blist3, 0105) \ |
| 162 | DEFINE (Blist4, 0106) \ |
| 163 | DEFINE (Blength, 0107) \ |
| 164 | DEFINE (Baref, 0110) \ |
| 165 | DEFINE (Baset, 0111) \ |
| 166 | DEFINE (Bsymbol_value, 0112) \ |
| 167 | DEFINE (Bsymbol_function, 0113) \ |
| 168 | DEFINE (Bset, 0114) \ |
| 169 | DEFINE (Bfset, 0115) \ |
| 170 | DEFINE (Bget, 0116) \ |
| 171 | DEFINE (Bsubstring, 0117) \ |
| 172 | DEFINE (Bconcat2, 0120) \ |
| 173 | DEFINE (Bconcat3, 0121) \ |
| 174 | DEFINE (Bconcat4, 0122) \ |
| 175 | DEFINE (Bsub1, 0123) \ |
| 176 | DEFINE (Badd1, 0124) \ |
| 177 | DEFINE (Beqlsign, 0125) \ |
| 178 | DEFINE (Bgtr, 0126) \ |
| 179 | DEFINE (Blss, 0127) \ |
| 180 | DEFINE (Bleq, 0130) \ |
| 181 | DEFINE (Bgeq, 0131) \ |
| 182 | DEFINE (Bdiff, 0132) \ |
| 183 | DEFINE (Bnegate, 0133) \ |
| 184 | DEFINE (Bplus, 0134) \ |
| 185 | DEFINE (Bmax, 0135) \ |
| 186 | DEFINE (Bmin, 0136) \ |
| 187 | DEFINE (Bmult, 0137) \ |
| 188 | \ |
| 189 | DEFINE (Bpoint, 0140) \ |
| 190 | /* Was Bmark in v17. */ \ |
| 191 | DEFINE (Bsave_current_buffer, 0141) /* Obsolete. */ \ |
| 192 | DEFINE (Bgoto_char, 0142) \ |
| 193 | DEFINE (Binsert, 0143) \ |
| 194 | DEFINE (Bpoint_max, 0144) \ |
| 195 | DEFINE (Bpoint_min, 0145) \ |
| 196 | DEFINE (Bchar_after, 0146) \ |
| 197 | DEFINE (Bfollowing_char, 0147) \ |
| 198 | DEFINE (Bpreceding_char, 0150) \ |
| 199 | DEFINE (Bcurrent_column, 0151) \ |
| 200 | DEFINE (Bindent_to, 0152) \ |
| 201 | DEFINE (Beolp, 0154) \ |
| 202 | DEFINE (Beobp, 0155) \ |
| 203 | DEFINE (Bbolp, 0156) \ |
| 204 | DEFINE (Bbobp, 0157) \ |
| 205 | DEFINE (Bcurrent_buffer, 0160) \ |
| 206 | DEFINE (Bset_buffer, 0161) \ |
| 207 | DEFINE (Bsave_current_buffer_1, 0162) /* Replacing Bsave_current_buffer. */ \ |
| 208 | DEFINE (Binteractive_p, 0164) /* Obsolete since Emacs-24.1. */ \ |
| 209 | \ |
| 210 | DEFINE (Bforward_char, 0165) \ |
| 211 | DEFINE (Bforward_word, 0166) \ |
| 212 | DEFINE (Bskip_chars_forward, 0167) \ |
| 213 | DEFINE (Bskip_chars_backward, 0170) \ |
| 214 | DEFINE (Bforward_line, 0171) \ |
| 215 | DEFINE (Bchar_syntax, 0172) \ |
| 216 | DEFINE (Bbuffer_substring, 0173) \ |
| 217 | DEFINE (Bdelete_region, 0174) \ |
| 218 | DEFINE (Bnarrow_to_region, 0175) \ |
| 219 | DEFINE (Bwiden, 0176) \ |
| 220 | DEFINE (Bend_of_line, 0177) \ |
| 221 | \ |
| 222 | DEFINE (Bconstant2, 0201) \ |
| 223 | DEFINE (Bgoto, 0202) \ |
| 224 | DEFINE (Bgotoifnil, 0203) \ |
| 225 | DEFINE (Bgotoifnonnil, 0204) \ |
| 226 | DEFINE (Bgotoifnilelsepop, 0205) \ |
| 227 | DEFINE (Bgotoifnonnilelsepop, 0206) \ |
| 228 | DEFINE (Breturn, 0207) \ |
| 229 | DEFINE (Bdiscard, 0210) \ |
| 230 | DEFINE (Bdup, 0211) \ |
| 231 | \ |
| 232 | DEFINE (Bsave_excursion, 0212) \ |
| 233 | DEFINE (Bsave_window_excursion, 0213) /* Obsolete since Emacs-24.1. */ \ |
| 234 | DEFINE (Bsave_restriction, 0214) \ |
| 235 | DEFINE (Bcatch, 0215) \ |
| 236 | \ |
| 237 | DEFINE (Bunwind_protect, 0216) \ |
| 238 | DEFINE (Bcondition_case, 0217) \ |
| 239 | DEFINE (Btemp_output_buffer_setup, 0220) /* Obsolete since Emacs-24.1. */ \ |
| 240 | DEFINE (Btemp_output_buffer_show, 0221) /* Obsolete since Emacs-24.1. */ \ |
| 241 | \ |
| 242 | DEFINE (Bunbind_all, 0222) /* Obsolete. Never used. */ \ |
| 243 | \ |
| 244 | DEFINE (Bset_marker, 0223) \ |
| 245 | DEFINE (Bmatch_beginning, 0224) \ |
| 246 | DEFINE (Bmatch_end, 0225) \ |
| 247 | DEFINE (Bupcase, 0226) \ |
| 248 | DEFINE (Bdowncase, 0227) \ |
| 249 | \ |
| 250 | DEFINE (Bstringeqlsign, 0230) \ |
| 251 | DEFINE (Bstringlss, 0231) \ |
| 252 | DEFINE (Bequal, 0232) \ |
| 253 | DEFINE (Bnthcdr, 0233) \ |
| 254 | DEFINE (Belt, 0234) \ |
| 255 | DEFINE (Bmember, 0235) \ |
| 256 | DEFINE (Bassq, 0236) \ |
| 257 | DEFINE (Bnreverse, 0237) \ |
| 258 | DEFINE (Bsetcar, 0240) \ |
| 259 | DEFINE (Bsetcdr, 0241) \ |
| 260 | DEFINE (Bcar_safe, 0242) \ |
| 261 | DEFINE (Bcdr_safe, 0243) \ |
| 262 | DEFINE (Bnconc, 0244) \ |
| 263 | DEFINE (Bquo, 0245) \ |
| 264 | DEFINE (Brem, 0246) \ |
| 265 | DEFINE (Bnumberp, 0247) \ |
| 266 | DEFINE (Bintegerp, 0250) \ |
| 267 | \ |
| 268 | DEFINE (BRgoto, 0252) \ |
| 269 | DEFINE (BRgotoifnil, 0253) \ |
| 270 | DEFINE (BRgotoifnonnil, 0254) \ |
| 271 | DEFINE (BRgotoifnilelsepop, 0255) \ |
| 272 | DEFINE (BRgotoifnonnilelsepop, 0256) \ |
| 273 | \ |
| 274 | DEFINE (BlistN, 0257) \ |
| 275 | DEFINE (BconcatN, 0260) \ |
| 276 | DEFINE (BinsertN, 0261) \ |
| 277 | \ |
| 278 | /* Bstack_ref is code 0. */ \ |
| 279 | DEFINE (Bstack_set, 0262) \ |
| 280 | DEFINE (Bstack_set2, 0263) \ |
| 281 | DEFINE (BdiscardN, 0266) \ |
| 282 | \ |
| 283 | DEFINE (Bconstant, 0300) |
| 284 | |
| 285 | enum byte_code_op |
| 286 | { |
| 287 | #define DEFINE(name, value) name = value, |
| 288 | BYTE_CODES |
| 289 | #undef DEFINE |
| 290 | |
| 291 | #ifdef BYTE_CODE_SAFE |
| 292 | Bscan_buffer = 0153, /* No longer generated as of v18. */ |
| 293 | Bset_mark = 0163, /* this loser is no longer generated as of v18 */ |
| 294 | #endif |
| 295 | }; |
| 296 | \f |
| 297 | /* Structure describing a value stack used during byte-code execution |
| 298 | in Fbyte_code. */ |
| 299 | |
| 300 | struct byte_stack |
| 301 | { |
| 302 | /* Program counter. This points into the byte_string below |
| 303 | and is relocated when that string is relocated. */ |
| 304 | const unsigned char *pc; |
| 305 | |
| 306 | /* The string containing the byte-code, and its current address. |
| 307 | Storing this here protects it from GC because mark_byte_stack |
| 308 | marks it. */ |
| 309 | Lisp_Object byte_string; |
| 310 | const unsigned char *byte_string_start; |
| 311 | |
| 312 | #if BYTE_MARK_STACK |
| 313 | /* The vector of constants used during byte-code execution. Storing |
| 314 | this here protects it from GC because mark_byte_stack marks it. */ |
| 315 | Lisp_Object constants; |
| 316 | #endif |
| 317 | }; |
| 318 | \f |
| 319 | /* Fetch the next byte from the bytecode stream. */ |
| 320 | |
| 321 | #ifdef BYTE_CODE_SAFE |
| 322 | #define FETCH (eassert (stack.byte_string_start == SDATA (stack.byte_string)), *stack.pc++) |
| 323 | #else |
| 324 | #define FETCH *stack.pc++ |
| 325 | #endif |
| 326 | |
| 327 | /* Fetch two bytes from the bytecode stream and make a 16-bit number |
| 328 | out of them. */ |
| 329 | |
| 330 | #define FETCH2 (op = FETCH, op + (FETCH << 8)) |
| 331 | |
| 332 | /* Push x onto the execution stack. This used to be #define PUSH(x) |
| 333 | (*++stackp = (x)) This oddity is necessary because Alliant can't be |
| 334 | bothered to compile the preincrement operator properly, as of 4/91. |
| 335 | -JimB */ |
| 336 | |
| 337 | #define PUSH(x) (top++, *top = (x)) |
| 338 | |
| 339 | /* Pop a value off the execution stack. */ |
| 340 | |
| 341 | #define POP (*top--) |
| 342 | |
| 343 | /* Discard n values from the execution stack. */ |
| 344 | |
| 345 | #define DISCARD(n) (top -= (n)) |
| 346 | |
| 347 | /* Get the value which is at the top of the execution stack, but don't |
| 348 | pop it. */ |
| 349 | |
| 350 | #define TOP (*top) |
| 351 | |
| 352 | /* Actions that must be performed before and after calling a function |
| 353 | that might GC. */ |
| 354 | |
| 355 | #define BEFORE_POTENTIAL_GC() ((void)0) |
| 356 | #define AFTER_POTENTIAL_GC() ((void)0) |
| 357 | |
| 358 | /* Garbage collect if we have consed enough since the last time. |
| 359 | We do this at every branch, to avoid loops that never GC. */ |
| 360 | |
| 361 | #define MAYBE_GC() \ |
| 362 | do { \ |
| 363 | BEFORE_POTENTIAL_GC (); \ |
| 364 | maybe_gc (); \ |
| 365 | AFTER_POTENTIAL_GC (); \ |
| 366 | } while (0) |
| 367 | |
| 368 | /* Check for jumping out of range. */ |
| 369 | |
| 370 | #ifdef BYTE_CODE_SAFE |
| 371 | |
| 372 | #define CHECK_RANGE(ARG) \ |
| 373 | if (ARG >= bytestr_length) emacs_abort () |
| 374 | |
| 375 | #else /* not BYTE_CODE_SAFE */ |
| 376 | |
| 377 | #define CHECK_RANGE(ARG) |
| 378 | |
| 379 | #endif /* not BYTE_CODE_SAFE */ |
| 380 | |
| 381 | /* A version of the QUIT macro which makes sure that the stack top is |
| 382 | set before signaling `quit'. */ |
| 383 | |
| 384 | #define BYTE_CODE_QUIT \ |
| 385 | do { \ |
| 386 | if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ |
| 387 | { \ |
| 388 | Lisp_Object flag = Vquit_flag; \ |
| 389 | Vquit_flag = Qnil; \ |
| 390 | BEFORE_POTENTIAL_GC (); \ |
| 391 | if (EQ (Vthrow_on_input, flag)) \ |
| 392 | Fthrow (Vthrow_on_input, Qt); \ |
| 393 | Fsignal (Qquit, Qnil); \ |
| 394 | AFTER_POTENTIAL_GC (); \ |
| 395 | } \ |
| 396 | else if (pending_signals) \ |
| 397 | process_pending_signals (); \ |
| 398 | } while (0) |
| 399 | |
| 400 | |
| 401 | DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, |
| 402 | doc: /* Function used internally in byte-compiled code. |
| 403 | The first argument, BYTESTR, is a string of byte code; |
| 404 | the second, VECTOR, a vector of constants; |
| 405 | the third, MAXDEPTH, the maximum stack depth used in this function. |
| 406 | If the third argument is incorrect, Emacs may crash. */) |
| 407 | (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) |
| 408 | { |
| 409 | return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL); |
| 410 | } |
| 411 | |
| 412 | static void |
| 413 | bcall0 (Lisp_Object f) |
| 414 | { |
| 415 | Ffuncall (1, &f); |
| 416 | } |
| 417 | |
| 418 | /* Execute the byte-code in BYTESTR. VECTOR is the constant vector, and |
| 419 | MAXDEPTH is the maximum stack depth used (if MAXDEPTH is incorrect, |
| 420 | emacs may crash!). If ARGS_TEMPLATE is non-nil, it should be a lisp |
| 421 | argument list (including &rest, &optional, etc.), and ARGS, of size |
| 422 | NARGS, should be a vector of the actual arguments. The arguments in |
| 423 | ARGS are pushed on the stack according to ARGS_TEMPLATE before |
| 424 | executing BYTESTR. */ |
| 425 | |
| 426 | Lisp_Object |
| 427 | exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, |
| 428 | Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) |
| 429 | { |
| 430 | ptrdiff_t count = SPECPDL_INDEX (); |
| 431 | #ifdef BYTE_CODE_METER |
| 432 | int volatile this_op = 0; |
| 433 | int prev_op; |
| 434 | #endif |
| 435 | int op; |
| 436 | /* Lisp_Object v1, v2; */ |
| 437 | Lisp_Object *vectorp; |
| 438 | #ifdef BYTE_CODE_SAFE |
| 439 | ptrdiff_t const_length; |
| 440 | Lisp_Object *stacke; |
| 441 | ptrdiff_t bytestr_length; |
| 442 | #endif |
| 443 | struct byte_stack stack; |
| 444 | Lisp_Object *top; |
| 445 | Lisp_Object result; |
| 446 | enum handlertype type; |
| 447 | |
| 448 | #if 0 /* CHECK_FRAME_FONT */ |
| 449 | { |
| 450 | struct frame *f = SELECTED_FRAME (); |
| 451 | if (FRAME_X_P (f) |
| 452 | && FRAME_FONT (f)->direction != 0 |
| 453 | && FRAME_FONT (f)->direction != 1) |
| 454 | emacs_abort (); |
| 455 | } |
| 456 | #endif |
| 457 | |
| 458 | CHECK_STRING (bytestr); |
| 459 | CHECK_VECTOR (vector); |
| 460 | CHECK_NATNUM (maxdepth); |
| 461 | |
| 462 | #ifdef BYTE_CODE_SAFE |
| 463 | const_length = ASIZE (vector); |
| 464 | #endif |
| 465 | |
| 466 | if (STRING_MULTIBYTE (bytestr)) |
| 467 | /* BYTESTR must have been produced by Emacs 20.2 or the earlier |
| 468 | because they produced a raw 8-bit string for byte-code and now |
| 469 | such a byte-code string is loaded as multibyte while raw 8-bit |
| 470 | characters converted to multibyte form. Thus, now we must |
| 471 | convert them back to the originally intended unibyte form. */ |
| 472 | bytestr = Fstring_as_unibyte (bytestr); |
| 473 | |
| 474 | #ifdef BYTE_CODE_SAFE |
| 475 | bytestr_length = SBYTES (bytestr); |
| 476 | #endif |
| 477 | vectorp = XVECTOR (vector)->contents; |
| 478 | |
| 479 | stack.byte_string = bytestr; |
| 480 | stack.pc = stack.byte_string_start = SDATA (bytestr); |
| 481 | #if BYTE_MARK_STACK |
| 482 | stack.constants = vector; |
| 483 | #endif |
| 484 | if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) |
| 485 | memory_full (SIZE_MAX); |
| 486 | top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); |
| 487 | |
| 488 | #ifdef BYTE_CODE_SAFE |
| 489 | stacke = stack.bottom - 1 + XFASTINT (maxdepth); |
| 490 | #endif |
| 491 | |
| 492 | if (INTEGERP (args_template)) |
| 493 | { |
| 494 | ptrdiff_t at = XINT (args_template); |
| 495 | bool rest = (at & 128) != 0; |
| 496 | int mandatory = at & 127; |
| 497 | ptrdiff_t nonrest = at >> 8; |
| 498 | eassert (mandatory <= nonrest); |
| 499 | if (nargs <= nonrest) |
| 500 | { |
| 501 | ptrdiff_t i; |
| 502 | for (i = 0 ; i < nargs; i++, args++) |
| 503 | PUSH (*args); |
| 504 | if (nargs < mandatory) |
| 505 | /* Too few arguments. */ |
| 506 | Fsignal (Qwrong_number_of_arguments, |
| 507 | list2 (Fcons (make_number (mandatory), |
| 508 | rest ? Qand_rest : make_number (nonrest)), |
| 509 | make_number (nargs))); |
| 510 | else |
| 511 | { |
| 512 | for (; i < nonrest; i++) |
| 513 | PUSH (Qnil); |
| 514 | if (rest) |
| 515 | PUSH (Qnil); |
| 516 | } |
| 517 | } |
| 518 | else if (rest) |
| 519 | { |
| 520 | ptrdiff_t i; |
| 521 | for (i = 0 ; i < nonrest; i++, args++) |
| 522 | PUSH (*args); |
| 523 | PUSH (Flist (nargs - nonrest, args)); |
| 524 | } |
| 525 | else |
| 526 | /* Too many arguments. */ |
| 527 | Fsignal (Qwrong_number_of_arguments, |
| 528 | list2 (Fcons (make_number (mandatory), make_number (nonrest)), |
| 529 | make_number (nargs))); |
| 530 | } |
| 531 | else if (! NILP (args_template)) |
| 532 | /* We should push some arguments on the stack. */ |
| 533 | { |
| 534 | error ("Unknown args template!"); |
| 535 | } |
| 536 | |
| 537 | while (1) |
| 538 | { |
| 539 | #ifdef BYTE_CODE_SAFE |
| 540 | if (top > stacke) |
| 541 | emacs_abort (); |
| 542 | else if (top < stack.bottom - 1) |
| 543 | emacs_abort (); |
| 544 | #endif |
| 545 | |
| 546 | #ifdef BYTE_CODE_METER |
| 547 | prev_op = this_op; |
| 548 | this_op = op = FETCH; |
| 549 | METER_CODE (prev_op, op); |
| 550 | #else |
| 551 | #ifndef BYTE_CODE_THREADED |
| 552 | op = FETCH; |
| 553 | #endif |
| 554 | #endif |
| 555 | |
| 556 | /* The interpreter can be compiled one of two ways: as an |
| 557 | ordinary switch-based interpreter, or as a threaded |
| 558 | interpreter. The threaded interpreter relies on GCC's |
| 559 | computed goto extension, so it is not available everywhere. |
| 560 | Threading provides a performance boost. These macros are how |
| 561 | we allow the code to be compiled both ways. */ |
| 562 | #ifdef BYTE_CODE_THREADED |
| 563 | /* The CASE macro introduces an instruction's body. It is |
| 564 | either a label or a case label. */ |
| 565 | #define CASE(OP) insn_ ## OP |
| 566 | /* NEXT is invoked at the end of an instruction to go to the |
| 567 | next instruction. It is either a computed goto, or a |
| 568 | plain break. */ |
| 569 | #define NEXT goto *(targets[op = FETCH]) |
| 570 | /* FIRST is like NEXT, but is only used at the start of the |
| 571 | interpreter body. In the switch-based interpreter it is the |
| 572 | switch, so the threaded definition must include a semicolon. */ |
| 573 | #define FIRST NEXT; |
| 574 | /* Most cases are labeled with the CASE macro, above. |
| 575 | CASE_DEFAULT is one exception; it is used if the interpreter |
| 576 | being built requires a default case. The threaded |
| 577 | interpreter does not, because the dispatch table is |
| 578 | completely filled. */ |
| 579 | #define CASE_DEFAULT |
| 580 | /* This introduces an instruction that is known to call abort. */ |
| 581 | #define CASE_ABORT CASE (Bstack_ref): CASE (default) |
| 582 | #else |
| 583 | /* See above for the meaning of the various defines. */ |
| 584 | #define CASE(OP) case OP |
| 585 | #define NEXT break |
| 586 | #define FIRST switch (op) |
| 587 | #define CASE_DEFAULT case 255: default: |
| 588 | #define CASE_ABORT case 0 |
| 589 | #endif |
| 590 | |
| 591 | #ifdef BYTE_CODE_THREADED |
| 592 | |
| 593 | /* A convenience define that saves us a lot of typing and makes |
| 594 | the table clearer. */ |
| 595 | #define LABEL(OP) [OP] = &&insn_ ## OP |
| 596 | |
| 597 | #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) |
| 598 | # pragma GCC diagnostic push |
| 599 | # pragma GCC diagnostic ignored "-Woverride-init" |
| 600 | #elif defined __clang__ |
| 601 | # pragma GCC diagnostic push |
| 602 | # pragma GCC diagnostic ignored "-Winitializer-overrides" |
| 603 | #endif |
| 604 | |
| 605 | /* This is the dispatch table for the threaded interpreter. */ |
| 606 | static const void *const targets[256] = |
| 607 | { |
| 608 | [0 ... (Bconstant - 1)] = &&insn_default, |
| 609 | [Bconstant ... 255] = &&insn_Bconstant, |
| 610 | |
| 611 | #define DEFINE(name, value) LABEL (name) , |
| 612 | BYTE_CODES |
| 613 | #undef DEFINE |
| 614 | }; |
| 615 | |
| 616 | #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__ |
| 617 | # pragma GCC diagnostic pop |
| 618 | #endif |
| 619 | |
| 620 | #endif |
| 621 | |
| 622 | |
| 623 | FIRST |
| 624 | { |
| 625 | CASE (Bvarref7): |
| 626 | op = FETCH2; |
| 627 | goto varref; |
| 628 | |
| 629 | CASE (Bvarref): |
| 630 | CASE (Bvarref1): |
| 631 | CASE (Bvarref2): |
| 632 | CASE (Bvarref3): |
| 633 | CASE (Bvarref4): |
| 634 | CASE (Bvarref5): |
| 635 | op = op - Bvarref; |
| 636 | goto varref; |
| 637 | |
| 638 | /* This seems to be the most frequently executed byte-code |
| 639 | among the Bvarref's, so avoid a goto here. */ |
| 640 | CASE (Bvarref6): |
| 641 | op = FETCH; |
| 642 | varref: |
| 643 | { |
| 644 | Lisp_Object v1, v2; |
| 645 | |
| 646 | v1 = vectorp[op]; |
| 647 | if (SYMBOLP (v1)) |
| 648 | { |
| 649 | if (XSYMBOL (v1)->redirect != SYMBOL_PLAINVAL |
| 650 | || (v2 = SYMBOL_VAL (XSYMBOL (v1)), |
| 651 | EQ (v2, Qunbound))) |
| 652 | { |
| 653 | BEFORE_POTENTIAL_GC (); |
| 654 | v2 = Fsymbol_value (v1); |
| 655 | AFTER_POTENTIAL_GC (); |
| 656 | } |
| 657 | } |
| 658 | else |
| 659 | { |
| 660 | BEFORE_POTENTIAL_GC (); |
| 661 | v2 = Fsymbol_value (v1); |
| 662 | AFTER_POTENTIAL_GC (); |
| 663 | } |
| 664 | PUSH (v2); |
| 665 | NEXT; |
| 666 | } |
| 667 | |
| 668 | CASE (Bgotoifnil): |
| 669 | { |
| 670 | Lisp_Object v1; |
| 671 | MAYBE_GC (); |
| 672 | op = FETCH2; |
| 673 | v1 = POP; |
| 674 | if (NILP (v1)) |
| 675 | { |
| 676 | BYTE_CODE_QUIT; |
| 677 | CHECK_RANGE (op); |
| 678 | stack.pc = stack.byte_string_start + op; |
| 679 | } |
| 680 | NEXT; |
| 681 | } |
| 682 | |
| 683 | CASE (Bcar): |
| 684 | { |
| 685 | Lisp_Object v1; |
| 686 | v1 = TOP; |
| 687 | if (CONSP (v1)) |
| 688 | TOP = XCAR (v1); |
| 689 | else if (NILP (v1)) |
| 690 | TOP = Qnil; |
| 691 | else |
| 692 | { |
| 693 | BEFORE_POTENTIAL_GC (); |
| 694 | wrong_type_argument (Qlistp, v1); |
| 695 | } |
| 696 | NEXT; |
| 697 | } |
| 698 | |
| 699 | CASE (Beq): |
| 700 | { |
| 701 | Lisp_Object v1; |
| 702 | v1 = POP; |
| 703 | TOP = EQ (v1, TOP) ? Qt : Qnil; |
| 704 | NEXT; |
| 705 | } |
| 706 | |
| 707 | CASE (Bmemq): |
| 708 | { |
| 709 | Lisp_Object v1; |
| 710 | BEFORE_POTENTIAL_GC (); |
| 711 | v1 = POP; |
| 712 | TOP = Fmemq (TOP, v1); |
| 713 | AFTER_POTENTIAL_GC (); |
| 714 | NEXT; |
| 715 | } |
| 716 | |
| 717 | CASE (Bcdr): |
| 718 | { |
| 719 | Lisp_Object v1; |
| 720 | v1 = TOP; |
| 721 | if (CONSP (v1)) |
| 722 | TOP = XCDR (v1); |
| 723 | else if (NILP (v1)) |
| 724 | TOP = Qnil; |
| 725 | else |
| 726 | { |
| 727 | BEFORE_POTENTIAL_GC (); |
| 728 | wrong_type_argument (Qlistp, v1); |
| 729 | } |
| 730 | NEXT; |
| 731 | } |
| 732 | |
| 733 | CASE (Bvarset): |
| 734 | CASE (Bvarset1): |
| 735 | CASE (Bvarset2): |
| 736 | CASE (Bvarset3): |
| 737 | CASE (Bvarset4): |
| 738 | CASE (Bvarset5): |
| 739 | op -= Bvarset; |
| 740 | goto varset; |
| 741 | |
| 742 | CASE (Bvarset7): |
| 743 | op = FETCH2; |
| 744 | goto varset; |
| 745 | |
| 746 | CASE (Bvarset6): |
| 747 | op = FETCH; |
| 748 | varset: |
| 749 | { |
| 750 | Lisp_Object sym, val; |
| 751 | |
| 752 | sym = vectorp[op]; |
| 753 | val = TOP; |
| 754 | |
| 755 | /* Inline the most common case. */ |
| 756 | if (SYMBOLP (sym) |
| 757 | && !EQ (val, Qunbound) |
| 758 | && !XSYMBOL (sym)->redirect |
| 759 | && !SYMBOL_CONSTANT_P (sym)) |
| 760 | SET_SYMBOL_VAL (XSYMBOL (sym), val); |
| 761 | else |
| 762 | { |
| 763 | BEFORE_POTENTIAL_GC (); |
| 764 | set_internal (sym, val, Qnil, 0); |
| 765 | AFTER_POTENTIAL_GC (); |
| 766 | } |
| 767 | } |
| 768 | (void) POP; |
| 769 | NEXT; |
| 770 | |
| 771 | CASE (Bdup): |
| 772 | { |
| 773 | Lisp_Object v1; |
| 774 | v1 = TOP; |
| 775 | PUSH (v1); |
| 776 | NEXT; |
| 777 | } |
| 778 | |
| 779 | /* ------------------ */ |
| 780 | |
| 781 | CASE (Bvarbind6): |
| 782 | op = FETCH; |
| 783 | goto varbind; |
| 784 | |
| 785 | CASE (Bvarbind7): |
| 786 | op = FETCH2; |
| 787 | goto varbind; |
| 788 | |
| 789 | CASE (Bvarbind): |
| 790 | CASE (Bvarbind1): |
| 791 | CASE (Bvarbind2): |
| 792 | CASE (Bvarbind3): |
| 793 | CASE (Bvarbind4): |
| 794 | CASE (Bvarbind5): |
| 795 | op -= Bvarbind; |
| 796 | varbind: |
| 797 | /* Specbind can signal and thus GC. */ |
| 798 | BEFORE_POTENTIAL_GC (); |
| 799 | specbind (vectorp[op], POP); |
| 800 | AFTER_POTENTIAL_GC (); |
| 801 | NEXT; |
| 802 | |
| 803 | CASE (Bcall6): |
| 804 | op = FETCH; |
| 805 | goto docall; |
| 806 | |
| 807 | CASE (Bcall7): |
| 808 | op = FETCH2; |
| 809 | goto docall; |
| 810 | |
| 811 | CASE (Bcall): |
| 812 | CASE (Bcall1): |
| 813 | CASE (Bcall2): |
| 814 | CASE (Bcall3): |
| 815 | CASE (Bcall4): |
| 816 | CASE (Bcall5): |
| 817 | op -= Bcall; |
| 818 | docall: |
| 819 | { |
| 820 | BEFORE_POTENTIAL_GC (); |
| 821 | DISCARD (op); |
| 822 | #ifdef BYTE_CODE_METER |
| 823 | if (byte_metering_on && SYMBOLP (TOP)) |
| 824 | { |
| 825 | Lisp_Object v1, v2; |
| 826 | |
| 827 | v1 = TOP; |
| 828 | v2 = Fget (v1, Qbyte_code_meter); |
| 829 | if (INTEGERP (v2) |
| 830 | && XINT (v2) < MOST_POSITIVE_FIXNUM) |
| 831 | { |
| 832 | XSETINT (v2, XINT (v2) + 1); |
| 833 | Fput (v1, Qbyte_code_meter, v2); |
| 834 | } |
| 835 | } |
| 836 | #endif |
| 837 | TOP = Ffuncall (op + 1, &TOP); |
| 838 | AFTER_POTENTIAL_GC (); |
| 839 | NEXT; |
| 840 | } |
| 841 | |
| 842 | CASE (Bunbind6): |
| 843 | op = FETCH; |
| 844 | goto dounbind; |
| 845 | |
| 846 | CASE (Bunbind7): |
| 847 | op = FETCH2; |
| 848 | goto dounbind; |
| 849 | |
| 850 | CASE (Bunbind): |
| 851 | CASE (Bunbind1): |
| 852 | CASE (Bunbind2): |
| 853 | CASE (Bunbind3): |
| 854 | CASE (Bunbind4): |
| 855 | CASE (Bunbind5): |
| 856 | op -= Bunbind; |
| 857 | dounbind: |
| 858 | BEFORE_POTENTIAL_GC (); |
| 859 | unbind_to (SPECPDL_INDEX () - op, Qnil); |
| 860 | AFTER_POTENTIAL_GC (); |
| 861 | NEXT; |
| 862 | |
| 863 | CASE (Bunbind_all): /* Obsolete. Never used. */ |
| 864 | /* To unbind back to the beginning of this frame. Not used yet, |
| 865 | but will be needed for tail-recursion elimination. */ |
| 866 | BEFORE_POTENTIAL_GC (); |
| 867 | unbind_to (count, Qnil); |
| 868 | AFTER_POTENTIAL_GC (); |
| 869 | NEXT; |
| 870 | |
| 871 | CASE (Bgoto): |
| 872 | MAYBE_GC (); |
| 873 | BYTE_CODE_QUIT; |
| 874 | op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ |
| 875 | CHECK_RANGE (op); |
| 876 | stack.pc = stack.byte_string_start + op; |
| 877 | NEXT; |
| 878 | |
| 879 | CASE (Bgotoifnonnil): |
| 880 | { |
| 881 | Lisp_Object v1; |
| 882 | MAYBE_GC (); |
| 883 | op = FETCH2; |
| 884 | v1 = POP; |
| 885 | if (!NILP (v1)) |
| 886 | { |
| 887 | BYTE_CODE_QUIT; |
| 888 | CHECK_RANGE (op); |
| 889 | stack.pc = stack.byte_string_start + op; |
| 890 | } |
| 891 | NEXT; |
| 892 | } |
| 893 | |
| 894 | CASE (Bgotoifnilelsepop): |
| 895 | MAYBE_GC (); |
| 896 | op = FETCH2; |
| 897 | if (NILP (TOP)) |
| 898 | { |
| 899 | BYTE_CODE_QUIT; |
| 900 | CHECK_RANGE (op); |
| 901 | stack.pc = stack.byte_string_start + op; |
| 902 | } |
| 903 | else DISCARD (1); |
| 904 | NEXT; |
| 905 | |
| 906 | CASE (Bgotoifnonnilelsepop): |
| 907 | MAYBE_GC (); |
| 908 | op = FETCH2; |
| 909 | if (!NILP (TOP)) |
| 910 | { |
| 911 | BYTE_CODE_QUIT; |
| 912 | CHECK_RANGE (op); |
| 913 | stack.pc = stack.byte_string_start + op; |
| 914 | } |
| 915 | else DISCARD (1); |
| 916 | NEXT; |
| 917 | |
| 918 | CASE (BRgoto): |
| 919 | MAYBE_GC (); |
| 920 | BYTE_CODE_QUIT; |
| 921 | stack.pc += (int) *stack.pc - 127; |
| 922 | NEXT; |
| 923 | |
| 924 | CASE (BRgotoifnil): |
| 925 | { |
| 926 | Lisp_Object v1; |
| 927 | MAYBE_GC (); |
| 928 | v1 = POP; |
| 929 | if (NILP (v1)) |
| 930 | { |
| 931 | BYTE_CODE_QUIT; |
| 932 | stack.pc += (int) *stack.pc - 128; |
| 933 | } |
| 934 | stack.pc++; |
| 935 | NEXT; |
| 936 | } |
| 937 | |
| 938 | CASE (BRgotoifnonnil): |
| 939 | { |
| 940 | Lisp_Object v1; |
| 941 | MAYBE_GC (); |
| 942 | v1 = POP; |
| 943 | if (!NILP (v1)) |
| 944 | { |
| 945 | BYTE_CODE_QUIT; |
| 946 | stack.pc += (int) *stack.pc - 128; |
| 947 | } |
| 948 | stack.pc++; |
| 949 | NEXT; |
| 950 | } |
| 951 | |
| 952 | CASE (BRgotoifnilelsepop): |
| 953 | MAYBE_GC (); |
| 954 | op = *stack.pc++; |
| 955 | if (NILP (TOP)) |
| 956 | { |
| 957 | BYTE_CODE_QUIT; |
| 958 | stack.pc += op - 128; |
| 959 | } |
| 960 | else DISCARD (1); |
| 961 | NEXT; |
| 962 | |
| 963 | CASE (BRgotoifnonnilelsepop): |
| 964 | MAYBE_GC (); |
| 965 | op = *stack.pc++; |
| 966 | if (!NILP (TOP)) |
| 967 | { |
| 968 | BYTE_CODE_QUIT; |
| 969 | stack.pc += op - 128; |
| 970 | } |
| 971 | else DISCARD (1); |
| 972 | NEXT; |
| 973 | |
| 974 | CASE (Breturn): |
| 975 | result = POP; |
| 976 | goto exit; |
| 977 | |
| 978 | CASE (Bdiscard): |
| 979 | DISCARD (1); |
| 980 | NEXT; |
| 981 | |
| 982 | CASE (Bconstant2): |
| 983 | PUSH (vectorp[FETCH2]); |
| 984 | NEXT; |
| 985 | |
| 986 | CASE (Bsave_excursion): |
| 987 | record_unwind_protect (save_excursion_restore, |
| 988 | save_excursion_save ()); |
| 989 | NEXT; |
| 990 | |
| 991 | CASE (Bsave_current_buffer): /* Obsolete since ??. */ |
| 992 | CASE (Bsave_current_buffer_1): |
| 993 | record_unwind_current_buffer (); |
| 994 | NEXT; |
| 995 | |
| 996 | CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ |
| 997 | { |
| 998 | ptrdiff_t count1 = SPECPDL_INDEX (); |
| 999 | record_unwind_protect (restore_window_configuration, |
| 1000 | Fcurrent_window_configuration (Qnil)); |
| 1001 | BEFORE_POTENTIAL_GC (); |
| 1002 | TOP = Fprogn (TOP); |
| 1003 | unbind_to (count1, TOP); |
| 1004 | AFTER_POTENTIAL_GC (); |
| 1005 | NEXT; |
| 1006 | } |
| 1007 | |
| 1008 | CASE (Bsave_restriction): |
| 1009 | record_unwind_protect (save_restriction_restore, |
| 1010 | save_restriction_save ()); |
| 1011 | NEXT; |
| 1012 | |
| 1013 | CASE (Bcatch): /* Obsolete since 24.4. */ |
| 1014 | { |
| 1015 | Lisp_Object v1; |
| 1016 | BEFORE_POTENTIAL_GC (); |
| 1017 | v1 = POP; |
| 1018 | TOP = internal_catch (TOP, eval_sub, v1); |
| 1019 | AFTER_POTENTIAL_GC (); |
| 1020 | NEXT; |
| 1021 | } |
| 1022 | |
| 1023 | CASE (Bpushcatch): /* New in 24.4. */ |
| 1024 | type = CATCHER; |
| 1025 | goto pushhandler; |
| 1026 | CASE (Bpushconditioncase): /* New in 24.4. */ |
| 1027 | { |
| 1028 | extern EMACS_INT lisp_eval_depth; |
| 1029 | extern int poll_suppress_count; |
| 1030 | extern int interrupt_input_blocked; |
| 1031 | struct handler *c; |
| 1032 | Lisp_Object tag; |
| 1033 | int dest; |
| 1034 | |
| 1035 | type = CONDITION_CASE; |
| 1036 | pushhandler: |
| 1037 | tag = POP; |
| 1038 | dest = FETCH2; |
| 1039 | |
| 1040 | PUSH_HANDLER (c, tag, type); |
| 1041 | c->bytecode_dest = dest; |
| 1042 | c->bytecode_top = top; |
| 1043 | |
| 1044 | if (sys_setjmp (c->jmp)) |
| 1045 | { |
| 1046 | struct handler *c = handlerlist; |
| 1047 | int dest; |
| 1048 | top = c->bytecode_top; |
| 1049 | dest = c->bytecode_dest; |
| 1050 | handlerlist = c->next; |
| 1051 | PUSH (c->val); |
| 1052 | CHECK_RANGE (dest); |
| 1053 | /* Might have been re-set by longjmp! */ |
| 1054 | stack.byte_string_start = SDATA (stack.byte_string); |
| 1055 | stack.pc = stack.byte_string_start + dest; |
| 1056 | } |
| 1057 | |
| 1058 | NEXT; |
| 1059 | } |
| 1060 | |
| 1061 | CASE (Bpophandler): /* New in 24.4. */ |
| 1062 | { |
| 1063 | handlerlist = handlerlist->next; |
| 1064 | NEXT; |
| 1065 | } |
| 1066 | |
| 1067 | CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */ |
| 1068 | { |
| 1069 | Lisp_Object handler = POP; |
| 1070 | /* Support for a function here is new in 24.4. */ |
| 1071 | record_unwind_protect (NILP (Ffunctionp (handler)) |
| 1072 | ? unwind_body : bcall0, |
| 1073 | handler); |
| 1074 | NEXT; |
| 1075 | } |
| 1076 | |
| 1077 | CASE (Bcondition_case): /* Obsolete since 24.4. */ |
| 1078 | { |
| 1079 | Lisp_Object handlers, body; |
| 1080 | handlers = POP; |
| 1081 | body = POP; |
| 1082 | BEFORE_POTENTIAL_GC (); |
| 1083 | TOP = internal_lisp_condition_case (TOP, body, handlers); |
| 1084 | AFTER_POTENTIAL_GC (); |
| 1085 | NEXT; |
| 1086 | } |
| 1087 | |
| 1088 | CASE (Btemp_output_buffer_setup): /* Obsolete since 24.1. */ |
| 1089 | BEFORE_POTENTIAL_GC (); |
| 1090 | CHECK_STRING (TOP); |
| 1091 | temp_output_buffer_setup (SSDATA (TOP)); |
| 1092 | AFTER_POTENTIAL_GC (); |
| 1093 | TOP = Vstandard_output; |
| 1094 | NEXT; |
| 1095 | |
| 1096 | CASE (Btemp_output_buffer_show): /* Obsolete since 24.1. */ |
| 1097 | { |
| 1098 | Lisp_Object v1; |
| 1099 | BEFORE_POTENTIAL_GC (); |
| 1100 | v1 = POP; |
| 1101 | temp_output_buffer_show (TOP); |
| 1102 | TOP = v1; |
| 1103 | /* pop binding of standard-output */ |
| 1104 | unbind_to (SPECPDL_INDEX () - 1, Qnil); |
| 1105 | AFTER_POTENTIAL_GC (); |
| 1106 | NEXT; |
| 1107 | } |
| 1108 | |
| 1109 | CASE (Bnth): |
| 1110 | { |
| 1111 | Lisp_Object v1, v2; |
| 1112 | EMACS_INT n; |
| 1113 | BEFORE_POTENTIAL_GC (); |
| 1114 | v1 = POP; |
| 1115 | v2 = TOP; |
| 1116 | CHECK_NUMBER (v2); |
| 1117 | n = XINT (v2); |
| 1118 | immediate_quit = 1; |
| 1119 | while (--n >= 0 && CONSP (v1)) |
| 1120 | v1 = XCDR (v1); |
| 1121 | immediate_quit = 0; |
| 1122 | TOP = CAR (v1); |
| 1123 | AFTER_POTENTIAL_GC (); |
| 1124 | NEXT; |
| 1125 | } |
| 1126 | |
| 1127 | CASE (Bsymbolp): |
| 1128 | TOP = SYMBOLP (TOP) ? Qt : Qnil; |
| 1129 | NEXT; |
| 1130 | |
| 1131 | CASE (Bconsp): |
| 1132 | TOP = CONSP (TOP) ? Qt : Qnil; |
| 1133 | NEXT; |
| 1134 | |
| 1135 | CASE (Bstringp): |
| 1136 | TOP = STRINGP (TOP) ? Qt : Qnil; |
| 1137 | NEXT; |
| 1138 | |
| 1139 | CASE (Blistp): |
| 1140 | TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil; |
| 1141 | NEXT; |
| 1142 | |
| 1143 | CASE (Bnot): |
| 1144 | TOP = NILP (TOP) ? Qt : Qnil; |
| 1145 | NEXT; |
| 1146 | |
| 1147 | CASE (Bcons): |
| 1148 | { |
| 1149 | Lisp_Object v1; |
| 1150 | v1 = POP; |
| 1151 | TOP = Fcons (TOP, v1); |
| 1152 | NEXT; |
| 1153 | } |
| 1154 | |
| 1155 | CASE (Blist1): |
| 1156 | TOP = list1 (TOP); |
| 1157 | NEXT; |
| 1158 | |
| 1159 | CASE (Blist2): |
| 1160 | { |
| 1161 | Lisp_Object v1; |
| 1162 | v1 = POP; |
| 1163 | TOP = list2 (TOP, v1); |
| 1164 | NEXT; |
| 1165 | } |
| 1166 | |
| 1167 | CASE (Blist3): |
| 1168 | DISCARD (2); |
| 1169 | TOP = Flist (3, &TOP); |
| 1170 | NEXT; |
| 1171 | |
| 1172 | CASE (Blist4): |
| 1173 | DISCARD (3); |
| 1174 | TOP = Flist (4, &TOP); |
| 1175 | NEXT; |
| 1176 | |
| 1177 | CASE (BlistN): |
| 1178 | op = FETCH; |
| 1179 | DISCARD (op - 1); |
| 1180 | TOP = Flist (op, &TOP); |
| 1181 | NEXT; |
| 1182 | |
| 1183 | CASE (Blength): |
| 1184 | BEFORE_POTENTIAL_GC (); |
| 1185 | TOP = Flength (TOP); |
| 1186 | AFTER_POTENTIAL_GC (); |
| 1187 | NEXT; |
| 1188 | |
| 1189 | CASE (Baref): |
| 1190 | { |
| 1191 | Lisp_Object v1; |
| 1192 | BEFORE_POTENTIAL_GC (); |
| 1193 | v1 = POP; |
| 1194 | TOP = Faref (TOP, v1); |
| 1195 | AFTER_POTENTIAL_GC (); |
| 1196 | NEXT; |
| 1197 | } |
| 1198 | |
| 1199 | CASE (Baset): |
| 1200 | { |
| 1201 | Lisp_Object v1, v2; |
| 1202 | BEFORE_POTENTIAL_GC (); |
| 1203 | v2 = POP; v1 = POP; |
| 1204 | TOP = Faset (TOP, v1, v2); |
| 1205 | AFTER_POTENTIAL_GC (); |
| 1206 | NEXT; |
| 1207 | } |
| 1208 | |
| 1209 | CASE (Bsymbol_value): |
| 1210 | BEFORE_POTENTIAL_GC (); |
| 1211 | TOP = Fsymbol_value (TOP); |
| 1212 | AFTER_POTENTIAL_GC (); |
| 1213 | NEXT; |
| 1214 | |
| 1215 | CASE (Bsymbol_function): |
| 1216 | BEFORE_POTENTIAL_GC (); |
| 1217 | TOP = Fsymbol_function (TOP); |
| 1218 | AFTER_POTENTIAL_GC (); |
| 1219 | NEXT; |
| 1220 | |
| 1221 | CASE (Bset): |
| 1222 | { |
| 1223 | Lisp_Object v1; |
| 1224 | BEFORE_POTENTIAL_GC (); |
| 1225 | v1 = POP; |
| 1226 | TOP = Fset (TOP, v1); |
| 1227 | AFTER_POTENTIAL_GC (); |
| 1228 | NEXT; |
| 1229 | } |
| 1230 | |
| 1231 | CASE (Bfset): |
| 1232 | { |
| 1233 | Lisp_Object v1; |
| 1234 | BEFORE_POTENTIAL_GC (); |
| 1235 | v1 = POP; |
| 1236 | TOP = Ffset (TOP, v1); |
| 1237 | AFTER_POTENTIAL_GC (); |
| 1238 | NEXT; |
| 1239 | } |
| 1240 | |
| 1241 | CASE (Bget): |
| 1242 | { |
| 1243 | Lisp_Object v1; |
| 1244 | BEFORE_POTENTIAL_GC (); |
| 1245 | v1 = POP; |
| 1246 | TOP = Fget (TOP, v1); |
| 1247 | AFTER_POTENTIAL_GC (); |
| 1248 | NEXT; |
| 1249 | } |
| 1250 | |
| 1251 | CASE (Bsubstring): |
| 1252 | { |
| 1253 | Lisp_Object v1, v2; |
| 1254 | BEFORE_POTENTIAL_GC (); |
| 1255 | v2 = POP; v1 = POP; |
| 1256 | TOP = Fsubstring (TOP, v1, v2); |
| 1257 | AFTER_POTENTIAL_GC (); |
| 1258 | NEXT; |
| 1259 | } |
| 1260 | |
| 1261 | CASE (Bconcat2): |
| 1262 | BEFORE_POTENTIAL_GC (); |
| 1263 | DISCARD (1); |
| 1264 | TOP = Fconcat (2, &TOP); |
| 1265 | AFTER_POTENTIAL_GC (); |
| 1266 | NEXT; |
| 1267 | |
| 1268 | CASE (Bconcat3): |
| 1269 | BEFORE_POTENTIAL_GC (); |
| 1270 | DISCARD (2); |
| 1271 | TOP = Fconcat (3, &TOP); |
| 1272 | AFTER_POTENTIAL_GC (); |
| 1273 | NEXT; |
| 1274 | |
| 1275 | CASE (Bconcat4): |
| 1276 | BEFORE_POTENTIAL_GC (); |
| 1277 | DISCARD (3); |
| 1278 | TOP = Fconcat (4, &TOP); |
| 1279 | AFTER_POTENTIAL_GC (); |
| 1280 | NEXT; |
| 1281 | |
| 1282 | CASE (BconcatN): |
| 1283 | op = FETCH; |
| 1284 | BEFORE_POTENTIAL_GC (); |
| 1285 | DISCARD (op - 1); |
| 1286 | TOP = Fconcat (op, &TOP); |
| 1287 | AFTER_POTENTIAL_GC (); |
| 1288 | NEXT; |
| 1289 | |
| 1290 | CASE (Bsub1): |
| 1291 | { |
| 1292 | Lisp_Object v1; |
| 1293 | v1 = TOP; |
| 1294 | if (INTEGERP (v1)) |
| 1295 | { |
| 1296 | XSETINT (v1, XINT (v1) - 1); |
| 1297 | TOP = v1; |
| 1298 | } |
| 1299 | else |
| 1300 | { |
| 1301 | BEFORE_POTENTIAL_GC (); |
| 1302 | TOP = Fsub1 (v1); |
| 1303 | AFTER_POTENTIAL_GC (); |
| 1304 | } |
| 1305 | NEXT; |
| 1306 | } |
| 1307 | |
| 1308 | CASE (Badd1): |
| 1309 | { |
| 1310 | Lisp_Object v1; |
| 1311 | v1 = TOP; |
| 1312 | if (INTEGERP (v1)) |
| 1313 | { |
| 1314 | XSETINT (v1, XINT (v1) + 1); |
| 1315 | TOP = v1; |
| 1316 | } |
| 1317 | else |
| 1318 | { |
| 1319 | BEFORE_POTENTIAL_GC (); |
| 1320 | TOP = Fadd1 (v1); |
| 1321 | AFTER_POTENTIAL_GC (); |
| 1322 | } |
| 1323 | NEXT; |
| 1324 | } |
| 1325 | |
| 1326 | CASE (Beqlsign): |
| 1327 | { |
| 1328 | Lisp_Object v1, v2; |
| 1329 | BEFORE_POTENTIAL_GC (); |
| 1330 | v2 = POP; v1 = TOP; |
| 1331 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1); |
| 1332 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2); |
| 1333 | AFTER_POTENTIAL_GC (); |
| 1334 | if (FLOATP (v1) || FLOATP (v2)) |
| 1335 | { |
| 1336 | double f1, f2; |
| 1337 | |
| 1338 | f1 = (FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1)); |
| 1339 | f2 = (FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2)); |
| 1340 | TOP = (f1 == f2 ? Qt : Qnil); |
| 1341 | } |
| 1342 | else |
| 1343 | TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil); |
| 1344 | NEXT; |
| 1345 | } |
| 1346 | |
| 1347 | CASE (Bgtr): |
| 1348 | { |
| 1349 | Lisp_Object v1; |
| 1350 | BEFORE_POTENTIAL_GC (); |
| 1351 | v1 = POP; |
| 1352 | TOP = arithcompare (TOP, v1, ARITH_GRTR); |
| 1353 | AFTER_POTENTIAL_GC (); |
| 1354 | NEXT; |
| 1355 | } |
| 1356 | |
| 1357 | CASE (Blss): |
| 1358 | { |
| 1359 | Lisp_Object v1; |
| 1360 | BEFORE_POTENTIAL_GC (); |
| 1361 | v1 = POP; |
| 1362 | TOP = arithcompare (TOP, v1, ARITH_LESS); |
| 1363 | AFTER_POTENTIAL_GC (); |
| 1364 | NEXT; |
| 1365 | } |
| 1366 | |
| 1367 | CASE (Bleq): |
| 1368 | { |
| 1369 | Lisp_Object v1; |
| 1370 | BEFORE_POTENTIAL_GC (); |
| 1371 | v1 = POP; |
| 1372 | TOP = arithcompare (TOP, v1, ARITH_LESS_OR_EQUAL); |
| 1373 | AFTER_POTENTIAL_GC (); |
| 1374 | NEXT; |
| 1375 | } |
| 1376 | |
| 1377 | CASE (Bgeq): |
| 1378 | { |
| 1379 | Lisp_Object v1; |
| 1380 | BEFORE_POTENTIAL_GC (); |
| 1381 | v1 = POP; |
| 1382 | TOP = arithcompare (TOP, v1, ARITH_GRTR_OR_EQUAL); |
| 1383 | AFTER_POTENTIAL_GC (); |
| 1384 | NEXT; |
| 1385 | } |
| 1386 | |
| 1387 | CASE (Bdiff): |
| 1388 | BEFORE_POTENTIAL_GC (); |
| 1389 | DISCARD (1); |
| 1390 | TOP = Fminus (2, &TOP); |
| 1391 | AFTER_POTENTIAL_GC (); |
| 1392 | NEXT; |
| 1393 | |
| 1394 | CASE (Bnegate): |
| 1395 | { |
| 1396 | Lisp_Object v1; |
| 1397 | v1 = TOP; |
| 1398 | if (INTEGERP (v1)) |
| 1399 | { |
| 1400 | XSETINT (v1, - XINT (v1)); |
| 1401 | TOP = v1; |
| 1402 | } |
| 1403 | else |
| 1404 | { |
| 1405 | BEFORE_POTENTIAL_GC (); |
| 1406 | TOP = Fminus (1, &TOP); |
| 1407 | AFTER_POTENTIAL_GC (); |
| 1408 | } |
| 1409 | NEXT; |
| 1410 | } |
| 1411 | |
| 1412 | CASE (Bplus): |
| 1413 | BEFORE_POTENTIAL_GC (); |
| 1414 | DISCARD (1); |
| 1415 | TOP = Fplus (2, &TOP); |
| 1416 | AFTER_POTENTIAL_GC (); |
| 1417 | NEXT; |
| 1418 | |
| 1419 | CASE (Bmax): |
| 1420 | BEFORE_POTENTIAL_GC (); |
| 1421 | DISCARD (1); |
| 1422 | TOP = Fmax (2, &TOP); |
| 1423 | AFTER_POTENTIAL_GC (); |
| 1424 | NEXT; |
| 1425 | |
| 1426 | CASE (Bmin): |
| 1427 | BEFORE_POTENTIAL_GC (); |
| 1428 | DISCARD (1); |
| 1429 | TOP = Fmin (2, &TOP); |
| 1430 | AFTER_POTENTIAL_GC (); |
| 1431 | NEXT; |
| 1432 | |
| 1433 | CASE (Bmult): |
| 1434 | BEFORE_POTENTIAL_GC (); |
| 1435 | DISCARD (1); |
| 1436 | TOP = Ftimes (2, &TOP); |
| 1437 | AFTER_POTENTIAL_GC (); |
| 1438 | NEXT; |
| 1439 | |
| 1440 | CASE (Bquo): |
| 1441 | BEFORE_POTENTIAL_GC (); |
| 1442 | DISCARD (1); |
| 1443 | TOP = Fquo (2, &TOP); |
| 1444 | AFTER_POTENTIAL_GC (); |
| 1445 | NEXT; |
| 1446 | |
| 1447 | CASE (Brem): |
| 1448 | { |
| 1449 | Lisp_Object v1; |
| 1450 | BEFORE_POTENTIAL_GC (); |
| 1451 | v1 = POP; |
| 1452 | TOP = Frem (TOP, v1); |
| 1453 | AFTER_POTENTIAL_GC (); |
| 1454 | NEXT; |
| 1455 | } |
| 1456 | |
| 1457 | CASE (Bpoint): |
| 1458 | { |
| 1459 | Lisp_Object v1; |
| 1460 | XSETFASTINT (v1, PT); |
| 1461 | PUSH (v1); |
| 1462 | NEXT; |
| 1463 | } |
| 1464 | |
| 1465 | CASE (Bgoto_char): |
| 1466 | BEFORE_POTENTIAL_GC (); |
| 1467 | TOP = Fgoto_char (TOP); |
| 1468 | AFTER_POTENTIAL_GC (); |
| 1469 | NEXT; |
| 1470 | |
| 1471 | CASE (Binsert): |
| 1472 | BEFORE_POTENTIAL_GC (); |
| 1473 | TOP = Finsert (1, &TOP); |
| 1474 | AFTER_POTENTIAL_GC (); |
| 1475 | NEXT; |
| 1476 | |
| 1477 | CASE (BinsertN): |
| 1478 | op = FETCH; |
| 1479 | BEFORE_POTENTIAL_GC (); |
| 1480 | DISCARD (op - 1); |
| 1481 | TOP = Finsert (op, &TOP); |
| 1482 | AFTER_POTENTIAL_GC (); |
| 1483 | NEXT; |
| 1484 | |
| 1485 | CASE (Bpoint_max): |
| 1486 | { |
| 1487 | Lisp_Object v1; |
| 1488 | XSETFASTINT (v1, ZV); |
| 1489 | PUSH (v1); |
| 1490 | NEXT; |
| 1491 | } |
| 1492 | |
| 1493 | CASE (Bpoint_min): |
| 1494 | { |
| 1495 | Lisp_Object v1; |
| 1496 | XSETFASTINT (v1, BEGV); |
| 1497 | PUSH (v1); |
| 1498 | NEXT; |
| 1499 | } |
| 1500 | |
| 1501 | CASE (Bchar_after): |
| 1502 | BEFORE_POTENTIAL_GC (); |
| 1503 | TOP = Fchar_after (TOP); |
| 1504 | AFTER_POTENTIAL_GC (); |
| 1505 | NEXT; |
| 1506 | |
| 1507 | CASE (Bfollowing_char): |
| 1508 | { |
| 1509 | Lisp_Object v1; |
| 1510 | BEFORE_POTENTIAL_GC (); |
| 1511 | v1 = Ffollowing_char (); |
| 1512 | AFTER_POTENTIAL_GC (); |
| 1513 | PUSH (v1); |
| 1514 | NEXT; |
| 1515 | } |
| 1516 | |
| 1517 | CASE (Bpreceding_char): |
| 1518 | { |
| 1519 | Lisp_Object v1; |
| 1520 | BEFORE_POTENTIAL_GC (); |
| 1521 | v1 = Fprevious_char (); |
| 1522 | AFTER_POTENTIAL_GC (); |
| 1523 | PUSH (v1); |
| 1524 | NEXT; |
| 1525 | } |
| 1526 | |
| 1527 | CASE (Bcurrent_column): |
| 1528 | { |
| 1529 | Lisp_Object v1; |
| 1530 | BEFORE_POTENTIAL_GC (); |
| 1531 | XSETFASTINT (v1, current_column ()); |
| 1532 | AFTER_POTENTIAL_GC (); |
| 1533 | PUSH (v1); |
| 1534 | NEXT; |
| 1535 | } |
| 1536 | |
| 1537 | CASE (Bindent_to): |
| 1538 | BEFORE_POTENTIAL_GC (); |
| 1539 | TOP = Findent_to (TOP, Qnil); |
| 1540 | AFTER_POTENTIAL_GC (); |
| 1541 | NEXT; |
| 1542 | |
| 1543 | CASE (Beolp): |
| 1544 | PUSH (Feolp ()); |
| 1545 | NEXT; |
| 1546 | |
| 1547 | CASE (Beobp): |
| 1548 | PUSH (Feobp ()); |
| 1549 | NEXT; |
| 1550 | |
| 1551 | CASE (Bbolp): |
| 1552 | PUSH (Fbolp ()); |
| 1553 | NEXT; |
| 1554 | |
| 1555 | CASE (Bbobp): |
| 1556 | PUSH (Fbobp ()); |
| 1557 | NEXT; |
| 1558 | |
| 1559 | CASE (Bcurrent_buffer): |
| 1560 | PUSH (Fcurrent_buffer ()); |
| 1561 | NEXT; |
| 1562 | |
| 1563 | CASE (Bset_buffer): |
| 1564 | BEFORE_POTENTIAL_GC (); |
| 1565 | TOP = Fset_buffer (TOP); |
| 1566 | AFTER_POTENTIAL_GC (); |
| 1567 | NEXT; |
| 1568 | |
| 1569 | CASE (Binteractive_p): /* Obsolete since 24.1. */ |
| 1570 | BEFORE_POTENTIAL_GC (); |
| 1571 | PUSH (call0 (intern ("interactive-p"))); |
| 1572 | AFTER_POTENTIAL_GC (); |
| 1573 | NEXT; |
| 1574 | |
| 1575 | CASE (Bforward_char): |
| 1576 | BEFORE_POTENTIAL_GC (); |
| 1577 | TOP = Fforward_char (TOP); |
| 1578 | AFTER_POTENTIAL_GC (); |
| 1579 | NEXT; |
| 1580 | |
| 1581 | CASE (Bforward_word): |
| 1582 | BEFORE_POTENTIAL_GC (); |
| 1583 | TOP = Fforward_word (TOP); |
| 1584 | AFTER_POTENTIAL_GC (); |
| 1585 | NEXT; |
| 1586 | |
| 1587 | CASE (Bskip_chars_forward): |
| 1588 | { |
| 1589 | Lisp_Object v1; |
| 1590 | BEFORE_POTENTIAL_GC (); |
| 1591 | v1 = POP; |
| 1592 | TOP = Fskip_chars_forward (TOP, v1); |
| 1593 | AFTER_POTENTIAL_GC (); |
| 1594 | NEXT; |
| 1595 | } |
| 1596 | |
| 1597 | CASE (Bskip_chars_backward): |
| 1598 | { |
| 1599 | Lisp_Object v1; |
| 1600 | BEFORE_POTENTIAL_GC (); |
| 1601 | v1 = POP; |
| 1602 | TOP = Fskip_chars_backward (TOP, v1); |
| 1603 | AFTER_POTENTIAL_GC (); |
| 1604 | NEXT; |
| 1605 | } |
| 1606 | |
| 1607 | CASE (Bforward_line): |
| 1608 | BEFORE_POTENTIAL_GC (); |
| 1609 | TOP = Fforward_line (TOP); |
| 1610 | AFTER_POTENTIAL_GC (); |
| 1611 | NEXT; |
| 1612 | |
| 1613 | CASE (Bchar_syntax): |
| 1614 | { |
| 1615 | int c; |
| 1616 | |
| 1617 | BEFORE_POTENTIAL_GC (); |
| 1618 | CHECK_CHARACTER (TOP); |
| 1619 | AFTER_POTENTIAL_GC (); |
| 1620 | c = XFASTINT (TOP); |
| 1621 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) |
| 1622 | MAKE_CHAR_MULTIBYTE (c); |
| 1623 | XSETFASTINT (TOP, syntax_code_spec[SYNTAX (c)]); |
| 1624 | } |
| 1625 | NEXT; |
| 1626 | |
| 1627 | CASE (Bbuffer_substring): |
| 1628 | { |
| 1629 | Lisp_Object v1; |
| 1630 | BEFORE_POTENTIAL_GC (); |
| 1631 | v1 = POP; |
| 1632 | TOP = Fbuffer_substring (TOP, v1); |
| 1633 | AFTER_POTENTIAL_GC (); |
| 1634 | NEXT; |
| 1635 | } |
| 1636 | |
| 1637 | CASE (Bdelete_region): |
| 1638 | { |
| 1639 | Lisp_Object v1; |
| 1640 | BEFORE_POTENTIAL_GC (); |
| 1641 | v1 = POP; |
| 1642 | TOP = Fdelete_region (TOP, v1); |
| 1643 | AFTER_POTENTIAL_GC (); |
| 1644 | NEXT; |
| 1645 | } |
| 1646 | |
| 1647 | CASE (Bnarrow_to_region): |
| 1648 | { |
| 1649 | Lisp_Object v1; |
| 1650 | BEFORE_POTENTIAL_GC (); |
| 1651 | v1 = POP; |
| 1652 | TOP = Fnarrow_to_region (TOP, v1); |
| 1653 | AFTER_POTENTIAL_GC (); |
| 1654 | NEXT; |
| 1655 | } |
| 1656 | |
| 1657 | CASE (Bwiden): |
| 1658 | BEFORE_POTENTIAL_GC (); |
| 1659 | PUSH (Fwiden ()); |
| 1660 | AFTER_POTENTIAL_GC (); |
| 1661 | NEXT; |
| 1662 | |
| 1663 | CASE (Bend_of_line): |
| 1664 | BEFORE_POTENTIAL_GC (); |
| 1665 | TOP = Fend_of_line (TOP); |
| 1666 | AFTER_POTENTIAL_GC (); |
| 1667 | NEXT; |
| 1668 | |
| 1669 | CASE (Bset_marker): |
| 1670 | { |
| 1671 | Lisp_Object v1, v2; |
| 1672 | BEFORE_POTENTIAL_GC (); |
| 1673 | v1 = POP; |
| 1674 | v2 = POP; |
| 1675 | TOP = Fset_marker (TOP, v2, v1); |
| 1676 | AFTER_POTENTIAL_GC (); |
| 1677 | NEXT; |
| 1678 | } |
| 1679 | |
| 1680 | CASE (Bmatch_beginning): |
| 1681 | BEFORE_POTENTIAL_GC (); |
| 1682 | TOP = Fmatch_beginning (TOP); |
| 1683 | AFTER_POTENTIAL_GC (); |
| 1684 | NEXT; |
| 1685 | |
| 1686 | CASE (Bmatch_end): |
| 1687 | BEFORE_POTENTIAL_GC (); |
| 1688 | TOP = Fmatch_end (TOP); |
| 1689 | AFTER_POTENTIAL_GC (); |
| 1690 | NEXT; |
| 1691 | |
| 1692 | CASE (Bupcase): |
| 1693 | BEFORE_POTENTIAL_GC (); |
| 1694 | TOP = Fupcase (TOP); |
| 1695 | AFTER_POTENTIAL_GC (); |
| 1696 | NEXT; |
| 1697 | |
| 1698 | CASE (Bdowncase): |
| 1699 | BEFORE_POTENTIAL_GC (); |
| 1700 | TOP = Fdowncase (TOP); |
| 1701 | AFTER_POTENTIAL_GC (); |
| 1702 | NEXT; |
| 1703 | |
| 1704 | CASE (Bstringeqlsign): |
| 1705 | { |
| 1706 | Lisp_Object v1; |
| 1707 | BEFORE_POTENTIAL_GC (); |
| 1708 | v1 = POP; |
| 1709 | TOP = Fstring_equal (TOP, v1); |
| 1710 | AFTER_POTENTIAL_GC (); |
| 1711 | NEXT; |
| 1712 | } |
| 1713 | |
| 1714 | CASE (Bstringlss): |
| 1715 | { |
| 1716 | Lisp_Object v1; |
| 1717 | BEFORE_POTENTIAL_GC (); |
| 1718 | v1 = POP; |
| 1719 | TOP = Fstring_lessp (TOP, v1); |
| 1720 | AFTER_POTENTIAL_GC (); |
| 1721 | NEXT; |
| 1722 | } |
| 1723 | |
| 1724 | CASE (Bequal): |
| 1725 | { |
| 1726 | Lisp_Object v1; |
| 1727 | v1 = POP; |
| 1728 | TOP = Fequal (TOP, v1); |
| 1729 | NEXT; |
| 1730 | } |
| 1731 | |
| 1732 | CASE (Bnthcdr): |
| 1733 | { |
| 1734 | Lisp_Object v1; |
| 1735 | BEFORE_POTENTIAL_GC (); |
| 1736 | v1 = POP; |
| 1737 | TOP = Fnthcdr (TOP, v1); |
| 1738 | AFTER_POTENTIAL_GC (); |
| 1739 | NEXT; |
| 1740 | } |
| 1741 | |
| 1742 | CASE (Belt): |
| 1743 | { |
| 1744 | Lisp_Object v1, v2; |
| 1745 | if (CONSP (TOP)) |
| 1746 | { |
| 1747 | /* Exchange args and then do nth. */ |
| 1748 | EMACS_INT n; |
| 1749 | BEFORE_POTENTIAL_GC (); |
| 1750 | v2 = POP; |
| 1751 | v1 = TOP; |
| 1752 | CHECK_NUMBER (v2); |
| 1753 | AFTER_POTENTIAL_GC (); |
| 1754 | n = XINT (v2); |
| 1755 | immediate_quit = 1; |
| 1756 | while (--n >= 0 && CONSP (v1)) |
| 1757 | v1 = XCDR (v1); |
| 1758 | immediate_quit = 0; |
| 1759 | TOP = CAR (v1); |
| 1760 | } |
| 1761 | else |
| 1762 | { |
| 1763 | BEFORE_POTENTIAL_GC (); |
| 1764 | v1 = POP; |
| 1765 | TOP = Felt (TOP, v1); |
| 1766 | AFTER_POTENTIAL_GC (); |
| 1767 | } |
| 1768 | NEXT; |
| 1769 | } |
| 1770 | |
| 1771 | CASE (Bmember): |
| 1772 | { |
| 1773 | Lisp_Object v1; |
| 1774 | BEFORE_POTENTIAL_GC (); |
| 1775 | v1 = POP; |
| 1776 | TOP = Fmember (TOP, v1); |
| 1777 | AFTER_POTENTIAL_GC (); |
| 1778 | NEXT; |
| 1779 | } |
| 1780 | |
| 1781 | CASE (Bassq): |
| 1782 | { |
| 1783 | Lisp_Object v1; |
| 1784 | BEFORE_POTENTIAL_GC (); |
| 1785 | v1 = POP; |
| 1786 | TOP = Fassq (TOP, v1); |
| 1787 | AFTER_POTENTIAL_GC (); |
| 1788 | NEXT; |
| 1789 | } |
| 1790 | |
| 1791 | CASE (Bnreverse): |
| 1792 | BEFORE_POTENTIAL_GC (); |
| 1793 | TOP = Fnreverse (TOP); |
| 1794 | AFTER_POTENTIAL_GC (); |
| 1795 | NEXT; |
| 1796 | |
| 1797 | CASE (Bsetcar): |
| 1798 | { |
| 1799 | Lisp_Object v1; |
| 1800 | BEFORE_POTENTIAL_GC (); |
| 1801 | v1 = POP; |
| 1802 | TOP = Fsetcar (TOP, v1); |
| 1803 | AFTER_POTENTIAL_GC (); |
| 1804 | NEXT; |
| 1805 | } |
| 1806 | |
| 1807 | CASE (Bsetcdr): |
| 1808 | { |
| 1809 | Lisp_Object v1; |
| 1810 | BEFORE_POTENTIAL_GC (); |
| 1811 | v1 = POP; |
| 1812 | TOP = Fsetcdr (TOP, v1); |
| 1813 | AFTER_POTENTIAL_GC (); |
| 1814 | NEXT; |
| 1815 | } |
| 1816 | |
| 1817 | CASE (Bcar_safe): |
| 1818 | { |
| 1819 | Lisp_Object v1; |
| 1820 | v1 = TOP; |
| 1821 | TOP = CAR_SAFE (v1); |
| 1822 | NEXT; |
| 1823 | } |
| 1824 | |
| 1825 | CASE (Bcdr_safe): |
| 1826 | { |
| 1827 | Lisp_Object v1; |
| 1828 | v1 = TOP; |
| 1829 | TOP = CDR_SAFE (v1); |
| 1830 | NEXT; |
| 1831 | } |
| 1832 | |
| 1833 | CASE (Bnconc): |
| 1834 | BEFORE_POTENTIAL_GC (); |
| 1835 | DISCARD (1); |
| 1836 | TOP = Fnconc (2, &TOP); |
| 1837 | AFTER_POTENTIAL_GC (); |
| 1838 | NEXT; |
| 1839 | |
| 1840 | CASE (Bnumberp): |
| 1841 | TOP = (NUMBERP (TOP) ? Qt : Qnil); |
| 1842 | NEXT; |
| 1843 | |
| 1844 | CASE (Bintegerp): |
| 1845 | TOP = INTEGERP (TOP) ? Qt : Qnil; |
| 1846 | NEXT; |
| 1847 | |
| 1848 | #ifdef BYTE_CODE_SAFE |
| 1849 | /* These are intentionally written using 'case' syntax, |
| 1850 | because they are incompatible with the threaded |
| 1851 | interpreter. */ |
| 1852 | |
| 1853 | case Bset_mark: |
| 1854 | BEFORE_POTENTIAL_GC (); |
| 1855 | error ("set-mark is an obsolete bytecode"); |
| 1856 | AFTER_POTENTIAL_GC (); |
| 1857 | break; |
| 1858 | case Bscan_buffer: |
| 1859 | BEFORE_POTENTIAL_GC (); |
| 1860 | error ("scan-buffer is an obsolete bytecode"); |
| 1861 | AFTER_POTENTIAL_GC (); |
| 1862 | break; |
| 1863 | #endif |
| 1864 | |
| 1865 | CASE_ABORT: |
| 1866 | /* Actually this is Bstack_ref with offset 0, but we use Bdup |
| 1867 | for that instead. */ |
| 1868 | /* CASE (Bstack_ref): */ |
| 1869 | call3 (intern ("error"), |
| 1870 | build_string ("Invalid byte opcode: op=%s, ptr=%d"), |
| 1871 | make_number (op), |
| 1872 | make_number ((stack.pc - 1) - stack.byte_string_start)); |
| 1873 | |
| 1874 | /* Handy byte-codes for lexical binding. */ |
| 1875 | CASE (Bstack_ref1): |
| 1876 | CASE (Bstack_ref2): |
| 1877 | CASE (Bstack_ref3): |
| 1878 | CASE (Bstack_ref4): |
| 1879 | CASE (Bstack_ref5): |
| 1880 | { |
| 1881 | Lisp_Object *ptr = top - (op - Bstack_ref); |
| 1882 | PUSH (*ptr); |
| 1883 | NEXT; |
| 1884 | } |
| 1885 | CASE (Bstack_ref6): |
| 1886 | { |
| 1887 | Lisp_Object *ptr = top - (FETCH); |
| 1888 | PUSH (*ptr); |
| 1889 | NEXT; |
| 1890 | } |
| 1891 | CASE (Bstack_ref7): |
| 1892 | { |
| 1893 | Lisp_Object *ptr = top - (FETCH2); |
| 1894 | PUSH (*ptr); |
| 1895 | NEXT; |
| 1896 | } |
| 1897 | CASE (Bstack_set): |
| 1898 | /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */ |
| 1899 | { |
| 1900 | Lisp_Object *ptr = top - (FETCH); |
| 1901 | *ptr = POP; |
| 1902 | NEXT; |
| 1903 | } |
| 1904 | CASE (Bstack_set2): |
| 1905 | { |
| 1906 | Lisp_Object *ptr = top - (FETCH2); |
| 1907 | *ptr = POP; |
| 1908 | NEXT; |
| 1909 | } |
| 1910 | CASE (BdiscardN): |
| 1911 | op = FETCH; |
| 1912 | if (op & 0x80) |
| 1913 | { |
| 1914 | op &= 0x7F; |
| 1915 | top[-op] = TOP; |
| 1916 | } |
| 1917 | DISCARD (op); |
| 1918 | NEXT; |
| 1919 | |
| 1920 | CASE_DEFAULT |
| 1921 | CASE (Bconstant): |
| 1922 | #ifdef BYTE_CODE_SAFE |
| 1923 | if (op < Bconstant) |
| 1924 | { |
| 1925 | emacs_abort (); |
| 1926 | } |
| 1927 | if ((op -= Bconstant) >= const_length) |
| 1928 | { |
| 1929 | emacs_abort (); |
| 1930 | } |
| 1931 | PUSH (vectorp[op]); |
| 1932 | #else |
| 1933 | PUSH (vectorp[op - Bconstant]); |
| 1934 | #endif |
| 1935 | NEXT; |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | exit: |
| 1940 | |
| 1941 | /* Binds and unbinds are supposed to be compiled balanced. */ |
| 1942 | if (SPECPDL_INDEX () != count) |
| 1943 | { |
| 1944 | if (SPECPDL_INDEX () > count) |
| 1945 | unbind_to (count, Qnil); |
| 1946 | error ("binding stack not balanced (serious byte compiler bug)"); |
| 1947 | } |
| 1948 | |
| 1949 | return result; |
| 1950 | } |
| 1951 | |
| 1952 | void |
| 1953 | syms_of_bytecode (void) |
| 1954 | { |
| 1955 | defsubr (&Sbyte_code); |
| 1956 | |
| 1957 | #ifdef BYTE_CODE_METER |
| 1958 | |
| 1959 | DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter, |
| 1960 | doc: /* A vector of vectors which holds a histogram of byte-code usage. |
| 1961 | \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte |
| 1962 | opcode CODE has been executed. |
| 1963 | \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0, |
| 1964 | indicates how many times the byte opcodes CODE1 and CODE2 have been |
| 1965 | executed in succession. */); |
| 1966 | |
| 1967 | DEFVAR_BOOL ("byte-metering-on", byte_metering_on, |
| 1968 | doc: /* If non-nil, keep profiling information on byte code usage. |
| 1969 | The variable byte-code-meter indicates how often each byte opcode is used. |
| 1970 | If a symbol has a property named `byte-code-meter' whose value is an |
| 1971 | integer, it is incremented each time that symbol's function is called. */); |
| 1972 | |
| 1973 | byte_metering_on = 0; |
| 1974 | Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0)); |
| 1975 | DEFSYM (Qbyte_code_meter, "byte-code-meter"); |
| 1976 | { |
| 1977 | int i = 256; |
| 1978 | while (i--) |
| 1979 | ASET (Vbyte_code_meter, i, |
| 1980 | Fmake_vector (make_number (256), make_number (0))); |
| 1981 | } |
| 1982 | #endif |
| 1983 | } |