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