1 /* Execution of byte code produced by bytecomp.el.
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 2000 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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)
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.
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.
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
28 o made the new bytecodes be called with args in the right order;
29 o added metering support.
32 o added relative jump instructions;
33 o all conditionals now only do QUIT if they jump.
42 #ifdef CHECK_FRAME_FONT
48 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
49 * debugging the byte compiler...)
51 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
53 /* #define BYTE_CODE_SAFE */
54 /* #define BYTE_CODE_METER */
57 #ifdef BYTE_CODE_METER
59 Lisp_Object Vbyte_code_meter
, Qbyte_code_meter
;
62 #define METER_2(code1, code2) \
63 XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \
66 #define METER_1(code) METER_2 (0, (code))
68 #define METER_CODE(last_code, this_code) \
70 if (byte_metering_on) \
72 if (METER_1 (this_code) != ((1<<VALBITS)-1)) \
73 METER_1 (this_code)++; \
75 && METER_2 (last_code, this_code) != ((1<<VALBITS)-1))\
76 METER_2 (last_code, this_code)++; \
80 #else /* no BYTE_CODE_METER */
82 #define METER_CODE(last_code, this_code)
84 #endif /* no BYTE_CODE_METER */
87 Lisp_Object Qbytecode
;
115 #define Bsymbol_value 0112
116 #define Bsymbol_function 0113
120 #define Bsubstring 0117
121 #define Bconcat2 0120
122 #define Bconcat3 0121
123 #define Bconcat4 0122
126 #define Beqlsign 0125
139 /* Was Bmark in v17. */
140 #define Bsave_current_buffer 0141
141 #define Bgoto_char 0142
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 */
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 */
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
172 #define Bend_of_line 0177
174 #define Bconstant2 0201
176 #define Bgotoifnil 0203
177 #define Bgotoifnonnil 0204
178 #define Bgotoifnilelsepop 0205
179 #define Bgotoifnonnilelsepop 0206
181 #define Bdiscard 0210
184 #define Bsave_excursion 0212
185 #define Bsave_window_excursion 0213
186 #define Bsave_restriction 0214
189 #define Bunwind_protect 0216
190 #define Bcondition_case 0217
191 #define Btemp_output_buffer_setup 0220
192 #define Btemp_output_buffer_show 0221
194 #define Bunbind_all 0222
196 #define Bset_marker 0223
197 #define Bmatch_beginning 0224
198 #define Bmatch_end 0225
200 #define Bdowncase 0227
202 #define Bstringeqlsign 0230
203 #define Bstringlss 0231
209 #define Bnreverse 0237
212 #define Bcar_safe 0242
213 #define Bcdr_safe 0243
217 #define Bnumberp 0247
218 #define Bintegerp 0250
221 #define BRgotoifnil 0253
222 #define BRgotoifnonnil 0254
223 #define BRgotoifnilelsepop 0255
224 #define BRgotoifnonnilelsepop 0256
227 #define BconcatN 0260
228 #define BinsertN 0261
230 #define Bconstant 0300
231 #define CONSTANTLIM 0100
234 /* Structure describing a value stack used during byte-code execution
239 /* Program counter. This points into the byte_string below
240 and is relocated when that string is relocated. */
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
;
247 /* The string containing the byte-code, and its current address.
248 Storing this here protects it from GC because mark_byte_stack
250 Lisp_Object byte_string
;
251 unsigned char *byte_string_start
;
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
;
257 /* Next entry in byte_stack_list. */
258 struct byte_stack
*next
;
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
267 struct byte_stack
*byte_stack_list
;
270 /* Mark objects on byte_stack_list. Called during GC. */
275 struct byte_stack
*stack
;
278 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
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. */
290 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
291 if (!XMARKBIT (*obj
))
297 if (!XMARKBIT (stack
->byte_string
))
299 mark_object (&stack
->byte_string
);
300 XMARK (stack
->byte_string
);
303 if (!XMARKBIT (stack
->constants
))
305 mark_object (&stack
->constants
);
306 XMARK (stack
->constants
);
312 /* Unmark objects in the stacks on byte_stack_list. Relocate program
313 counters. Called when GC has completed. */
318 struct byte_stack
*stack
;
321 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
323 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
326 XUNMARK (stack
->byte_string
);
327 XUNMARK (stack
->constants
);
329 if (stack
->byte_string_start
!= XSTRING (stack
->byte_string
)->data
)
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
;
339 /* Fetch the next byte from the bytecode stream */
341 #define FETCH *stack.pc++
343 /* Fetch two bytes from the bytecode stream and make a 16-bit number
346 #define FETCH2 (op = FETCH, op + (FETCH << 8))
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.
353 #define PUSH(x) (top++, *top = (x))
355 /* Pop a value off the execution stack. */
359 /* Discard n values from the execution stack. */
361 #define DISCARD(n) (top -= (n))
363 /* Get the value which is at the top of the execution stack, but don't
368 /* Actions that must be performed before and after calling a function
371 #define BEFORE_POTENTIAL_GC() stack.top = top
372 #define AFTER_POTENTIAL_GC() stack.top = NULL
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. */
378 if (consing_since_gc > gc_cons_threshold) \
380 BEFORE_POTENTIAL_GC (); \
381 Fgarbage_collect (); \
382 AFTER_POTENTIAL_GC (); \
386 /* Check for jumping out of range. */
388 #ifdef BYTE_CODE_SAFE
390 #define CHECK_RANGE(ARG) \
391 if (ARG >= bytestr_length) abort ()
393 #else /* not BYTE_CODE_SAFE */
395 #define CHECK_RANGE(ARG)
397 #endif /* not BYTE_CODE_SAFE */
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
;
409 int count
= specpdl_ptr
- specpdl
;
410 #ifdef BYTE_CODE_METER
415 /* Lisp_Object v1, v2; */
416 Lisp_Object
*vectorp
;
417 #ifdef BYTE_CODE_SAFE
418 int const_length
= XVECTOR (vector
)->size
;
422 struct byte_stack stack
;
426 #ifdef CHECK_FRAME_FONT
428 struct frame
*f
= SELECTED_FRAME ();
430 && FRAME_FONT (f
)->direction
!= 0
431 && FRAME_FONT (f
)->direction
!= 1)
436 CHECK_STRING (bytestr
, 0);
437 if (!VECTORP (vector
))
438 vector
= wrong_type_argument (Qvectorp
, vector
);
439 CHECK_NUMBER (maxdepth
, 2);
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
);
449 bytestr_length
= STRING_BYTES (XSTRING (bytestr
));
450 vectorp
= XVECTOR (vector
)->contents
;
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;
459 stack
.next
= byte_stack_list
;
460 byte_stack_list
= &stack
;
462 #ifdef BYTE_CODE_SAFE
463 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
468 #ifdef BYTE_CODE_SAFE
471 else if (top
< stack
.bottom
- 1)
475 #ifdef BYTE_CODE_METER
477 this_op
= op
= FETCH
;
478 METER_CODE (prev_op
, op
);
498 /* This seems to be the most frequently executed byte-code
499 among the Bvarref's, so avoid a goto here. */
509 v2
= XSYMBOL (v1
)->value
;
510 if (MISCP (v2
) || EQ (v2
, Qunbound
))
512 BEFORE_POTENTIAL_GC ();
513 v2
= Fsymbol_value (v1
);
514 AFTER_POTENTIAL_GC ();
519 BEFORE_POTENTIAL_GC ();
520 v2
= Fsymbol_value (v1
);
521 AFTER_POTENTIAL_GC ();
534 stack
.pc
= stack
.byte_string_start
+ op
;
548 BEFORE_POTENTIAL_GC ();
549 Fcar (wrong_type_argument (Qlistp
, v1
));
550 AFTER_POTENTIAL_GC ();
559 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
566 BEFORE_POTENTIAL_GC ();
568 TOP
= Fmemq (TOP
, v1
);
569 AFTER_POTENTIAL_GC ();
583 BEFORE_POTENTIAL_GC ();
584 Fcdr (wrong_type_argument (Qlistp
, v1
));
585 AFTER_POTENTIAL_GC ();
607 Lisp_Object sym
, val
;
612 /* Inline the most common case. */
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. */
622 && !(XSYMBOL (sym
)->name
->data
[0] == ':'
623 && EQ (XSYMBOL (sym
)->obarray
, initial_obarray
)
625 XSYMBOL (sym
)->value
= val
;
628 BEFORE_POTENTIAL_GC ();
629 set_internal (sym
, val
, current_buffer
, 0);
630 AFTER_POTENTIAL_GC ();
644 /* ------------------ */
662 /* Specbind can signal and thus GC. */
663 BEFORE_POTENTIAL_GC ();
664 specbind (vectorp
[op
], POP
);
665 AFTER_POTENTIAL_GC ();
685 BEFORE_POTENTIAL_GC ();
687 #ifdef BYTE_CODE_METER
688 if (byte_metering_on
&& SYMBOLP (TOP
))
693 v2
= Fget (v1
, Qbyte_code_meter
);
695 && XINT (v2
) != ((1<<VALBITS
)-1))
697 XSETINT (v2
, XINT (v2
) + 1);
698 Fput (v1
, Qbyte_code_meter
, v2
);
702 TOP
= Ffuncall (op
+ 1, &TOP
);
703 AFTER_POTENTIAL_GC ();
723 BEFORE_POTENTIAL_GC ();
724 unbind_to (specpdl_ptr
- specpdl
- op
, Qnil
);
725 AFTER_POTENTIAL_GC ();
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 ();
739 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
741 stack
.pc
= stack
.byte_string_start
+ op
;
751 stack
.pc
= stack
.byte_string_start
+ op
;
755 case Bgotoifnilelsepop
:
762 stack
.pc
= stack
.byte_string_start
+ op
;
767 case Bgotoifnonnilelsepop
:
774 stack
.pc
= stack
.byte_string_start
+ op
;
782 stack
.pc
+= (int) *stack
.pc
- 127;
790 stack
.pc
+= (int) *stack
.pc
- 128;
800 stack
.pc
+= (int) *stack
.pc
- 128;
805 case BRgotoifnilelsepop
:
811 stack
.pc
+= op
- 128;
816 case BRgotoifnonnilelsepop
:
822 stack
.pc
+= op
- 128;
836 PUSH (vectorp
[FETCH2
]);
839 case Bsave_excursion
:
840 record_unwind_protect (save_excursion_restore
,
841 save_excursion_save ());
844 case Bsave_current_buffer
:
845 case Bsave_current_buffer_1
:
846 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
849 case Bsave_window_excursion
:
850 BEFORE_POTENTIAL_GC ();
851 TOP
= Fsave_window_excursion (TOP
);
852 AFTER_POTENTIAL_GC ();
855 case Bsave_restriction
:
856 record_unwind_protect (save_restriction_restore
,
857 save_restriction_save ());
863 BEFORE_POTENTIAL_GC ();
865 TOP
= internal_catch (TOP
, Feval
, v1
);
866 AFTER_POTENTIAL_GC ();
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
;
878 case Bcondition_case
:
882 v1
= Fcons (POP
, v1
);
883 BEFORE_POTENTIAL_GC ();
884 TOP
= Fcondition_case (Fcons (TOP
, v1
));
885 AFTER_POTENTIAL_GC ();
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
;
897 case Btemp_output_buffer_show
:
900 BEFORE_POTENTIAL_GC ();
902 temp_output_buffer_show (TOP
);
904 /* pop binding of standard-output */
905 unbind_to (specpdl_ptr
- specpdl
- 1, Qnil
);
906 AFTER_POTENTIAL_GC ();
913 BEFORE_POTENTIAL_GC ();
916 CHECK_NUMBER (v2
, 0);
917 AFTER_POTENTIAL_GC ();
927 BEFORE_POTENTIAL_GC ();
928 v1
= wrong_type_argument (Qlistp
, v1
);
929 AFTER_POTENTIAL_GC ();
941 BEFORE_POTENTIAL_GC ();
942 Fcar (wrong_type_argument (Qlistp
, v1
));
943 AFTER_POTENTIAL_GC ();
949 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
953 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
957 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
961 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
965 TOP
= NILP (TOP
) ? Qt
: Qnil
;
972 TOP
= Fcons (TOP
, v1
);
977 TOP
= Fcons (TOP
, Qnil
);
984 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
990 TOP
= Flist (3, &TOP
);
995 TOP
= Flist (4, &TOP
);
1001 TOP
= Flist (op
, &TOP
);
1005 BEFORE_POTENTIAL_GC ();
1006 TOP
= Flength (TOP
);
1007 AFTER_POTENTIAL_GC ();
1013 BEFORE_POTENTIAL_GC ();
1015 TOP
= Faref (TOP
, v1
);
1016 AFTER_POTENTIAL_GC ();
1023 BEFORE_POTENTIAL_GC ();
1025 TOP
= Faset (TOP
, v1
, v2
);
1026 AFTER_POTENTIAL_GC ();
1031 BEFORE_POTENTIAL_GC ();
1032 TOP
= Fsymbol_value (TOP
);
1033 AFTER_POTENTIAL_GC ();
1036 case Bsymbol_function
:
1037 BEFORE_POTENTIAL_GC ();
1038 TOP
= Fsymbol_function (TOP
);
1039 AFTER_POTENTIAL_GC ();
1045 BEFORE_POTENTIAL_GC ();
1047 TOP
= Fset (TOP
, v1
);
1048 AFTER_POTENTIAL_GC ();
1055 BEFORE_POTENTIAL_GC ();
1057 TOP
= Ffset (TOP
, v1
);
1058 AFTER_POTENTIAL_GC ();
1065 BEFORE_POTENTIAL_GC ();
1067 TOP
= Fget (TOP
, v1
);
1068 AFTER_POTENTIAL_GC ();
1075 BEFORE_POTENTIAL_GC ();
1077 TOP
= Fsubstring (TOP
, v1
, v2
);
1078 AFTER_POTENTIAL_GC ();
1083 BEFORE_POTENTIAL_GC ();
1085 TOP
= Fconcat (2, &TOP
);
1086 AFTER_POTENTIAL_GC ();
1090 BEFORE_POTENTIAL_GC ();
1092 TOP
= Fconcat (3, &TOP
);
1093 AFTER_POTENTIAL_GC ();
1097 BEFORE_POTENTIAL_GC ();
1099 TOP
= Fconcat (4, &TOP
);
1100 AFTER_POTENTIAL_GC ();
1105 BEFORE_POTENTIAL_GC ();
1107 TOP
= Fconcat (op
, &TOP
);
1108 AFTER_POTENTIAL_GC ();
1117 XSETINT (v1
, XINT (v1
) - 1);
1131 XSETINT (v1
, XINT (v1
) + 1);
1136 BEFORE_POTENTIAL_GC ();
1138 AFTER_POTENTIAL_GC ();
1146 BEFORE_POTENTIAL_GC ();
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
))
1155 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1156 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1157 TOP
= (f1
== f2
? Qt
: Qnil
);
1160 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1167 BEFORE_POTENTIAL_GC ();
1169 TOP
= Fgtr (TOP
, v1
);
1170 AFTER_POTENTIAL_GC ();
1177 BEFORE_POTENTIAL_GC ();
1179 TOP
= Flss (TOP
, v1
);
1180 AFTER_POTENTIAL_GC ();
1187 BEFORE_POTENTIAL_GC ();
1189 TOP
= Fleq (TOP
, v1
);
1190 AFTER_POTENTIAL_GC ();
1197 BEFORE_POTENTIAL_GC ();
1199 TOP
= Fgeq (TOP
, v1
);
1200 AFTER_POTENTIAL_GC ();
1205 BEFORE_POTENTIAL_GC ();
1207 TOP
= Fminus (2, &TOP
);
1208 AFTER_POTENTIAL_GC ();
1217 XSETINT (v1
, - XINT (v1
));
1222 BEFORE_POTENTIAL_GC ();
1223 TOP
= Fminus (1, &TOP
);
1224 AFTER_POTENTIAL_GC ();
1230 BEFORE_POTENTIAL_GC ();
1232 TOP
= Fplus (2, &TOP
);
1233 AFTER_POTENTIAL_GC ();
1237 BEFORE_POTENTIAL_GC ();
1239 TOP
= Fmax (2, &TOP
);
1240 AFTER_POTENTIAL_GC ();
1244 BEFORE_POTENTIAL_GC ();
1246 TOP
= Fmin (2, &TOP
);
1247 AFTER_POTENTIAL_GC ();
1251 BEFORE_POTENTIAL_GC ();
1253 TOP
= Ftimes (2, &TOP
);
1254 AFTER_POTENTIAL_GC ();
1258 BEFORE_POTENTIAL_GC ();
1260 TOP
= Fquo (2, &TOP
);
1261 AFTER_POTENTIAL_GC ();
1267 BEFORE_POTENTIAL_GC ();
1269 TOP
= Frem (TOP
, v1
);
1270 AFTER_POTENTIAL_GC ();
1277 XSETFASTINT (v1
, PT
);
1283 BEFORE_POTENTIAL_GC ();
1284 TOP
= Fgoto_char (TOP
);
1285 AFTER_POTENTIAL_GC ();
1289 BEFORE_POTENTIAL_GC ();
1290 TOP
= Finsert (1, &TOP
);
1291 AFTER_POTENTIAL_GC ();
1296 BEFORE_POTENTIAL_GC ();
1298 TOP
= Finsert (op
, &TOP
);
1299 AFTER_POTENTIAL_GC ();
1305 XSETFASTINT (v1
, ZV
);
1313 XSETFASTINT (v1
, BEGV
);
1319 BEFORE_POTENTIAL_GC ();
1320 TOP
= Fchar_after (TOP
);
1321 AFTER_POTENTIAL_GC ();
1324 case Bfollowing_char
:
1327 BEFORE_POTENTIAL_GC ();
1328 v1
= Ffollowing_char ();
1329 AFTER_POTENTIAL_GC ();
1334 case Bpreceding_char
:
1337 BEFORE_POTENTIAL_GC ();
1338 v1
= Fprevious_char ();
1339 AFTER_POTENTIAL_GC ();
1344 case Bcurrent_column
:
1347 BEFORE_POTENTIAL_GC ();
1348 XSETFASTINT (v1
, current_column ());
1349 AFTER_POTENTIAL_GC ();
1355 BEFORE_POTENTIAL_GC ();
1356 TOP
= Findent_to (TOP
, Qnil
);
1357 AFTER_POTENTIAL_GC ();
1376 case Bcurrent_buffer
:
1377 PUSH (Fcurrent_buffer ());
1381 BEFORE_POTENTIAL_GC ();
1382 TOP
= Fset_buffer (TOP
);
1383 AFTER_POTENTIAL_GC ();
1386 case Binteractive_p
:
1387 PUSH (Finteractive_p ());
1391 BEFORE_POTENTIAL_GC ();
1392 TOP
= Fforward_char (TOP
);
1393 AFTER_POTENTIAL_GC ();
1397 BEFORE_POTENTIAL_GC ();
1398 TOP
= Fforward_word (TOP
);
1399 AFTER_POTENTIAL_GC ();
1402 case Bskip_chars_forward
:
1405 BEFORE_POTENTIAL_GC ();
1407 TOP
= Fskip_chars_forward (TOP
, v1
);
1408 AFTER_POTENTIAL_GC ();
1412 case Bskip_chars_backward
:
1415 BEFORE_POTENTIAL_GC ();
1417 TOP
= Fskip_chars_backward (TOP
, v1
);
1418 AFTER_POTENTIAL_GC ();
1423 BEFORE_POTENTIAL_GC ();
1424 TOP
= Fforward_line (TOP
);
1425 AFTER_POTENTIAL_GC ();
1429 BEFORE_POTENTIAL_GC ();
1430 CHECK_NUMBER (TOP
, 0);
1431 AFTER_POTENTIAL_GC ();
1432 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (XINT (TOP
))]);
1435 case Bbuffer_substring
:
1438 BEFORE_POTENTIAL_GC ();
1440 TOP
= Fbuffer_substring (TOP
, v1
);
1441 AFTER_POTENTIAL_GC ();
1445 case Bdelete_region
:
1448 BEFORE_POTENTIAL_GC ();
1450 TOP
= Fdelete_region (TOP
, v1
);
1451 AFTER_POTENTIAL_GC ();
1455 case Bnarrow_to_region
:
1458 BEFORE_POTENTIAL_GC ();
1460 TOP
= Fnarrow_to_region (TOP
, v1
);
1461 AFTER_POTENTIAL_GC ();
1466 BEFORE_POTENTIAL_GC ();
1468 AFTER_POTENTIAL_GC ();
1472 BEFORE_POTENTIAL_GC ();
1473 TOP
= Fend_of_line (TOP
);
1474 AFTER_POTENTIAL_GC ();
1480 BEFORE_POTENTIAL_GC ();
1483 TOP
= Fset_marker (TOP
, v2
, v1
);
1484 AFTER_POTENTIAL_GC ();
1488 case Bmatch_beginning
:
1489 BEFORE_POTENTIAL_GC ();
1490 TOP
= Fmatch_beginning (TOP
);
1491 AFTER_POTENTIAL_GC ();
1495 BEFORE_POTENTIAL_GC ();
1496 TOP
= Fmatch_end (TOP
);
1497 AFTER_POTENTIAL_GC ();
1501 BEFORE_POTENTIAL_GC ();
1502 TOP
= Fupcase (TOP
);
1503 AFTER_POTENTIAL_GC ();
1507 BEFORE_POTENTIAL_GC ();
1508 TOP
= Fdowncase (TOP
);
1509 AFTER_POTENTIAL_GC ();
1512 case Bstringeqlsign
:
1515 BEFORE_POTENTIAL_GC ();
1517 TOP
= Fstring_equal (TOP
, v1
);
1518 AFTER_POTENTIAL_GC ();
1525 BEFORE_POTENTIAL_GC ();
1527 TOP
= Fstring_lessp (TOP
, v1
);
1528 AFTER_POTENTIAL_GC ();
1536 TOP
= Fequal (TOP
, v1
);
1543 BEFORE_POTENTIAL_GC ();
1545 TOP
= Fnthcdr (TOP
, v1
);
1546 AFTER_POTENTIAL_GC ();
1555 /* Exchange args and then do nth. */
1556 BEFORE_POTENTIAL_GC ();
1559 CHECK_NUMBER (v2
, 0);
1560 AFTER_POTENTIAL_GC ();
1567 else if (!NILP (v1
))
1570 BEFORE_POTENTIAL_GC ();
1571 v1
= wrong_type_argument (Qlistp
, v1
);
1572 AFTER_POTENTIAL_GC ();
1584 BEFORE_POTENTIAL_GC ();
1585 Fcar (wrong_type_argument (Qlistp
, v1
));
1586 AFTER_POTENTIAL_GC ();
1591 BEFORE_POTENTIAL_GC ();
1593 TOP
= Felt (TOP
, v1
);
1594 AFTER_POTENTIAL_GC ();
1602 BEFORE_POTENTIAL_GC ();
1604 TOP
= Fmember (TOP
, v1
);
1605 AFTER_POTENTIAL_GC ();
1612 BEFORE_POTENTIAL_GC ();
1614 TOP
= Fassq (TOP
, v1
);
1615 AFTER_POTENTIAL_GC ();
1620 BEFORE_POTENTIAL_GC ();
1621 TOP
= Fnreverse (TOP
);
1622 AFTER_POTENTIAL_GC ();
1628 BEFORE_POTENTIAL_GC ();
1630 TOP
= Fsetcar (TOP
, v1
);
1631 AFTER_POTENTIAL_GC ();
1638 BEFORE_POTENTIAL_GC ();
1640 TOP
= Fsetcdr (TOP
, v1
);
1641 AFTER_POTENTIAL_GC ();
1668 BEFORE_POTENTIAL_GC ();
1670 TOP
= Fnconc (2, &TOP
);
1671 AFTER_POTENTIAL_GC ();
1675 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1679 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1682 #ifdef BYTE_CODE_SAFE
1684 BEFORE_POTENTIAL_GC ();
1685 error ("set-mark is an obsolete bytecode");
1686 AFTER_POTENTIAL_GC ();
1689 BEFORE_POTENTIAL_GC ();
1690 error ("scan-buffer is an obsolete bytecode");
1691 AFTER_POTENTIAL_GC ();
1700 #ifdef BYTE_CODE_SAFE
1705 if ((op
-= Bconstant
) >= const_length
)
1711 PUSH (vectorp
[op
- Bconstant
]);
1718 byte_stack_list
= byte_stack_list
->next
;
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)");
1734 Qbytecode
= intern ("byte-code");
1735 staticpro (&Qbytecode
);
1737 defsubr (&Sbyte_code
);
1739 #ifdef BYTE_CODE_METER
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.");
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
);
1761 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1762 Fmake_vector (make_number (256), make_number (0));