]> code.delx.au - gnu-emacs/blob - src/bytecode.c
(buffer_posn_from_coords): Adjust prototype.
[gnu-emacs] / 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 CHECK_STRING (TOP, 0);
892 temp_output_buffer_setup (XSTRING (TOP)->data);
893 AFTER_POTENTIAL_GC ();
894 TOP = Vstandard_output;
895 break;
896
897 case Btemp_output_buffer_show:
898 {
899 Lisp_Object v1;
900 BEFORE_POTENTIAL_GC ();
901 v1 = POP;
902 temp_output_buffer_show (TOP);
903 TOP = v1;
904 /* pop binding of standard-output */
905 unbind_to (specpdl_ptr - specpdl - 1, Qnil);
906 AFTER_POTENTIAL_GC ();
907 break;
908 }
909
910 case Bnth:
911 {
912 Lisp_Object v1, v2;
913 BEFORE_POTENTIAL_GC ();
914 v1 = POP;
915 v2 = TOP;
916 CHECK_NUMBER (v2, 0);
917 AFTER_POTENTIAL_GC ();
918 op = XINT (v2);
919 immediate_quit = 1;
920 while (--op >= 0)
921 {
922 if (CONSP (v1))
923 v1 = XCDR (v1);
924 else if (!NILP (v1))
925 {
926 immediate_quit = 0;
927 BEFORE_POTENTIAL_GC ();
928 v1 = wrong_type_argument (Qlistp, v1);
929 AFTER_POTENTIAL_GC ();
930 immediate_quit = 1;
931 op++;
932 }
933 }
934 immediate_quit = 0;
935 if (CONSP (v1))
936 TOP = XCAR (v1);
937 else if (NILP (v1))
938 TOP = Qnil;
939 else
940 {
941 BEFORE_POTENTIAL_GC ();
942 Fcar (wrong_type_argument (Qlistp, v1));
943 AFTER_POTENTIAL_GC ();
944 }
945 break;
946 }
947
948 case Bsymbolp:
949 TOP = SYMBOLP (TOP) ? Qt : Qnil;
950 break;
951
952 case Bconsp:
953 TOP = CONSP (TOP) ? Qt : Qnil;
954 break;
955
956 case Bstringp:
957 TOP = STRINGP (TOP) ? Qt : Qnil;
958 break;
959
960 case Blistp:
961 TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil;
962 break;
963
964 case Bnot:
965 TOP = NILP (TOP) ? Qt : Qnil;
966 break;
967
968 case Bcons:
969 {
970 Lisp_Object v1;
971 v1 = POP;
972 TOP = Fcons (TOP, v1);
973 break;
974 }
975
976 case Blist1:
977 TOP = Fcons (TOP, Qnil);
978 break;
979
980 case Blist2:
981 {
982 Lisp_Object v1;
983 v1 = POP;
984 TOP = Fcons (TOP, Fcons (v1, Qnil));
985 break;
986 }
987
988 case Blist3:
989 DISCARD (2);
990 TOP = Flist (3, &TOP);
991 break;
992
993 case Blist4:
994 DISCARD (3);
995 TOP = Flist (4, &TOP);
996 break;
997
998 case BlistN:
999 op = FETCH;
1000 DISCARD (op - 1);
1001 TOP = Flist (op, &TOP);
1002 break;
1003
1004 case Blength:
1005 BEFORE_POTENTIAL_GC ();
1006 TOP = Flength (TOP);
1007 AFTER_POTENTIAL_GC ();
1008 break;
1009
1010 case Baref:
1011 {
1012 Lisp_Object v1;
1013 BEFORE_POTENTIAL_GC ();
1014 v1 = POP;
1015 TOP = Faref (TOP, v1);
1016 AFTER_POTENTIAL_GC ();
1017 break;
1018 }
1019
1020 case Baset:
1021 {
1022 Lisp_Object v1, v2;
1023 BEFORE_POTENTIAL_GC ();
1024 v2 = POP; v1 = POP;
1025 TOP = Faset (TOP, v1, v2);
1026 AFTER_POTENTIAL_GC ();
1027 break;
1028 }
1029
1030 case Bsymbol_value:
1031 BEFORE_POTENTIAL_GC ();
1032 TOP = Fsymbol_value (TOP);
1033 AFTER_POTENTIAL_GC ();
1034 break;
1035
1036 case Bsymbol_function:
1037 BEFORE_POTENTIAL_GC ();
1038 TOP = Fsymbol_function (TOP);
1039 AFTER_POTENTIAL_GC ();
1040 break;
1041
1042 case Bset:
1043 {
1044 Lisp_Object v1;
1045 BEFORE_POTENTIAL_GC ();
1046 v1 = POP;
1047 TOP = Fset (TOP, v1);
1048 AFTER_POTENTIAL_GC ();
1049 break;
1050 }
1051
1052 case Bfset:
1053 {
1054 Lisp_Object v1;
1055 BEFORE_POTENTIAL_GC ();
1056 v1 = POP;
1057 TOP = Ffset (TOP, v1);
1058 AFTER_POTENTIAL_GC ();
1059 break;
1060 }
1061
1062 case Bget:
1063 {
1064 Lisp_Object v1;
1065 BEFORE_POTENTIAL_GC ();
1066 v1 = POP;
1067 TOP = Fget (TOP, v1);
1068 AFTER_POTENTIAL_GC ();
1069 break;
1070 }
1071
1072 case Bsubstring:
1073 {
1074 Lisp_Object v1, v2;
1075 BEFORE_POTENTIAL_GC ();
1076 v2 = POP; v1 = POP;
1077 TOP = Fsubstring (TOP, v1, v2);
1078 AFTER_POTENTIAL_GC ();
1079 break;
1080 }
1081
1082 case Bconcat2:
1083 BEFORE_POTENTIAL_GC ();
1084 DISCARD (1);
1085 TOP = Fconcat (2, &TOP);
1086 AFTER_POTENTIAL_GC ();
1087 break;
1088
1089 case Bconcat3:
1090 BEFORE_POTENTIAL_GC ();
1091 DISCARD (2);
1092 TOP = Fconcat (3, &TOP);
1093 AFTER_POTENTIAL_GC ();
1094 break;
1095
1096 case Bconcat4:
1097 BEFORE_POTENTIAL_GC ();
1098 DISCARD (3);
1099 TOP = Fconcat (4, &TOP);
1100 AFTER_POTENTIAL_GC ();
1101 break;
1102
1103 case BconcatN:
1104 op = FETCH;
1105 BEFORE_POTENTIAL_GC ();
1106 DISCARD (op - 1);
1107 TOP = Fconcat (op, &TOP);
1108 AFTER_POTENTIAL_GC ();
1109 break;
1110
1111 case Bsub1:
1112 {
1113 Lisp_Object v1;
1114 v1 = TOP;
1115 if (INTEGERP (v1))
1116 {
1117 XSETINT (v1, XINT (v1) - 1);
1118 TOP = v1;
1119 }
1120 else
1121 TOP = Fsub1 (v1);
1122 break;
1123 }
1124
1125 case Badd1:
1126 {
1127 Lisp_Object v1;
1128 v1 = TOP;
1129 if (INTEGERP (v1))
1130 {
1131 XSETINT (v1, XINT (v1) + 1);
1132 TOP = v1;
1133 }
1134 else
1135 {
1136 BEFORE_POTENTIAL_GC ();
1137 TOP = Fadd1 (v1);
1138 AFTER_POTENTIAL_GC ();
1139 }
1140 break;
1141 }
1142
1143 case Beqlsign:
1144 {
1145 Lisp_Object v1, v2;
1146 BEFORE_POTENTIAL_GC ();
1147 v2 = POP; v1 = TOP;
1148 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1, 0);
1149 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2, 0);
1150 AFTER_POTENTIAL_GC ();
1151 if (FLOATP (v1) || FLOATP (v2))
1152 {
1153 double f1, f2;
1154
1155 f1 = (FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1));
1156 f2 = (FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2));
1157 TOP = (f1 == f2 ? Qt : Qnil);
1158 }
1159 else
1160 TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil);
1161 break;
1162 }
1163
1164 case Bgtr:
1165 {
1166 Lisp_Object v1;
1167 BEFORE_POTENTIAL_GC ();
1168 v1 = POP;
1169 TOP = Fgtr (TOP, v1);
1170 AFTER_POTENTIAL_GC ();
1171 break;
1172 }
1173
1174 case Blss:
1175 {
1176 Lisp_Object v1;
1177 BEFORE_POTENTIAL_GC ();
1178 v1 = POP;
1179 TOP = Flss (TOP, v1);
1180 AFTER_POTENTIAL_GC ();
1181 break;
1182 }
1183
1184 case Bleq:
1185 {
1186 Lisp_Object v1;
1187 BEFORE_POTENTIAL_GC ();
1188 v1 = POP;
1189 TOP = Fleq (TOP, v1);
1190 AFTER_POTENTIAL_GC ();
1191 break;
1192 }
1193
1194 case Bgeq:
1195 {
1196 Lisp_Object v1;
1197 BEFORE_POTENTIAL_GC ();
1198 v1 = POP;
1199 TOP = Fgeq (TOP, v1);
1200 AFTER_POTENTIAL_GC ();
1201 break;
1202 }
1203
1204 case Bdiff:
1205 BEFORE_POTENTIAL_GC ();
1206 DISCARD (1);
1207 TOP = Fminus (2, &TOP);
1208 AFTER_POTENTIAL_GC ();
1209 break;
1210
1211 case Bnegate:
1212 {
1213 Lisp_Object v1;
1214 v1 = TOP;
1215 if (INTEGERP (v1))
1216 {
1217 XSETINT (v1, - XINT (v1));
1218 TOP = v1;
1219 }
1220 else
1221 {
1222 BEFORE_POTENTIAL_GC ();
1223 TOP = Fminus (1, &TOP);
1224 AFTER_POTENTIAL_GC ();
1225 }
1226 break;
1227 }
1228
1229 case Bplus:
1230 BEFORE_POTENTIAL_GC ();
1231 DISCARD (1);
1232 TOP = Fplus (2, &TOP);
1233 AFTER_POTENTIAL_GC ();
1234 break;
1235
1236 case Bmax:
1237 BEFORE_POTENTIAL_GC ();
1238 DISCARD (1);
1239 TOP = Fmax (2, &TOP);
1240 AFTER_POTENTIAL_GC ();
1241 break;
1242
1243 case Bmin:
1244 BEFORE_POTENTIAL_GC ();
1245 DISCARD (1);
1246 TOP = Fmin (2, &TOP);
1247 AFTER_POTENTIAL_GC ();
1248 break;
1249
1250 case Bmult:
1251 BEFORE_POTENTIAL_GC ();
1252 DISCARD (1);
1253 TOP = Ftimes (2, &TOP);
1254 AFTER_POTENTIAL_GC ();
1255 break;
1256
1257 case Bquo:
1258 BEFORE_POTENTIAL_GC ();
1259 DISCARD (1);
1260 TOP = Fquo (2, &TOP);
1261 AFTER_POTENTIAL_GC ();
1262 break;
1263
1264 case Brem:
1265 {
1266 Lisp_Object v1;
1267 BEFORE_POTENTIAL_GC ();
1268 v1 = POP;
1269 TOP = Frem (TOP, v1);
1270 AFTER_POTENTIAL_GC ();
1271 break;
1272 }
1273
1274 case Bpoint:
1275 {
1276 Lisp_Object v1;
1277 XSETFASTINT (v1, PT);
1278 PUSH (v1);
1279 break;
1280 }
1281
1282 case Bgoto_char:
1283 BEFORE_POTENTIAL_GC ();
1284 TOP = Fgoto_char (TOP);
1285 AFTER_POTENTIAL_GC ();
1286 break;
1287
1288 case Binsert:
1289 BEFORE_POTENTIAL_GC ();
1290 TOP = Finsert (1, &TOP);
1291 AFTER_POTENTIAL_GC ();
1292 break;
1293
1294 case BinsertN:
1295 op = FETCH;
1296 BEFORE_POTENTIAL_GC ();
1297 DISCARD (op - 1);
1298 TOP = Finsert (op, &TOP);
1299 AFTER_POTENTIAL_GC ();
1300 break;
1301
1302 case Bpoint_max:
1303 {
1304 Lisp_Object v1;
1305 XSETFASTINT (v1, ZV);
1306 PUSH (v1);
1307 break;
1308 }
1309
1310 case Bpoint_min:
1311 {
1312 Lisp_Object v1;
1313 XSETFASTINT (v1, BEGV);
1314 PUSH (v1);
1315 break;
1316 }
1317
1318 case Bchar_after:
1319 BEFORE_POTENTIAL_GC ();
1320 TOP = Fchar_after (TOP);
1321 AFTER_POTENTIAL_GC ();
1322 break;
1323
1324 case Bfollowing_char:
1325 {
1326 Lisp_Object v1;
1327 BEFORE_POTENTIAL_GC ();
1328 v1 = Ffollowing_char ();
1329 AFTER_POTENTIAL_GC ();
1330 PUSH (v1);
1331 break;
1332 }
1333
1334 case Bpreceding_char:
1335 {
1336 Lisp_Object v1;
1337 BEFORE_POTENTIAL_GC ();
1338 v1 = Fprevious_char ();
1339 AFTER_POTENTIAL_GC ();
1340 PUSH (v1);
1341 break;
1342 }
1343
1344 case Bcurrent_column:
1345 {
1346 Lisp_Object v1;
1347 BEFORE_POTENTIAL_GC ();
1348 XSETFASTINT (v1, current_column ());
1349 AFTER_POTENTIAL_GC ();
1350 PUSH (v1);
1351 break;
1352 }
1353
1354 case Bindent_to:
1355 BEFORE_POTENTIAL_GC ();
1356 TOP = Findent_to (TOP, Qnil);
1357 AFTER_POTENTIAL_GC ();
1358 break;
1359
1360 case Beolp:
1361 PUSH (Feolp ());
1362 break;
1363
1364 case Beobp:
1365 PUSH (Feobp ());
1366 break;
1367
1368 case Bbolp:
1369 PUSH (Fbolp ());
1370 break;
1371
1372 case Bbobp:
1373 PUSH (Fbobp ());
1374 break;
1375
1376 case Bcurrent_buffer:
1377 PUSH (Fcurrent_buffer ());
1378 break;
1379
1380 case Bset_buffer:
1381 BEFORE_POTENTIAL_GC ();
1382 TOP = Fset_buffer (TOP);
1383 AFTER_POTENTIAL_GC ();
1384 break;
1385
1386 case Binteractive_p:
1387 PUSH (Finteractive_p ());
1388 break;
1389
1390 case Bforward_char:
1391 BEFORE_POTENTIAL_GC ();
1392 TOP = Fforward_char (TOP);
1393 AFTER_POTENTIAL_GC ();
1394 break;
1395
1396 case Bforward_word:
1397 BEFORE_POTENTIAL_GC ();
1398 TOP = Fforward_word (TOP);
1399 AFTER_POTENTIAL_GC ();
1400 break;
1401
1402 case Bskip_chars_forward:
1403 {
1404 Lisp_Object v1;
1405 BEFORE_POTENTIAL_GC ();
1406 v1 = POP;
1407 TOP = Fskip_chars_forward (TOP, v1);
1408 AFTER_POTENTIAL_GC ();
1409 break;
1410 }
1411
1412 case Bskip_chars_backward:
1413 {
1414 Lisp_Object v1;
1415 BEFORE_POTENTIAL_GC ();
1416 v1 = POP;
1417 TOP = Fskip_chars_backward (TOP, v1);
1418 AFTER_POTENTIAL_GC ();
1419 break;
1420 }
1421
1422 case Bforward_line:
1423 BEFORE_POTENTIAL_GC ();
1424 TOP = Fforward_line (TOP);
1425 AFTER_POTENTIAL_GC ();
1426 break;
1427
1428 case Bchar_syntax:
1429 BEFORE_POTENTIAL_GC ();
1430 CHECK_NUMBER (TOP, 0);
1431 AFTER_POTENTIAL_GC ();
1432 XSETFASTINT (TOP, syntax_code_spec[(int) SYNTAX (XINT (TOP))]);
1433 break;
1434
1435 case Bbuffer_substring:
1436 {
1437 Lisp_Object v1;
1438 BEFORE_POTENTIAL_GC ();
1439 v1 = POP;
1440 TOP = Fbuffer_substring (TOP, v1);
1441 AFTER_POTENTIAL_GC ();
1442 break;
1443 }
1444
1445 case Bdelete_region:
1446 {
1447 Lisp_Object v1;
1448 BEFORE_POTENTIAL_GC ();
1449 v1 = POP;
1450 TOP = Fdelete_region (TOP, v1);
1451 AFTER_POTENTIAL_GC ();
1452 break;
1453 }
1454
1455 case Bnarrow_to_region:
1456 {
1457 Lisp_Object v1;
1458 BEFORE_POTENTIAL_GC ();
1459 v1 = POP;
1460 TOP = Fnarrow_to_region (TOP, v1);
1461 AFTER_POTENTIAL_GC ();
1462 break;
1463 }
1464
1465 case Bwiden:
1466 BEFORE_POTENTIAL_GC ();
1467 PUSH (Fwiden ());
1468 AFTER_POTENTIAL_GC ();
1469 break;
1470
1471 case Bend_of_line:
1472 BEFORE_POTENTIAL_GC ();
1473 TOP = Fend_of_line (TOP);
1474 AFTER_POTENTIAL_GC ();
1475 break;
1476
1477 case Bset_marker:
1478 {
1479 Lisp_Object v1, v2;
1480 BEFORE_POTENTIAL_GC ();
1481 v1 = POP;
1482 v2 = POP;
1483 TOP = Fset_marker (TOP, v2, v1);
1484 AFTER_POTENTIAL_GC ();
1485 break;
1486 }
1487
1488 case Bmatch_beginning:
1489 BEFORE_POTENTIAL_GC ();
1490 TOP = Fmatch_beginning (TOP);
1491 AFTER_POTENTIAL_GC ();
1492 break;
1493
1494 case Bmatch_end:
1495 BEFORE_POTENTIAL_GC ();
1496 TOP = Fmatch_end (TOP);
1497 AFTER_POTENTIAL_GC ();
1498 break;
1499
1500 case Bupcase:
1501 BEFORE_POTENTIAL_GC ();
1502 TOP = Fupcase (TOP);
1503 AFTER_POTENTIAL_GC ();
1504 break;
1505
1506 case Bdowncase:
1507 BEFORE_POTENTIAL_GC ();
1508 TOP = Fdowncase (TOP);
1509 AFTER_POTENTIAL_GC ();
1510 break;
1511
1512 case Bstringeqlsign:
1513 {
1514 Lisp_Object v1;
1515 BEFORE_POTENTIAL_GC ();
1516 v1 = POP;
1517 TOP = Fstring_equal (TOP, v1);
1518 AFTER_POTENTIAL_GC ();
1519 break;
1520 }
1521
1522 case Bstringlss:
1523 {
1524 Lisp_Object v1;
1525 BEFORE_POTENTIAL_GC ();
1526 v1 = POP;
1527 TOP = Fstring_lessp (TOP, v1);
1528 AFTER_POTENTIAL_GC ();
1529 break;
1530 }
1531
1532 case Bequal:
1533 {
1534 Lisp_Object v1;
1535 v1 = POP;
1536 TOP = Fequal (TOP, v1);
1537 break;
1538 }
1539
1540 case Bnthcdr:
1541 {
1542 Lisp_Object v1;
1543 BEFORE_POTENTIAL_GC ();
1544 v1 = POP;
1545 TOP = Fnthcdr (TOP, v1);
1546 AFTER_POTENTIAL_GC ();
1547 break;
1548 }
1549
1550 case Belt:
1551 {
1552 Lisp_Object v1, v2;
1553 if (CONSP (TOP))
1554 {
1555 /* Exchange args and then do nth. */
1556 BEFORE_POTENTIAL_GC ();
1557 v2 = POP;
1558 v1 = TOP;
1559 CHECK_NUMBER (v2, 0);
1560 AFTER_POTENTIAL_GC ();
1561 op = XINT (v2);
1562 immediate_quit = 1;
1563 while (--op >= 0)
1564 {
1565 if (CONSP (v1))
1566 v1 = XCDR (v1);
1567 else if (!NILP (v1))
1568 {
1569 immediate_quit = 0;
1570 BEFORE_POTENTIAL_GC ();
1571 v1 = wrong_type_argument (Qlistp, v1);
1572 AFTER_POTENTIAL_GC ();
1573 immediate_quit = 1;
1574 op++;
1575 }
1576 }
1577 immediate_quit = 0;
1578 if (CONSP (v1))
1579 TOP = XCAR (v1);
1580 else if (NILP (v1))
1581 TOP = Qnil;
1582 else
1583 {
1584 BEFORE_POTENTIAL_GC ();
1585 Fcar (wrong_type_argument (Qlistp, v1));
1586 AFTER_POTENTIAL_GC ();
1587 }
1588 }
1589 else
1590 {
1591 BEFORE_POTENTIAL_GC ();
1592 v1 = POP;
1593 TOP = Felt (TOP, v1);
1594 AFTER_POTENTIAL_GC ();
1595 }
1596 break;
1597 }
1598
1599 case Bmember:
1600 {
1601 Lisp_Object v1;
1602 BEFORE_POTENTIAL_GC ();
1603 v1 = POP;
1604 TOP = Fmember (TOP, v1);
1605 AFTER_POTENTIAL_GC ();
1606 break;
1607 }
1608
1609 case Bassq:
1610 {
1611 Lisp_Object v1;
1612 BEFORE_POTENTIAL_GC ();
1613 v1 = POP;
1614 TOP = Fassq (TOP, v1);
1615 AFTER_POTENTIAL_GC ();
1616 break;
1617 }
1618
1619 case Bnreverse:
1620 BEFORE_POTENTIAL_GC ();
1621 TOP = Fnreverse (TOP);
1622 AFTER_POTENTIAL_GC ();
1623 break;
1624
1625 case Bsetcar:
1626 {
1627 Lisp_Object v1;
1628 BEFORE_POTENTIAL_GC ();
1629 v1 = POP;
1630 TOP = Fsetcar (TOP, v1);
1631 AFTER_POTENTIAL_GC ();
1632 break;
1633 }
1634
1635 case Bsetcdr:
1636 {
1637 Lisp_Object v1;
1638 BEFORE_POTENTIAL_GC ();
1639 v1 = POP;
1640 TOP = Fsetcdr (TOP, v1);
1641 AFTER_POTENTIAL_GC ();
1642 break;
1643 }
1644
1645 case Bcar_safe:
1646 {
1647 Lisp_Object v1;
1648 v1 = TOP;
1649 if (CONSP (v1))
1650 TOP = XCAR (v1);
1651 else
1652 TOP = Qnil;
1653 break;
1654 }
1655
1656 case Bcdr_safe:
1657 {
1658 Lisp_Object v1;
1659 v1 = TOP;
1660 if (CONSP (v1))
1661 TOP = XCDR (v1);
1662 else
1663 TOP = Qnil;
1664 break;
1665 }
1666
1667 case Bnconc:
1668 BEFORE_POTENTIAL_GC ();
1669 DISCARD (1);
1670 TOP = Fnconc (2, &TOP);
1671 AFTER_POTENTIAL_GC ();
1672 break;
1673
1674 case Bnumberp:
1675 TOP = (NUMBERP (TOP) ? Qt : Qnil);
1676 break;
1677
1678 case Bintegerp:
1679 TOP = INTEGERP (TOP) ? Qt : Qnil;
1680 break;
1681
1682 #ifdef BYTE_CODE_SAFE
1683 case Bset_mark:
1684 BEFORE_POTENTIAL_GC ();
1685 error ("set-mark is an obsolete bytecode");
1686 AFTER_POTENTIAL_GC ();
1687 break;
1688 case Bscan_buffer:
1689 BEFORE_POTENTIAL_GC ();
1690 error ("scan-buffer is an obsolete bytecode");
1691 AFTER_POTENTIAL_GC ();
1692 break;
1693 #endif
1694
1695 case 0:
1696 abort ();
1697
1698 case 255:
1699 default:
1700 #ifdef BYTE_CODE_SAFE
1701 if (op < Bconstant)
1702 {
1703 abort ();
1704 }
1705 if ((op -= Bconstant) >= const_length)
1706 {
1707 abort ();
1708 }
1709 PUSH (vectorp[op]);
1710 #else
1711 PUSH (vectorp[op - Bconstant]);
1712 #endif
1713 }
1714 }
1715
1716 exit:
1717
1718 byte_stack_list = byte_stack_list->next;
1719
1720 /* Binds and unbinds are supposed to be compiled balanced. */
1721 if (specpdl_ptr - specpdl != count)
1722 #ifdef BYTE_CODE_SAFE
1723 error ("binding stack not balanced (serious byte compiler bug)");
1724 #else
1725 abort ();
1726 #endif
1727
1728 return result;
1729 }
1730
1731 void
1732 syms_of_bytecode ()
1733 {
1734 Qbytecode = intern ("byte-code");
1735 staticpro (&Qbytecode);
1736
1737 defsubr (&Sbyte_code);
1738
1739 #ifdef BYTE_CODE_METER
1740
1741 DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter,
1742 "A vector of vectors which holds a histogram of byte-code usage.\n\
1743 (aref (aref byte-code-meter 0) CODE) indicates how many times the byte\n\
1744 opcode CODE has been executed.\n\
1745 (aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,\n\
1746 indicates how many times the byte opcodes CODE1 and CODE2 have been\n\
1747 executed in succession.");
1748 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on,
1749 "If non-nil, keep profiling information on byte code usage.\n\
1750 The variable byte-code-meter indicates how often each byte opcode is used.\n\
1751 If a symbol has a property named `byte-code-meter' whose value is an\n\
1752 integer, it is incremented each time that symbol's function is called.");
1753
1754 byte_metering_on = 0;
1755 Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0));
1756 Qbyte_code_meter = intern ("byte-code-meter");
1757 staticpro (&Qbyte_code_meter);
1758 {
1759 int i = 256;
1760 while (i--)
1761 XVECTOR (Vbyte_code_meter)->contents[i] =
1762 Fmake_vector (make_number (256), make_number (0));
1763 }
1764 #endif
1765 }