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