bytecode.c 42.9 KB
Newer Older
Jim Blandy's avatar
Jim Blandy committed
1
/* Execution of byte code produced by bytecomp.el.
2
   Copyright (C) 1985-1988, 1993, 2000-2012 Free Software Foundation, Inc.
Jim Blandy's avatar
Jim Blandy committed
3 4 5

This file is part of GNU Emacs.

6
GNU Emacs is free software: you can redistribute it and/or modify
Jim Blandy's avatar
Jim Blandy committed
7
it under the terms of the GNU General Public License as published by
8 9
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Jim Blandy's avatar
Jim Blandy committed
10 11 12 13 14 15 16

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
17
along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
Jim Blandy's avatar
Jim Blandy committed
18

19
/*
20
hacked on by jwz@lucid.com 17-jun-91
Jim Blandy's avatar
Jim Blandy committed
21 22
  o  added a compile-time switch to turn on simple sanity checking;
  o  put back the obsolete byte-codes for error-detection;
23
  o  added a new instruction, unbind_all, which I will use for
Jim Blandy's avatar
Jim Blandy committed
24
     tail-recursion elimination;
25
  o  made temp_output_buffer_show be called with the right number
Jim Blandy's avatar
Jim Blandy committed
26 27 28 29 30
     of args;
  o  made the new bytecodes be called with args in the right order;
  o  added metering support.

by Hallvard:
31
  o  added relative jump instructions;
Jim Blandy's avatar
Jim Blandy committed
32 33 34
  o  all conditionals now only do QUIT if they jump.
 */

35
#include <config.h>
36
#include <setjmp.h>
Jim Blandy's avatar
Jim Blandy committed
37
#include "lisp.h"
38
#include "character.h"
39
#include "buffer.h"
Jim Blandy's avatar
Jim Blandy committed
40
#include "syntax.h"
Stefan Monnier's avatar
Stefan Monnier committed
41
#include "window.h"
Jim Blandy's avatar
Jim Blandy committed
42

43 44 45 46 47
#ifdef CHECK_FRAME_FONT
#include "frame.h"
#include "xterm.h"
#endif

48
/*
49
 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
50 51
 * debugging the byte compiler...)
 *
52
 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
Jim Blandy's avatar
Jim Blandy committed
53
 */
54 55
/* #define BYTE_CODE_SAFE */
/* #define BYTE_CODE_METER */
Jim Blandy's avatar
Jim Blandy committed
56

Tom Tromey's avatar
Tom Tromey committed
57 58 59 60 61 62 63 64
/* 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

Jim Blandy's avatar
Jim Blandy committed
65 66 67

#ifdef BYTE_CODE_METER

68
Lisp_Object Qbyte_code_meter;
69 70
#define METER_2(code1, code2) AREF (AREF (Vbyte_code_meter, code1), code2)
#define METER_1(code) METER_2 (0, code)
71

72 73 74 75
#define METER_CODE(last_code, this_code)				\
{									\
  if (byte_metering_on)							\
    {									\
76 77 78
      if (XFASTINT (METER_1 (this_code)) < MOST_POSITIVE_FIXNUM)	\
        XSETFASTINT (METER_1 (this_code),				\
		     XFASTINT (METER_1 (this_code)) + 1);		\
79
      if (last_code							\
80 81 82 83
	  && (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);	\
84
    }									\
85
}
Jim Blandy's avatar
Jim Blandy committed
86

87
#endif /* BYTE_CODE_METER */
Jim Blandy's avatar
Jim Blandy committed
88 89 90 91 92 93


Lisp_Object Qbytecode;

/*  Byte codes: */

Tom Tromey's avatar
Tom Tromey committed
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
#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

287
#ifdef BYTE_CODE_SAFE
Tom Tromey's avatar
Tom Tromey committed
288 289
    Bscan_buffer = 0153, /* No longer generated as of v18.  */
    Bset_mark = 0163 /* this loser is no longer generated as of v18 */
290
#endif
Tom Tromey's avatar
Tom Tromey committed
291
};
Gerd Moellmann's avatar
Gerd Moellmann committed
292

293 294
/* Whether to maintain a `top' and `bottom' field in the stack frame.  */
#define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK)
295

Gerd Moellmann's avatar
Gerd Moellmann committed
296 297 298 299 300 301 302
/* Structure describing a value stack used during byte-code execution
   in Fbyte_code.  */

struct byte_stack
{
  /* Program counter.  This points into the byte_string below
     and is relocated when that string is relocated.  */
303
  const unsigned char *pc;
Gerd Moellmann's avatar
Gerd Moellmann committed
304 305 306

  /* Top and bottom of stack.  The bottom points to an area of memory
     allocated with alloca in Fbyte_code.  */
307
#if BYTE_MAINTAIN_TOP
Gerd Moellmann's avatar
Gerd Moellmann committed
308
  Lisp_Object *top, *bottom;
309
#endif
Gerd Moellmann's avatar
Gerd Moellmann committed
310 311 312 313 314

