(window_loop) <GET_BUFFER_WINDOW>: Prefer to return
[bpt/emacs.git] / src / bytecode.c
1 /* Execution of byte code produced by bytecomp.el.
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 2000 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20
21 hacked on by jwz@lucid.com 17-jun-91
22 o added a compile-time switch to turn on simple sanity checking;
23 o put back the obsolete byte-codes for error-detection;
24 o added a new instruction, unbind_all, which I will use for
25 tail-recursion elimination;
26 o made temp_output_buffer_show be called with the right number
27 of args;
28 o made the new bytecodes be called with args in the right order;
29 o added metering support.
30
31 by Hallvard:
32 o added relative jump instructions;
33 o all conditionals now only do QUIT if they jump.
34 */
35
36 #include <config.h>
37 #include "lisp.h"
38 #include "buffer.h"
39 #include "charset.h"
40 #include "syntax.h"
41
42 #ifdef CHECK_FRAME_FONT
43 #include "frame.h"
44 #include "xterm.h"
45 #endif
46
47 /*
48 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
49 * debugging the byte compiler...)
50 *
51 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
52 */
53 /* #define BYTE_CODE_SAFE */
54 /* #define BYTE_CODE_METER */
55
56 \f
57 #ifdef BYTE_CODE_METER
58
59 Lisp_Object Vbyte_code_meter, Qbyte_code_meter;
60 int byte_metering_on;
61
62 #define METER_2(code1, code2) \
63 XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \
64 ->contents[(code2)])
65
66 #define METER_1(code) METER_2 (0, (code))
67
68 #define METER_CODE(last_code, this_code) \
69 { \
70 if (byte_metering_on) \
71 { \
72 if (METER_1 (this_code) != ((1<<VALBITS)-1)) \
73 METER_1 (this_code)++; \
74 if (last_code \
75 && METER_2 (last_code, this_code) != ((1<<VALBITS)-1))\
76 METER_2 (last_code, this_code)++; \
77 } \
78 }
79
80 #else /* no BYTE_CODE_METER */
81
82 #define METER_CODE(last_code, this_code)
83
84 #endif /* no BYTE_CODE_METER */
85 \f
86
87 Lisp_Object Qbytecode;
88
89 /* Byte codes: */
90
91 #define Bvarref 010
92 #define Bvarset 020
93 #define Bvarbind 030
94 #define Bcall 040
95 #define Bunbind 050
96
97 #define Bnth 070
98 #define Bsymbolp 071
99 #define Bconsp 072
100 #define Bstringp 073
101 #define Blistp 074
102 #define Beq 075
103 #define Bmemq 076
104 #define Bnot 077
105 #define Bcar 0100
106 #define Bcdr 0101
107 #define Bcons 0102
108 #define Blist1 0103
109 #define Blist2 0104
110 #define Blist3 0105
111 #define Blist4 0106
112 #define Blength 0107
113 #define Baref 0110
114 #define Baset 0111
115 #define Bsymbol_value 0112
116 #define Bsymbol_function 0113
117 #define Bset 0114
118 #define Bfset 0115
119 #define Bget 0116
120 #define Bsubstring 0117
121 #define Bconcat2 0120
122 #define Bconcat3 0121
123 #define Bconcat4 0122
124 #define Bsub1 0123
125 #define Badd1 0124
126 #define Beqlsign 0125
127 #define Bgtr 0126
128 #define Blss 0127
129 #define Bleq 0130
130 #define Bgeq 0131
131 #define Bdiff 0132
132 #define Bnegate 0133
133 #define Bplus 0134
134 #define Bmax 0135
135 #define Bmin 0136
136 #define Bmult 0137
137
138 #define Bpoint 0140
139 /* Was Bmark in v17. */
140 #define Bsave_current_buffer 0141
141 #define Bgoto_char 0142
142 #define Binsert 0143
143 #define Bpoint_max 0144
144 #define Bpoint_min 0145
145 #define Bchar_after 0146
146 #define Bfollowing_char 0147
147 #define Bpreceding_char 0150
148 #define Bcurrent_column 0151
149 #define Bindent_to 0152
150 #define Bscan_buffer 0153 /* No longer generated as of v18 */
151 #define Beolp 0154
152 #define Beobp 0155
153 #define Bbolp 0156
154 #define Bbobp 0157
155 #define Bcurrent_buffer 0160
156 #define Bset_buffer 0161
157 #define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */
158 #define Bread_char 0162 /* No longer generated as of v19 */
159 #define Bset_mark 0163 /* this loser is no longer generated as of v18 */
160 #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */
161
162 #define Bforward_char 0165
163 #define Bforward_word 0166
164 #define Bskip_chars_forward 0167
165 #define Bskip_chars_backward 0170
166 #define Bforward_line 0171
167 #define Bchar_syntax 0172
168 #define Bbuffer_substring 0173
169 #define Bdelete_region 0174
170 #define Bnarrow_to_region 0175
171 #define Bwiden 0176
172 #define Bend_of_line 0177
173
174 #define Bconstant2 0201
175 #define Bgoto 0202
176 #define Bgotoifnil 0203
177 #define Bgotoifnonnil 0204
178 #define Bgotoifnilelsepop 0205
179 #define Bgotoifnonnilelsepop 0206
180 #define Breturn 0207
181 #define Bdiscard 0210
182 #define Bdup 0211
183
184 #define Bsave_excursion 0212
185 #define Bsave_window_excursion 0213
186 #define Bsave_restriction 0214
187 #define Bcatch 0215
188
189 #define Bunwind_protect 0216
190 #define Bcondition_case 0217
191 #define Btemp_output_buffer_setup 0220
192 #define Btemp_output_buffer_show 0221
193
194 #define Bunbind_all 0222
195
196 #define Bset_marker 0223
197 #define Bmatch_beginning 0224
198 #define Bmatch_end 0225
199 #define Bupcase 0226
200 #define Bdowncase 0227
201
202 #define Bstringeqlsign 0230
203 #define Bstringlss 0231
204 #define Bequal 0232
205 #define Bnthcdr 0233
206 #define Belt 0234
207 #define Bmember 0235
208 #define Bassq 0236
209 #define Bnreverse 0237
210 #define Bsetcar 0240
211 #define Bsetcdr 0241
212 #define Bcar_safe 0242
213 #define Bcdr_safe 0243
214 #define Bnconc 0244
215 #define Bquo 0245
216 #define Brem 0246
217 #define Bnumberp 0247
218 #define Bintegerp 0250
219
220 #define BRgoto 0252
221 #define BRgotoifnil 0253
222 #define BRgotoifnonnil 0254
223 #define BRgotoifnilelsepop 0255
224 #define BRgotoifnonnilelsepop 0256
225
226 #define BlistN 0257
227 #define BconcatN 0260
228 #define BinsertN 0261
229
230 #define Bconstant 0300
231 #define CONSTANTLIM 0100
232
233 \f
234 /* Structure describing a value stack used during byte-code execution
235 in Fbyte_code. */
236
237 struct byte_stack
238 {
239 /* Program counter. This points into the byte_string below
240 and is relocated when that string is relocated. */
241 unsigned char *pc;
242
243 /* Top and bottom of stack. The bottom points to an area of memory
244 allocated with alloca in Fbyte_code. */
245 Lisp_Object *top, *bottom;
246
247 /* The string containing the byte-code, and its current address.
248 Storing this here protects it from GC because mark_byte_stack
249 marks it. */
250 Lisp_Object byte_string;
251 unsigned char *byte_string_start;
252
253 /* The vector of constants used during byte-code execution. Storing
254 this here protects it from GC because mark_byte_stack marks it. */
255 Lisp_Object constants;
256
257 /* Next entry in byte_stack_list. */
258 struct byte_stack *next;
259 };
260
261 /* A list of currently active byte-code execution value stacks.
262 Fbyte_code adds an entry to the head of this list before it starts
263 processing byte-code, and it removed the entry again when it is
264 done. Signalling an error truncates the list analoguous to
265 gcprolist. */
266
267 struct byte_stack *byte_stack_list;
268
269 \f
270 /* Mark objects on byte_stack_list. Called during GC. */
271
272 void
273 mark_byte_stack ()
274 {
275 struct byte_stack *stack;
276 Lisp_Object *obj;
277
278 for (stack = byte_stack_list; stack; stack = stack->next)
279 {
280 /* If STACK->top is null here, this means there's an opcode in
281 Fbyte_code that wasn't expected to GC, but did. To find out
282 which opcode this is, record the value of `stack', and walk
283 up the stack in a debugger, stopping in frames of Fbyte_code.
284 The culprit is found in the frame of Fbyte_code where the
285 address of its local variable `stack' is equal to the
286 recorded value of `stack' here. */
287 if (!stack->top)
288 abort ();
289
290 for (obj = stack->bottom; obj <= stack->top; ++obj)
291 if (!XMARKBIT (*obj))
292 {
293 mark_object (obj);
294 XMARK (*obj);
295 }
296
297 if (!XMARKBIT (stack->byte_string))
298 {
299 mark_object (&stack->byte_string);
300 XMARK (stack->byte_string);
301 }
302
303 if (!XMARKBIT (stack->constants))
304 {
305 mark_object (&stack->constants);
306 XMARK (stack->constants);
307 }
308 }
309 }
310
311
312 /* Unmark objects in the stacks on byte_stack_list. Relocate program
313 counters. Called when GC has completed. */
314
315 void
316 unmark_byte_stack ()
317 {
318 struct byte_stack *stack;
319 Lisp_Object *obj;
320
321 for (stack = byte_stack_list; stack; stack = stack->next)
322 {
323 for (obj = stack->bottom; obj <= stack->top; ++obj)
324 XUNMARK (*obj);
325
326 XUNMARK (stack->byte_string);
327 XUNMARK (stack->constants);
328
329 if (stack->byte_string_start != XSTRING (stack->byte_string)->data)
330 {
331 int offset = stack->pc - stack->byte_string_start;
332 stack->byte_string_start = XSTRING (stack->byte_string)->data;
333 stack->pc = stack->byte_string_start + offset;
334 }
335 }
336 }
337
338 \f
339 /* Fetch the next byte from the bytecode stream */
340
341 #define FETCH *stack.pc++
342
343 /* Fetch two bytes from the bytecode stream and make a 16-bit number
344 out of them */
345
346 #define FETCH2 (op = FETCH, op + (FETCH << 8))
347
348 /* Push x onto the execution stack. This used to be #define PUSH(x)
349 (*++stackp = (x)) This oddity is necessary because Alliant can't be
350 bothered to compile the preincrement operator properly, as of 4/91.
351 -JimB */
352
353 #define PUSH(x) (top++, *top = (x))
354
355 /* Pop a value off the execution stack. */
356
357 #define POP (*top--)
358
359 /* Discard n values from the execution stack. */
360
361 #define DISCARD(n) (top -= (n))
362
363 /* Get the value which is at the top of the execution stack, but don't
364 pop it. */
365
366 #define TOP (*top)
367
368 /* Actions that must be performed before and after calling a function
369 that might GC. */
370
371 #define BEFORE_POTENTIAL_GC() stack.top = top
372 #define AFTER_POTENTIAL_GC() stack.top = NULL
373
374 /* Garbage collect if we have consed enough since the last time.
375 We do this at every branch, to avoid loops that never GC. */
376
377 #define MAYBE_GC() \
378 if (consing_since_gc > gc_cons_threshold) \
379 { \
380 BEFORE_POTENTIAL_GC (); \
381 Fgarbage_collect (); \
382 AFTER_POTENTIAL_GC (); \
383 } \
384 else
385
386 /* Check for jumping out of range. */
387
388 #ifdef BYTE_CODE_SAFE
389
390 #define CHECK_RANGE(ARG) \
391 if (ARG >= bytestr_length) abort ()
392
393 #else /* not BYTE_CODE_SAFE */
394
395 #define CHECK_RANGE(ARG)
396
397 #endif /* not BYTE_CODE_SAFE */
398
399
400 DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0,
401 "Function used internally in byte-compiled code.\n\
402 The first argument, BYTESTR, is a string of byte code;\n\
403 the second, VECTOR, a vector of constants;\n\
404 the third, MAXDEPTH, the maximum stack depth used in this function.\n\
405 If the third argument is incorrect, Emacs may crash.")
406 (bytestr, vector, maxdepth)
407 Lisp_Object bytestr, vector, maxdepth;
408 {
409 int count = specpdl_ptr - specpdl;
410 #ifdef BYTE_CODE_METER
411 int this_op = 0;
412 int prev_op;
413 #endif
414 int op;
415 /* Lisp_Object v1, v2; */
416 Lisp_Object *vectorp;
417 #ifdef BYTE_CODE_SAFE
418 int const_length = XVECTOR (vector)->size;
419 Lisp_Object *stacke;
420 #endif
421 int bytestr_length;
422 struct byte_stack stack;
423 Lisp_Object *top;
424 Lisp_Object result;
425
426 #ifdef CHECK_FRAME_FONT
427 {
428 struct frame *f = SELECTED_FRAME ();
429 if (FRAME_X_P (f)
430 && FRAME_FONT (f)->direction != 0
431 && FRAME_FONT (f)->direction != 1)
432 abort ();
433 }
434 #endif
435
436 CHECK_STRING (bytestr, 0);
437 if (!VECTORP (vector))
438 vector = wrong_type_argument (Qvectorp, vector);
439 CHECK_NUMBER (maxdepth, 2);
440
441 if (STRING_MULTIBYTE (bytestr))
442 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
443 because they produced a raw 8-bit string for byte-code and now
444 such a byte-code string is loaded as multibyte while raw 8-bit
445 characters converted to multibyte form. Thus, now we must
446 convert them back to the original unibyte form. */
447 bytestr = Fstring_as_unibyte (bytestr);
448
449 bytestr_length = STRING_BYTES (XSTRING (bytestr));
450 vectorp = XVECTOR (vector)->contents;
451
452 stack.byte_string = bytestr;
453 stack.pc = stack.byte_string_start = XSTRING (bytestr)->data;
454 stack.constants = vector;
455 stack.bottom = (Lisp_Object *) alloca (XFASTINT (maxdepth)
456 * sizeof (Lisp_Object));
457 top = stack.bottom - 1;
458 stack.top = NULL;
459 stack.next = byte_stack_list;
460 byte_stack_list = &stack;
461
462 #ifdef BYTE_CODE_SAFE
463 stacke = stack.bottom - 1 + XFASTINT (maxdepth);
464 #endif
465
466 while (1)
467 {
468 #ifdef BYTE_CODE_SAFE
469 if (top > stacke)
470 abort ();
471 else if (top < stack.bottom - 1)
472 abort ();
473 #endif
474
475 #ifdef BYTE_CODE_METER
476 prev_op = this_op;
477 this_op = op = FETCH;
478 METER_CODE (prev_op, op);
479 #else
480 op = FETCH;
481 #endif
482
483 switch (op)
484 {
485 case Bvarref + 7:
486 op = FETCH2;
487 goto varref;
488
489 case Bvarref:
490 case Bvarref + 1:
491 case Bvarref + 2:
492 case Bvarref + 3:
493 case Bvarref + 4:
494 case Bvarref + 5:
495 op = op - Bvarref;
496 goto varref;
497
498 /* This seems to be the most frequently executed byte-code
499 among the Bvarref's, so avoid a goto here. */
500 case Bvarref+6:
501 op = FETCH;
502 varref:
503 {
504 Lisp_Object v1, v2;
505
506 v1 = vectorp[op];
507 if (SYMBOLP (v1))
508 {
509 v2 = XSYMBOL (v1)->value;
510 if (MISCP (v2) || EQ (v2, Qunbound))
511 {
512 BEFORE_POTENTIAL_GC ();
513 v2 = Fsymbol_value (v1);
514 AFTER_POTENTIAL_GC ();
515 }
516 }
517 else
518 {
519 BEFORE_POTENTIAL_GC ();
520 v2 = Fsymbol_value (v1);
521 AFTER_POTENTIAL_GC ();
522 }
523 PUSH (v2);
524 break;
525 }
526
527 case Bgotoifnil:
528 MAYBE_GC ();
529 op = FETCH2;
530 if (NILP (POP))
531 {
532 QUIT;
533 CHECK_RANGE (op);
534 stack.pc = stack.byte_string_start + op;
535 }
536 break;
537
538 case Bcar:
539 {
540 Lisp_Object v1;
541 v1 = TOP;
542 if (CONSP (v1))
543 TOP = XCAR (v1);
544 else if (NILP (v1))
545 TOP = Qnil;
546 else
547 {
548 BEFORE_POTENTIAL_GC ();
549 Fcar (wrong_type_argument (Qlistp, v1));
550 AFTER_POTENTIAL_GC ();
551 }
552 break;
553 }
554
555 case Beq:
556 {
557 Lisp_Object v1;
558 v1 = POP;
559 TOP = EQ (v1, TOP) ? Qt : Qnil;
560 break;
561 }
562
563 case Bmemq:
564 {
565 Lisp_Object v1;
566 BEFORE_POTENTIAL_GC ();
567 v1 = POP;
568 TOP = Fmemq (TOP, v1);
569 AFTER_POTENTIAL_GC ();
570 break;
571 }
572
573 case Bcdr:
574 {
575 Lisp_Object v1;
576 v1 = TOP;
577 if (CONSP (v1))
578 TOP = XCDR (v1);
579 else if (NILP (v1))
580 TOP = Qnil;
581 else
582 {
583 BEFORE_POTENTIAL_GC ();
584 Fcdr (wrong_type_argument (Qlistp, v1));
585 AFTER_POTENTIAL_GC ();
586 }
587 break;
588 }
589
590 case Bvarset:
591 case Bvarset+1:
592 case Bvarset+2:
593 case Bvarset+3:
594 case Bvarset+4:
595 case Bvarset+5:
596 op -= Bvarset;
597 goto varset;
598
599 case Bvarset+7:
600 op = FETCH2;
601 goto varset;
602
603 case Bvarset+6:
604 op = FETCH;
605 varset:
606 {
607 Lisp_Object sym, val;
608
609 sym = vectorp[op];
610 val = TOP;
611
612 /* Inline the most common case. */
613 if (SYMBOLP (sym)
614 && !EQ (val, Qunbound)
615 && !MISCP (XSYMBOL (sym)->value)
616 /* I think this should either be checked in the byte
617 compiler, or there should be a flag indicating that
618 a symbol might be constant in Lisp_Symbol, instead
619 of checking this here over and over again. --gerd. */
620 && !EQ (sym, Qnil)
621 && !EQ (sym, Qt)
622 && !(XSYMBOL (sym)->name->data[0] == ':'
623 && EQ (XSYMBOL (sym)->obarray, initial_obarray)
624 && !EQ (val, sym)))
625 XSYMBOL (sym)->value = val;
626 else
627 {
628 BEFORE_POTENTIAL_GC ();
629 set_internal (sym, val, current_buffer, 0);
630 AFTER_POTENTIAL_GC ();
631 }
632 }
633 POP;
634 break;
635
636 case Bdup:
637 {
638 Lisp_Object v1;
639 v1 = TOP;
640 PUSH (v1);
641 break;
642 }
643
644 /* ------------------ */
645
646 case Bvarbind+6:
647 op = FETCH;
648 goto varbind;
649
650 case Bvarbind+7:
651 op = FETCH2;
652 goto varbind;
653
654 case Bvarbind:
655 case Bvarbind+1:
656 case Bvarbind+2:
657 case Bvarbind+3:
658 case Bvarbind+4:
659 case Bvarbind+5:
660 op -= Bvarbind;
661 varbind:
662 /* Specbind can signal and thus GC. */
663 BEFORE_POTENTIAL_GC ();
664 specbind (vectorp[op], POP);
665 AFTER_POTENTIAL_GC ();
666 break;
667
668 case Bcall+6:
669 op = FETCH;
670 goto docall;
671
672 case Bcall+7:
673 op = FETCH2;
674 goto docall;
675
676 case Bcall:
677 case Bcall+1:
678 case Bcall+2:
679 case Bcall+3:
680 case Bcall+4:
681 case Bcall+5:
682 op -= Bcall;
683 docall:
684 {
685 BEFORE_POTENTIAL_GC ();
686 DISCARD (op);
687 #ifdef BYTE_CODE_METER
688 if (byte_metering_on && SYMBOLP (TOP))
689 {
690 Lisp_Object v1, v2;
691
692 v1 = TOP;
693 v2 = Fget (v1, Qbyte_code_meter);
694 if (INTEGERP (v2)
695 && XINT (v2) != ((1<<VALBITS)-1))
696 {
697 XSETINT (v2, XINT (v2) + 1);
698 Fput (v1, Qbyte_code_meter, v2);
699 }
700 }
701 #endif
702 TOP = Ffuncall (op + 1, &TOP);
703 AFTER_POTENTIAL_GC ();
704 break;
705 }
706
707 case Bunbind+6:
708 op = FETCH;
709 goto dounbind;
710
711 case Bunbind+7:
712 op = FETCH2;
713 goto dounbind;
714
715 case Bunbind:
716 case Bunbind+1:
717 case Bunbind+2:
718 case Bunbind+3:
719 case Bunbind+4:
720 case Bunbind+5:
721 op -= Bunbind;
722 dounbind:
723 BEFORE_POTENTIAL_GC ();
724 unbind_to (specpdl_ptr - specpdl - op, Qnil);
725 AFTER_POTENTIAL_GC ();
726 break;
727
728 case Bunbind_all:
729 /* To unbind back to the beginning of this frame. Not used yet,
730 but will be needed for tail-recursion elimination. */
731 BEFORE_POTENTIAL_GC ();
732 unbind_to (count, Qnil);
733 AFTER_POTENTIAL_GC ();
734 break;
735
736 case Bgoto:
737 MAYBE_GC ();
738 QUIT;
739 op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */
740 CHECK_RANGE (op);
741 stack.pc = stack.byte_string_start + op;
742 break;
743
744 case Bgotoifnonnil:
745 MAYBE_GC ();
746 op = FETCH2;
747 if (!NILP (POP))
748 {
749 QUIT;
750 CHECK_RANGE (op);
751 stack.pc = stack.byte_string_start + op;
752 }
753 break;
754
755 case Bgotoifnilelsepop:
756 MAYBE_GC ();
757 op = FETCH2;
758 if (NILP (TOP))
759 {
760 QUIT;
761 CHECK_RANGE (op);
762 stack.pc = stack.byte_string_start + op;
763 }
764 else DISCARD (1);
765 break;
766
767 case Bgotoifnonnilelsepop:
768 MAYBE_GC ();
769 op = FETCH2;
770 if (!NILP (TOP))
771 {
772 QUIT;
773 CHECK_RANGE (op);
774 stack.pc = stack.byte_string_start + op;
775 }
776 else DISCARD (1);
777 break;
778
779 case BRgoto:
780 MAYBE_GC ();
781 QUIT;
782 stack.pc += (int) *stack.pc - 127;
783 break;
784
785 case BRgotoifnil:
786 MAYBE_GC ();
787 if (NILP (POP))
788 {
789 QUIT;
790 stack.pc += (int) *stack.pc - 128;
791 }
792 stack.pc++;
793 break;
794
795 case BRgotoifnonnil:
796 MAYBE_GC ();
797 if (!NILP (POP))
798 {
799 QUIT;
800 stack.pc += (int) *stack.pc - 128;
801 }
802 stack.pc++;
803 break;
804
805 case BRgotoifnilelsepop:
806 MAYBE_GC ();
807 op = *stack.pc++;
808 if (NILP (TOP))
809 {
810 QUIT;
811 stack.pc += op - 128;
812 }
813 else DISCARD (1);
814 break;
815
816 case BRgotoifnonnilelsepop:
817 MAYBE_GC ();
818 op = *stack.pc++;
819 if (!NILP (TOP))
820 {
821 QUIT;
822 stack.pc += op - 128;
823 }
824 else DISCARD (1);
825 break;
826
827 case Breturn:
828 result = POP;
829 goto exit;
830
831 case Bdiscard:
832 DISCARD (1);
833 break;
834
835 case Bconstant2:
836 PUSH (vectorp[FETCH2]);
837 break;
838
839 case Bsave_excursion:
840 record_unwind_protect (save_excursion_restore,
841 save_excursion_save ());
842 break;
843
844 case Bsave_current_buffer:
845 case Bsave_current_buffer_1:
846 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
847 break;
848
849 case Bsave_window_excursion:
850 BEFORE_POTENTIAL_GC ();
851 TOP = Fsave_window_excursion (TOP);
852 AFTER_POTENTIAL_GC ();
853 break;
854
855 case Bsave_restriction:
856 record_unwind_protect (save_restriction_restore,
857 save_restriction_save ());
858 break;
859
860 case Bcatch:
861 {
862 Lisp_Object v1;
863 BEFORE_POTENTIAL_GC ();
864 v1 = POP;
865 TOP = internal_catch (TOP, Feval, v1);
866 AFTER_POTENTIAL_GC ();
867 break;
868 }
869
870 case Bunwind_protect:
871 /* The function record_unwind_protect can GC. */
872 BEFORE_POTENTIAL_GC ();
873 record_unwind_protect (0, POP);
874 AFTER_POTENTIAL_GC ();
875 (specpdl_ptr - 1)->symbol = Qnil;
876 break;
877
878 case Bcondition_case:
879 {
880 Lisp_Object v1;
881 v1 = POP;
882 v1 = Fcons (POP, v1);
883 BEFORE_POTENTIAL_GC ();
884 TOP = Fcondition_case (Fcons (TOP, v1));
885 AFTER_POTENTIAL_GC ();
886 break;
887 }
888
889 case Btemp_output_buffer_setup:
890 BEFORE_POTENTIAL_GC ();
891 temp_output_buffer_setup (XSTRING (TOP)->data);
892 AFTER_POTENTIAL_GC ();
893 TOP = Vstandard_output;
894 break;
895
896 case Btemp_output_buffer_show:
897 {
898 Lisp_Object v1;
899 BEFORE_POTENTIAL_GC ();
900 v1 = POP;
901 temp_output_buffer_show (TOP);
902 TOP = v1;
903 /* pop binding of standard-output */
904 unbind_to (specpdl_ptr - specpdl - 1, Qnil);
905 AFTER_POTENTIAL_GC ();
906 break;
907 }
908
909 case Bnth:
910 {
911 Lisp_Object v1, v2;
912 BEFORE_POTENTIAL_GC ();
913 v1 = POP;
914 v2 = TOP;
915 CHECK_NUMBER (v2, 0);
916 AFTER_POTENTIAL_GC ();
917 op = XINT (v2);
918 immediate_quit = 1;
919 while (--op >= 0)
920 {
921 if (CONSP (v1))
922 v1 = XCDR (v1);
923 else if (!NILP (v1))
924 {
925 immediate_quit = 0;
926 BEFORE_POTENTIAL_GC ();
927 v1 = wrong_type_argument (Qlistp, v1);
928 AFTER_POTENTIAL_GC ();
929 immediate_quit = 1;
930 op++;
931 }
932 }
933 immediate_quit = 0;
934 if (CONSP (v1))
935 TOP = XCAR (v1);
936 else if (NILP (v1))
937 TOP = Qnil;
938 else
939 {
940 BEFORE_POTENTIAL_GC ();
941 Fcar (wrong_type_argument (Qlistp, v1));
942 AFTER_POTENTIAL_GC ();
943 }
944 break;
945 }
946
947 case Bsymbolp:
948 TOP = SYMBOLP (TOP) ? Qt : Qnil;
949 break;
950
951 case Bconsp:
952 TOP = CONSP (TOP) ? Qt : Qnil;
953 break;
954
955 case Bstringp:
956 TOP = STRINGP (TOP) ? Qt : Qnil;
957 break;
958
959 case Blistp:
960 TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil;
961 break;
962
963 case Bnot:
964 TOP = NILP (TOP) ? Qt : Qnil;
965 break;
966
967 case Bcons:
968 {
969 Lisp_Object v1;
970 v1 = POP;
971 TOP = Fcons (TOP, v1);
972 break;
973 }
974
975 case Blist1:
976 TOP = Fcons (TOP, Qnil);
977 break;
978
979 case Blist2:
980 {
981 Lisp_Object v1;
982 v1 = POP;
983 TOP = Fcons (TOP, Fcons (v1, Qnil));
984 break;
985 }
986
987 case Blist3:
988 DISCARD (2);
989 TOP = Flist (3, &TOP);
990 break;
991
992 case Blist4:
993 DISCARD (3);
994 TOP = Flist (4, &TOP);
995 break;
996
997 case BlistN:
998 op = FETCH;
999 DISCARD (op - 1);
1000 TOP = Flist (op, &TOP);
1001 break;
1002
1003 case Blength:
1004 BEFORE_POTENTIAL_GC ();
1005 TOP = Flength (TOP);
1006 AFTER_POTENTIAL_GC ();
1007 break;
1008
1009 case Baref:
1010 {
1011 Lisp_Object v1;
1012 BEFORE_POTENTIAL_GC ();
1013 v1 = POP;
1014 TOP = Faref (TOP, v1);
1015 AFTER_POTENTIAL_GC ();
1016 break;
1017 }
1018
1019 case Baset:
1020 {
1021 Lisp_Object v1, v2;
1022 BEFORE_POTENTIAL_GC ();
1023 v2 = POP; v1 = POP;
1024 TOP = Faset (TOP, v1, v2);
1025 AFTER_POTENTIAL_GC ();
1026 break;
1027 }
1028
1029 case Bsymbol_value:
1030 BEFORE_POTENTIAL_GC ();
1031 TOP = Fsymbol_value (TOP);
1032 AFTER_POTENTIAL_GC ();
1033 break;
1034
1035 case Bsymbol_function:
1036 BEFORE_POTENTIAL_GC ();
1037 TOP = Fsymbol_function (TOP);
1038 AFTER_POTENTIAL_GC ();
1039 break;
1040
1041 case Bset:
1042 {
1043 Lisp_Object v1;
1044 BEFORE_POTENTIAL_GC ();
1045 v1 = POP;
1046 TOP = Fset (TOP, v1);
1047 AFTER_POTENTIAL_GC ();
1048 break;
1049 }
1050
1051 case Bfset:
1052 {
1053 Lisp_Object v1;
1054 BEFORE_POTENTIAL_GC ();
1055 v1 = POP;
1056 TOP = Ffset (TOP, v1);
1057 AFTER_POTENTIAL_GC ();
1058 break;
1059 }
1060
1061 case Bget:
1062 {
1063 Lisp_Object v1;
1064 BEFORE_POTENTIAL_GC ();
1065 v1 = POP;
1066 TOP = Fget (TOP, v1);
1067 AFTER_POTENTIAL_GC ();
1068 break;
1069 }
1070
1071 case Bsubstring:
1072 {
1073 Lisp_Object v1, v2;
1074 BEFORE_POTENTIAL_GC ();
1075 v2 = POP; v1 = POP;
1076 TOP = Fsubstring (TOP, v1, v2);
1077 AFTER_POTENTIAL_GC ();
1078 break;
1079 }
1080
1081 case Bconcat2:
1082 BEFORE_POTENTIAL_GC ();
1083 DISCARD (1);
1084 TOP = Fconcat (2, &TOP);
1085 AFTER_POTENTIAL_GC ();
1086 break;
1087
1088 case Bconcat3:
1089 BEFORE_POTENTIAL_GC ();
1090 DISCARD (2);
1091 TOP = Fconcat (3, &TOP);
1092 AFTER_POTENTIAL_GC ();
1093 break;
1094
1095 case Bconcat4:
1096 BEFORE_POTENTIAL_GC ();
1097 DISCARD (3);
1098 TOP = Fconcat (4, &TOP);
1099 AFTER_POTENTIAL_GC ();
1100 break;
1101
1102 case BconcatN:
1103 op = FETCH;
1104 BEFORE_POTENTIAL_GC ();
1105 DISCARD (op - 1);
1106 TOP = Fconcat (op, &TOP);
1107 AFTER_POTENTIAL_GC ();
1108 break;
1109
1110 case Bsub1:
1111 {
1112 Lisp_Object v1;
1113 v1 = TOP;
1114 if (INTEGERP (v1))
1115 {
1116 XSETINT (v1, XINT (v1) - 1);
1117 TOP = v1;
1118 }
1119 else
1120 TOP = Fsub1 (v1);
1121 break;
1122 }
1123
1124 case Badd1:
1125 {
1126 Lisp_Object v1;
1127 v1 = TOP;
1128 if (INTEGERP (v1))
1129 {
1130 XSETINT (v1, XINT (v1) + 1);
1131 TOP = v1;
1132 }
1133 else
1134 {
1135 BEFORE_POTENTIAL_GC ();
1136 TOP = Fadd1 (v1);
1137 AFTER_POTENTIAL_GC ();
1138 }
1139 break;
1140 }
1141
1142 case Beqlsign:
1143 {
1144 Lisp_Object v1, v2;
1145 BEFORE_POTENTIAL_GC ();
1146 v2 = POP; v1 = TOP;
1147 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1, 0);
1148 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2, 0);
1149 AFTER_POTENTIAL_GC ();
1150 if (FLOATP (v1) || FLOATP (v2))
1151 {
1152 double f1, f2;
1153
1154 f1 = (FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1));
1155 f2 = (FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2));
1156 TOP = (f1 == f2 ? Qt : Qnil);
1157 }
1158 else
1159 TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil);
1160 break;
1161 }
1162
1163 case Bgtr:
1164 {
1165 Lisp_Object v1;
1166 BEFORE_POTENTIAL_GC ();
1167 v1 = POP;
1168 TOP = Fgtr (TOP, v1);
1169 AFTER_POTENTIAL_GC ();
1170 break;
1171 }
1172
1173 case Blss:
1174 {
1175 Lisp_Object v1;
1176 BEFORE_POTENTIAL_GC ();
1177 v1 = POP;
1178 TOP = Flss (TOP, v1);
1179 AFTER_POTENTIAL_GC ();
1180 break;
1181 }
1182
1183 case Bleq:
1184 {
1185 Lisp_Object v1;
1186 BEFORE_POTENTIAL_GC ();
1187 v1 = POP;
1188 TOP = Fleq (TOP, v1);
1189 AFTER_POTENTIAL_GC ();
1190 break;
1191 }
1192
1193 case Bgeq:
1194 {
1195 Lisp_Object v1;
1196 BEFORE_POTENTIAL_GC ();
1197 v1 = POP;
1198 TOP = Fgeq (TOP, v1);
1199 AFTER_POTENTIAL_GC ();
1200 break;
1201 }
1202
1203 case Bdiff:
1204 BEFORE_POTENTIAL_GC ();
1205 DISCARD (1);
1206 TOP = Fminus (2, &TOP);
1207 AFTER_POTENTIAL_GC ();
1208 break;
1209
1210 case Bnegate:
1211 {
1212 Lisp_Object v1;
1213 v1 = TOP;
1214 if (INTEGERP (v1))
1215 {
1216 XSETINT (v1, - XINT (v1));
1217 TOP = v1;
1218 }
1219 else
1220 {
1221 BEFORE_POTENTIAL_GC ();
1222 TOP = Fminus (1, &TOP);
1223 AFTER_POTENTIAL_GC ();
1224 }
1225 break;
1226 }
1227
1228 case Bplus:
1229 BEFORE_POTENTIAL_GC ();
1230 DISCARD (1);
1231 TOP = Fplus (2, &TOP);
1232 AFTER_POTENTIAL_GC ();
1233 break;
1234
1235 case Bmax:
1236 BEFORE_POTENTIAL_GC ();
1237 DISCARD (1);
1238 TOP = Fmax (2, &TOP);
1239 AFTER_POTENTIAL_GC ();
1240 break;
1241
1242 case Bmin:
1243 BEFORE_POTENTIAL_GC ();
1244 DISCARD (1);
1245 TOP = Fmin (2, &TOP);
1246 AFTER_POTENTIAL_GC ();
1247 break;
1248
1249 case Bmult:
1250 BEFORE_POTENTIAL_GC ();
1251 DISCARD (1);
1252 TOP = Ftimes (2, &TOP);
1253 AFTER_POTENTIAL_GC ();
1254 break;
1255
1256 case Bquo:
1257 BEFORE_POTENTIAL_GC ();
1258 DISCARD (1);
1259 TOP = Fquo (2, &TOP);
1260 AFTER_POTENTIAL_GC ();
1261 break;
1262
1263 case Brem:
1264 {
1265 Lisp_Object v1;
1266 BEFORE_POTENTIAL_GC ();
1267 v1 = POP;
1268 TOP = Frem (TOP, v1);
1269 AFTER_POTENTIAL_GC ();
1270 break;
1271 }
1272
1273 case Bpoint:
1274 {
1275 Lisp_Object v1;
1276 XSETFASTINT (v1, PT);
1277 PUSH (v1);
1278 break;
1279 }
1280
1281 case Bgoto_char:
1282 BEFORE_POTENTIAL_GC ();
1283 TOP = Fgoto_char (TOP);
1284 AFTER_POTENTIAL_GC ();
1285 break;
1286
1287 case Binsert:
1288 BEFORE_POTENTIAL_GC ();
1289 TOP = Finsert (1, &TOP);
1290 AFTER_POTENTIAL_GC ();
1291 break;
1292
1293 case BinsertN:
1294 op = FETCH;
1295 BEFORE_POTENTIAL_GC ();
1296 DISCARD (op - 1);
1297 TOP = Finsert (op, &TOP);
1298 AFTER_POTENTIAL_GC ();
1299 break;
1300
1301 case Bpoint_max:
1302 {
1303 Lisp_Object v1;
1304 XSETFASTINT (v1, ZV);
1305 PUSH (v1);
1306 break;
1307 }
1308
1309 case Bpoint_min:
1310 {
1311 Lisp_Object v1;
1312 XSETFASTINT (v1, BEGV);
1313 PUSH (v1);
1314 break;
1315 }
1316
1317 case Bchar_after:
1318 BEFORE_POTENTIAL_GC ();
1319 TOP = Fchar_after (TOP);
1320 AFTER_POTENTIAL_GC ();
1321 break;
1322
1323 case Bfollowing_char:
1324 {
1325 Lisp_Object v1;
1326 BEFORE_POTENTIAL_GC ();
1327 v1 = Ffollowing_char ();
1328 AFTER_POTENTIAL_GC ();
1329 PUSH (v1);
1330 break;
1331 }
1332
1333 case Bpreceding_char:
1334 {
1335 Lisp_Object v1;
1336 BEFORE_POTENTIAL_GC ();
1337 v1 = Fprevious_char ();
1338 AFTER_POTENTIAL_GC ();
1339 PUSH (v1);
1340 break;
1341 }
1342
1343 case Bcurrent_column:
1344 {
1345 Lisp_Object v1;
1346 BEFORE_POTENTIAL_GC ();
1347 XSETFASTINT (v1, current_column ());
1348 AFTER_POTENTIAL_GC ();
1349 PUSH (v1);
1350 break;
1351 }
1352
1353 case Bindent_to:
1354 BEFORE_POTENTIAL_GC ();
1355 TOP = Findent_to (TOP, Qnil);
1356 AFTER_POTENTIAL_GC ();
1357 break;
1358
1359 case Beolp:
1360 PUSH (Feolp ());
1361 break;
1362
1363 case Beobp:
1364 PUSH (Feobp ());
1365 break;
1366
1367 case Bbolp:
1368 PUSH (Fbolp ());
1369 break;
1370
1371 case Bbobp:
1372 PUSH (Fbobp ());
1373 break;
1374
1375 case Bcurrent_buffer:
1376 PUSH (Fcurrent_buffer ());
1377 break;
1378
1379 case Bset_buffer:
1380 BEFORE_POTENTIAL_GC ();
1381 TOP = Fset_buffer (TOP);
1382 AFTER_POTENTIAL_GC ();
1383 break;
1384
1385 case Binteractive_p:
1386 PUSH (Finteractive_p ());
1387 break;
1388
1389 case Bforward_char:
1390 BEFORE_POTENTIAL_GC ();
1391 TOP = Fforward_char (TOP);
1392 AFTER_POTENTIAL_GC ();
1393 break;
1394
1395 case Bforward_word:
1396 BEFORE_POTENTIAL_GC ();
1397 TOP = Fforward_word (TOP);
1398 AFTER_POTENTIAL_GC ();
1399 break;
1400
1401 case Bskip_chars_forward:
1402 {
1403 Lisp_Object v1;
1404 BEFORE_POTENTIAL_GC ();
1405 v1 = POP;
1406 TOP = Fskip_chars_forward (TOP, v1);
1407 AFTER_POTENTIAL_GC ();
1408 break;
1409 }
1410
1411 case Bskip_chars_backward:
1412 {
1413 Lisp_Object v1;
1414 BEFORE_POTENTIAL_GC ();
1415 v1 = POP;
1416 TOP = Fskip_chars_backward (TOP, v1);
1417 AFTER_POTENTIAL_GC ();
1418 break;
1419 }
1420
1421 case Bforward_line:
1422 BEFORE_POTENTIAL_GC ();
1423 TOP = Fforward_line (TOP);
1424 AFTER_POTENTIAL_GC ();
1425 break;
1426
1427 case Bchar_syntax:
1428 BEFORE_POTENTIAL_GC ();
1429 CHECK_NUMBER (TOP, 0);
1430 AFTER_POTENTIAL_GC ();
1431 XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (XINT (TOP))]);
1432 break;
1433
1434 case Bbuffer_substring:
1435 {
1436 Lisp_Object v1;
1437 BEFORE_POTENTIAL_GC ();
1438 v1 = POP;
1439 TOP = Fbuffer_substring (TOP, v1);
1440 AFTER_POTENTIAL_GC ();
1441 break;
1442 }
1443
1444 case Bdelete_region:
1445 {
1446 Lisp_Object v1;
1447 BEFORE_POTENTIAL_GC ();
1448 v1 = POP;
1449 TOP = Fdelete_region (TOP, v1);
1450 AFTER_POTENTIAL_GC ();
1451 break;
1452 }
1453
1454 case Bnarrow_to_region:
1455 {
1456 Lisp_Object v1;
1457 BEFORE_POTENTIAL_GC ();
1458 v1 = POP;
1459 TOP = Fnarrow_to_region (TOP, v1);
1460 AFTER_POTENTIAL_GC ();
1461 break;
1462 }
1463
1464 case Bwiden:
1465 BEFORE_POTENTIAL_GC ();
1466 PUSH (Fwiden ());
1467 AFTER_POTENTIAL_GC ();
1468 break;
1469
1470 case Bend_of_line:
1471 BEFORE_POTENTIAL_GC ();
1472 TOP = Fend_of_line (TOP);
1473 AFTER_POTENTIAL_GC ();
1474 break;
1475
1476 case Bset_marker:
1477 {
1478 Lisp_Object v1, v2;
1479 BEFORE_POTENTIAL_GC ();
1480 v1 = POP;
1481 v2 = POP;
1482 TOP = Fset_marker (TOP, v2, v1);
1483 AFTER_POTENTIAL_GC ();
1484 break;
1485 }
1486
1487 case Bmatch_beginning:
1488 BEFORE_POTENTIAL_GC ();
1489 TOP = Fmatch_beginning (TOP);
1490 AFTER_POTENTIAL_GC ();
1491 break;
1492
1493 case Bmatch_end:
1494 BEFORE_POTENTIAL_GC ();
1495 TOP = Fmatch_end (TOP);
1496 AFTER_POTENTIAL_GC ();
1497 break;
1498
1499 case Bupcase:
1500 BEFORE_POTENTIAL_GC ();
1501 TOP = Fupcase (TOP);
1502 AFTER_POTENTIAL_GC ();
1503 break;
1504
1505 case Bdowncase:
1506 BEFORE_POTENTIAL_GC ();
1507 TOP = Fdowncase (TOP);
1508 AFTER_POTENTIAL_GC ();
1509 break;
1510
1511 case Bstringeqlsign:
1512 {
1513 Lisp_Object v1;
1514 BEFORE_POTENTIAL_GC ();
1515 v1 = POP;
1516 TOP = Fstring_equal (TOP, v1);
1517 AFTER_POTENTIAL_GC ();
1518 break;
1519 }
1520
1521 case Bstringlss:
1522 {
1523 Lisp_Object v1;
1524 BEFORE_POTENTIAL_GC ();
1525 v1 = POP;
1526 TOP = Fstring_lessp (TOP, v1);
1527 AFTER_POTENTIAL_GC ();
1528 break;
1529 }
1530
1531 case Bequal:
1532 {
1533 Lisp_Object v1;
1534 v1 = POP;
1535 TOP = Fequal (TOP, v1);
1536 break;
1537 }
1538
1539 case Bnthcdr:
1540 {
1541 Lisp_Object v1;
1542 BEFORE_POTENTIAL_GC ();
1543 v1 = POP;
1544 TOP = Fnthcdr (TOP, v1);
1545 AFTER_POTENTIAL_GC ();
1546 break;
1547 }
1548
1549 case Belt:
1550 {
1551 Lisp_Object v1, v2;
1552 if (CONSP (TOP))
1553 {
1554 /* Exchange args and then do nth. */
1555 BEFORE_POTENTIAL_GC ();
1556 v2 = POP;
1557 v1 = TOP;
1558 CHECK_NUMBER (v2, 0);
1559 AFTER_POTENTIAL_GC ();
1560 op = XINT (v2);
1561 immediate_quit = 1;
1562 while (--op >= 0)
1563 {
1564 if (CONSP (v1))
1565 v1 = XCDR (v1);
1566 else if (!NILP (v1))
1567 {
1568 immediate_quit = 0;
1569 BEFORE_POTENTIAL_GC ();
1570 v1 = wrong_type_argument (Qlistp, v1);
1571 AFTER_POTENTIAL_GC ();
1572 immediate_quit = 1;
1573 op++;
1574 }
1575 }
1576 immediate_quit = 0;
1577 if (CONSP (v1))
1578 TOP = XCAR (v1);
1579 else if (NILP (v1))
1580 TOP = Qnil;
1581 else
1582 {
1583 BEFORE_POTENTIAL_GC ();
1584 Fcar (wrong_type_argument (Qlistp, v1));
1585 AFTER_POTENTIAL_GC ();
1586 }
1587 }
1588 else
1589 {
1590 BEFORE_POTENTIAL_GC ();
1591 v1 = POP;
1592 TOP = Felt (TOP, v1);
1593 AFTER_POTENTIAL_GC ();
1594 }
1595 break;
1596 }
1597
1598 case Bmember:
1599 {
1600 Lisp_Object v1;
1601 BEFORE_POTENTIAL_GC ();
1602 v1 = POP;
1603 TOP = Fmember (TOP, v1);
1604 AFTER_POTENTIAL_GC ();
1605 break;
1606 }
1607
1608 case Bassq:
1609 {
1610 Lisp_Object v1;
1611 BEFORE_POTENTIAL_GC ();
1612 v1 = POP;
1613 TOP = Fassq (TOP, v1);
1614 AFTER_POTENTIAL_GC ();
1615 break;
1616 }
1617
1618 case Bnreverse:
1619 BEFORE_POTENTIAL_GC ();
1620 TOP = Fnreverse (TOP);
1621 AFTER_POTENTIAL_GC ();
1622 break;
1623
1624 case Bsetcar:
1625 {
1626 Lisp_Object v1;
1627 BEFORE_POTENTIAL_GC ();
1628 v1 = POP;
1629 TOP = Fsetcar (TOP, v1);
1630 AFTER_POTENTIAL_GC ();
1631 break;
1632 }
1633
1634 case Bsetcdr:
1635 {
1636 Lisp_Object v1;
1637 BEFORE_POTENTIAL_GC ();
1638 v1 = POP;
1639 TOP = Fsetcdr (TOP, v1);
1640 AFTER_POTENTIAL_GC ();
1641 break;
1642 }
1643
1644 case Bcar_safe:
1645 {
1646 Lisp_Object v1;
1647 v1 = TOP;
1648 if (CONSP (v1))
1649 TOP = XCAR (v1);
1650 else
1651 TOP = Qnil;
1652 break;
1653 }
1654
1655 case Bcdr_safe:
1656 {
1657 Lisp_Object v1;
1658 v1 = TOP;
1659 if (CONSP (v1))
1660 TOP = XCDR (v1);
1661 else
1662 TOP = Qnil;
1663 break;
1664 }
1665
1666 case Bnconc:
1667 BEFORE_POTENTIAL_GC ();
1668 DISCARD (1);
1669 TOP = Fnconc (2, &TOP);
1670 AFTER_POTENTIAL_GC ();
1671 break;
1672
1673 case Bnumberp:
1674 TOP = (NUMBERP (TOP) ? Qt : Qnil);
1675 break;
1676
1677 case Bintegerp:
1678 TOP = INTEGERP (TOP) ? Qt : Qnil;
1679 break;
1680
1681 #ifdef BYTE_CODE_SAFE
1682 case Bset_mark:
1683 BEFORE_POTENTIAL_GC ();
1684 error ("set-mark is an obsolete bytecode");
1685 AFTER_POTENTIAL_GC ();
1686 break;
1687 case Bscan_buffer:
1688 BEFORE_POTENTIAL_GC ();
1689 error ("scan-buffer is an obsolete bytecode");
1690 AFTER_POTENTIAL_GC ();
1691 break;
1692 #endif
1693
1694 case 0:
1695 abort ();
1696
1697 case 255:
1698 default:
1699 #ifdef BYTE_CODE_SAFE
1700 if (op < Bconstant)
1701 {
1702 abort ();
1703 }
1704 if ((op -= Bconstant) >= const_length)
1705 {
1706 abort ();
1707 }
1708 PUSH (vectorp[op]);
1709 #else
1710 PUSH (vectorp[op - Bconstant]);
1711 #endif
1712 }
1713 }
1714
1715 exit:
1716
1717 byte_stack_list = byte_stack_list->next;
1718
1719 /* Binds and unbinds are supposed to be compiled balanced. */
1720 if (specpdl_ptr - specpdl != count)
1721 #ifdef BYTE_CODE_SAFE
1722 error ("binding stack not balanced (serious byte compiler bug)");
1723 #else
1724 abort ();
1725 #endif
1726
1727 return result;
1728 }
1729
1730 void
1731 syms_of_bytecode ()
1732 {
1733 Qbytecode = intern ("byte-code");
1734 staticpro (&Qbytecode);
1735
1736 defsubr (&Sbyte_code);
1737
1738 #ifdef BYTE_CODE_METER
1739
1740 DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter,
1741 "A vector of vectors which holds a histogram of byte-code usage.\n\
1742 (aref (aref byte-code-meter 0) CODE) indicates how many times the byte\n\
1743 opcode CODE has been executed.\n\
1744 (aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,\n\
1745 indicates how many times the byte opcodes CODE1 and CODE2 have been\n\
1746 executed in succession.");
1747 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on,
1748 "If non-nil, keep profiling information on byte code usage.\n\
1749 The variable byte-code-meter indicates how often each byte opcode is used.\n\
1750 If a symbol has a property named `byte-code-meter' whose value is an\n\
1751 integer, it is incremented each time that symbol's function is called.");
1752
1753 byte_metering_on = 0;
1754 Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0));
1755 Qbyte_code_meter = intern ("byte-code-meter");
1756 staticpro (&Qbyte_code_meter);
1757 {
1758 int i = 256;
1759 while (i--)
1760 XVECTOR (Vbyte_code_meter)->contents[i] =
1761 Fmake_vector (make_number (256), make_number (0));
1762 }
1763 #endif
1764 }