Drop idle buffer compaction due to an absence of the
[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
3414f2d8 426#define MAYBE_GC() \
7914961c 427 do { \
3414f2d8
RS
428 if (consing_since_gc > gc_cons_threshold \
429 && consing_since_gc > gc_relative_threshold) \
430 { \
431 BEFORE_POTENTIAL_GC (); \
432 Fgarbage_collect (); \
433 AFTER_POTENTIAL_GC (); \
434 } \
7914961c 435 } while (0)
5e7ed093 436
3d5fc37b 437/* Check for jumping out of range. */
7ca1e8b7
GM
438
439#ifdef BYTE_CODE_SAFE
440
4015b3c0 441#define CHECK_RANGE(ARG) \
3d5fc37b
RS
442 if (ARG >= bytestr_length) abort ()
443
4015b3c0 444#else /* not BYTE_CODE_SAFE */
7ca1e8b7
GM
445
446#define CHECK_RANGE(ARG)
447
4015b3c0 448#endif /* not BYTE_CODE_SAFE */
7ca1e8b7 449
e12ea64e
GM
450/* A version of the QUIT macro which makes sure that the stack top is
451 set before signaling `quit'. */
452
453#define BYTE_CODE_QUIT \
454 do { \
455 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
456 { \
731475e7 457 Lisp_Object flag = Vquit_flag; \
e12ea64e
GM
458 Vquit_flag = Qnil; \
459 BEFORE_POTENTIAL_GC (); \
731475e7 460 if (EQ (Vthrow_on_input, flag)) \
a8f0f551 461 Fthrow (Vthrow_on_input, Qt); \
e12ea64e 462 Fsignal (Qquit, Qnil); \
892a8eb5 463 AFTER_POTENTIAL_GC (); \
e12ea64e 464 } \
c0335e02 465 ELSE_PENDING_SIGNALS \
e12ea64e
GM
466 } while (0)
467
7ca1e8b7 468
36f7ba0a 469DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0,
39f624fa
PJ
470 doc: /* Function used internally in byte-compiled code.
471The first argument, BYTESTR, is a string of byte code;
472the second, VECTOR, a vector of constants;
473the third, MAXDEPTH, the maximum stack depth used in this function.
474If the third argument is incorrect, Emacs may crash. */)
5842a27b 475 (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth)
b9598260 476{
7200d79c 477 return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL);
b9598260
SM
478}
479
480/* Execute the byte-code in BYTESTR. VECTOR is the constant vector, and
481 MAXDEPTH is the maximum stack depth used (if MAXDEPTH is incorrect,
482 emacs may crash!). If ARGS_TEMPLATE is non-nil, it should be a lisp
483 argument list (including &rest, &optional, etc.), and ARGS, of size
484 NARGS, should be a vector of the actual arguments. The arguments in
485 ARGS are pushed on the stack according to ARGS_TEMPLATE before
486 executing BYTESTR. */
487
488Lisp_Object
0ee81a0c 489exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
f66c7cf8 490 Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
36f7ba0a 491{
d311d28c 492 ptrdiff_t count = SPECPDL_INDEX ();
36f7ba0a
JB
493#ifdef BYTE_CODE_METER
494 int this_op = 0;
495 int prev_op;
496#endif
7ca1e8b7 497 int op;
4015b3c0 498 /* Lisp_Object v1, v2; */
089b985f 499 Lisp_Object *vectorp;
36f7ba0a 500#ifdef BYTE_CODE_SAFE
80e88859 501 ptrdiff_t const_length;
7ca1e8b7 502 Lisp_Object *stacke;
39b5db3b 503 ptrdiff_t bytestr_length;
1be4d761 504#endif
7ca1e8b7
GM
505 struct byte_stack stack;
506 Lisp_Object *top;
4015b3c0 507 Lisp_Object result;
36f7ba0a 508
603a0937 509#if 0 /* CHECK_FRAME_FONT */
ad7de7d7
GM
510 {
511 struct frame *f = SELECTED_FRAME ();
512 if (FRAME_X_P (f)
513 && FRAME_FONT (f)->direction != 0
514 && FRAME_FONT (f)->direction != 1)
515 abort ();
516 }
517#endif
518
b7826503 519 CHECK_STRING (bytestr);
c616acb8 520 CHECK_VECTOR (vector);
f66c7cf8 521 CHECK_NATNUM (maxdepth);
36f7ba0a 522
0df1eac5 523#ifdef BYTE_CODE_SAFE
77b37c05 524 const_length = ASIZE (vector);
0df1eac5
PE
525#endif
526
089b985f
KH
527 if (STRING_MULTIBYTE (bytestr))
528 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
529 because they produced a raw 8-bit string for byte-code and now
530 such a byte-code string is loaded as multibyte while raw 8-bit
531 characters converted to multibyte form. Thus, now we must
fbd98f82 532 convert them back to the originally intended unibyte form. */
5274126b 533 bytestr = Fstring_as_unibyte (bytestr);
089b985f 534
1be4d761 535#ifdef BYTE_CODE_SAFE
d5db4077 536 bytestr_length = SBYTES (bytestr);
1be4d761 537#endif
089b985f
KH
538 vectorp = XVECTOR (vector)->contents;
539
7ca1e8b7 540 stack.byte_string = bytestr;
d5db4077 541 stack.pc = stack.byte_string_start = SDATA (bytestr);
7ca1e8b7 542 stack.constants = vector;
39b5db3b
PE
543 if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth))
544 memory_full (SIZE_MAX);
38182d90 545 top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
b286858c 546#if BYTE_MAINTAIN_TOP
39b5db3b 547 stack.bottom = top + 1;
7ca1e8b7 548 stack.top = NULL;
b286858c 549#endif
7ca1e8b7
GM
550 stack.next = byte_stack_list;
551 byte_stack_list = &stack;
36f7ba0a 552
7ca1e8b7
GM
553#ifdef BYTE_CODE_SAFE
554 stacke = stack.bottom - 1 + XFASTINT (maxdepth);
555#endif
8e11578b 556
e2abe5a1 557 if (INTEGERP (args_template))
b9598260 558 {
619e0f19 559 ptrdiff_t at = XINT (args_template);
e2abe5a1
SM
560 int rest = at & 128;
561 int mandatory = at & 127;
619e0f19 562 ptrdiff_t nonrest = at >> 8;
e2abe5a1
SM
563 eassert (mandatory <= nonrest);
564 if (nargs <= nonrest)
565 {
619e0f19 566 ptrdiff_t i;
e2abe5a1
SM
567 for (i = 0 ; i < nargs; i++, args++)
568 PUSH (*args);
569 if (nargs < mandatory)
570 /* Too few arguments. */
571 Fsignal (Qwrong_number_of_arguments,
572 Fcons (Fcons (make_number (mandatory),
573 rest ? Qand_rest : make_number (nonrest)),
574 Fcons (make_number (nargs), Qnil)));
575 else
576 {
577 for (; i < nonrest; i++)
578 PUSH (Qnil);
579 if (rest)
580 PUSH (Qnil);
581 }
582 }
583 else if (rest)
584 {
f66c7cf8 585 ptrdiff_t i;
e2abe5a1
SM
586 for (i = 0 ; i < nonrest; i++, args++)
587 PUSH (*args);
588 PUSH (Flist (nargs - nonrest, args));
589 }
590 else
591 /* Too many arguments. */
b9598260 592 Fsignal (Qwrong_number_of_arguments,
e2abe5a1
SM
593 Fcons (Fcons (make_number (mandatory),
594 make_number (nonrest)),
595 Fcons (make_number (nargs), Qnil)));
596 }
597 else if (! NILP (args_template))
598 /* We should push some arguments on the stack. */
599 {
600 error ("Unknown args template!");
b9598260
SM
601 }
602
36f7ba0a
JB
603 while (1)
604 {
605#ifdef BYTE_CODE_SAFE
9e49c990 606 if (top > stacke)
cc94f3b2 607 abort ();
7ca1e8b7 608 else if (top < stack.bottom - 1)
cc94f3b2 609 abort ();
36f7ba0a
JB
610#endif
611
36f7ba0a
JB
612#ifdef BYTE_CODE_METER
613 prev_op = this_op;
614 this_op = op = FETCH;
615 METER_CODE (prev_op, op);
36f7ba0a 616#else
3a4c8000 617#ifndef BYTE_CODE_THREADED
4015b3c0 618 op = FETCH;
36f7ba0a 619#endif
3a4c8000
TT
620#endif
621
622 /* The interpreter can be compiled one of two ways: as an
623 ordinary switch-based interpreter, or as a threaded
624 interpreter. The threaded interpreter relies on GCC's
625 computed goto extension, so it is not available everywhere.
626 Threading provides a performance boost. These macros are how
627 we allow the code to be compiled both ways. */
628#ifdef BYTE_CODE_THREADED
629 /* The CASE macro introduces an instruction's body. It is
630 either a label or a case label. */
631#define CASE(OP) insn_ ## OP
632 /* NEXT is invoked at the end of an instruction to go to the
633 next instruction. It is either a computed goto, or a
634 plain break. */
635#define NEXT goto *(targets[op = FETCH])
636 /* FIRST is like NEXT, but is only used at the start of the
637 interpreter body. In the switch-based interpreter it is the
638 switch, so the threaded definition must include a semicolon. */
639#define FIRST NEXT;
640 /* Most cases are labeled with the CASE macro, above.
641 CASE_DEFAULT is one exception; it is used if the interpreter
642 being built requires a default case. The threaded
643 interpreter does not, because the dispatch table is
644 completely filled. */
645#define CASE_DEFAULT
646 /* This introduces an instruction that is known to call abort. */
647#define CASE_ABORT CASE (Bstack_ref): CASE (default)
648#else
649 /* See above for the meaning of the various defines. */
650#define CASE(OP) case OP
651#define NEXT break
652#define FIRST switch (op)
653#define CASE_DEFAULT case 255: default:
654#define CASE_ABORT case 0
655#endif
656
657#ifdef BYTE_CODE_THREADED
658
659 /* A convenience define that saves us a lot of typing and makes
660 the table clearer. */
661#define LABEL(OP) [OP] = &&insn_ ## OP
36f7ba0a 662
ffacb126
PE
663#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
664# pragma GCC diagnostic push
665# pragma GCC diagnostic ignored "-Woverride-init"
666#endif
667
3a4c8000
TT
668 /* This is the dispatch table for the threaded interpreter. */
669 static const void *const targets[256] =
4015b3c0 670 {
3a4c8000
TT
671 [0 ... (Bconstant - 1)] = &&insn_default,
672 [Bconstant ... 255] = &&insn_Bconstant,
673
674#define DEFINE(name, value) LABEL (name) ,
675 BYTE_CODES
676#undef DEFINE
677 };
ffacb126
PE
678
679#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
680# pragma GCC diagnostic pop
681#endif
682
3a4c8000
TT
683#endif
684
685
686 FIRST
687 {
688 CASE (Bvarref7):
36f7ba0a
JB
689 op = FETCH2;
690 goto varref;
691
3a4c8000
TT
692 CASE (Bvarref):
693 CASE (Bvarref1):
694 CASE (Bvarref2):
695 CASE (Bvarref3):
696 CASE (Bvarref4):
697 CASE (Bvarref5):
36f7ba0a 698 op = op - Bvarref;
4015b3c0
GM
699 goto varref;
700
701 /* This seems to be the most frequently executed byte-code
702 among the Bvarref's, so avoid a goto here. */
3a4c8000 703 CASE (Bvarref6):
4015b3c0 704 op = FETCH;
36f7ba0a 705 varref:
4015b3c0
GM
706 {
707 Lisp_Object v1, v2;
708
709 v1 = vectorp[op];
710 if (SYMBOLP (v1))
711 {
ce5b453a
SM
712 if (XSYMBOL (v1)->redirect != SYMBOL_PLAINVAL
713 || (v2 = SYMBOL_VAL (XSYMBOL (v1)),
714 EQ (v2, Qunbound)))
bf1de43e
GM
715 {
716 BEFORE_POTENTIAL_GC ();
717 v2 = Fsymbol_value (v1);
718 AFTER_POTENTIAL_GC ();
719 }
4015b3c0
GM
720 }
721 else
bf1de43e
GM
722 {
723 BEFORE_POTENTIAL_GC ();
724 v2 = Fsymbol_value (v1);
725 AFTER_POTENTIAL_GC ();
726 }
4015b3c0 727 PUSH (v2);
3a4c8000 728 NEXT;
4015b3c0
GM
729 }
730
3a4c8000 731 CASE (Bgotoifnil):
21ed6de3
KR
732 {
733 Lisp_Object v1;
734 MAYBE_GC ();
735 op = FETCH2;
736 v1 = POP;
737 if (NILP (v1))
738 {
739 BYTE_CODE_QUIT;
740 CHECK_RANGE (op);
741 stack.pc = stack.byte_string_start + op;
742 }
3a4c8000 743 NEXT;
21ed6de3 744 }
36f7ba0a 745
3a4c8000 746 CASE (Bcar):
4015b3c0
GM
747 {
748 Lisp_Object v1;
749 v1 = TOP;
1c470562
SM
750 if (CONSP (v1))
751 TOP = XCAR (v1);
752 else if (NILP (v1))
753 TOP = Qnil;
754 else
755 {
756 BEFORE_POTENTIAL_GC ();
757 wrong_type_argument (Qlistp, v1);
758 AFTER_POTENTIAL_GC ();
759 }
3a4c8000 760 NEXT;
4015b3c0
GM
761 }
762
3a4c8000 763 CASE (Beq):
4015b3c0
GM
764 {
765 Lisp_Object v1;
766 v1 = POP;
767 TOP = EQ (v1, TOP) ? Qt : Qnil;
3a4c8000 768 NEXT;
4015b3c0
GM
769 }
770
3a4c8000 771 CASE (Bmemq):
4015b3c0
GM
772 {
773 Lisp_Object v1;
bf1de43e 774 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
775 v1 = POP;
776 TOP = Fmemq (TOP, v1);
bf1de43e 777 AFTER_POTENTIAL_GC ();
3a4c8000 778 NEXT;
4015b3c0
GM
779 }
780
3a4c8000 781 CASE (Bcdr):
4015b3c0
GM
782 {
783 Lisp_Object v1;
784 v1 = TOP;
1c470562
SM
785 if (CONSP (v1))
786 TOP = XCDR (v1);
787 else if (NILP (v1))
788 TOP = Qnil;
789 else
790 {
791 BEFORE_POTENTIAL_GC ();
792 wrong_type_argument (Qlistp, v1);
793 AFTER_POTENTIAL_GC ();
794 }
3a4c8000 795 NEXT;
4015b3c0 796 }
36f7ba0a 797
3a4c8000
TT
798 CASE (Bvarset):
799 CASE (Bvarset1):
800 CASE (Bvarset2):
801 CASE (Bvarset3):
802 CASE (Bvarset4):
803 CASE (Bvarset5):
620cc5fa 804 op -= Bvarset;
36f7ba0a
JB
805 goto varset;
806
3a4c8000 807 CASE (Bvarset7):
620cc5fa 808 op = FETCH2;
4015b3c0
GM
809 goto varset;
810
3a4c8000 811 CASE (Bvarset6):
4015b3c0 812 op = FETCH;
36f7ba0a 813 varset:
620cc5fa
GM
814 {
815 Lisp_Object sym, val;
8e11578b 816
620cc5fa 817 sym = vectorp[op];
bf1de43e 818 val = TOP;
620cc5fa
GM
819
820 /* Inline the most common case. */
821 if (SYMBOLP (sym)
822 && !EQ (val, Qunbound)
ce5b453a
SM
823 && !XSYMBOL (sym)->redirect
824 && !SYMBOL_CONSTANT_P (sym))
825 XSYMBOL (sym)->val.value = val;
620cc5fa 826 else
bf1de43e
GM
827 {
828 BEFORE_POTENTIAL_GC ();
94b612ad 829 set_internal (sym, val, Qnil, 0);
bf1de43e
GM
830 AFTER_POTENTIAL_GC ();
831 }
620cc5fa 832 }
3789dcdf 833 (void) POP;
3a4c8000 834 NEXT;
36f7ba0a 835
3a4c8000 836 CASE (Bdup):
4015b3c0
GM
837 {
838 Lisp_Object v1;
839 v1 = TOP;
840 PUSH (v1);
3a4c8000 841 NEXT;
4015b3c0
GM
842 }
843
844 /* ------------------ */
845
3a4c8000 846 CASE (Bvarbind6):
36f7ba0a
JB
847 op = FETCH;
848 goto varbind;
849
3a4c8000 850 CASE (Bvarbind7):
36f7ba0a
JB
851 op = FETCH2;
852 goto varbind;
853
3a4c8000
TT
854 CASE (Bvarbind):
855 CASE (Bvarbind1):
856 CASE (Bvarbind2):
857 CASE (Bvarbind3):
858 CASE (Bvarbind4):
859 CASE (Bvarbind5):
36f7ba0a
JB
860 op -= Bvarbind;
861 varbind:
56b8eef5
GM
862 /* Specbind can signal and thus GC. */
863 BEFORE_POTENTIAL_GC ();
36f7ba0a 864 specbind (vectorp[op], POP);
56b8eef5 865 AFTER_POTENTIAL_GC ();
3a4c8000 866 NEXT;
36f7ba0a 867
3a4c8000 868 CASE (Bcall6):
36f7ba0a
JB
869 op = FETCH;
870 goto docall;
871
3a4c8000 872 CASE (Bcall7):
36f7ba0a
JB
873 op = FETCH2;
874 goto docall;
875
3a4c8000
TT
876 CASE (Bcall):
877 CASE (Bcall1):
878 CASE (Bcall2):
879 CASE (Bcall3):
880 CASE (Bcall4):
881 CASE (Bcall5):
36f7ba0a
JB
882 op -= Bcall;
883 docall:
4015b3c0 884 {
fa9aabf6 885 BEFORE_POTENTIAL_GC ();
4015b3c0 886 DISCARD (op);
63639d44 887#ifdef BYTE_CODE_METER
4015b3c0
GM
888 if (byte_metering_on && SYMBOLP (TOP))
889 {
890 Lisp_Object v1, v2;
891
892 v1 = TOP;
893 v2 = Fget (v1, Qbyte_code_meter);
894 if (INTEGERP (v2)
f28e6371 895 && XINT (v2) < MOST_POSITIVE_FIXNUM)
4015b3c0
GM
896 {
897 XSETINT (v2, XINT (v2) + 1);
898 Fput (v1, Qbyte_code_meter, v2);
899 }
900 }
63639d44 901#endif
4015b3c0
GM
902 TOP = Ffuncall (op + 1, &TOP);
903 AFTER_POTENTIAL_GC ();
3a4c8000 904 NEXT;
4015b3c0 905 }
36f7ba0a 906
3a4c8000 907 CASE (Bunbind6):
36f7ba0a
JB
908 op = FETCH;
909 goto dounbind;
910
3a4c8000 911 CASE (Bunbind7):
36f7ba0a
JB
912 op = FETCH2;
913 goto dounbind;
914
3a4c8000
TT
915 CASE (Bunbind):
916 CASE (Bunbind1):
917 CASE (Bunbind2):
918 CASE (Bunbind3):
919 CASE (Bunbind4):
920 CASE (Bunbind5):
36f7ba0a
JB
921 op -= Bunbind;
922 dounbind:
7ca1e8b7 923 BEFORE_POTENTIAL_GC ();
aed13378 924 unbind_to (SPECPDL_INDEX () - op, Qnil);
7ca1e8b7 925 AFTER_POTENTIAL_GC ();
3a4c8000 926 NEXT;
36f7ba0a 927
3a4c8000 928 CASE (Bunbind_all): /* Obsolete. Never used. */
36f7ba0a 929 /* To unbind back to the beginning of this frame. Not used yet,
63639d44 930 but will be needed for tail-recursion elimination. */
7ca1e8b7 931 BEFORE_POTENTIAL_GC ();
36f7ba0a 932 unbind_to (count, Qnil);
7ca1e8b7 933 AFTER_POTENTIAL_GC ();
3a4c8000 934 NEXT;
36f7ba0a 935
3a4c8000 936 CASE (Bgoto):
14726871 937 MAYBE_GC ();
e12ea64e 938 BYTE_CODE_QUIT;
36f7ba0a 939 op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */
3d5fc37b 940 CHECK_RANGE (op);
7ca1e8b7 941 stack.pc = stack.byte_string_start + op;
3a4c8000 942 NEXT;
36f7ba0a 943
3a4c8000 944 CASE (Bgotoifnonnil):
21ed6de3
KR
945 {
946 Lisp_Object v1;
947 MAYBE_GC ();
948 op = FETCH2;
949 v1 = POP;
950 if (!NILP (v1))
951 {
952 BYTE_CODE_QUIT;
953 CHECK_RANGE (op);
954 stack.pc = stack.byte_string_start + op;
955 }
3a4c8000 956 NEXT;
21ed6de3 957 }
36f7ba0a 958
3a4c8000 959 CASE (Bgotoifnilelsepop):
14726871 960 MAYBE_GC ();
36f7ba0a 961 op = FETCH2;
921a8935 962 if (NILP (TOP))
36f7ba0a 963 {
e12ea64e 964 BYTE_CODE_QUIT;
3d5fc37b 965 CHECK_RANGE (op);
7ca1e8b7 966 stack.pc = stack.byte_string_start + op;
36f7ba0a 967 }
63639d44 968 else DISCARD (1);
3a4c8000 969 NEXT;
36f7ba0a 970
3a4c8000 971 CASE (Bgotoifnonnilelsepop):
14726871 972 MAYBE_GC ();
36f7ba0a 973 op = FETCH2;
921a8935 974 if (!NILP (TOP))
36f7ba0a 975 {
e12ea64e 976 BYTE_CODE_QUIT;
3d5fc37b 977 CHECK_RANGE (op);
7ca1e8b7 978 stack.pc = stack.byte_string_start + op;
36f7ba0a 979 }
63639d44 980 else DISCARD (1);
3a4c8000 981 NEXT;
63639d44 982
3a4c8000 983 CASE (BRgoto):
14726871 984 MAYBE_GC ();
e12ea64e 985 BYTE_CODE_QUIT;
7ca1e8b7 986 stack.pc += (int) *stack.pc - 127;
3a4c8000 987 NEXT;
63639d44 988
3a4c8000 989 CASE (BRgotoifnil):
21ed6de3
KR
990 {
991 Lisp_Object v1;
992 MAYBE_GC ();
993 v1 = POP;
994 if (NILP (v1))
995 {
996 BYTE_CODE_QUIT;
997 stack.pc += (int) *stack.pc - 128;
998 }
999 stack.pc++;
3a4c8000 1000 NEXT;
21ed6de3 1001 }
63639d44 1002
3a4c8000 1003 CASE (BRgotoifnonnil):
21ed6de3
KR
1004 {
1005 Lisp_Object v1;
1006 MAYBE_GC ();
1007 v1 = POP;
1008 if (!NILP (v1))
1009 {
1010 BYTE_CODE_QUIT;
1011 stack.pc += (int) *stack.pc - 128;
1012 }
1013 stack.pc++;
3a4c8000 1014 NEXT;
21ed6de3 1015 }
63639d44 1016
3a4c8000 1017 CASE (BRgotoifnilelsepop):
14726871 1018 MAYBE_GC ();
7ca1e8b7 1019 op = *stack.pc++;
63639d44
JB
1020 if (NILP (TOP))
1021 {
e12ea64e 1022 BYTE_CODE_QUIT;
7ca1e8b7 1023 stack.pc += op - 128;
63639d44
JB
1024 }
1025 else DISCARD (1);
3a4c8000 1026 NEXT;
63639d44 1027
3a4c8000 1028 CASE (BRgotoifnonnilelsepop):
14726871 1029 MAYBE_GC ();
7ca1e8b7 1030 op = *stack.pc++;
63639d44
JB
1031 if (!NILP (TOP))
1032 {
e12ea64e 1033 BYTE_CODE_QUIT;
7ca1e8b7 1034 stack.pc += op - 128;
63639d44
JB
1035 }
1036 else DISCARD (1);
3a4c8000 1037 NEXT;
98bf0c8d 1038
3a4c8000 1039 CASE (Breturn):
4015b3c0 1040 result = POP;
36f7ba0a
JB
1041 goto exit;
1042
3a4c8000 1043 CASE (Bdiscard):
63639d44 1044 DISCARD (1);
3a4c8000 1045 NEXT;
36f7ba0a 1046
3a4c8000 1047 CASE (Bconstant2):
36f7ba0a 1048 PUSH (vectorp[FETCH2]);
3a4c8000 1049 NEXT;
36f7ba0a 1050
3a4c8000 1051 CASE (Bsave_excursion):
fa9aabf6
GM
1052 record_unwind_protect (save_excursion_restore,
1053 save_excursion_save ());
3a4c8000 1054 NEXT;
36f7ba0a 1055
3a4c8000
TT
1056 CASE (Bsave_current_buffer): /* Obsolete since ??. */
1057 CASE (Bsave_current_buffer_1):
de404585 1058 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
3a4c8000 1059 NEXT;
3b841abc 1060
3a4c8000 1061 CASE (Bsave_window_excursion): /* Obsolete since 24.1. */
e0f57e65 1062 {
d311d28c 1063 register ptrdiff_t count1 = SPECPDL_INDEX ();
e0f57e65
SM
1064 record_unwind_protect (Fset_window_configuration,
1065 Fcurrent_window_configuration (Qnil));
1066 BEFORE_POTENTIAL_GC ();
1067 TOP = Fprogn (TOP);
fdfc4bf3 1068 unbind_to (count1, TOP);
e0f57e65 1069 AFTER_POTENTIAL_GC ();
3a4c8000 1070 NEXT;
e0f57e65 1071 }
36f7ba0a 1072
3a4c8000 1073 CASE (Bsave_restriction):
fa9aabf6
GM
1074 record_unwind_protect (save_restriction_restore,
1075 save_restriction_save ());
3a4c8000 1076 NEXT;
36f7ba0a 1077
3a4c8000 1078 CASE (Bcatch): /* FIXME: ill-suited for lexbind. */
4015b3c0
GM
1079 {
1080 Lisp_Object v1;
4015b3c0 1081 BEFORE_POTENTIAL_GC ();
bf1de43e 1082 v1 = POP;
ca105506 1083 TOP = internal_catch (TOP, eval_sub, v1);
4015b3c0 1084 AFTER_POTENTIAL_GC ();
3a4c8000 1085 NEXT;
4015b3c0 1086 }
36f7ba0a 1087
3a4c8000 1088 CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */
ba3fb063 1089 record_unwind_protect (Fprogn, POP);
3a4c8000 1090 NEXT;
36f7ba0a 1091
3a4c8000 1092 CASE (Bcondition_case): /* FIXME: ill-suited for lexbind. */
4015b3c0 1093 {
5c125a13
RS
1094 Lisp_Object handlers, body;
1095 handlers = POP;
1096 body = POP;
4015b3c0 1097 BEFORE_POTENTIAL_GC ();
5c125a13 1098 TOP = internal_lisp_condition_case (TOP, body, handlers);
4015b3c0 1099 AFTER_POTENTIAL_GC ();
3a4c8000 1100 NEXT;
4015b3c0 1101 }
36f7ba0a 1102
3a4c8000 1103 CASE (Btemp_output_buffer_setup): /* Obsolete since 24.1. */
4015b3c0 1104 BEFORE_POTENTIAL_GC ();
b7826503 1105 CHECK_STRING (TOP);
42a5b22f 1106 temp_output_buffer_setup (SSDATA (TOP));
4015b3c0 1107 AFTER_POTENTIAL_GC ();
36f7ba0a 1108 TOP = Vstandard_output;
3a4c8000 1109 NEXT;
36f7ba0a 1110
3a4c8000 1111 CASE (Btemp_output_buffer_show): /* Obsolete since 24.1. */
4015b3c0
GM
1112 {
1113 Lisp_Object v1;
4015b3c0 1114 BEFORE_POTENTIAL_GC ();
bf1de43e 1115 v1 = POP;
4015b3c0
GM
1116 temp_output_buffer_show (TOP);
1117 TOP = v1;
1118 /* pop binding of standard-output */
aed13378 1119 unbind_to (SPECPDL_INDEX () - 1, Qnil);
4015b3c0 1120 AFTER_POTENTIAL_GC ();
3a4c8000 1121 NEXT;
4015b3c0 1122 }
36f7ba0a 1123
3a4c8000 1124 CASE (Bnth):
4015b3c0
GM
1125 {
1126 Lisp_Object v1, v2;
d311d28c 1127 EMACS_INT n;
bf1de43e 1128 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1129 v1 = POP;
1130 v2 = TOP;
b7826503 1131 CHECK_NUMBER (v2);
d311d28c 1132 n = XINT (v2);
4015b3c0 1133 immediate_quit = 1;
d311d28c 1134 while (--n >= 0 && CONSP (v1))
14c5155a 1135 v1 = XCDR (v1);
4015b3c0 1136 immediate_quit = 0;
14c5155a 1137 TOP = CAR (v1);
1c470562 1138 AFTER_POTENTIAL_GC ();
3a4c8000 1139 NEXT;
4015b3c0 1140 }
36f7ba0a 1141
3a4c8000 1142 CASE (Bsymbolp):
617bd3f6 1143 TOP = SYMBOLP (TOP) ? Qt : Qnil;
3a4c8000 1144 NEXT;
36f7ba0a 1145
3a4c8000 1146 CASE (Bconsp):
36f7ba0a 1147 TOP = CONSP (TOP) ? Qt : Qnil;
3a4c8000 1148 NEXT;
36f7ba0a 1149
3a4c8000 1150 CASE (Bstringp):
617bd3f6 1151 TOP = STRINGP (TOP) ? Qt : Qnil;
3a4c8000 1152 NEXT;
36f7ba0a 1153
3a4c8000 1154 CASE (Blistp):
921a8935 1155 TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil;
3a4c8000 1156 NEXT;
36f7ba0a 1157
3a4c8000 1158 CASE (Bnot):
921a8935 1159 TOP = NILP (TOP) ? Qt : Qnil;
3a4c8000 1160 NEXT;
36f7ba0a 1161
3a4c8000 1162 CASE (Bcons):
4015b3c0
GM
1163 {
1164 Lisp_Object v1;
1165 v1 = POP;
1166 TOP = Fcons (TOP, v1);
3a4c8000 1167 NEXT;
4015b3c0 1168 }
36f7ba0a 1169
3a4c8000 1170 CASE (Blist1):
36f7ba0a 1171 TOP = Fcons (TOP, Qnil);
3a4c8000 1172 NEXT;
36f7ba0a 1173
3a4c8000 1174 CASE (Blist2):
4015b3c0
GM
1175 {
1176 Lisp_Object v1;
1177 v1 = POP;
1178 TOP = Fcons (TOP, Fcons (v1, Qnil));
3a4c8000 1179 NEXT;
4015b3c0 1180 }
36f7ba0a 1181
3a4c8000 1182 CASE (Blist3):
63639d44 1183 DISCARD (2);
36f7ba0a 1184 TOP = Flist (3, &TOP);
3a4c8000 1185 NEXT;
36f7ba0a 1186
3a4c8000 1187 CASE (Blist4):
63639d44 1188 DISCARD (3);
36f7ba0a 1189 TOP = Flist (4, &TOP);
3a4c8000 1190 NEXT;
36f7ba0a 1191
3a4c8000 1192 CASE (BlistN):
63639d44
JB
1193 op = FETCH;
1194 DISCARD (op - 1);
1195 TOP = Flist (op, &TOP);
3a4c8000 1196 NEXT;
63639d44 1197
3a4c8000 1198 CASE (Blength):
bf1de43e 1199 BEFORE_POTENTIAL_GC ();
36f7ba0a 1200 TOP = Flength (TOP);
bf1de43e 1201 AFTER_POTENTIAL_GC ();
3a4c8000 1202 NEXT;
36f7ba0a 1203
3a4c8000 1204 CASE (Baref):
4015b3c0
GM
1205 {
1206 Lisp_Object v1;
bf1de43e 1207 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1208 v1 = POP;
1209 TOP = Faref (TOP, v1);
bf1de43e 1210 AFTER_POTENTIAL_GC ();
3a4c8000 1211 NEXT;
4015b3c0 1212 }
36f7ba0a 1213
3a4c8000 1214 CASE (Baset):
4015b3c0
GM
1215 {
1216 Lisp_Object v1, v2;
bf1de43e 1217 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1218 v2 = POP; v1 = POP;
1219 TOP = Faset (TOP, v1, v2);
bf1de43e 1220 AFTER_POTENTIAL_GC ();
3a4c8000 1221 NEXT;
4015b3c0 1222 }
36f7ba0a 1223
3a4c8000 1224 CASE (Bsymbol_value):
bf1de43e 1225 BEFORE_POTENTIAL_GC ();
36f7ba0a 1226 TOP = Fsymbol_value (TOP);
bf1de43e 1227 AFTER_POTENTIAL_GC ();
3a4c8000 1228 NEXT;
36f7ba0a 1229
3a4c8000 1230 CASE (Bsymbol_function):
bf1de43e 1231 BEFORE_POTENTIAL_GC ();
36f7ba0a 1232 TOP = Fsymbol_function (TOP);
bf1de43e 1233 AFTER_POTENTIAL_GC ();
3a4c8000 1234 NEXT;
36f7ba0a 1235
3a4c8000 1236 CASE (Bset):
4015b3c0
GM
1237 {
1238 Lisp_Object v1;
bf1de43e 1239 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1240 v1 = POP;
1241 TOP = Fset (TOP, v1);
bf1de43e 1242 AFTER_POTENTIAL_GC ();
3a4c8000 1243 NEXT;
4015b3c0 1244 }
36f7ba0a 1245
3a4c8000 1246 CASE (Bfset):
4015b3c0
GM
1247 {
1248 Lisp_Object v1;
bf1de43e 1249 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1250 v1 = POP;
1251 TOP = Ffset (TOP, v1);
bf1de43e 1252 AFTER_POTENTIAL_GC ();
3a4c8000 1253 NEXT;
4015b3c0 1254 }
36f7ba0a 1255
3a4c8000 1256 CASE (Bget):
4015b3c0
GM
1257 {
1258 Lisp_Object v1;
bf1de43e 1259 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1260 v1 = POP;
1261 TOP = Fget (TOP, v1);
bf1de43e 1262 AFTER_POTENTIAL_GC ();
3a4c8000 1263 NEXT;
4015b3c0 1264 }
36f7ba0a 1265
3a4c8000 1266 CASE (Bsubstring):
4015b3c0
GM
1267 {
1268 Lisp_Object v1, v2;
fa9aabf6 1269 BEFORE_POTENTIAL_GC ();
bf1de43e 1270 v2 = POP; v1 = POP;
4015b3c0 1271 TOP = Fsubstring (TOP, v1, v2);
fa9aabf6 1272 AFTER_POTENTIAL_GC ();
3a4c8000 1273 NEXT;
4015b3c0 1274 }
36f7ba0a 1275
3a4c8000 1276 CASE (Bconcat2):
bf1de43e 1277 BEFORE_POTENTIAL_GC ();
63639d44 1278 DISCARD (1);
36f7ba0a 1279 TOP = Fconcat (2, &TOP);
bf1de43e 1280 AFTER_POTENTIAL_GC ();
3a4c8000 1281 NEXT;
36f7ba0a 1282
3a4c8000 1283 CASE (Bconcat3):
bf1de43e 1284 BEFORE_POTENTIAL_GC ();
63639d44 1285 DISCARD (2);
36f7ba0a 1286 TOP = Fconcat (3, &TOP);
bf1de43e 1287 AFTER_POTENTIAL_GC ();
3a4c8000 1288 NEXT;
36f7ba0a 1289
3a4c8000 1290 CASE (Bconcat4):
bf1de43e 1291 BEFORE_POTENTIAL_GC ();
63639d44 1292 DISCARD (3);
36f7ba0a 1293 TOP = Fconcat (4, &TOP);
bf1de43e 1294 AFTER_POTENTIAL_GC ();
3a4c8000 1295 NEXT;
36f7ba0a 1296
3a4c8000 1297 CASE (BconcatN):
63639d44 1298 op = FETCH;
bf1de43e 1299 BEFORE_POTENTIAL_GC ();
63639d44
JB
1300 DISCARD (op - 1);
1301 TOP = Fconcat (op, &TOP);
bf1de43e 1302 AFTER_POTENTIAL_GC ();
3a4c8000 1303 NEXT;
63639d44 1304
3a4c8000 1305 CASE (Bsub1):
4015b3c0
GM
1306 {
1307 Lisp_Object v1;
1308 v1 = TOP;
1309 if (INTEGERP (v1))
1310 {
1311 XSETINT (v1, XINT (v1) - 1);
1312 TOP = v1;
1313 }
1314 else
e494eee5
MB
1315 {
1316 BEFORE_POTENTIAL_GC ();
1317 TOP = Fsub1 (v1);
1318 AFTER_POTENTIAL_GC ();
1319 }
3a4c8000 1320 NEXT;
4015b3c0 1321 }
36f7ba0a 1322
3a4c8000 1323 CASE (Badd1):
4015b3c0
GM
1324 {
1325 Lisp_Object v1;
1326 v1 = TOP;
1327 if (INTEGERP (v1))
1328 {
1329 XSETINT (v1, XINT (v1) + 1);
1330 TOP = v1;
1331 }
1332 else
bf1de43e
GM
1333 {
1334 BEFORE_POTENTIAL_GC ();
1335 TOP = Fadd1 (v1);
1336 AFTER_POTENTIAL_GC ();
1337 }
3a4c8000 1338 NEXT;
4015b3c0 1339 }
36f7ba0a 1340
3a4c8000 1341 CASE (Beqlsign):
4015b3c0
GM
1342 {
1343 Lisp_Object v1, v2;
f5941bf8 1344 BEFORE_POTENTIAL_GC ();
bf1de43e 1345 v2 = POP; v1 = TOP;
b7826503
PJ
1346 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1);
1347 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2);
f5941bf8 1348 AFTER_POTENTIAL_GC ();
4015b3c0
GM
1349 if (FLOATP (v1) || FLOATP (v2))
1350 {
1351 double f1, f2;
1352
1353 f1 = (FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1));
1354 f2 = (FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2));
1355 TOP = (f1 == f2 ? Qt : Qnil);
1356 }
1357 else
4015b3c0 1358 TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil);
3a4c8000 1359 NEXT;
4015b3c0 1360 }
36f7ba0a 1361
3a4c8000 1362 CASE (Bgtr):
4015b3c0
GM
1363 {
1364 Lisp_Object v1;
bf1de43e 1365 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1366 v1 = POP;
1367 TOP = Fgtr (TOP, v1);
bf1de43e 1368 AFTER_POTENTIAL_GC ();
3a4c8000 1369 NEXT;
4015b3c0 1370 }
36f7ba0a 1371
3a4c8000 1372 CASE (Blss):
4015b3c0
GM
1373 {
1374 Lisp_Object v1;
bf1de43e 1375 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1376 v1 = POP;
1377 TOP = Flss (TOP, v1);
bf1de43e 1378 AFTER_POTENTIAL_GC ();
3a4c8000 1379 NEXT;
4015b3c0 1380 }
36f7ba0a 1381
3a4c8000 1382 CASE (Bleq):
4015b3c0
GM
1383 {
1384 Lisp_Object v1;
bf1de43e 1385 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1386 v1 = POP;
1387 TOP = Fleq (TOP, v1);
bf1de43e 1388 AFTER_POTENTIAL_GC ();
3a4c8000 1389 NEXT;
4015b3c0 1390 }
36f7ba0a 1391
3a4c8000 1392 CASE (Bgeq):
4015b3c0
GM
1393 {
1394 Lisp_Object v1;
d9c1f6f9 1395 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1396 v1 = POP;
1397 TOP = Fgeq (TOP, v1);
d9c1f6f9 1398 AFTER_POTENTIAL_GC ();
3a4c8000 1399 NEXT;
4015b3c0 1400 }
36f7ba0a 1401
3a4c8000 1402 CASE (Bdiff):
bf1de43e 1403 BEFORE_POTENTIAL_GC ();
63639d44 1404 DISCARD (1);
36f7ba0a 1405 TOP = Fminus (2, &TOP);
bf1de43e 1406 AFTER_POTENTIAL_GC ();
3a4c8000 1407 NEXT;
36f7ba0a 1408
3a4c8000 1409 CASE (Bnegate):
4015b3c0
GM
1410 {
1411 Lisp_Object v1;
1412 v1 = TOP;
1413 if (INTEGERP (v1))
1414 {
1415 XSETINT (v1, - XINT (v1));
1416 TOP = v1;
1417 }
1418 else
bf1de43e
GM
1419 {
1420 BEFORE_POTENTIAL_GC ();
1421 TOP = Fminus (1, &TOP);
1422 AFTER_POTENTIAL_GC ();
1423 }
3a4c8000 1424 NEXT;
4015b3c0 1425 }
36f7ba0a 1426
3a4c8000 1427 CASE (Bplus):
bf1de43e 1428 BEFORE_POTENTIAL_GC ();
63639d44 1429 DISCARD (1);
36f7ba0a 1430 TOP = Fplus (2, &TOP);
bf1de43e 1431 AFTER_POTENTIAL_GC ();
3a4c8000 1432 NEXT;
36f7ba0a 1433
3a4c8000 1434 CASE (Bmax):
bf1de43e 1435 BEFORE_POTENTIAL_GC ();
63639d44 1436 DISCARD (1);
36f7ba0a 1437 TOP = Fmax (2, &TOP);
bf1de43e 1438 AFTER_POTENTIAL_GC ();
3a4c8000 1439 NEXT;
36f7ba0a 1440
3a4c8000 1441 CASE (Bmin):
bf1de43e 1442 BEFORE_POTENTIAL_GC ();
63639d44 1443 DISCARD (1);
36f7ba0a 1444 TOP = Fmin (2, &TOP);
bf1de43e 1445 AFTER_POTENTIAL_GC ();
3a4c8000 1446 NEXT;
36f7ba0a 1447
3a4c8000 1448 CASE (Bmult):
bf1de43e 1449 BEFORE_POTENTIAL_GC ();
63639d44 1450 DISCARD (1);
36f7ba0a 1451 TOP = Ftimes (2, &TOP);
bf1de43e 1452 AFTER_POTENTIAL_GC ();
3a4c8000 1453 NEXT;
36f7ba0a 1454
3a4c8000 1455 CASE (Bquo):
bf1de43e 1456 BEFORE_POTENTIAL_GC ();
63639d44 1457 DISCARD (1);
36f7ba0a 1458 TOP = Fquo (2, &TOP);
bf1de43e 1459 AFTER_POTENTIAL_GC ();
3a4c8000 1460 NEXT;
36f7ba0a 1461
3a4c8000 1462 CASE (Brem):
4015b3c0
GM
1463 {
1464 Lisp_Object v1;
bf1de43e 1465 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1466 v1 = POP;
1467 TOP = Frem (TOP, v1);
bf1de43e 1468 AFTER_POTENTIAL_GC ();
3a4c8000 1469 NEXT;
4015b3c0 1470 }
36f7ba0a 1471
3a4c8000 1472 CASE (Bpoint):
4015b3c0
GM
1473 {
1474 Lisp_Object v1;
1475 XSETFASTINT (v1, PT);
1476 PUSH (v1);
3a4c8000 1477 NEXT;
4015b3c0 1478 }
36f7ba0a 1479
3a4c8000 1480 CASE (Bgoto_char):
4015b3c0 1481 BEFORE_POTENTIAL_GC ();
36f7ba0a 1482 TOP = Fgoto_char (TOP);
4015b3c0 1483 AFTER_POTENTIAL_GC ();
3a4c8000 1484 NEXT;
36f7ba0a 1485
3a4c8000 1486 CASE (Binsert):
4015b3c0 1487 BEFORE_POTENTIAL_GC ();
36f7ba0a 1488 TOP = Finsert (1, &TOP);
4015b3c0 1489 AFTER_POTENTIAL_GC ();
3a4c8000 1490 NEXT;
36f7ba0a 1491
3a4c8000 1492 CASE (BinsertN):
63639d44 1493 op = FETCH;
4015b3c0 1494 BEFORE_POTENTIAL_GC ();
fa9aabf6 1495 DISCARD (op - 1);
63639d44 1496 TOP = Finsert (op, &TOP);
4015b3c0 1497 AFTER_POTENTIAL_GC ();
3a4c8000 1498 NEXT;
63639d44 1499
3a4c8000 1500 CASE (Bpoint_max):
4015b3c0
GM
1501 {
1502 Lisp_Object v1;
1503 XSETFASTINT (v1, ZV);
1504 PUSH (v1);
3a4c8000 1505 NEXT;
4015b3c0 1506 }
36f7ba0a 1507
3a4c8000 1508 CASE (Bpoint_min):
4015b3c0
GM
1509 {
1510 Lisp_Object v1;
1511 XSETFASTINT (v1, BEGV);
1512 PUSH (v1);
3a4c8000 1513 NEXT;
4015b3c0 1514 }
36f7ba0a 1515
3a4c8000 1516 CASE (Bchar_after):
bf1de43e 1517 BEFORE_POTENTIAL_GC ();
36f7ba0a 1518 TOP = Fchar_after (TOP);
bf1de43e 1519 AFTER_POTENTIAL_GC ();
3a4c8000 1520 NEXT;
36f7ba0a 1521
3a4c8000 1522 CASE (Bfollowing_char):
4015b3c0
GM
1523 {
1524 Lisp_Object v1;
bf1de43e 1525 BEFORE_POTENTIAL_GC ();
4015b3c0 1526 v1 = Ffollowing_char ();
bf1de43e 1527 AFTER_POTENTIAL_GC ();
4015b3c0 1528 PUSH (v1);
3a4c8000 1529 NEXT;
4015b3c0 1530 }
36f7ba0a 1531
3a4c8000 1532 CASE (Bpreceding_char):
4015b3c0
GM
1533 {
1534 Lisp_Object v1;
bf1de43e 1535 BEFORE_POTENTIAL_GC ();
4015b3c0 1536 v1 = Fprevious_char ();
bf1de43e 1537 AFTER_POTENTIAL_GC ();
4015b3c0 1538 PUSH (v1);
3a4c8000 1539 NEXT;
4015b3c0 1540 }
36f7ba0a 1541
3a4c8000 1542 CASE (Bcurrent_column):
4015b3c0
GM
1543 {
1544 Lisp_Object v1;
96111f48 1545 BEFORE_POTENTIAL_GC ();
7831777b 1546 XSETFASTINT (v1, current_column ());
96111f48 1547 AFTER_POTENTIAL_GC ();
4015b3c0 1548 PUSH (v1);
3a4c8000 1549 NEXT;
4015b3c0 1550 }
36f7ba0a 1551
3a4c8000 1552 CASE (Bindent_to):
4015b3c0 1553 BEFORE_POTENTIAL_GC ();
36f7ba0a 1554 TOP = Findent_to (TOP, Qnil);
4015b3c0 1555 AFTER_POTENTIAL_GC ();
3a4c8000 1556 NEXT;
36f7ba0a 1557
3a4c8000 1558 CASE (Beolp):
36f7ba0a 1559 PUSH (Feolp ());
3a4c8000 1560 NEXT;
36f7ba0a 1561
3a4c8000 1562 CASE (Beobp):
36f7ba0a 1563 PUSH (Feobp ());
3a4c8000 1564 NEXT;
36f7ba0a 1565
3a4c8000 1566 CASE (Bbolp):
36f7ba0a 1567 PUSH (Fbolp ());
3a4c8000 1568 NEXT;
36f7ba0a 1569
3a4c8000 1570 CASE (Bbobp):
36f7ba0a 1571 PUSH (Fbobp ());
3a4c8000 1572 NEXT;
36f7ba0a 1573
3a4c8000 1574 CASE (Bcurrent_buffer):
36f7ba0a 1575 PUSH (Fcurrent_buffer ());
3a4c8000 1576 NEXT;
36f7ba0a 1577
3a4c8000 1578 CASE (Bset_buffer):
4015b3c0 1579 BEFORE_POTENTIAL_GC ();
36f7ba0a 1580 TOP = Fset_buffer (TOP);
4015b3c0 1581 AFTER_POTENTIAL_GC ();
3a4c8000 1582 NEXT;
36f7ba0a 1583
3a4c8000 1584 CASE (Binteractive_p): /* Obsolete since 24.1. */
36f7ba0a 1585 PUSH (Finteractive_p ());
3a4c8000 1586 NEXT;
36f7ba0a 1587
3a4c8000 1588 CASE (Bforward_char):
4015b3c0 1589 BEFORE_POTENTIAL_GC ();
36f7ba0a 1590 TOP = Fforward_char (TOP);
4015b3c0 1591 AFTER_POTENTIAL_GC ();
3a4c8000 1592 NEXT;
36f7ba0a 1593
3a4c8000 1594 CASE (Bforward_word):
4015b3c0 1595 BEFORE_POTENTIAL_GC ();
36f7ba0a 1596 TOP = Fforward_word (TOP);
4015b3c0 1597 AFTER_POTENTIAL_GC ();
3a4c8000 1598 NEXT;
36f7ba0a 1599
3a4c8000 1600 CASE (Bskip_chars_forward):
4015b3c0
GM
1601 {
1602 Lisp_Object v1;
4015b3c0 1603 BEFORE_POTENTIAL_GC ();
bf1de43e 1604 v1 = POP;
4015b3c0
GM
1605 TOP = Fskip_chars_forward (TOP, v1);
1606 AFTER_POTENTIAL_GC ();
3a4c8000 1607 NEXT;
4015b3c0 1608 }
36f7ba0a 1609
3a4c8000 1610 CASE (Bskip_chars_backward):
4015b3c0
GM
1611 {
1612 Lisp_Object v1;
4015b3c0 1613 BEFORE_POTENTIAL_GC ();
bf1de43e 1614 v1 = POP;
4015b3c0
GM
1615 TOP = Fskip_chars_backward (TOP, v1);
1616 AFTER_POTENTIAL_GC ();
3a4c8000 1617 NEXT;
4015b3c0 1618 }
36f7ba0a 1619
3a4c8000 1620 CASE (Bforward_line):
4015b3c0 1621 BEFORE_POTENTIAL_GC ();
36f7ba0a 1622 TOP = Fforward_line (TOP);
4015b3c0 1623 AFTER_POTENTIAL_GC ();
3a4c8000 1624 NEXT;
36f7ba0a 1625
3a4c8000 1626 CASE (Bchar_syntax):
9281d077
KH
1627 {
1628 int c;
1629
1630 BEFORE_POTENTIAL_GC ();
1631 CHECK_CHARACTER (TOP);
1632 AFTER_POTENTIAL_GC ();
1633 c = XFASTINT (TOP);
4b4deea2 1634 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
9281d077
KH
1635 MAKE_CHAR_MULTIBYTE (c);
1636 XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (c)]);
8f924df7 1637 }
3a4c8000 1638 NEXT;
36f7ba0a 1639
3a4c8000 1640 CASE (Bbuffer_substring):
4015b3c0
GM
1641 {
1642 Lisp_Object v1;
4015b3c0 1643 BEFORE_POTENTIAL_GC ();
bf1de43e 1644 v1 = POP;
4015b3c0
GM
1645 TOP = Fbuffer_substring (TOP, v1);
1646 AFTER_POTENTIAL_GC ();
3a4c8000 1647 NEXT;
4015b3c0 1648 }
36f7ba0a 1649
3a4c8000 1650 CASE (Bdelete_region):
4015b3c0
GM
1651 {
1652 Lisp_Object v1;
4015b3c0 1653 BEFORE_POTENTIAL_GC ();
bf1de43e 1654 v1 = POP;
4015b3c0
GM
1655 TOP = Fdelete_region (TOP, v1);
1656 AFTER_POTENTIAL_GC ();
3a4c8000 1657 NEXT;
4015b3c0 1658 }
36f7ba0a 1659
3a4c8000 1660 CASE (Bnarrow_to_region):
4015b3c0
GM
1661 {
1662 Lisp_Object v1;
4015b3c0 1663 BEFORE_POTENTIAL_GC ();
bf1de43e 1664 v1 = POP;
4015b3c0
GM
1665 TOP = Fnarrow_to_region (TOP, v1);
1666 AFTER_POTENTIAL_GC ();
3a4c8000 1667 NEXT;
4015b3c0 1668 }
36f7ba0a 1669
3a4c8000 1670 CASE (Bwiden):
4015b3c0 1671 BEFORE_POTENTIAL_GC ();
36f7ba0a 1672 PUSH (Fwiden ());
4015b3c0 1673 AFTER_POTENTIAL_GC ();
3a4c8000 1674 NEXT;
36f7ba0a 1675
3a4c8000 1676 CASE (Bend_of_line):
4015b3c0 1677 BEFORE_POTENTIAL_GC ();
63639d44 1678 TOP = Fend_of_line (TOP);
4015b3c0 1679 AFTER_POTENTIAL_GC ();
3a4c8000 1680 NEXT;
63639d44 1681
3a4c8000 1682 CASE (Bset_marker):
4015b3c0
GM
1683 {
1684 Lisp_Object v1, v2;
bf1de43e 1685 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1686 v1 = POP;
1687 v2 = POP;
1688 TOP = Fset_marker (TOP, v2, v1);
bf1de43e 1689 AFTER_POTENTIAL_GC ();
3a4c8000 1690 NEXT;
4015b3c0 1691 }
63639d44 1692
3a4c8000 1693 CASE (Bmatch_beginning):
bf1de43e 1694 BEFORE_POTENTIAL_GC ();
63639d44 1695 TOP = Fmatch_beginning (TOP);
bf1de43e 1696 AFTER_POTENTIAL_GC ();
3a4c8000 1697 NEXT;
63639d44 1698
3a4c8000 1699 CASE (Bmatch_end):
bf1de43e 1700 BEFORE_POTENTIAL_GC ();
63639d44 1701 TOP = Fmatch_end (TOP);
bf1de43e 1702 AFTER_POTENTIAL_GC ();
3a4c8000 1703 NEXT;
63639d44 1704
3a4c8000 1705 CASE (Bupcase):
bf1de43e 1706 BEFORE_POTENTIAL_GC ();
63639d44 1707 TOP = Fupcase (TOP);
bf1de43e 1708 AFTER_POTENTIAL_GC ();
3a4c8000 1709 NEXT;
63639d44 1710
3a4c8000 1711 CASE (Bdowncase):
bf1de43e 1712 BEFORE_POTENTIAL_GC ();
63639d44 1713 TOP = Fdowncase (TOP);
bf1de43e 1714 AFTER_POTENTIAL_GC ();
3a4c8000 1715 NEXT;
63639d44 1716
3a4c8000 1717 CASE (Bstringeqlsign):
4015b3c0
GM
1718 {
1719 Lisp_Object v1;
bf1de43e 1720 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1721 v1 = POP;
1722 TOP = Fstring_equal (TOP, v1);
bf1de43e 1723 AFTER_POTENTIAL_GC ();
3a4c8000 1724 NEXT;
4015b3c0 1725 }
36f7ba0a 1726
3a4c8000 1727 CASE (Bstringlss):
4015b3c0
GM
1728 {
1729 Lisp_Object v1;
bf1de43e 1730 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1731 v1 = POP;
1732 TOP = Fstring_lessp (TOP, v1);
bf1de43e 1733 AFTER_POTENTIAL_GC ();
3a4c8000 1734 NEXT;
4015b3c0 1735 }
36f7ba0a 1736
3a4c8000 1737 CASE (Bequal):
4015b3c0
GM
1738 {
1739 Lisp_Object v1;
1740 v1 = POP;
1741 TOP = Fequal (TOP, v1);
3a4c8000 1742 NEXT;
4015b3c0 1743 }
36f7ba0a 1744
3a4c8000 1745 CASE (Bnthcdr):
4015b3c0
GM
1746 {
1747 Lisp_Object v1;
bf1de43e 1748 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1749 v1 = POP;
1750 TOP = Fnthcdr (TOP, v1);
bf1de43e 1751 AFTER_POTENTIAL_GC ();
3a4c8000 1752 NEXT;
4015b3c0 1753 }
36f7ba0a 1754
3a4c8000 1755 CASE (Belt):
4015b3c0
GM
1756 {
1757 Lisp_Object v1, v2;
1758 if (CONSP (TOP))
1759 {
1760 /* Exchange args and then do nth. */
d311d28c 1761 EMACS_INT n;
bf1de43e 1762 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1763 v2 = POP;
1764 v1 = TOP;
b7826503 1765 CHECK_NUMBER (v2);
f5941bf8 1766 AFTER_POTENTIAL_GC ();
d311d28c 1767 n = XINT (v2);
4015b3c0 1768 immediate_quit = 1;
d311d28c 1769 while (--n >= 0 && CONSP (v1))
14c5155a 1770 v1 = XCDR (v1);
4015b3c0 1771 immediate_quit = 0;
14c5155a 1772 TOP = CAR (v1);
4015b3c0
GM
1773 }
1774 else
1775 {
bf1de43e 1776 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1777 v1 = POP;
1778 TOP = Felt (TOP, v1);
bf1de43e 1779 AFTER_POTENTIAL_GC ();
4015b3c0 1780 }
3a4c8000 1781 NEXT;
4015b3c0 1782 }
36f7ba0a 1783
3a4c8000 1784 CASE (Bmember):
4015b3c0
GM
1785 {
1786 Lisp_Object v1;
bf1de43e 1787 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1788 v1 = POP;
1789 TOP = Fmember (TOP, v1);
bf1de43e 1790 AFTER_POTENTIAL_GC ();
3a4c8000 1791 NEXT;
4015b3c0 1792 }
36f7ba0a 1793
3a4c8000 1794 CASE (Bassq):
4015b3c0
GM
1795 {
1796 Lisp_Object v1;
bf1de43e 1797 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1798 v1 = POP;
1799 TOP = Fassq (TOP, v1);
bf1de43e 1800 AFTER_POTENTIAL_GC ();
3a4c8000 1801 NEXT;
4015b3c0 1802 }
36f7ba0a 1803
3a4c8000 1804 CASE (Bnreverse):
bf1de43e 1805 BEFORE_POTENTIAL_GC ();
36f7ba0a 1806 TOP = Fnreverse (TOP);
bf1de43e 1807 AFTER_POTENTIAL_GC ();
3a4c8000 1808 NEXT;
36f7ba0a 1809
3a4c8000 1810 CASE (Bsetcar):
4015b3c0
GM
1811 {
1812 Lisp_Object v1;
bf1de43e 1813 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1814 v1 = POP;
1815 TOP = Fsetcar (TOP, v1);
bf1de43e 1816 AFTER_POTENTIAL_GC ();
3a4c8000 1817 NEXT;
4015b3c0 1818 }
36f7ba0a 1819
3a4c8000 1820 CASE (Bsetcdr):
4015b3c0
GM
1821 {
1822 Lisp_Object v1;
bf1de43e 1823 BEFORE_POTENTIAL_GC ();
4015b3c0
GM
1824 v1 = POP;
1825 TOP = Fsetcdr (TOP, v1);
bf1de43e 1826 AFTER_POTENTIAL_GC ();
3a4c8000 1827 NEXT;
4015b3c0 1828 }
36f7ba0a 1829
3a4c8000 1830 CASE (Bcar_safe):
4015b3c0
GM
1831 {
1832 Lisp_Object v1;
1833 v1 = TOP;
14c5155a 1834 TOP = CAR_SAFE (v1);
3a4c8000 1835 NEXT;
4015b3c0 1836 }
36f7ba0a 1837
3a4c8000 1838 CASE (Bcdr_safe):
4015b3c0
GM
1839 {
1840 Lisp_Object v1;
1841 v1 = TOP;
14c5155a 1842 TOP = CDR_SAFE (v1);
3a4c8000 1843 NEXT;
4015b3c0 1844 }
36f7ba0a 1845
3a4c8000 1846 CASE (Bnconc):
bf1de43e 1847 BEFORE_POTENTIAL_GC ();
63639d44 1848 DISCARD (1);
36f7ba0a 1849 TOP = Fnconc (2, &TOP);
bf1de43e 1850 AFTER_POTENTIAL_GC ();
3a4c8000 1851 NEXT;
36f7ba0a 1852
3a4c8000 1853 CASE (Bnumberp):
63639d44 1854 TOP = (NUMBERP (TOP) ? Qt : Qnil);
3a4c8000 1855 NEXT;
36f7ba0a 1856
3a4c8000 1857 CASE (Bintegerp):
617bd3f6 1858 TOP = INTEGERP (TOP) ? Qt : Qnil;
3a4c8000 1859 NEXT;
36f7ba0a
JB
1860
1861#ifdef BYTE_CODE_SAFE
3a4c8000
TT
1862 /* These are intentionally written using 'case' syntax,
1863 because they are incompatible with the threaded
1864 interpreter. */
1865
36f7ba0a 1866 case Bset_mark:
f5941bf8 1867 BEFORE_POTENTIAL_GC ();
36f7ba0a 1868 error ("set-mark is an obsolete bytecode");
f5941bf8 1869 AFTER_POTENTIAL_GC ();
36f7ba0a
JB
1870 break;
1871 case Bscan_buffer:
f5941bf8 1872 BEFORE_POTENTIAL_GC ();
36f7ba0a 1873 error ("scan-buffer is an obsolete bytecode");
f5941bf8 1874 AFTER_POTENTIAL_GC ();
36f7ba0a 1875 break;
36f7ba0a
JB
1876#endif
1877
3a4c8000 1878 CASE_ABORT:
876c194c
SM
1879 /* Actually this is Bstack_ref with offset 0, but we use Bdup
1880 for that instead. */
3a4c8000 1881 /* CASE (Bstack_ref): */
c96d71f7
RS
1882 abort ();
1883
b9598260 1884 /* Handy byte-codes for lexical binding. */
3a4c8000
TT
1885 CASE (Bstack_ref1):
1886 CASE (Bstack_ref2):
1887 CASE (Bstack_ref3):
1888 CASE (Bstack_ref4):
1889 CASE (Bstack_ref5):
3e21b6a7
SM
1890 {
1891 Lisp_Object *ptr = top - (op - Bstack_ref);
1892 PUSH (*ptr);
3a4c8000 1893 NEXT;
3e21b6a7 1894 }
3a4c8000 1895 CASE (Bstack_ref6):
3e21b6a7
SM
1896 {
1897 Lisp_Object *ptr = top - (FETCH);
1898 PUSH (*ptr);
3a4c8000 1899 NEXT;
3e21b6a7 1900 }
3a4c8000 1901 CASE (Bstack_ref7):
3e21b6a7
SM
1902 {
1903 Lisp_Object *ptr = top - (FETCH2);
1904 PUSH (*ptr);
3a4c8000 1905 NEXT;
3e21b6a7 1906 }
3a4c8000 1907 CASE (Bstack_set):
2462470b 1908 /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */
3e21b6a7
SM
1909 {
1910 Lisp_Object *ptr = top - (FETCH);
1911 *ptr = POP;
3a4c8000 1912 NEXT;
3e21b6a7 1913 }
3a4c8000 1914 CASE (Bstack_set2):
3e21b6a7
SM
1915 {
1916 Lisp_Object *ptr = top - (FETCH2);
1917 *ptr = POP;
3a4c8000 1918 NEXT;
3e21b6a7 1919 }
3a4c8000 1920 CASE (BdiscardN):
b9598260
SM
1921 op = FETCH;
1922 if (op & 0x80)
1923 {
1924 op &= 0x7F;
1925 top[-op] = TOP;
1926 }
1927 DISCARD (op);
3a4c8000 1928 NEXT;
c96d71f7 1929
3a4c8000
TT
1930 CASE_DEFAULT
1931 CASE (Bconstant):
36f7ba0a
JB
1932#ifdef BYTE_CODE_SAFE
1933 if (op < Bconstant)
f5941bf8 1934 {
cc94f3b2 1935 abort ();
f5941bf8 1936 }
36f7ba0a 1937 if ((op -= Bconstant) >= const_length)
f5941bf8 1938 {
cc94f3b2 1939 abort ();
f5941bf8 1940 }
36f7ba0a
JB
1941 PUSH (vectorp[op]);
1942#else
1943 PUSH (vectorp[op - Bconstant]);
1944#endif
3a4c8000 1945 NEXT;
36f7ba0a
JB
1946 }
1947 }
1948
1949 exit:
7ca1e8b7
GM
1950
1951 byte_stack_list = byte_stack_list->next;
1952
36f7ba0a 1953 /* Binds and unbinds are supposed to be compiled balanced. */
aed13378 1954 if (SPECPDL_INDEX () != count)
36f7ba0a
JB
1955#ifdef BYTE_CODE_SAFE
1956 error ("binding stack not balanced (serious byte compiler bug)");
1957#else
1958 abort ();
1959#endif
8e11578b 1960
4015b3c0 1961 return result;
36f7ba0a
JB
1962}
1963
dfcf069d 1964void
971de7fb 1965syms_of_bytecode (void)
36f7ba0a 1966{
cd3520a4 1967 DEFSYM (Qbytecode, "byte-code");
36f7ba0a
JB
1968
1969 defsubr (&Sbyte_code);
1970
1971#ifdef BYTE_CODE_METER
1972
29208e82 1973 DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter,
39f624fa
PJ
1974 doc: /* A vector of vectors which holds a histogram of byte-code usage.
1975\(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1976opcode CODE has been executed.
1977\(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1978indicates how many times the byte opcodes CODE1 and CODE2 have been
1979executed in succession. */);
8e11578b 1980
29208e82 1981 DEFVAR_BOOL ("byte-metering-on", byte_metering_on,
39f624fa
PJ
1982 doc: /* If non-nil, keep profiling information on byte code usage.
1983The variable byte-code-meter indicates how often each byte opcode is used.
1984If a symbol has a property named `byte-code-meter' whose value is an
1985integer, it is incremented each time that symbol's function is called. */);
36f7ba0a
JB
1986
1987 byte_metering_on = 0;
63639d44 1988 Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0));
cd3520a4 1989 DEFSYM (Qbyte_code_meter, "byte-code-meter");
36f7ba0a
JB
1990 {
1991 int i = 256;
1992 while (i--)
28be1ada
DA
1993 ASET (Vbyte_code_meter, i,
1994 Fmake_vector (make_number (256), make_number (0)));
36f7ba0a
JB
1995 }
1996#endif
1997}