  /* The string containing the byte-code, and its current address.
     Storing this here protects it from GC because mark_byte_stack
     marks it.  */
  Lisp_Object byte_string;
315
  const unsigned char *byte_string_start;
Gerd Moellmann's avatar
Gerd Moellmann committed
316 317 318 319 320 321 322 323 324 325 326 327

  /* 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;

  /* Next entry in byte_stack_list.  */
  struct byte_stack *next;
};

/* A list of currently active byte-code execution value stacks.
   Fbyte_code adds an entry to the head of this list before it starts
   processing byte-code, and it removed the entry again when it is
Paul Eggert's avatar
Paul Eggert committed
328
   done.  Signaling an error truncates the list analogous to
Gerd Moellmann's avatar
Gerd Moellmann committed
329 330 331 332
   gcprolist.  */

struct byte_stack *byte_stack_list;

333

Gerd Moellmann's avatar
Gerd Moellmann committed
334 335
/* Mark objects on byte_stack_list.  Called during GC.  */

336
#if BYTE_MARK_STACK
Gerd Moellmann's avatar
Gerd Moellmann committed
337
void
338
mark_byte_stack (void)
Gerd Moellmann's avatar
Gerd Moellmann committed
339 340 341 342 343 344
{
  struct byte_stack *stack;
  Lisp_Object *obj;

  for (stack = byte_stack_list; stack; stack = stack->next)
    {
345 346 347 348 349 350 351
      /* If STACK->top is null here, this means there's an opcode in
	 Fbyte_code that wasn't expected to GC, but did.  To find out
	 which opcode this is, record the value of `stack', and walk
	 up the stack in a debugger, stopping in frames of Fbyte_code.
	 The culprit is found in the frame of Fbyte_code where the
	 address of its local variable `stack' is equal to the
	 recorded value of `stack' here.  */
Kenichi Handa's avatar
Kenichi Handa committed
352
      eassert (stack->top);
353

Gerd Moellmann's avatar
Gerd Moellmann committed
354
      for (obj = stack->bottom; obj <= stack->top; ++obj)
Kenichi Handa's avatar
Kenichi Handa committed
355
	mark_object (*obj);
356

Kenichi Handa's avatar
Kenichi Handa committed
357 358
      mark_object (stack->byte_string);
      mark_object (stack->constants);
Gerd Moellmann's avatar
Gerd Moellmann committed
359 360
    }
}
361
#endif
Gerd Moellmann's avatar
Gerd Moellmann committed
362

363 364
/* Unmark objects in the stacks on byte_stack_list.  Relocate program
   counters.  Called when GC has completed.  */
Gerd Moellmann's avatar
Gerd Moellmann committed
365

366
void
367
unmark_byte_stack (void)
Gerd Moellmann's avatar
Gerd Moellmann committed
368 369 370 371
{
  struct byte_stack *stack;

  for (stack = byte_stack_list; stack; stack = stack->next)
372
    {
373
      if (stack->byte_string_start != SDATA (stack->byte_string))
374
	{
375
	  ptrdiff_t offset = stack->pc - stack->byte_string_start;
376
	  stack->byte_string_start = SDATA (stack->byte_string);
377 378 379
	  stack->pc = stack->byte_string_start + offset;
	}
    }
Gerd Moellmann's avatar
Gerd Moellmann committed
380 381
}

Jim Blandy's avatar
Jim Blandy committed
382 383 384

/* Fetch the next byte from the bytecode stream */

Gerd Moellmann's avatar
Gerd Moellmann committed
385
#define FETCH *stack.pc++
Jim Blandy's avatar
Jim Blandy committed
386

387 388
/* Fetch two bytes from the bytecode stream and make a 16-bit number
   out of them */
Jim Blandy's avatar
Jim Blandy committed
389 390 391

#define FETCH2 (op = FETCH, op + (FETCH << 8))

392 393 394 395
/* Push x onto the execution stack.  This used to be #define PUSH(x)
   (*++stackp = (x)) This oddity is necessary because Alliant can't be
   bothered to compile the preincrement operator properly, as of 4/91.
   -JimB */
Gerd Moellmann's avatar
Gerd Moellmann committed
396 397

#define PUSH(x) (top++, *top = (x))
Jim Blandy's avatar
Jim Blandy committed
398 399 400

/* Pop a value off the execution stack.  */

Gerd Moellmann's avatar
Gerd Moellmann committed
401
#define POP (*top--)
Jim Blandy's avatar
Jim Blandy committed
402 403 404

/* Discard n values from the execution stack.  */

Gerd Moellmann's avatar
Gerd Moellmann committed
405 406 407 408 409 410
#define DISCARD(n) (top -= (n))

/* Get the value which is at the top of the execution stack, but don't
   pop it. */

#define TOP (*top)
Jim Blandy's avatar
Jim Blandy committed
411

