1 /* Execution of byte code produced by bytecomp.el.
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 hacked on by jwz@lucid.com 17-jun-91
23 o added a compile-time switch to turn on simple sanity checking;
24 o put back the obsolete byte-codes for error-detection;
25 o added a new instruction, unbind_all, which I will use for
26 tail-recursion elimination;
27 o made temp_output_buffer_show be called with the right number
29 o made the new bytecodes be called with args in the right order;
30 o added metering support.
33 o added relative jump instructions;
34 o all conditionals now only do QUIT if they jump.
43 #ifdef CHECK_FRAME_FONT
49 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
50 * debugging the byte compiler...)
52 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
54 /* #define BYTE_CODE_SAFE */
55 /* #define BYTE_CODE_METER */
58 #ifdef BYTE_CODE_METER
60 Lisp_Object Vbyte_code_meter
, Qbyte_code_meter
;
63 #define METER_2(code1, code2) \
64 XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \
67 #define METER_1(code) METER_2 (0, (code))
69 #define METER_CODE(last_code, this_code) \
71 if (byte_metering_on) \
73 if (METER_1 (this_code) < MOST_POSITIVE_FIXNUM) \
74 METER_1 (this_code)++; \
76 && METER_2 (last_code, this_code) < MOST_POSITIVE_FIXNUM) \
77 METER_2 (last_code, this_code)++; \
81 #else /* no BYTE_CODE_METER */
83 #define METER_CODE(last_code, this_code)
85 #endif /* no BYTE_CODE_METER */
88 Lisp_Object Qbytecode
;
116 #define Bsymbol_value 0112
117 #define Bsymbol_function 0113
121 #define Bsubstring 0117
122 #define Bconcat2 0120
123 #define Bconcat3 0121
124 #define Bconcat4 0122
127 #define Beqlsign 0125
140 /* Was Bmark in v17. */
141 #define Bsave_current_buffer 0141
142 #define Bgoto_char 0142
144 #define Bpoint_max 0144
145 #define Bpoint_min 0145
146 #define Bchar_after 0146
147 #define Bfollowing_char 0147
148 #define Bpreceding_char 0150
149 #define Bcurrent_column 0151
150 #define Bindent_to 0152
151 #define Bscan_buffer 0153 /* No longer generated as of v18 */
156 #define Bcurrent_buffer 0160
157 #define Bset_buffer 0161
158 #define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */
159 #define Bread_char 0162 /* No longer generated as of v19 */
160 #define Bset_mark 0163 /* this loser is no longer generated as of v18 */
161 #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */
163 #define Bforward_char 0165
164 #define Bforward_word 0166
165 #define Bskip_chars_forward 0167
166 #define Bskip_chars_backward 0170
167 #define Bforward_line 0171
168 #define Bchar_syntax 0172
169 #define Bbuffer_substring 0173
170 #define Bdelete_region 0174
171 #define Bnarrow_to_region 0175
173 #define Bend_of_line 0177
175 #define Bconstant2 0201
177 #define Bgotoifnil 0203
178 #define Bgotoifnonnil 0204
179 #define Bgotoifnilelsepop 0205
180 #define Bgotoifnonnilelsepop 0206
182 #define Bdiscard 0210
185 #define Bsave_excursion 0212
186 #define Bsave_window_excursion 0213
187 #define Bsave_restriction 0214
190 #define Bunwind_protect 0216
191 #define Bcondition_case 0217
192 #define Btemp_output_buffer_setup 0220
193 #define Btemp_output_buffer_show 0221
195 #define Bunbind_all 0222
197 #define Bset_marker 0223
198 #define Bmatch_beginning 0224
199 #define Bmatch_end 0225
201 #define Bdowncase 0227
203 #define Bstringeqlsign 0230
204 #define Bstringlss 0231
210 #define Bnreverse 0237
213 #define Bcar_safe 0242
214 #define Bcdr_safe 0243
218 #define Bnumberp 0247
219 #define Bintegerp 0250
222 #define BRgotoifnil 0253
223 #define BRgotoifnonnil 0254
224 #define BRgotoifnilelsepop 0255
225 #define BRgotoifnonnilelsepop 0256
228 #define BconcatN 0260
229 #define BinsertN 0261
231 #define Bconstant 0300
232 #define CONSTANTLIM 0100
235 /* Structure describing a value stack used during byte-code execution
240 /* Program counter. This points into the byte_string below
241 and is relocated when that string is relocated. */
242 const unsigned char *pc
;
244 /* Top and bottom of stack. The bottom points to an area of memory
245 allocated with alloca in Fbyte_code. */
246 Lisp_Object
*top
, *bottom
;
248 /* The string containing the byte-code, and its current address.
249 Storing this here protects it from GC because mark_byte_stack
251 Lisp_Object byte_string
;
252 const unsigned char *byte_string_start
;
254 /* The vector of constants used during byte-code execution. Storing
255 this here protects it from GC because mark_byte_stack marks it. */
256 Lisp_Object constants
;
258 /* Next entry in byte_stack_list. */
259 struct byte_stack
*next
;
262 /* A list of currently active byte-code execution value stacks.
263 Fbyte_code adds an entry to the head of this list before it starts
264 processing byte-code, and it removed the entry again when it is
265 done. Signalling an error truncates the list analoguous to
268 struct byte_stack
*byte_stack_list
;
271 /* Mark objects on byte_stack_list. Called during GC. */
276 struct byte_stack
*stack
;
279 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
281 /* If STACK->top is null here, this means there's an opcode in
282 Fbyte_code that wasn't expected to GC, but did. To find out
283 which opcode this is, record the value of `stack', and walk
284 up the stack in a debugger, stopping in frames of Fbyte_code.
285 The culprit is found in the frame of Fbyte_code where the
286 address of its local variable `stack' is equal to the
287 recorded value of `stack' here. */
291 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
292 if (!XMARKBIT (*obj
))
298 if (!XMARKBIT (stack
->byte_string
))
300 mark_object (&stack
->byte_string
);
301 XMARK (stack
->byte_string
);
304 if (!XMARKBIT (stack
->constants
))
306 mark_object (&stack
->constants
);
307 XMARK (stack
->constants
);
313 /* Unmark objects in the stacks on byte_stack_list. Relocate program
314 counters. Called when GC has completed. */
319 struct byte_stack
*stack
;
322 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
324 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
327 XUNMARK (stack
->byte_string
);
328 XUNMARK (stack
->constants
);
330 if (stack
->byte_string_start
!= SDATA (stack
->byte_string
))
332 int offset
= stack
->pc
- stack
->byte_string_start
;
333 stack
->byte_string_start
= SDATA (stack
->byte_string
);
334 stack
->pc
= stack
->byte_string_start
+ offset
;
340 /* Fetch the next byte from the bytecode stream */
342 #define FETCH *stack.pc++
344 /* Fetch two bytes from the bytecode stream and make a 16-bit number
347 #define FETCH2 (op = FETCH, op + (FETCH << 8))
349 /* Push x onto the execution stack. This used to be #define PUSH(x)
350 (*++stackp = (x)) This oddity is necessary because Alliant can't be
351 bothered to compile the preincrement operator properly, as of 4/91.
354 #define PUSH(x) (top++, *top = (x))
356 /* Pop a value off the execution stack. */
360 /* Discard n values from the execution stack. */
362 #define DISCARD(n) (top -= (n))
364 /* Get the value which is at the top of the execution stack, but don't
369 /* Actions that must be performed before and after calling a function
372 #define BEFORE_POTENTIAL_GC() stack.top = top
373 #define AFTER_POTENTIAL_GC() stack.top = NULL
375 /* Garbage collect if we have consed enough since the last time.
376 We do this at every branch, to avoid loops that never GC. */
379 if (consing_since_gc > gc_cons_threshold) \
381 BEFORE_POTENTIAL_GC (); \
382 Fgarbage_collect (); \
383 AFTER_POTENTIAL_GC (); \
387 /* Check for jumping out of range. */
389 #ifdef BYTE_CODE_SAFE
391 #define CHECK_RANGE(ARG) \
392 if (ARG >= bytestr_length) abort ()
394 #else /* not BYTE_CODE_SAFE */
396 #define CHECK_RANGE(ARG)
398 #endif /* not BYTE_CODE_SAFE */
400 /* A version of the QUIT macro which makes sure that the stack top is
401 set before signaling `quit'. */
403 #define BYTE_CODE_QUIT \
405 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
408 BEFORE_POTENTIAL_GC (); \
409 Fsignal (Qquit, Qnil); \
414 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
415 doc
: /* Function used internally in byte-compiled code.
416 The first argument, BYTESTR, is a string of byte code;
417 the second, VECTOR, a vector of constants;
418 the third, MAXDEPTH, the maximum stack depth used in this function.
419 If the third argument is incorrect, Emacs may crash. */)
420 (bytestr
, vector
, maxdepth
)
421 Lisp_Object bytestr
, vector
, maxdepth
;
423 int count
= SPECPDL_INDEX ();
424 #ifdef BYTE_CODE_METER
429 /* Lisp_Object v1, v2; */
430 Lisp_Object
*vectorp
;
431 #ifdef BYTE_CODE_SAFE
432 int const_length
= XVECTOR (vector
)->size
;
436 struct byte_stack stack
;
440 #ifdef CHECK_FRAME_FONT
442 struct frame
*f
= SELECTED_FRAME ();
444 && FRAME_FONT (f
)->direction
!= 0
445 && FRAME_FONT (f
)->direction
!= 1)
450 CHECK_STRING (bytestr
);
451 if (!VECTORP (vector
))
452 vector
= wrong_type_argument (Qvectorp
, vector
);
453 CHECK_NUMBER (maxdepth
);
455 if (STRING_MULTIBYTE (bytestr
))
456 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
457 because they produced a raw 8-bit string for byte-code and now
458 such a byte-code string is loaded as multibyte while raw 8-bit
459 characters converted to multibyte form. Thus, now we must
460 convert them back to the originally intended unibyte form. */
461 bytestr
= Fstring_as_unibyte (bytestr
);
463 bytestr_length
= SBYTES (bytestr
);
464 vectorp
= XVECTOR (vector
)->contents
;
466 stack
.byte_string
= bytestr
;
467 stack
.pc
= stack
.byte_string_start
= SDATA (bytestr
);
468 stack
.constants
= vector
;
469 stack
.bottom
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
470 * sizeof (Lisp_Object
));
471 top
= stack
.bottom
- 1;
473 stack
.next
= byte_stack_list
;
474 byte_stack_list
= &stack
;
476 #ifdef BYTE_CODE_SAFE
477 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
482 #ifdef BYTE_CODE_SAFE
485 else if (top
< stack
.bottom
- 1)
489 #ifdef BYTE_CODE_METER
491 this_op
= op
= FETCH
;
492 METER_CODE (prev_op
, op
);
512 /* This seems to be the most frequently executed byte-code
513 among the Bvarref's, so avoid a goto here. */
523 v2
= SYMBOL_VALUE (v1
);
524 if (MISCP (v2
) || EQ (v2
, Qunbound
))
526 BEFORE_POTENTIAL_GC ();
527 v2
= Fsymbol_value (v1
);
528 AFTER_POTENTIAL_GC ();
533 BEFORE_POTENTIAL_GC ();
534 v2
= Fsymbol_value (v1
);
535 AFTER_POTENTIAL_GC ();
548 stack
.pc
= stack
.byte_string_start
+ op
;
562 BEFORE_POTENTIAL_GC ();
563 Fcar (wrong_type_argument (Qlistp
, v1
));
564 AFTER_POTENTIAL_GC ();
573 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
580 BEFORE_POTENTIAL_GC ();
582 TOP
= Fmemq (TOP
, v1
);
583 AFTER_POTENTIAL_GC ();
597 BEFORE_POTENTIAL_GC ();
598 Fcdr (wrong_type_argument (Qlistp
, v1
));
599 AFTER_POTENTIAL_GC ();
621 Lisp_Object sym
, val
;
626 /* Inline the most common case. */
628 && !EQ (val
, Qunbound
)
629 && !XSYMBOL (sym
)->indirect_variable
630 && !XSYMBOL (sym
)->constant
631 && !MISCP (XSYMBOL (sym
)->value
))
632 XSYMBOL (sym
)->value
= val
;
635 BEFORE_POTENTIAL_GC ();
636 set_internal (sym
, val
, current_buffer
, 0);
637 AFTER_POTENTIAL_GC ();
651 /* ------------------ */
669 /* Specbind can signal and thus GC. */
670 BEFORE_POTENTIAL_GC ();
671 specbind (vectorp
[op
], POP
);
672 AFTER_POTENTIAL_GC ();
692 BEFORE_POTENTIAL_GC ();
694 #ifdef BYTE_CODE_METER
695 if (byte_metering_on
&& SYMBOLP (TOP
))
700 v2
= Fget (v1
, Qbyte_code_meter
);
702 && XINT (v2
) < MOST_POSITIVE_FIXNUM
)
704 XSETINT (v2
, XINT (v2
) + 1);
705 Fput (v1
, Qbyte_code_meter
, v2
);
709 TOP
= Ffuncall (op
+ 1, &TOP
);
710 AFTER_POTENTIAL_GC ();
730 BEFORE_POTENTIAL_GC ();
731 unbind_to (SPECPDL_INDEX () - op
, Qnil
);
732 AFTER_POTENTIAL_GC ();
736 /* To unbind back to the beginning of this frame. Not used yet,
737 but will be needed for tail-recursion elimination. */
738 BEFORE_POTENTIAL_GC ();
739 unbind_to (count
, Qnil
);
740 AFTER_POTENTIAL_GC ();
746 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
748 stack
.pc
= stack
.byte_string_start
+ op
;
758 stack
.pc
= stack
.byte_string_start
+ op
;
762 case Bgotoifnilelsepop
:
769 stack
.pc
= stack
.byte_string_start
+ op
;
774 case Bgotoifnonnilelsepop
:
781 stack
.pc
= stack
.byte_string_start
+ op
;
789 stack
.pc
+= (int) *stack
.pc
- 127;
797 stack
.pc
+= (int) *stack
.pc
- 128;
807 stack
.pc
+= (int) *stack
.pc
- 128;
812 case BRgotoifnilelsepop
:
818 stack
.pc
+= op
- 128;
823 case BRgotoifnonnilelsepop
:
829 stack
.pc
+= op
- 128;
843 PUSH (vectorp
[FETCH2
]);
846 case Bsave_excursion
:
847 record_unwind_protect (save_excursion_restore
,
848 save_excursion_save ());
851 case Bsave_current_buffer
:
852 case Bsave_current_buffer_1
:
853 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
856 case Bsave_window_excursion
:
857 BEFORE_POTENTIAL_GC ();
858 TOP
= Fsave_window_excursion (TOP
);
859 AFTER_POTENTIAL_GC ();
862 case Bsave_restriction
:
863 record_unwind_protect (save_restriction_restore
,
864 save_restriction_save ());
870 BEFORE_POTENTIAL_GC ();
872 TOP
= internal_catch (TOP
, Feval
, v1
);
873 AFTER_POTENTIAL_GC ();
877 case Bunwind_protect
:
878 /* The function record_unwind_protect can GC. */
879 BEFORE_POTENTIAL_GC ();
880 record_unwind_protect (Fprogn
, POP
);
881 AFTER_POTENTIAL_GC ();
884 case Bcondition_case
:
888 v1
= Fcons (POP
, v1
);
889 BEFORE_POTENTIAL_GC ();
890 TOP
= Fcondition_case (Fcons (TOP
, v1
));
891 AFTER_POTENTIAL_GC ();
895 case Btemp_output_buffer_setup
:
896 BEFORE_POTENTIAL_GC ();
898 temp_output_buffer_setup (SDATA (TOP
));
899 AFTER_POTENTIAL_GC ();
900 TOP
= Vstandard_output
;
903 case Btemp_output_buffer_show
:
906 BEFORE_POTENTIAL_GC ();
908 temp_output_buffer_show (TOP
);
910 /* pop binding of standard-output */
911 unbind_to (SPECPDL_INDEX () - 1, Qnil
);
912 AFTER_POTENTIAL_GC ();
919 BEFORE_POTENTIAL_GC ();
923 AFTER_POTENTIAL_GC ();
933 BEFORE_POTENTIAL_GC ();
934 v1
= wrong_type_argument (Qlistp
, v1
);
935 AFTER_POTENTIAL_GC ();
947 BEFORE_POTENTIAL_GC ();
948 Fcar (wrong_type_argument (Qlistp
, v1
));
949 AFTER_POTENTIAL_GC ();
955 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
959 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
963 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
967 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
971 TOP
= NILP (TOP
) ? Qt
: Qnil
;
978 TOP
= Fcons (TOP
, v1
);
983 TOP
= Fcons (TOP
, Qnil
);
990 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
996 TOP
= Flist (3, &TOP
);
1001 TOP
= Flist (4, &TOP
);
1007 TOP
= Flist (op
, &TOP
);
1011 BEFORE_POTENTIAL_GC ();
1012 TOP
= Flength (TOP
);
1013 AFTER_POTENTIAL_GC ();
1019 BEFORE_POTENTIAL_GC ();
1021 TOP
= Faref (TOP
, v1
);
1022 AFTER_POTENTIAL_GC ();
1029 BEFORE_POTENTIAL_GC ();
1031 TOP
= Faset (TOP
, v1
, v2
);
1032 AFTER_POTENTIAL_GC ();
1037 BEFORE_POTENTIAL_GC ();
1038 TOP
= Fsymbol_value (TOP
);
1039 AFTER_POTENTIAL_GC ();
1042 case Bsymbol_function
:
1043 BEFORE_POTENTIAL_GC ();
1044 TOP
= Fsymbol_function (TOP
);
1045 AFTER_POTENTIAL_GC ();
1051 BEFORE_POTENTIAL_GC ();
1053 TOP
= Fset (TOP
, v1
);
1054 AFTER_POTENTIAL_GC ();
1061 BEFORE_POTENTIAL_GC ();
1063 TOP
= Ffset (TOP
, v1
);
1064 AFTER_POTENTIAL_GC ();
1071 BEFORE_POTENTIAL_GC ();
1073 TOP
= Fget (TOP
, v1
);
1074 AFTER_POTENTIAL_GC ();
1081 BEFORE_POTENTIAL_GC ();
1083 TOP
= Fsubstring (TOP
, v1
, v2
);
1084 AFTER_POTENTIAL_GC ();
1089 BEFORE_POTENTIAL_GC ();
1091 TOP
= Fconcat (2, &TOP
);
1092 AFTER_POTENTIAL_GC ();
1096 BEFORE_POTENTIAL_GC ();
1098 TOP
= Fconcat (3, &TOP
);
1099 AFTER_POTENTIAL_GC ();
1103 BEFORE_POTENTIAL_GC ();
1105 TOP
= Fconcat (4, &TOP
);
1106 AFTER_POTENTIAL_GC ();
1111 BEFORE_POTENTIAL_GC ();
1113 TOP
= Fconcat (op
, &TOP
);
1114 AFTER_POTENTIAL_GC ();
1123 XSETINT (v1
, XINT (v1
) - 1);
1128 BEFORE_POTENTIAL_GC ();
1130 AFTER_POTENTIAL_GC ();
1141 XSETINT (v1
, XINT (v1
) + 1);
1146 BEFORE_POTENTIAL_GC ();
1148 AFTER_POTENTIAL_GC ();
1156 BEFORE_POTENTIAL_GC ();
1158 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1
);
1159 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
);
1160 AFTER_POTENTIAL_GC ();
1161 if (FLOATP (v1
) || FLOATP (v2
))
1165 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1166 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1167 TOP
= (f1
== f2
? Qt
: Qnil
);
1170 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1177 BEFORE_POTENTIAL_GC ();
1179 TOP
= Fgtr (TOP
, v1
);
1180 AFTER_POTENTIAL_GC ();
1187 BEFORE_POTENTIAL_GC ();
1189 TOP
= Flss (TOP
, v1
);
1190 AFTER_POTENTIAL_GC ();
1197 BEFORE_POTENTIAL_GC ();
1199 TOP
= Fleq (TOP
, v1
);
1200 AFTER_POTENTIAL_GC ();
1207 BEFORE_POTENTIAL_GC ();
1209 TOP
= Fgeq (TOP
, v1
);
1210 AFTER_POTENTIAL_GC ();
1215 BEFORE_POTENTIAL_GC ();
1217 TOP
= Fminus (2, &TOP
);
1218 AFTER_POTENTIAL_GC ();
1227 XSETINT (v1
, - XINT (v1
));
1232 BEFORE_POTENTIAL_GC ();
1233 TOP
= Fminus (1, &TOP
);
1234 AFTER_POTENTIAL_GC ();
1240 BEFORE_POTENTIAL_GC ();
1242 TOP
= Fplus (2, &TOP
);
1243 AFTER_POTENTIAL_GC ();
1247 BEFORE_POTENTIAL_GC ();
1249 TOP
= Fmax (2, &TOP
);
1250 AFTER_POTENTIAL_GC ();
1254 BEFORE_POTENTIAL_GC ();
1256 TOP
= Fmin (2, &TOP
);
1257 AFTER_POTENTIAL_GC ();
1261 BEFORE_POTENTIAL_GC ();
1263 TOP
= Ftimes (2, &TOP
);
1264 AFTER_POTENTIAL_GC ();
1268 BEFORE_POTENTIAL_GC ();
1270 TOP
= Fquo (2, &TOP
);
1271 AFTER_POTENTIAL_GC ();
1277 BEFORE_POTENTIAL_GC ();
1279 TOP
= Frem (TOP
, v1
);
1280 AFTER_POTENTIAL_GC ();
1287 XSETFASTINT (v1
, PT
);
1293 BEFORE_POTENTIAL_GC ();
1294 TOP
= Fgoto_char (TOP
);
1295 AFTER_POTENTIAL_GC ();
1299 BEFORE_POTENTIAL_GC ();
1300 TOP
= Finsert (1, &TOP
);
1301 AFTER_POTENTIAL_GC ();
1306 BEFORE_POTENTIAL_GC ();
1308 TOP
= Finsert (op
, &TOP
);
1309 AFTER_POTENTIAL_GC ();
1315 XSETFASTINT (v1
, ZV
);
1323 XSETFASTINT (v1
, BEGV
);
1329 BEFORE_POTENTIAL_GC ();
1330 TOP
= Fchar_after (TOP
);
1331 AFTER_POTENTIAL_GC ();
1334 case Bfollowing_char
:
1337 BEFORE_POTENTIAL_GC ();
1338 v1
= Ffollowing_char ();
1339 AFTER_POTENTIAL_GC ();
1344 case Bpreceding_char
:
1347 BEFORE_POTENTIAL_GC ();
1348 v1
= Fprevious_char ();
1349 AFTER_POTENTIAL_GC ();
1354 case Bcurrent_column
:
1357 BEFORE_POTENTIAL_GC ();
1358 XSETFASTINT (v1
, (int) current_column ()); /* iftc */
1359 AFTER_POTENTIAL_GC ();
1365 BEFORE_POTENTIAL_GC ();
1366 TOP
= Findent_to (TOP
, Qnil
);
1367 AFTER_POTENTIAL_GC ();
1386 case Bcurrent_buffer
:
1387 PUSH (Fcurrent_buffer ());
1391 BEFORE_POTENTIAL_GC ();
1392 TOP
= Fset_buffer (TOP
);
1393 AFTER_POTENTIAL_GC ();
1396 case Binteractive_p
:
1397 PUSH (Finteractive_p ());
1401 BEFORE_POTENTIAL_GC ();
1402 TOP
= Fforward_char (TOP
);
1403 AFTER_POTENTIAL_GC ();
1407 BEFORE_POTENTIAL_GC ();
1408 TOP
= Fforward_word (TOP
);
1409 AFTER_POTENTIAL_GC ();
1412 case Bskip_chars_forward
:
1415 BEFORE_POTENTIAL_GC ();
1417 TOP
= Fskip_chars_forward (TOP
, v1
);
1418 AFTER_POTENTIAL_GC ();
1422 case Bskip_chars_backward
:
1425 BEFORE_POTENTIAL_GC ();
1427 TOP
= Fskip_chars_backward (TOP
, v1
);
1428 AFTER_POTENTIAL_GC ();
1433 BEFORE_POTENTIAL_GC ();
1434 TOP
= Fforward_line (TOP
);
1435 AFTER_POTENTIAL_GC ();
1439 BEFORE_POTENTIAL_GC ();
1441 AFTER_POTENTIAL_GC ();
1442 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (XINT (TOP
))]);
1445 case Bbuffer_substring
:
1448 BEFORE_POTENTIAL_GC ();
1450 TOP
= Fbuffer_substring (TOP
, v1
);
1451 AFTER_POTENTIAL_GC ();
1455 case Bdelete_region
:
1458 BEFORE_POTENTIAL_GC ();
1460 TOP
= Fdelete_region (TOP
, v1
);
1461 AFTER_POTENTIAL_GC ();
1465 case Bnarrow_to_region
:
1468 BEFORE_POTENTIAL_GC ();
1470 TOP
= Fnarrow_to_region (TOP
, v1
);
1471 AFTER_POTENTIAL_GC ();
1476 BEFORE_POTENTIAL_GC ();
1478 AFTER_POTENTIAL_GC ();
1482 BEFORE_POTENTIAL_GC ();
1483 TOP
= Fend_of_line (TOP
);
1484 AFTER_POTENTIAL_GC ();
1490 BEFORE_POTENTIAL_GC ();
1493 TOP
= Fset_marker (TOP
, v2
, v1
);
1494 AFTER_POTENTIAL_GC ();
1498 case Bmatch_beginning
:
1499 BEFORE_POTENTIAL_GC ();
1500 TOP
= Fmatch_beginning (TOP
);
1501 AFTER_POTENTIAL_GC ();
1505 BEFORE_POTENTIAL_GC ();
1506 TOP
= Fmatch_end (TOP
);
1507 AFTER_POTENTIAL_GC ();
1511 BEFORE_POTENTIAL_GC ();
1512 TOP
= Fupcase (TOP
);
1513 AFTER_POTENTIAL_GC ();
1517 BEFORE_POTENTIAL_GC ();
1518 TOP
= Fdowncase (TOP
);
1519 AFTER_POTENTIAL_GC ();
1522 case Bstringeqlsign
:
1525 BEFORE_POTENTIAL_GC ();
1527 TOP
= Fstring_equal (TOP
, v1
);
1528 AFTER_POTENTIAL_GC ();
1535 BEFORE_POTENTIAL_GC ();
1537 TOP
= Fstring_lessp (TOP
, v1
);
1538 AFTER_POTENTIAL_GC ();
1546 TOP
= Fequal (TOP
, v1
);
1553 BEFORE_POTENTIAL_GC ();
1555 TOP
= Fnthcdr (TOP
, v1
);
1556 AFTER_POTENTIAL_GC ();
1565 /* Exchange args and then do nth. */
1566 BEFORE_POTENTIAL_GC ();
1570 AFTER_POTENTIAL_GC ();
1577 else if (!NILP (v1
))
1580 BEFORE_POTENTIAL_GC ();
1581 v1
= wrong_type_argument (Qlistp
, v1
);
1582 AFTER_POTENTIAL_GC ();
1594 BEFORE_POTENTIAL_GC ();
1595 Fcar (wrong_type_argument (Qlistp
, v1
));
1596 AFTER_POTENTIAL_GC ();
1601 BEFORE_POTENTIAL_GC ();
1603 TOP
= Felt (TOP
, v1
);
1604 AFTER_POTENTIAL_GC ();
1612 BEFORE_POTENTIAL_GC ();
1614 TOP
= Fmember (TOP
, v1
);
1615 AFTER_POTENTIAL_GC ();
1622 BEFORE_POTENTIAL_GC ();
1624 TOP
= Fassq (TOP
, v1
);
1625 AFTER_POTENTIAL_GC ();
1630 BEFORE_POTENTIAL_GC ();
1631 TOP
= Fnreverse (TOP
);
1632 AFTER_POTENTIAL_GC ();
1638 BEFORE_POTENTIAL_GC ();
1640 TOP
= Fsetcar (TOP
, v1
);
1641 AFTER_POTENTIAL_GC ();
1648 BEFORE_POTENTIAL_GC ();
1650 TOP
= Fsetcdr (TOP
, v1
);
1651 AFTER_POTENTIAL_GC ();
1678 BEFORE_POTENTIAL_GC ();
1680 TOP
= Fnconc (2, &TOP
);
1681 AFTER_POTENTIAL_GC ();
1685 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1689 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1692 #ifdef BYTE_CODE_SAFE
1694 BEFORE_POTENTIAL_GC ();
1695 error ("set-mark is an obsolete bytecode");
1696 AFTER_POTENTIAL_GC ();
1699 BEFORE_POTENTIAL_GC ();
1700 error ("scan-buffer is an obsolete bytecode");
1701 AFTER_POTENTIAL_GC ();
1710 #ifdef BYTE_CODE_SAFE
1715 if ((op
-= Bconstant
) >= const_length
)
1721 PUSH (vectorp
[op
- Bconstant
]);
1728 byte_stack_list
= byte_stack_list
->next
;
1730 /* Binds and unbinds are supposed to be compiled balanced. */
1731 if (SPECPDL_INDEX () != count
)
1732 #ifdef BYTE_CODE_SAFE
1733 error ("binding stack not balanced (serious byte compiler bug)");
1744 Qbytecode
= intern ("byte-code");
1745 staticpro (&Qbytecode
);
1747 defsubr (&Sbyte_code
);
1749 #ifdef BYTE_CODE_METER
1751 DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter
,
1752 doc
: /* A vector of vectors which holds a histogram of byte-code usage.
1753 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1754 opcode CODE has been executed.
1755 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1756 indicates how many times the byte opcodes CODE1 and CODE2 have been
1757 executed in succession. */);
1759 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on
,
1760 doc
: /* If non-nil, keep profiling information on byte code usage.
1761 The variable byte-code-meter indicates how often each byte opcode is used.
1762 If a symbol has a property named `byte-code-meter' whose value is an
1763 integer, it is incremented each time that symbol's function is called. */);
1765 byte_metering_on
= 0;
1766 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1767 Qbyte_code_meter
= intern ("byte-code-meter");
1768 staticpro (&Qbyte_code_meter
);
1772 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1773 Fmake_vector (make_number (256), make_number (0));