1 /* Execution of byte code produced by bytecomp.el.
2 Copyright (C) 1985-1988, 1993, 2000-2011 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 3 of the License, or
9 (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>. */
20 hacked on by jwz@lucid.com 17-jun-91
21 o added a compile-time switch to turn on simple sanity checking;
22 o put back the obsolete byte-codes for error-detection;
23 o added a new instruction, unbind_all, which I will use for
24 tail-recursion elimination;
25 o made temp_output_buffer_show be called with the right number
27 o made the new bytecodes be called with args in the right order;
28 o added metering support.
31 o added relative jump instructions;
32 o all conditionals now only do QUIT if they jump.
39 #include "character.h"
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 Qbyte_code_meter
;
61 #define METER_2(code1, code2) \
62 XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \
65 #define METER_1(code) METER_2 (0, (code))
67 #define METER_CODE(last_code, this_code) \
69 if (byte_metering_on) \
71 if (METER_1 (this_code) < MOST_POSITIVE_FIXNUM) \
72 METER_1 (this_code)++; \
74 && METER_2 (last_code, this_code) < MOST_POSITIVE_FIXNUM) \
75 METER_2 (last_code, this_code)++; \
79 #else /* no BYTE_CODE_METER */
81 #define METER_CODE(last_code, this_code)
83 #endif /* no BYTE_CODE_METER */
86 Lisp_Object Qbytecode
;
114 #define Bsymbol_value 0112
115 #define Bsymbol_function 0113
119 #define Bsubstring 0117
120 #define Bconcat2 0120
121 #define Bconcat3 0121
122 #define Bconcat4 0122
125 #define Beqlsign 0125
138 /* Was Bmark in v17. */
139 #define Bsave_current_buffer 0141
140 #define Bgoto_char 0142
142 #define Bpoint_max 0144
143 #define Bpoint_min 0145
144 #define Bchar_after 0146
145 #define Bfollowing_char 0147
146 #define Bpreceding_char 0150
147 #define Bcurrent_column 0151
148 #define Bindent_to 0152
149 #define Bscan_buffer 0153 /* No longer generated as of v18 */
154 #define Bcurrent_buffer 0160
155 #define Bset_buffer 0161
156 #define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */
157 #define Bread_char 0162 /* No longer generated as of v19 */
158 #define Bset_mark 0163 /* this loser is no longer generated as of v18 */
159 #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */
161 #define Bforward_char 0165
162 #define Bforward_word 0166
163 #define Bskip_chars_forward 0167
164 #define Bskip_chars_backward 0170
165 #define Bforward_line 0171
166 #define Bchar_syntax 0172
167 #define Bbuffer_substring 0173
168 #define Bdelete_region 0174
169 #define Bnarrow_to_region 0175
171 #define Bend_of_line 0177
173 #define Bconstant2 0201
175 #define Bgotoifnil 0203
176 #define Bgotoifnonnil 0204
177 #define Bgotoifnilelsepop 0205
178 #define Bgotoifnonnilelsepop 0206
180 #define Bdiscard 0210
183 #define Bsave_excursion 0212
184 #define Bsave_window_excursion 0213
185 #define Bsave_restriction 0214
188 #define Bunwind_protect 0216
189 #define Bcondition_case 0217
190 #define Btemp_output_buffer_setup 0220
191 #define Btemp_output_buffer_show 0221
193 #define Bunbind_all 0222
195 #define Bset_marker 0223
196 #define Bmatch_beginning 0224
197 #define Bmatch_end 0225
199 #define Bdowncase 0227
201 #define Bstringeqlsign 0230
202 #define Bstringlss 0231
208 #define Bnreverse 0237
211 #define Bcar_safe 0242
212 #define Bcdr_safe 0243
216 #define Bnumberp 0247
217 #define Bintegerp 0250
220 #define BRgotoifnil 0253
221 #define BRgotoifnonnil 0254
222 #define BRgotoifnilelsepop 0255
223 #define BRgotoifnonnilelsepop 0256
226 #define BconcatN 0260
227 #define BinsertN 0261
229 #define Bconstant 0300
230 #define CONSTANTLIM 0100
233 /* Structure describing a value stack used during byte-code execution
238 /* Program counter. This points into the byte_string below
239 and is relocated when that string is relocated. */
240 const unsigned char *pc
;
242 /* Top and bottom of stack. The bottom points to an area of memory
243 allocated with alloca in Fbyte_code. */
244 Lisp_Object
*top
, *bottom
;
246 /* The string containing the byte-code, and its current address.
247 Storing this here protects it from GC because mark_byte_stack
249 Lisp_Object byte_string
;
250 const unsigned char *byte_string_start
;
252 /* The vector of constants used during byte-code execution. Storing
253 this here protects it from GC because mark_byte_stack marks it. */
254 Lisp_Object constants
;
256 /* Next entry in byte_stack_list. */
257 struct byte_stack
*next
;
260 /* A list of currently active byte-code execution value stacks.
261 Fbyte_code adds an entry to the head of this list before it starts
262 processing byte-code, and it removed the entry again when it is
263 done. Signalling an error truncates the list analoguous to
266 struct byte_stack
*byte_stack_list
;
269 /* Mark objects on byte_stack_list. Called during GC. */
272 mark_byte_stack (void)
274 struct byte_stack
*stack
;
277 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
279 /* If STACK->top is null here, this means there's an opcode in
280 Fbyte_code that wasn't expected to GC, but did. To find out
281 which opcode this is, record the value of `stack', and walk
282 up the stack in a debugger, stopping in frames of Fbyte_code.
283 The culprit is found in the frame of Fbyte_code where the
284 address of its local variable `stack' is equal to the
285 recorded value of `stack' here. */
286 eassert (stack
->top
);
288 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
291 mark_object (stack
->byte_string
);
292 mark_object (stack
->constants
);
297 /* Unmark objects in the stacks on byte_stack_list. Relocate program
298 counters. Called when GC has completed. */
301 unmark_byte_stack (void)
303 struct byte_stack
*stack
;
305 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
307 if (stack
->byte_string_start
!= SDATA (stack
->byte_string
))
309 int offset
= stack
->pc
- stack
->byte_string_start
;
310 stack
->byte_string_start
= SDATA (stack
->byte_string
);
311 stack
->pc
= stack
->byte_string_start
+ offset
;
317 /* Fetch the next byte from the bytecode stream */
319 #define FETCH *stack.pc++
321 /* Fetch two bytes from the bytecode stream and make a 16-bit number
324 #define FETCH2 (op = FETCH, op + (FETCH << 8))
326 /* Push x onto the execution stack. This used to be #define PUSH(x)
327 (*++stackp = (x)) This oddity is necessary because Alliant can't be
328 bothered to compile the preincrement operator properly, as of 4/91.
331 #define PUSH(x) (top++, *top = (x))
333 /* Pop a value off the execution stack. */
337 /* Discard n values from the execution stack. */
339 #define DISCARD(n) (top -= (n))
341 /* Get the value which is at the top of the execution stack, but don't
346 /* Actions that must be performed before and after calling a function
349 #define BEFORE_POTENTIAL_GC() stack.top = top
350 #define AFTER_POTENTIAL_GC() stack.top = NULL
352 /* Garbage collect if we have consed enough since the last time.
353 We do this at every branch, to avoid loops that never GC. */
356 if (consing_since_gc > gc_cons_threshold \
357 && consing_since_gc > gc_relative_threshold) \
359 BEFORE_POTENTIAL_GC (); \
360 Fgarbage_collect (); \
361 AFTER_POTENTIAL_GC (); \
365 /* Check for jumping out of range. */
367 #ifdef BYTE_CODE_SAFE
369 #define CHECK_RANGE(ARG) \
370 if (ARG >= bytestr_length) abort ()
372 #else /* not BYTE_CODE_SAFE */
374 #define CHECK_RANGE(ARG)
376 #endif /* not BYTE_CODE_SAFE */
378 /* A version of the QUIT macro which makes sure that the stack top is
379 set before signaling `quit'. */
381 #define BYTE_CODE_QUIT \
383 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
385 Lisp_Object flag = Vquit_flag; \
387 BEFORE_POTENTIAL_GC (); \
388 if (EQ (Vthrow_on_input, flag)) \
389 Fthrow (Vthrow_on_input, Qt); \
390 Fsignal (Qquit, Qnil); \
391 AFTER_POTENTIAL_GC (); \
393 ELSE_PENDING_SIGNALS \
397 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
398 doc
: /* Function used internally in byte-compiled code.
399 The first argument, BYTESTR, is a string of byte code;
400 the second, VECTOR, a vector of constants;
401 the third, MAXDEPTH, the maximum stack depth used in this function.
402 If the third argument is incorrect, Emacs may crash. */)
403 (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
)
405 int count
= SPECPDL_INDEX ();
406 #ifdef BYTE_CODE_METER
411 /* Lisp_Object v1, v2; */
412 Lisp_Object
*vectorp
;
413 #ifdef BYTE_CODE_SAFE
414 int const_length
= XVECTOR (vector
)->size
;
418 struct byte_stack stack
;
422 #if 0 /* CHECK_FRAME_FONT */
424 struct frame
*f
= SELECTED_FRAME ();
426 && FRAME_FONT (f
)->direction
!= 0
427 && FRAME_FONT (f
)->direction
!= 1)
432 CHECK_STRING (bytestr
);
433 CHECK_VECTOR (vector
);
434 CHECK_NUMBER (maxdepth
);
436 if (STRING_MULTIBYTE (bytestr
))
437 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
438 because they produced a raw 8-bit string for byte-code and now
439 such a byte-code string is loaded as multibyte while raw 8-bit
440 characters converted to multibyte form. Thus, now we must
441 convert them back to the originally intended unibyte form. */
442 bytestr
= Fstring_as_unibyte (bytestr
);
444 bytestr_length
= SBYTES (bytestr
);
445 vectorp
= XVECTOR (vector
)->contents
;
447 stack
.byte_string
= bytestr
;
448 stack
.pc
= stack
.byte_string_start
= SDATA (bytestr
);
449 stack
.constants
= vector
;
450 stack
.bottom
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
451 * sizeof (Lisp_Object
));
452 top
= stack
.bottom
- 1;
454 stack
.next
= byte_stack_list
;
455 byte_stack_list
= &stack
;
457 #ifdef BYTE_CODE_SAFE
458 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
463 #ifdef BYTE_CODE_SAFE
466 else if (top
< stack
.bottom
- 1)
470 #ifdef BYTE_CODE_METER
472 this_op
= op
= FETCH
;
473 METER_CODE (prev_op
, op
);
493 /* This seems to be the most frequently executed byte-code
494 among the Bvarref's, so avoid a goto here. */
504 if (XSYMBOL (v1
)->redirect
!= SYMBOL_PLAINVAL
505 || (v2
= SYMBOL_VAL (XSYMBOL (v1
)),
508 BEFORE_POTENTIAL_GC ();
509 v2
= Fsymbol_value (v1
);
510 AFTER_POTENTIAL_GC ();
515 BEFORE_POTENTIAL_GC ();
516 v2
= Fsymbol_value (v1
);
517 AFTER_POTENTIAL_GC ();
533 stack
.pc
= stack
.byte_string_start
+ op
;
550 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
557 BEFORE_POTENTIAL_GC ();
559 TOP
= Fmemq (TOP
, v1
);
560 AFTER_POTENTIAL_GC ();
589 Lisp_Object sym
, val
;
594 /* Inline the most common case. */
596 && !EQ (val
, Qunbound
)
597 && !XSYMBOL (sym
)->redirect
598 && !SYMBOL_CONSTANT_P (sym
))
599 XSYMBOL (sym
)->val
.value
= val
;
602 BEFORE_POTENTIAL_GC ();
603 set_internal (sym
, val
, Qnil
, 0);
604 AFTER_POTENTIAL_GC ();
618 /* ------------------ */
636 /* Specbind can signal and thus GC. */
637 BEFORE_POTENTIAL_GC ();
638 specbind (vectorp
[op
], POP
);
639 AFTER_POTENTIAL_GC ();
659 BEFORE_POTENTIAL_GC ();
661 #ifdef BYTE_CODE_METER
662 if (byte_metering_on
&& SYMBOLP (TOP
))
667 v2
= Fget (v1
, Qbyte_code_meter
);
669 && XINT (v2
) < MOST_POSITIVE_FIXNUM
)
671 XSETINT (v2
, XINT (v2
) + 1);
672 Fput (v1
, Qbyte_code_meter
, v2
);
676 TOP
= Ffuncall (op
+ 1, &TOP
);
677 AFTER_POTENTIAL_GC ();
697 BEFORE_POTENTIAL_GC ();
698 unbind_to (SPECPDL_INDEX () - op
, Qnil
);
699 AFTER_POTENTIAL_GC ();
703 /* To unbind back to the beginning of this frame. Not used yet,
704 but will be needed for tail-recursion elimination. */
705 BEFORE_POTENTIAL_GC ();
706 unbind_to (count
, Qnil
);
707 AFTER_POTENTIAL_GC ();
713 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
715 stack
.pc
= stack
.byte_string_start
+ op
;
728 stack
.pc
= stack
.byte_string_start
+ op
;
733 case Bgotoifnilelsepop
:
740 stack
.pc
= stack
.byte_string_start
+ op
;
745 case Bgotoifnonnilelsepop
:
752 stack
.pc
= stack
.byte_string_start
+ op
;
760 stack
.pc
+= (int) *stack
.pc
- 127;
771 stack
.pc
+= (int) *stack
.pc
- 128;
785 stack
.pc
+= (int) *stack
.pc
- 128;
791 case BRgotoifnilelsepop
:
797 stack
.pc
+= op
- 128;
802 case BRgotoifnonnilelsepop
:
808 stack
.pc
+= op
- 128;
822 PUSH (vectorp
[FETCH2
]);
825 case Bsave_excursion
:
826 record_unwind_protect (save_excursion_restore
,
827 save_excursion_save ());
830 case Bsave_current_buffer
:
831 case Bsave_current_buffer_1
:
832 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
835 case Bsave_window_excursion
:
836 BEFORE_POTENTIAL_GC ();
837 TOP
= Fsave_window_excursion (TOP
);
838 AFTER_POTENTIAL_GC ();
841 case Bsave_restriction
:
842 record_unwind_protect (save_restriction_restore
,
843 save_restriction_save ());
849 BEFORE_POTENTIAL_GC ();
851 TOP
= internal_catch (TOP
, Feval
, v1
);
852 AFTER_POTENTIAL_GC ();
856 case Bunwind_protect
:
857 record_unwind_protect (Fprogn
, POP
);
860 case Bcondition_case
:
862 Lisp_Object handlers
, body
;
865 BEFORE_POTENTIAL_GC ();
866 TOP
= internal_lisp_condition_case (TOP
, body
, handlers
);
867 AFTER_POTENTIAL_GC ();
871 case Btemp_output_buffer_setup
:
872 BEFORE_POTENTIAL_GC ();
874 temp_output_buffer_setup (SSDATA (TOP
));
875 AFTER_POTENTIAL_GC ();
876 TOP
= Vstandard_output
;
879 case Btemp_output_buffer_show
:
882 BEFORE_POTENTIAL_GC ();
884 temp_output_buffer_show (TOP
);
886 /* pop binding of standard-output */
887 unbind_to (SPECPDL_INDEX () - 1, Qnil
);
888 AFTER_POTENTIAL_GC ();
895 BEFORE_POTENTIAL_GC ();
899 AFTER_POTENTIAL_GC ();
902 while (--op
>= 0 && CONSP (v1
))
910 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
914 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
918 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
922 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
926 TOP
= NILP (TOP
) ? Qt
: Qnil
;
933 TOP
= Fcons (TOP
, v1
);
938 TOP
= Fcons (TOP
, Qnil
);
945 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
951 TOP
= Flist (3, &TOP
);
956 TOP
= Flist (4, &TOP
);
962 TOP
= Flist (op
, &TOP
);
966 BEFORE_POTENTIAL_GC ();
968 AFTER_POTENTIAL_GC ();
974 BEFORE_POTENTIAL_GC ();
976 TOP
= Faref (TOP
, v1
);
977 AFTER_POTENTIAL_GC ();
984 BEFORE_POTENTIAL_GC ();
986 TOP
= Faset (TOP
, v1
, v2
);
987 AFTER_POTENTIAL_GC ();
992 BEFORE_POTENTIAL_GC ();
993 TOP
= Fsymbol_value (TOP
);
994 AFTER_POTENTIAL_GC ();
997 case Bsymbol_function
:
998 BEFORE_POTENTIAL_GC ();
999 TOP
= Fsymbol_function (TOP
);
1000 AFTER_POTENTIAL_GC ();
1006 BEFORE_POTENTIAL_GC ();
1008 TOP
= Fset (TOP
, v1
);
1009 AFTER_POTENTIAL_GC ();
1016 BEFORE_POTENTIAL_GC ();
1018 TOP
= Ffset (TOP
, v1
);
1019 AFTER_POTENTIAL_GC ();
1026 BEFORE_POTENTIAL_GC ();
1028 TOP
= Fget (TOP
, v1
);
1029 AFTER_POTENTIAL_GC ();
1036 BEFORE_POTENTIAL_GC ();
1038 TOP
= Fsubstring (TOP
, v1
, v2
);
1039 AFTER_POTENTIAL_GC ();
1044 BEFORE_POTENTIAL_GC ();
1046 TOP
= Fconcat (2, &TOP
);
1047 AFTER_POTENTIAL_GC ();
1051 BEFORE_POTENTIAL_GC ();
1053 TOP
= Fconcat (3, &TOP
);
1054 AFTER_POTENTIAL_GC ();
1058 BEFORE_POTENTIAL_GC ();
1060 TOP
= Fconcat (4, &TOP
);
1061 AFTER_POTENTIAL_GC ();
1066 BEFORE_POTENTIAL_GC ();
1068 TOP
= Fconcat (op
, &TOP
);
1069 AFTER_POTENTIAL_GC ();
1078 XSETINT (v1
, XINT (v1
) - 1);
1083 BEFORE_POTENTIAL_GC ();
1085 AFTER_POTENTIAL_GC ();
1096 XSETINT (v1
, XINT (v1
) + 1);
1101 BEFORE_POTENTIAL_GC ();
1103 AFTER_POTENTIAL_GC ();
1111 BEFORE_POTENTIAL_GC ();
1113 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1
);
1114 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
);
1115 AFTER_POTENTIAL_GC ();
1116 if (FLOATP (v1
) || FLOATP (v2
))
1120 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1121 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1122 TOP
= (f1
== f2
? Qt
: Qnil
);
1125 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1132 BEFORE_POTENTIAL_GC ();
1134 TOP
= Fgtr (TOP
, v1
);
1135 AFTER_POTENTIAL_GC ();
1142 BEFORE_POTENTIAL_GC ();
1144 TOP
= Flss (TOP
, v1
);
1145 AFTER_POTENTIAL_GC ();
1152 BEFORE_POTENTIAL_GC ();
1154 TOP
= Fleq (TOP
, v1
);
1155 AFTER_POTENTIAL_GC ();
1162 BEFORE_POTENTIAL_GC ();
1164 TOP
= Fgeq (TOP
, v1
);
1165 AFTER_POTENTIAL_GC ();
1170 BEFORE_POTENTIAL_GC ();
1172 TOP
= Fminus (2, &TOP
);
1173 AFTER_POTENTIAL_GC ();
1182 XSETINT (v1
, - XINT (v1
));
1187 BEFORE_POTENTIAL_GC ();
1188 TOP
= Fminus (1, &TOP
);
1189 AFTER_POTENTIAL_GC ();
1195 BEFORE_POTENTIAL_GC ();
1197 TOP
= Fplus (2, &TOP
);
1198 AFTER_POTENTIAL_GC ();
1202 BEFORE_POTENTIAL_GC ();
1204 TOP
= Fmax (2, &TOP
);
1205 AFTER_POTENTIAL_GC ();
1209 BEFORE_POTENTIAL_GC ();
1211 TOP
= Fmin (2, &TOP
);
1212 AFTER_POTENTIAL_GC ();
1216 BEFORE_POTENTIAL_GC ();
1218 TOP
= Ftimes (2, &TOP
);
1219 AFTER_POTENTIAL_GC ();
1223 BEFORE_POTENTIAL_GC ();
1225 TOP
= Fquo (2, &TOP
);
1226 AFTER_POTENTIAL_GC ();
1232 BEFORE_POTENTIAL_GC ();
1234 TOP
= Frem (TOP
, v1
);
1235 AFTER_POTENTIAL_GC ();
1242 XSETFASTINT (v1
, PT
);
1248 BEFORE_POTENTIAL_GC ();
1249 TOP
= Fgoto_char (TOP
);
1250 AFTER_POTENTIAL_GC ();
1254 BEFORE_POTENTIAL_GC ();
1255 TOP
= Finsert (1, &TOP
);
1256 AFTER_POTENTIAL_GC ();
1261 BEFORE_POTENTIAL_GC ();
1263 TOP
= Finsert (op
, &TOP
);
1264 AFTER_POTENTIAL_GC ();
1270 XSETFASTINT (v1
, ZV
);
1278 XSETFASTINT (v1
, BEGV
);
1284 BEFORE_POTENTIAL_GC ();
1285 TOP
= Fchar_after (TOP
);
1286 AFTER_POTENTIAL_GC ();
1289 case Bfollowing_char
:
1292 BEFORE_POTENTIAL_GC ();
1293 v1
= Ffollowing_char ();
1294 AFTER_POTENTIAL_GC ();
1299 case Bpreceding_char
:
1302 BEFORE_POTENTIAL_GC ();
1303 v1
= Fprevious_char ();
1304 AFTER_POTENTIAL_GC ();
1309 case Bcurrent_column
:
1312 BEFORE_POTENTIAL_GC ();
1313 XSETFASTINT (v1
, (int) current_column ()); /* iftc */
1314 AFTER_POTENTIAL_GC ();
1320 BEFORE_POTENTIAL_GC ();
1321 TOP
= Findent_to (TOP
, Qnil
);
1322 AFTER_POTENTIAL_GC ();
1341 case Bcurrent_buffer
:
1342 PUSH (Fcurrent_buffer ());
1346 BEFORE_POTENTIAL_GC ();
1347 TOP
= Fset_buffer (TOP
);
1348 AFTER_POTENTIAL_GC ();
1351 case Binteractive_p
:
1352 PUSH (Finteractive_p ());
1356 BEFORE_POTENTIAL_GC ();
1357 TOP
= Fforward_char (TOP
);
1358 AFTER_POTENTIAL_GC ();
1362 BEFORE_POTENTIAL_GC ();
1363 TOP
= Fforward_word (TOP
);
1364 AFTER_POTENTIAL_GC ();
1367 case Bskip_chars_forward
:
1370 BEFORE_POTENTIAL_GC ();
1372 TOP
= Fskip_chars_forward (TOP
, v1
);
1373 AFTER_POTENTIAL_GC ();
1377 case Bskip_chars_backward
:
1380 BEFORE_POTENTIAL_GC ();
1382 TOP
= Fskip_chars_backward (TOP
, v1
);
1383 AFTER_POTENTIAL_GC ();
1388 BEFORE_POTENTIAL_GC ();
1389 TOP
= Fforward_line (TOP
);
1390 AFTER_POTENTIAL_GC ();
1397 BEFORE_POTENTIAL_GC ();
1398 CHECK_CHARACTER (TOP
);
1399 AFTER_POTENTIAL_GC ();
1401 if (NILP (BVAR (current_buffer
, enable_multibyte_characters
)))
1402 MAKE_CHAR_MULTIBYTE (c
);
1403 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (c
)]);
1407 case Bbuffer_substring
:
1410 BEFORE_POTENTIAL_GC ();
1412 TOP
= Fbuffer_substring (TOP
, v1
);
1413 AFTER_POTENTIAL_GC ();
1417 case Bdelete_region
:
1420 BEFORE_POTENTIAL_GC ();
1422 TOP
= Fdelete_region (TOP
, v1
);
1423 AFTER_POTENTIAL_GC ();
1427 case Bnarrow_to_region
:
1430 BEFORE_POTENTIAL_GC ();
1432 TOP
= Fnarrow_to_region (TOP
, v1
);
1433 AFTER_POTENTIAL_GC ();
1438 BEFORE_POTENTIAL_GC ();
1440 AFTER_POTENTIAL_GC ();
1444 BEFORE_POTENTIAL_GC ();
1445 TOP
= Fend_of_line (TOP
);
1446 AFTER_POTENTIAL_GC ();
1452 BEFORE_POTENTIAL_GC ();
1455 TOP
= Fset_marker (TOP
, v2
, v1
);
1456 AFTER_POTENTIAL_GC ();
1460 case Bmatch_beginning
:
1461 BEFORE_POTENTIAL_GC ();
1462 TOP
= Fmatch_beginning (TOP
);
1463 AFTER_POTENTIAL_GC ();
1467 BEFORE_POTENTIAL_GC ();
1468 TOP
= Fmatch_end (TOP
);
1469 AFTER_POTENTIAL_GC ();
1473 BEFORE_POTENTIAL_GC ();
1474 TOP
= Fupcase (TOP
);
1475 AFTER_POTENTIAL_GC ();
1479 BEFORE_POTENTIAL_GC ();
1480 TOP
= Fdowncase (TOP
);
1481 AFTER_POTENTIAL_GC ();
1484 case Bstringeqlsign
:
1487 BEFORE_POTENTIAL_GC ();
1489 TOP
= Fstring_equal (TOP
, v1
);
1490 AFTER_POTENTIAL_GC ();
1497 BEFORE_POTENTIAL_GC ();
1499 TOP
= Fstring_lessp (TOP
, v1
);
1500 AFTER_POTENTIAL_GC ();
1508 TOP
= Fequal (TOP
, v1
);
1515 BEFORE_POTENTIAL_GC ();
1517 TOP
= Fnthcdr (TOP
, v1
);
1518 AFTER_POTENTIAL_GC ();
1527 /* Exchange args and then do nth. */
1528 BEFORE_POTENTIAL_GC ();
1532 AFTER_POTENTIAL_GC ();
1535 while (--op
>= 0 && CONSP (v1
))
1542 BEFORE_POTENTIAL_GC ();
1544 TOP
= Felt (TOP
, v1
);
1545 AFTER_POTENTIAL_GC ();
1553 BEFORE_POTENTIAL_GC ();
1555 TOP
= Fmember (TOP
, v1
);
1556 AFTER_POTENTIAL_GC ();
1563 BEFORE_POTENTIAL_GC ();
1565 TOP
= Fassq (TOP
, v1
);
1566 AFTER_POTENTIAL_GC ();
1571 BEFORE_POTENTIAL_GC ();
1572 TOP
= Fnreverse (TOP
);
1573 AFTER_POTENTIAL_GC ();
1579 BEFORE_POTENTIAL_GC ();
1581 TOP
= Fsetcar (TOP
, v1
);
1582 AFTER_POTENTIAL_GC ();
1589 BEFORE_POTENTIAL_GC ();
1591 TOP
= Fsetcdr (TOP
, v1
);
1592 AFTER_POTENTIAL_GC ();
1600 TOP
= CAR_SAFE (v1
);
1608 TOP
= CDR_SAFE (v1
);
1613 BEFORE_POTENTIAL_GC ();
1615 TOP
= Fnconc (2, &TOP
);
1616 AFTER_POTENTIAL_GC ();
1620 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1624 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1627 #ifdef BYTE_CODE_SAFE
1629 BEFORE_POTENTIAL_GC ();
1630 error ("set-mark is an obsolete bytecode");
1631 AFTER_POTENTIAL_GC ();
1634 BEFORE_POTENTIAL_GC ();
1635 error ("scan-buffer is an obsolete bytecode");
1636 AFTER_POTENTIAL_GC ();
1645 #ifdef BYTE_CODE_SAFE
1650 if ((op
-= Bconstant
) >= const_length
)
1656 PUSH (vectorp
[op
- Bconstant
]);
1663 byte_stack_list
= byte_stack_list
->next
;
1665 /* Binds and unbinds are supposed to be compiled balanced. */
1666 if (SPECPDL_INDEX () != count
)
1667 #ifdef BYTE_CODE_SAFE
1668 error ("binding stack not balanced (serious byte compiler bug)");
1677 syms_of_bytecode (void)
1679 Qbytecode
= intern_c_string ("byte-code");
1680 staticpro (&Qbytecode
);
1682 defsubr (&Sbyte_code
);
1684 #ifdef BYTE_CODE_METER
1686 DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter
,
1687 doc
: /* A vector of vectors which holds a histogram of byte-code usage.
1688 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1689 opcode CODE has been executed.
1690 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1691 indicates how many times the byte opcodes CODE1 and CODE2 have been
1692 executed in succession. */);
1694 DEFVAR_BOOL ("byte-metering-on", byte_metering_on
,
1695 doc
: /* If non-nil, keep profiling information on byte code usage.
1696 The variable byte-code-meter indicates how often each byte opcode is used.
1697 If a symbol has a property named `byte-code-meter' whose value is an
1698 integer, it is incremented each time that symbol's function is called. */);
1700 byte_metering_on
= 0;
1701 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1702 Qbyte_code_meter
= intern_c_string ("byte-code-meter");
1703 staticpro (&Qbyte_code_meter
);
1707 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1708 Fmake_vector (make_number (256), make_number (0));