412
/* Actions that must be performed before and after calling a function
Gerd Moellmann's avatar
Gerd Moellmann committed
413
   that might GC.  */
Jim Blandy's avatar
Jim Blandy committed
414

415 416 417 418
#if !BYTE_MAINTAIN_TOP
#define BEFORE_POTENTIAL_GC()	((void)0)
#define AFTER_POTENTIAL_GC()	((void)0)
#else
Gerd Moellmann's avatar
Gerd Moellmann committed
419 420
#define BEFORE_POTENTIAL_GC()	stack.top = top
#define AFTER_POTENTIAL_GC()	stack.top = NULL
421
#endif
Jim Blandy's avatar
Jim Blandy committed
422

Richard M. Stallman's avatar
Richard M. Stallman committed
423 424 425
/* Garbage collect if we have consed enough since the last time.
   We do this at every branch, to avoid loops that never GC.  */

426 427 428 429 430
#define MAYBE_GC()		\
  do {				\
   BEFORE_POTENTIAL_GC ();	\
   maybe_gc ();			\
   AFTER_POTENTIAL_GC ();	\
431
 } while (0)
432

433
/* Check for jumping out of range.  */
Gerd Moellmann's avatar
Gerd Moellmann committed
434 435 436

#ifdef BYTE_CODE_SAFE

437
#define CHECK_RANGE(ARG) \
438 439
  if (ARG >= bytestr_length) abort ()

440
#else /* not BYTE_CODE_SAFE */
Gerd Moellmann's avatar
Gerd Moellmann committed
441 442 443

#define CHECK_RANGE(ARG)

444
#endif /* not BYTE_CODE_SAFE */
Gerd Moellmann's avatar
Gerd Moellmann committed
445

Gerd Moellmann's avatar
Gerd Moellmann committed
446 447 448 449 450 451 452
/* A version of the QUIT macro which makes sure that the stack top is
   set before signaling `quit'.  */

#define BYTE_CODE_QUIT					\
  do {							\
    if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))	\
      {							\
453
        Lisp_Object flag = Vquit_flag;			\
Gerd Moellmann's avatar
Gerd Moellmann committed
454 455
	Vquit_flag = Qnil;				\
        BEFORE_POTENTIAL_GC ();				\
456
	if (EQ (Vthrow_on_input, flag))			\
457
	  Fthrow (Vthrow_on_input, Qt);			\
Gerd Moellmann's avatar
Gerd Moellmann committed
458
	Fsignal (Qquit, Qnil);				\
459
	AFTER_POTENTIAL_GC ();				\
Gerd Moellmann's avatar
Gerd Moellmann committed
460
      }							\
461
    ELSE_PENDING_SIGNALS				\
Gerd Moellmann's avatar
Gerd Moellmann committed
462 463
  } while (0)

Gerd Moellmann's avatar
Gerd Moellmann committed
464

Jim Blandy's avatar
Jim Blandy committed
465
DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0,
466 467 468 469 470
       doc: /* Function used internally in byte-compiled code.
The first argument, BYTESTR, is a string of byte code;
the second, VECTOR, a vector of constants;
the third, MAXDEPTH, the maximum stack depth used in this function.
If the third argument is incorrect, Emacs may crash.  */)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
471
  (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth)
472
{
473
  return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL);
474 475 476 477 478 479 480 481 482 483 484
}

/* Execute the byte-code in BYTESTR.  VECTOR is the constant vector, and
   MAXDEPTH is the maximum stack depth used (if MAXDEPTH is incorrect,
   emacs may crash!).  If ARGS_TEMPLATE is non-nil, it should be a lisp
   argument list (including &rest, &optional, etc.), and ARGS, of size
   NARGS, should be a vector of the actual arguments.  The arguments in
   ARGS are pushed on the stack according to ARGS_TEMPLATE before
   executing BYTESTR.  */

Lisp_Object
Stefan Monnier's avatar
Stefan Monnier committed
485
exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
486
		Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
Jim Blandy's avatar
Jim Blandy committed
487
{
488
  ptrdiff_t count = SPECPDL_INDEX ();
Jim Blandy's avatar
Jim Blandy committed
489 490 491 492
#ifdef BYTE_CODE_METER
  int this_op = 0;
  int prev_op;
#endif
Gerd Moellmann's avatar
Gerd Moellmann committed
493
  int op;
494
  /* Lisp_Object v1, v2; */
495
  Lisp_Object *vectorp;
Jim Blandy's avatar
Jim Blandy committed
496
#ifdef BYTE_CODE_SAFE
497
  ptrdiff_t const_length;
Gerd Moellmann's avatar
Gerd Moellmann committed
498
  Lisp_Object *stacke;
499
  ptrdiff_t bytestr_length;
500
#endif
Gerd Moellmann's avatar
Gerd Moellmann committed
501 502
  struct byte_stack stack;
  Lisp_Object *top;
503
  Lisp_Object result;
Jim Blandy's avatar
Jim Blandy committed
504

505
#if 0 /* CHECK_FRAME_FONT */
506 507 508 509 510 511 512 513 514
 {
   struct frame *f = SELECTED_FRAME ();
   if (FRAME_X_P (f)
       && FRAME_FONT (f)->direction != 0
       && FRAME_FONT (f)->direction != 1)
     abort ();
 }
#endif

515
  CHECK_STRING (bytestr);
Kim F. Storm's avatar
Kim F. Storm committed
516
  CHECK_VECTOR (vector);
517
  CHECK_NATNUM (maxdepth);
Jim Blandy's avatar
Jim Blandy committed
518

519
#ifdef BYTE_CODE_SAFE
520
  const_length = ASIZE (vector);
521 522
#endif

523 524 525 526 527
  if (STRING_MULTIBYTE (bytestr))
    /* BYTESTR must have been produced by Emacs 20.2 or the earlier
       because they produced a raw 8-bit string for byte-code and now
       such a byte-code string is loaded as multibyte while raw 8-bit
       characters converted to multibyte form.  Thus, now we must
528
       convert them back to the originally intended unibyte form.  */
529
    bytestr = Fstring_as_unibyte (bytestr);
530

531
#ifdef BYTE_CODE_SAFE
532
  bytestr_length = SBYTES (bytestr);
533
#endif
534 535
  vectorp = XVECTOR (vector)->contents;

Gerd Moellmann's avatar
Gerd Moellmann committed
536
  stack.byte_string = bytestr;
537
  stack.pc = stack.byte_string_start = SDATA (bytestr);
Gerd Moellmann's avatar
Gerd Moellmann committed
538
  stack.constants = vector;
539
  if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth))
540
    memory_full (SIZE_MAX);
541
  top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
542
#if BYTE_MAINTAIN_TOP
543
  stack.bottom = top + 1;
Gerd Moellmann's avatar
Gerd Moellmann committed
544
  stack.top = NULL;
545
#endif
Gerd Moellmann's avatar
Gerd Moellmann committed
546 547
  stack.next = byte_stack_list;
  byte_stack_list = &stack;
Jim Blandy's avatar
Jim Blandy committed
548

Gerd Moellmann's avatar
Gerd Moellmann committed
549 550 551
#ifdef BYTE_CODE_SAFE
  stacke = stack.bottom - 1 + XFASTINT (maxdepth);
#endif
552

553
  if (INTEGERP (args_template))
554
    {
555
      ptrdiff_t at = XINT (args_template);
556 557
      int rest = at & 128;
      int mandatory = at & 127;
558
      ptrdiff_t nonrest = at >> 8;
559 560 561
      eassert (mandatory <= nonrest);
      if (nargs <= nonrest)
	{
562
	  ptrdiff_t i;
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
	  for (i = 0 ; i < nargs; i++, args++)
	    PUSH (*args);
	  if (nargs < mandatory)
	    /* Too few arguments.  */
	    Fsignal (Qwrong_number_of_arguments,
		     Fcons (Fcons (make_number (mandatory),
				   rest ? Qand_rest : make_number (nonrest)),
			    Fcons (make_number (nargs), Qnil)));
	  else
	    {
	      for (; i < nonrest; i++)
		PUSH (Qnil);
	      if (rest)
		PUSH (Qnil);
	    }
	}
      else if (rest)
	{
581
	  ptrdiff_t i;
582 583 584 585 586 587
	  for (i = 0 ; i < nonrest; i++, args++)
	    PUSH (*args);
	  PUSH (Flist (nargs - nonrest, args));
	}
      else
	/* Too many arguments.  */
588
	Fsignal (Qwrong_number_of_arguments,
589 590 591 592 593 594 595 596
		 Fcons (Fcons (make_number (mandatory),
			       make_number (nonrest)),
			Fcons (make_number (nargs), Qnil)));
    }
  else if (! NILP (args_template))
    /* We should push some arguments on the stack.  */
    {
      error ("Unknown args template!");
597 598
    }

Jim Blandy's avatar
Jim Blandy committed
599 600 601
  while (1)
    {
#ifdef BYTE_CODE_SAFE
602
      if (top > stacke)
603
	abort ();
Gerd Moellmann's avatar
Gerd Moellmann committed
604
      else if (top < stack.bottom - 1)
605
	abort ();
Jim Blandy's avatar
Jim Blandy committed
606 607 608 609 610 611 612
#endif

#ifdef BYTE_CODE_METER
      prev_op = this_op;
      this_op = op = FETCH;
      METER_CODE (prev_op, op);
#else
Tom Tromey's avatar
Tom Tromey committed
613
#ifndef BYTE_CODE_THREADED
614
      op = FETCH;
Jim Blandy's avatar
Jim Blandy committed
615
#endif
Tom Tromey's avatar
Tom Tromey committed
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
#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
Jim Blandy's avatar
Jim Blandy committed
658

659 660 661 662 663
#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Woverride-init"
#endif

Tom Tromey's avatar
Tom Tromey committed
664 665
      /* This is the dispatch table for the threaded interpreter.  */
      static const void *const targets[256] =
666
	{
Tom Tromey's avatar
Tom Tromey committed
667 668 669 670 671 672 673
	  [0 ... (Bconstant - 1)] = &&insn_default,
	  [Bconstant ... 255] = &&insn_Bconstant,

#define DEFINE(name, value) LABEL (name) ,
	  BYTE_CODES
#undef DEFINE
	};
674 675 676 677 678

#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
# pragma GCC diagnostic pop
#endif

Tom Tromey's avatar
Tom Tromey committed
679 680 681 682 683 684
#endif


      FIRST
	{
	CASE (Bvarref7):
Jim Blandy's avatar
Jim Blandy committed
685 686 687
	  op = FETCH2;
	  goto varref;

Tom Tromey's avatar
Tom Tromey committed
688 689 690 691 692 693
	CASE (Bvarref):
	CASE (Bvarref1):
	CASE (Bvarref2):
	CASE (Bvarref3):
	CASE (Bvarref4):
	CASE (Bvarref5):
Jim Blandy's avatar
Jim Blandy committed
694
	  op = op - Bvarref;
695 696 697 698
	  goto varref;

	/* This seems to be the most frequently executed byte-code
	   among the Bvarref's, so avoid a goto here.  */
Tom Tromey's avatar
Tom Tromey committed
699
	CASE (Bvarref6):
700
	  op = FETCH;
Jim Blandy's avatar
Jim Blandy committed
701
	varref:
702 703 704 705 706 707
	  {
	    Lisp_Object v1, v2;

	    v1 = vectorp[op];
	    if (SYMBOLP (v1))
	      {
708 709 710
		if (XSYMBOL (v1)->redirect != SYMBOL_PLAINVAL
		    || (v2 = SYMBOL_VAL (XSYMBOL (v1)),
			EQ (v2, Qunbound)))
711 712 713 714 715
		  {
		    BEFORE_POTENTIAL_GC ();
		    v2 = Fsymbol_value (v1);
		    AFTER_POTENTIAL_GC ();
		  }
716 717
	      }
	    else
718 719 720 721 722
	      {
		BEFORE_POTENTIAL_GC ();
		v2 = Fsymbol_value (v1);
		AFTER_POTENTIAL_GC ();
	      }
723
	    PUSH (v2);
Tom Tromey's avatar
Tom Tromey committed
724
	    NEXT;
725 726
	  }

Tom Tromey's avatar
Tom Tromey committed
727
	CASE (Bgotoifnil):
728 729 730 731 732 733 734 735 736 737 738
	  {
	    Lisp_Object v1;
	    MAYBE_GC ();
	    op = FETCH2;
	    v1 = POP;
	    if (NILP (v1))
	      {
		BYTE_CODE_QUIT;
		CHECK_RANGE (op);
		stack.pc = stack.byte_string_start + op;
	      }
Tom Tromey's avatar
Tom Tromey committed
739
	    NEXT;
740
	  }
Jim Blandy's avatar
Jim Blandy committed
741

Tom Tromey's avatar
Tom Tromey committed
742
	CASE (Bcar):
743 744 745
	  {
	    Lisp_Object v1;
	    v1 = TOP;
746 747 748 749 750 751 752 753 754 755
	    if (CONSP (v1))
	      TOP = XCAR (v1);
	    else if (NILP (v1))
	      TOP = Qnil;
	    else
	      {
		BEFORE_POTENTIAL_GC ();
		wrong_type_argument (Qlistp, v1);
		AFTER_POTENTIAL_GC ();
	      }
Tom Tromey's avatar
Tom Tromey committed
756
	    NEXT;
757 758
	  }

Tom Tromey's avatar
Tom Tromey committed
759
	CASE (Beq):
760 761 762 763
	  {
	    Lisp_Object v1;
	    v1 = POP;
	    TOP = EQ (v1, TOP) ? Qt : Qnil;
Tom Tromey's avatar
Tom Tromey committed
764
	    NEXT;
765 766
	  }

Tom Tromey's avatar
Tom Tromey committed
767
	CASE (Bmemq):
768 769
	  {
	    Lisp_Object v1;
770
	    BEFORE_POTENTIAL_GC ();
771 772
	    v1 = POP;
	    TOP = Fmemq (TOP, v1);
773
	    AFTER_POTENTIAL_GC ();
Tom Tromey's avatar
Tom Tromey committed
774
	    NEXT;
775 776
	  }

Tom Tromey's avatar
Tom Tromey committed
777
	CASE (Bcdr):
778 779 780
	  {
	    Lisp_Object v1;
	    v1 = TOP;
781 782 783 784 785 786 787 788 789 790
	    if (CONSP (v1))
	      TOP = XCDR (v1);
	    else if (NILP (v1))
	      TOP = Qnil;
	    else
	      {
		BEFORE_POTENTIAL_GC ();
		wrong_type_argument (Qlistp, v1);
		AFTER_POTENTIAL_GC ();
	      }
Tom Tromey's avatar
Tom Tromey committed
791
	    NEXT;
792
	  }
Jim Blandy's avatar
Jim Blandy committed
793

Tom Tromey's avatar
Tom Tromey committed
794 795 796 797 798 799
	CASE (Bvarset):
	CASE (Bvarset1):
	CASE (Bvarset2):
	CASE (Bvarset3):
	CASE (Bvarset4):
	CASE (Bvarset5):
800
	  op -= Bvarset;
Jim Blandy's avatar
Jim Blandy committed
801 802
	  goto varset;

Tom Tromey's avatar
Tom Tromey committed
803
	CASE (Bvarset7):
804
	  op = FETCH2;
805 806
	  goto varset;

Tom Tromey's avatar
Tom Tromey committed
807
	CASE (Bvarset6):
808
	  op = FETCH;
Jim Blandy's avatar
Jim Blandy committed
809
	varset:
810 811
	  {
	    Lisp_Object sym, val;
812

813
	    sym = vectorp[op];
814
	    val = TOP;
815 816 817 818

	    /* Inline the most common case.  */
	    if (SYMBOLP (sym)
		&& !EQ (val, Qunbound)
819 820
		&& !XSYMBOL (sym)->redirect
		&& !SYMBOL_CONSTANT_P (sym))
821
	      SET_SYMBOL_VAL (XSYMBOL (sym), val);
822
	    else
823 824
	      {
		BEFORE_POTENTIAL_GC ();
825
		set_internal (sym, val, Qnil, 0);
826 827
		AFTER_POTENTIAL_GC ();
	      }
828
	  }
829
	  (void) POP;
Tom Tromey's avatar
Tom Tromey committed
830
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
831

Tom Tromey's avatar
Tom Tromey committed
832
	CASE (Bdup):
833 834 835 836
	  {
	    Lisp_Object v1;
	    v1 = TOP;
	    PUSH (v1);
Tom Tromey's avatar
Tom Tromey committed
837
	    NEXT;
838 839 840 841
	  }

	/* ------------------ */

Tom Tromey's avatar
Tom Tromey committed
842
	CASE (Bvarbind6):
Jim Blandy's avatar
Jim Blandy committed
843 844 845
	  op = FETCH;
	  goto varbind;

Tom Tromey's avatar
Tom Tromey committed
846
	CASE (Bvarbind7):
Jim Blandy's avatar
Jim Blandy committed
847 848 849
	  op = FETCH2;
	  goto varbind;

Tom Tromey's avatar
Tom Tromey committed
850 851 852 853 854 855
	CASE (Bvarbind):
	CASE (Bvarbind1):
	CASE (Bvarbind2):
	CASE (Bvarbind3):
	CASE (Bvarbind4):
	CASE (Bvarbind5):
Jim Blandy's avatar
Jim Blandy committed
856 857
	  op -= Bvarbind;
	varbind:
858 859
	  /* Specbind can signal and thus GC.  */
	  BEFORE_POTENTIAL_GC ();
Jim Blandy's avatar
Jim Blandy committed
860
	  specbind (vectorp[op], POP);
861
	  AFTER_POTENTIAL_GC ();
Tom Tromey's avatar
Tom Tromey committed
862
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
863

Tom Tromey's avatar
Tom Tromey committed
864
	CASE (Bcall6):
Jim Blandy's avatar
Jim Blandy committed
865 866 867
	  op = FETCH;
	  goto docall;

Tom Tromey's avatar
Tom Tromey committed
868
	CASE (Bcall7):
Jim Blandy's avatar
Jim Blandy committed
869 870 871
	  op = FETCH2;
	  goto docall;

Tom Tromey's avatar
Tom Tromey committed
872 873 874 875 876 877
	CASE (Bcall):
	CASE (Bcall1):
	CASE (Bcall2):
	CASE (Bcall3):
	CASE (Bcall4):
	CASE (Bcall5):
Jim Blandy's avatar
Jim Blandy committed
878 879
	  op -= Bcall;
	docall:
880
	  {
881
	    BEFORE_POTENTIAL_GC ();
882
	    DISCARD (op);
883
#ifdef BYTE_CODE_METER
884 885 886 887 888 889 890
	    if (byte_metering_on && SYMBOLP (TOP))
	      {
		Lisp_Object v1, v2;

		v1 = TOP;
		v2 = Fget (v1, Qbyte_code_meter);
		if (INTEGERP (v2)
891
		    && XINT (v2) < MOST_POSITIVE_FIXNUM)
892 893 894 895 896
		  {
		    XSETINT (v2, XINT (v2) + 1);
		    Fput (v1, Qbyte_code_meter, v2);
		  }
	      }
897
#endif
898 899
	    TOP = Ffuncall (op + 1, &TOP);
	    AFTER_POTENTIAL_GC ();
Tom Tromey's avatar
Tom Tromey committed
900
	    NEXT;
901
	  }
Jim Blandy's avatar
Jim Blandy committed
902

Tom Tromey's avatar
Tom Tromey committed
903
	CASE (Bunbind6):
Jim Blandy's avatar
Jim Blandy committed
904 905 906
	  op = FETCH;
	  goto dounbind;

Tom Tromey's avatar
Tom Tromey committed
907
	CASE (Bunbind7):
Jim Blandy's avatar
Jim Blandy committed
908 909 910
	  op = FETCH2;
	  goto dounbind;

Tom Tromey's avatar
Tom Tromey committed
911 912 913 914 915 916
	CASE (Bunbind):
	CASE (Bunbind1):
	CASE (Bunbind2):
	CASE (Bunbind3):
	CASE (Bunbind4):
	CASE (Bunbind5):
Jim Blandy's avatar
Jim Blandy committed
917 918
	  op -= Bunbind;
	dounbind:
Gerd Moellmann's avatar
Gerd Moellmann committed
919
	  BEFORE_POTENTIAL_GC ();
Juanma Barranquero's avatar
Juanma Barranquero committed
920
	  unbind_to (SPECPDL_INDEX () - op, Qnil);
Gerd Moellmann's avatar
Gerd Moellmann committed
921
	  AFTER_POTENTIAL_GC ();
Tom Tromey's avatar
Tom Tromey committed
922
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
923

Tom Tromey's avatar
Tom Tromey committed
924
	CASE (Bunbind_all):	/* Obsolete.  Never used.  */
Jim Blandy's avatar
Jim Blandy committed
925
	  /* To unbind back to the beginning of this frame.  Not used yet,
926
	     but will be needed for tail-recursion elimination.  */
Gerd Moellmann's avatar
Gerd Moellmann committed
927
	  BEFORE_POTENTIAL_GC ();
Jim Blandy's avatar
Jim Blandy committed
928
	  unbind_to (count, Qnil);
Gerd Moellmann's avatar
Gerd Moellmann committed
929
	  AFTER_POTENTIAL_GC ();
Tom Tromey's avatar
Tom Tromey committed
930
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
931

Tom Tromey's avatar
Tom Tromey committed
932
	CASE (Bgoto):
Richard M. Stallman's avatar
Richard M. Stallman committed
933
	  MAYBE_GC ();
Gerd Moellmann's avatar
Gerd Moellmann committed
934
	  BYTE_CODE_QUIT;
Jim Blandy's avatar
Jim Blandy committed
935
	  op = FETCH2;    /* pc = FETCH2 loses since FETCH2 contains pc++ */
936
	  CHECK_RANGE (op);
Gerd Moellmann's avatar
Gerd Moellmann committed
937
	  stack.pc = stack.byte_string_start + op;
Tom Tromey's avatar
Tom Tromey committed
938
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
939

Tom Tromey's avatar
Tom Tromey committed
940
	CASE (Bgotoifnonnil):
941 942 943 944 945 946 947 948 949 950 951
	  {
	    Lisp_Object v1;
	    MAYBE_GC ();
	    op = FETCH2;
	    v1 = POP;
	    if (!NILP (v1))
	      {
		BYTE_CODE_QUIT;
		CHECK_RANGE (op);
		stack.pc = stack.byte_string_start + op;
	      }
Tom Tromey's avatar
Tom Tromey committed
952
	    NEXT;
953
	  }
Jim Blandy's avatar
Jim Blandy committed
954

Tom Tromey's avatar
Tom Tromey committed
955
	CASE (Bgotoifnilelsepop):
Richard M. Stallman's avatar
Richard M. Stallman committed
956
	  MAYBE_GC ();
Jim Blandy's avatar
Jim Blandy committed
957
	  op = FETCH2;
Joseph Arceneaux's avatar
Joseph Arceneaux committed
958
	  if (NILP (TOP))
Jim Blandy's avatar
Jim Blandy committed
959
	    {
Gerd Moellmann's avatar
Gerd Moellmann committed
960
	      BYTE_CODE_QUIT;
961
	      CHECK_RANGE (op);
Gerd Moellmann's avatar
Gerd Moellmann committed
962
	      stack.pc = stack.byte_string_start + op;
Jim Blandy's avatar
Jim Blandy committed
963
	    }
964
	  else DISCARD (1);
Tom Tromey's avatar
Tom Tromey committed
965
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
966

Tom Tromey's avatar
Tom Tromey committed
967
	CASE (Bgotoifnonnilelsepop):
Richard M. Stallman's avatar
Richard M. Stallman committed
968
	  MAYBE_GC ();
Jim Blandy's avatar
Jim Blandy committed
969
	  op = FETCH2;
Joseph Arceneaux's avatar
Joseph Arceneaux committed
970
	  if (!NILP (TOP))
Jim Blandy's avatar
Jim Blandy committed
971
	    {
Gerd Moellmann's avatar
Gerd Moellmann committed
972
	      BYTE_CODE_QUIT;
973
	      CHECK_RANGE (op);
Gerd Moellmann's avatar
Gerd Moellmann committed
974
	      stack.pc = stack.byte_string_start + op;
Jim Blandy's avatar
Jim Blandy committed
975
	    }
976
	  else DISCARD (1);
Tom Tromey's avatar
Tom Tromey committed
977
	  NEXT;
978

Tom Tromey's avatar
Tom Tromey committed
979
	CASE (BRgoto):
Richard M. Stallman's avatar
Richard M. Stallman committed
980
	  MAYBE_GC ();
Gerd Moellmann's avatar
Gerd Moellmann committed
981
	  BYTE_CODE_QUIT;
Gerd Moellmann's avatar
Gerd Moellmann committed
982
	  stack.pc += (int) *stack.pc - 127;
Tom Tromey's avatar
Tom Tromey committed
983
	  NEXT;
984

Tom Tromey's avatar
Tom Tromey committed
985
	CASE (BRgotoifnil):
986 987 988 989 990 991 992 993 994 995
	  {
	    Lisp_Object v1;
	    MAYBE_GC ();
	    v1 = POP;
	    if (NILP (v1))
	      {
		BYTE_CODE_QUIT;
		stack.pc += (int) *stack.pc - 128;
	      }
	    stack.pc++;
Tom Tromey's avatar
Tom Tromey committed
996
	    NEXT;
997
	  }
998

Tom Tromey's avatar
Tom Tromey committed
999
	CASE (BRgotoifnonnil):
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
	  {
	    Lisp_Object v1;
	    MAYBE_GC ();
	    v1 = POP;
	    if (!NILP (v1))
	      {
		BYTE_CODE_QUIT;
		stack.pc += (int) *stack.pc - 128;
	      }
	    stack.pc++;
Tom Tromey's avatar
Tom Tromey committed
1010
	    NEXT;
1011
	  }
1012

Tom Tromey's avatar
Tom Tromey committed
1013
	CASE (BRgotoifnilelsepop):
Richard M. Stallman's avatar
Richard M. Stallman committed
1014
	  MAYBE_GC ();
Gerd Moellmann's avatar
Gerd Moellmann committed
1015
	  op = *stack.pc++;
1016 1017
	  if (NILP (TOP))
	    {
Gerd Moellmann's avatar
Gerd Moellmann committed
1018
	      BYTE_CODE_QUIT;
Gerd Moellmann's avatar
Gerd Moellmann committed
1019
	      stack.pc += op - 128;
1020 1021
	    }
	  else DISCARD (1);
Tom Tromey's avatar
Tom Tromey committed
1022
	  NEXT;
1023

Tom Tromey's avatar
Tom Tromey committed
1024
	CASE (BRgotoifnonnilelsepop):
Richard M. Stallman's avatar
Richard M. Stallman committed
1025
	  MAYBE_GC ();
Gerd Moellmann's avatar
Gerd Moellmann committed
1026
	  op = *stack.pc++;
1027 1028
	  if (!NILP (TOP))
	    {
Gerd Moellmann's avatar
Gerd Moellmann committed
1029
	      BYTE_CODE_QUIT;
Gerd Moellmann's avatar
Gerd Moellmann committed
1030
	      stack.pc += op - 128;
1031 1032
	    }
	  else DISCARD (1);
Tom Tromey's avatar
Tom Tromey committed
1033
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
1034

Tom Tromey's avatar
Tom Tromey committed
1035
	CASE (Breturn):
1036
	  result = POP;
Jim Blandy's avatar
Jim Blandy committed
1037 1038
	  goto exit;

Tom Tromey's avatar
Tom Tromey committed
1039
	CASE (Bdiscard):
1040
	  DISCARD (1);
Tom Tromey's avatar
Tom Tromey committed
1041
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
1042

Tom Tromey's avatar
Tom Tromey committed
1043
	CASE (Bconstant2):
Jim Blandy's avatar
Jim Blandy committed
1044
	  PUSH (vectorp[FETCH2]);
Tom Tromey's avatar
Tom Tromey committed
1045
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
1046

Tom Tromey's avatar
Tom Tromey committed
1047
	CASE (Bsave_excursion):
1048 1049
	  record_unwind_protect (save_excursion_restore,
				 save_excursion_save ());
Tom Tromey's avatar
Tom Tromey committed
1050
	  NEXT;
Jim Blandy's avatar
Jim Blandy committed
1051

Tom Tromey's avatar
Tom Tromey committed
1052 1053
	CASE (Bsave_current_buffer): /* Obsolete since ??.  */
	CASE (Bsave_current_buffer_1):
1054
	  record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
Tom Tromey's avatar
Tom Tromey committed
1055
	  NEXT;
1056

Tom Tromey's avatar
Tom Tromey committed
1057
	CASE (Bsave_window_excursion): /* Obsolete since 24.1.  */