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 #endif /* BYTE_CODE_METER */
82 Lisp_Object Qbytecode
;
110 #define Bsymbol_value 0112
111 #define Bsymbol_function 0113
115 #define Bsubstring 0117
116 #define Bconcat2 0120
117 #define Bconcat3 0121
118 #define Bconcat4 0122
121 #define Beqlsign 0125
134 /* Was Bmark in v17. */
135 #define Bsave_current_buffer 0141
136 #define Bgoto_char 0142
138 #define Bpoint_max 0144
139 #define Bpoint_min 0145
140 #define Bchar_after 0146
141 #define Bfollowing_char 0147
142 #define Bpreceding_char 0150
143 #define Bcurrent_column 0151
144 #define Bindent_to 0152
145 #ifdef BYTE_CODE_SAFE
146 #define Bscan_buffer 0153 /* No longer generated as of v18 */
152 #define Bcurrent_buffer 0160
153 #define Bset_buffer 0161
154 #define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */
156 #define Bread_char 0162 /* No longer generated as of v19 */
158 #ifdef BYTE_CODE_SAFE
159 #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
233 /* Whether to maintain a `top' and `bottom' field in the stack frame. */
234 #define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK)
236 /* Structure describing a value stack used during byte-code execution
241 /* Program counter. This points into the byte_string below
242 and is relocated when that string is relocated. */
243 const unsigned char *pc
;
245 /* Top and bottom of stack. The bottom points to an area of memory
246 allocated with alloca in Fbyte_code. */
247 #if BYTE_MAINTAIN_TOP
248 Lisp_Object
*top
, *bottom
;
251 /* The string containing the byte-code, and its current address.
252 Storing this here protects it from GC because mark_byte_stack
254 Lisp_Object byte_string
;
255 const unsigned char *byte_string_start
;
257 /* The vector of constants used during byte-code execution. Storing
258 this here protects it from GC because mark_byte_stack marks it. */
259 Lisp_Object constants
;
261 /* Next entry in byte_stack_list. */
262 struct byte_stack
*next
;
265 /* A list of currently active byte-code execution value stacks.
266 Fbyte_code adds an entry to the head of this list before it starts
267 processing byte-code, and it removed the entry again when it is
268 done. Signalling an error truncates the list analoguous to
271 struct byte_stack
*byte_stack_list
;
274 /* Mark objects on byte_stack_list. Called during GC. */
278 mark_byte_stack (void)
280 struct byte_stack
*stack
;
283 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
285 /* If STACK->top is null here, this means there's an opcode in
286 Fbyte_code that wasn't expected to GC, but did. To find out
287 which opcode this is, record the value of `stack', and walk
288 up the stack in a debugger, stopping in frames of Fbyte_code.
289 The culprit is found in the frame of Fbyte_code where the
290 address of its local variable `stack' is equal to the
291 recorded value of `stack' here. */
292 eassert (stack
->top
);
294 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
297 mark_object (stack
->byte_string
);
298 mark_object (stack
->constants
);
303 /* Unmark objects in the stacks on byte_stack_list. Relocate program
304 counters. Called when GC has completed. */
307 unmark_byte_stack (void)
309 struct byte_stack
*stack
;
311 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
313 if (stack
->byte_string_start
!= SDATA (stack
->byte_string
))
315 int offset
= stack
->pc
- stack
->byte_string_start
;
316 stack
->byte_string_start
= SDATA (stack
->byte_string
);
317 stack
->pc
= stack
->byte_string_start
+ offset
;
323 /* Fetch the next byte from the bytecode stream */
325 #define FETCH *stack.pc++
327 /* Fetch two bytes from the bytecode stream and make a 16-bit number
330 #define FETCH2 (op = FETCH, op + (FETCH << 8))
332 /* Push x onto the execution stack. This used to be #define PUSH(x)
333 (*++stackp = (x)) This oddity is necessary because Alliant can't be
334 bothered to compile the preincrement operator properly, as of 4/91.
337 #define PUSH(x) (top++, *top = (x))
339 /* Pop a value off the execution stack. */
343 /* Discard n values from the execution stack. */
345 #define DISCARD(n) (top -= (n))
347 /* Get the value which is at the top of the execution stack, but don't
352 /* Actions that must be performed before and after calling a function
355 #if !BYTE_MAINTAIN_TOP
356 #define BEFORE_POTENTIAL_GC() ((void)0)
357 #define AFTER_POTENTIAL_GC() ((void)0)
359 #define BEFORE_POTENTIAL_GC() stack.top = top
360 #define AFTER_POTENTIAL_GC() stack.top = NULL
363 /* Garbage collect if we have consed enough since the last time.
364 We do this at every branch, to avoid loops that never GC. */
368 if (consing_since_gc > gc_cons_threshold \
369 && consing_since_gc > gc_relative_threshold) \
371 BEFORE_POTENTIAL_GC (); \
372 Fgarbage_collect (); \
373 AFTER_POTENTIAL_GC (); \
377 /* Check for jumping out of range. */
379 #ifdef BYTE_CODE_SAFE
381 #define CHECK_RANGE(ARG) \
382 if (ARG >= bytestr_length) abort ()
384 #else /* not BYTE_CODE_SAFE */
386 #define CHECK_RANGE(ARG)
388 #endif /* not BYTE_CODE_SAFE */
390 /* A version of the QUIT macro which makes sure that the stack top is
391 set before signaling `quit'. */
393 #define BYTE_CODE_QUIT \
395 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
397 Lisp_Object flag = Vquit_flag; \
399 BEFORE_POTENTIAL_GC (); \
400 if (EQ (Vthrow_on_input, flag)) \
401 Fthrow (Vthrow_on_input, Qt); \
402 Fsignal (Qquit, Qnil); \
403 AFTER_POTENTIAL_GC (); \
405 ELSE_PENDING_SIGNALS \
409 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
410 doc
: /* Function used internally in byte-compiled code.
411 The first argument, BYTESTR, is a string of byte code;
412 the second, VECTOR, a vector of constants;
413 the third, MAXDEPTH, the maximum stack depth used in this function.
414 If the third argument is incorrect, Emacs may crash. */)
415 (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
)
417 int count
= SPECPDL_INDEX ();
418 #ifdef BYTE_CODE_METER
423 /* Lisp_Object v1, v2; */
424 Lisp_Object
*vectorp
;
425 #ifdef BYTE_CODE_SAFE
426 int const_length
= XVECTOR (vector
)->size
;
430 struct byte_stack stack
;
434 #if 0 /* CHECK_FRAME_FONT */
436 struct frame
*f
= SELECTED_FRAME ();
438 && FRAME_FONT (f
)->direction
!= 0
439 && FRAME_FONT (f
)->direction
!= 1)
444 CHECK_STRING (bytestr
);
445 CHECK_VECTOR (vector
);
446 CHECK_NUMBER (maxdepth
);
448 if (STRING_MULTIBYTE (bytestr
))
449 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
450 because they produced a raw 8-bit string for byte-code and now
451 such a byte-code string is loaded as multibyte while raw 8-bit
452 characters converted to multibyte form. Thus, now we must
453 convert them back to the originally intended unibyte form. */
454 bytestr
= Fstring_as_unibyte (bytestr
);
456 bytestr_length
= SBYTES (bytestr
);
457 vectorp
= XVECTOR (vector
)->contents
;
459 stack
.byte_string
= bytestr
;
460 stack
.pc
= stack
.byte_string_start
= SDATA (bytestr
);
461 stack
.constants
= vector
;
462 top
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
463 * sizeof (Lisp_Object
));
464 #if BYTE_MAINTAIN_TOP
469 stack
.next
= byte_stack_list
;
470 byte_stack_list
= &stack
;
472 #ifdef BYTE_CODE_SAFE
473 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
478 #ifdef BYTE_CODE_SAFE
481 else if (top
< stack
.bottom
- 1)
485 #ifdef BYTE_CODE_METER
487 this_op
= op
= FETCH
;
488 METER_CODE (prev_op
, op
);
508 /* This seems to be the most frequently executed byte-code
509 among the Bvarref's, so avoid a goto here. */
519 if (XSYMBOL (v1
)->redirect
!= SYMBOL_PLAINVAL
520 || (v2
= SYMBOL_VAL (XSYMBOL (v1
)),
523 BEFORE_POTENTIAL_GC ();
524 v2
= Fsymbol_value (v1
);
525 AFTER_POTENTIAL_GC ();
530 BEFORE_POTENTIAL_GC ();
531 v2
= Fsymbol_value (v1
);
532 AFTER_POTENTIAL_GC ();
548 stack
.pc
= stack
.byte_string_start
+ op
;
563 BEFORE_POTENTIAL_GC ();
564 wrong_type_argument (Qlistp
, v1
);
565 AFTER_POTENTIAL_GC ();
574 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
581 BEFORE_POTENTIAL_GC ();
583 TOP
= Fmemq (TOP
, v1
);
584 AFTER_POTENTIAL_GC ();
598 BEFORE_POTENTIAL_GC ();
599 wrong_type_argument (Qlistp
, v1
);
600 AFTER_POTENTIAL_GC ();
623 Lisp_Object sym
, val
;
628 /* Inline the most common case. */
630 && !EQ (val
, Qunbound
)
631 && !XSYMBOL (sym
)->redirect
632 && !SYMBOL_CONSTANT_P (sym
))
633 XSYMBOL (sym
)->val
.value
= val
;
636 BEFORE_POTENTIAL_GC ();
637 set_internal (sym
, val
, Qnil
, 0);
638 AFTER_POTENTIAL_GC ();
652 /* ------------------ */
670 /* Specbind can signal and thus GC. */
671 BEFORE_POTENTIAL_GC ();
672 specbind (vectorp
[op
], POP
);
673 AFTER_POTENTIAL_GC ();
693 BEFORE_POTENTIAL_GC ();
695 #ifdef BYTE_CODE_METER
696 if (byte_metering_on
&& SYMBOLP (TOP
))
701 v2
= Fget (v1
, Qbyte_code_meter
);
703 && XINT (v2
) < MOST_POSITIVE_FIXNUM
)
705 XSETINT (v2
, XINT (v2
) + 1);
706 Fput (v1
, Qbyte_code_meter
, v2
);
710 TOP
= Ffuncall (op
+ 1, &TOP
);
711 AFTER_POTENTIAL_GC ();
731 BEFORE_POTENTIAL_GC ();
732 unbind_to (SPECPDL_INDEX () - op
, Qnil
);
733 AFTER_POTENTIAL_GC ();
737 /* To unbind back to the beginning of this frame. Not used yet,
738 but will be needed for tail-recursion elimination. */
739 BEFORE_POTENTIAL_GC ();
740 unbind_to (count
, Qnil
);
741 AFTER_POTENTIAL_GC ();
747 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
749 stack
.pc
= stack
.byte_string_start
+ op
;
762 stack
.pc
= stack
.byte_string_start
+ op
;
767 case Bgotoifnilelsepop
:
774 stack
.pc
= stack
.byte_string_start
+ op
;
779 case Bgotoifnonnilelsepop
:
786 stack
.pc
= stack
.byte_string_start
+ op
;
794 stack
.pc
+= (int) *stack
.pc
- 127;
805 stack
.pc
+= (int) *stack
.pc
- 128;
819 stack
.pc
+= (int) *stack
.pc
- 128;
825 case BRgotoifnilelsepop
:
831 stack
.pc
+= op
- 128;
836 case BRgotoifnonnilelsepop
:
842 stack
.pc
+= op
- 128;
856 PUSH (vectorp
[FETCH2
]);
859 case Bsave_excursion
:
860 record_unwind_protect (save_excursion_restore
,
861 save_excursion_save ());
864 case Bsave_current_buffer
:
865 case Bsave_current_buffer_1
:
866 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
869 case Bsave_window_excursion
:
870 BEFORE_POTENTIAL_GC ();
871 TOP
= Fsave_window_excursion (TOP
);
872 AFTER_POTENTIAL_GC ();
875 case Bsave_restriction
:
876 record_unwind_protect (save_restriction_restore
,
877 save_restriction_save ());
883 BEFORE_POTENTIAL_GC ();
885 TOP
= internal_catch (TOP
, Feval
, v1
);
886 AFTER_POTENTIAL_GC ();
890 case Bunwind_protect
:
891 record_unwind_protect (Fprogn
, POP
);
894 case Bcondition_case
:
896 Lisp_Object handlers
, body
;
899 BEFORE_POTENTIAL_GC ();
900 TOP
= internal_lisp_condition_case (TOP
, body
, handlers
);
901 AFTER_POTENTIAL_GC ();
905 case Btemp_output_buffer_setup
:
906 BEFORE_POTENTIAL_GC ();
908 temp_output_buffer_setup (SSDATA (TOP
));
909 AFTER_POTENTIAL_GC ();
910 TOP
= Vstandard_output
;
913 case Btemp_output_buffer_show
:
916 BEFORE_POTENTIAL_GC ();
918 temp_output_buffer_show (TOP
);
920 /* pop binding of standard-output */
921 unbind_to (SPECPDL_INDEX () - 1, Qnil
);
922 AFTER_POTENTIAL_GC ();
929 BEFORE_POTENTIAL_GC ();
935 while (--op
>= 0 && CONSP (v1
))
939 AFTER_POTENTIAL_GC ();
944 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
948 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
952 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
956 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
960 TOP
= NILP (TOP
) ? Qt
: Qnil
;
967 TOP
= Fcons (TOP
, v1
);
972 TOP
= Fcons (TOP
, Qnil
);
979 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
985 TOP
= Flist (3, &TOP
);
990 TOP
= Flist (4, &TOP
);
996 TOP
= Flist (op
, &TOP
);
1000 BEFORE_POTENTIAL_GC ();
1001 TOP
= Flength (TOP
);
1002 AFTER_POTENTIAL_GC ();
1008 BEFORE_POTENTIAL_GC ();
1010 TOP
= Faref (TOP
, v1
);
1011 AFTER_POTENTIAL_GC ();
1018 BEFORE_POTENTIAL_GC ();
1020 TOP
= Faset (TOP
, v1
, v2
);
1021 AFTER_POTENTIAL_GC ();
1026 BEFORE_POTENTIAL_GC ();
1027 TOP
= Fsymbol_value (TOP
);
1028 AFTER_POTENTIAL_GC ();
1031 case Bsymbol_function
:
1032 BEFORE_POTENTIAL_GC ();
1033 TOP
= Fsymbol_function (TOP
);
1034 AFTER_POTENTIAL_GC ();
1040 BEFORE_POTENTIAL_GC ();
1042 TOP
= Fset (TOP
, v1
);
1043 AFTER_POTENTIAL_GC ();
1050 BEFORE_POTENTIAL_GC ();
1052 TOP
= Ffset (TOP
, v1
);
1053 AFTER_POTENTIAL_GC ();
1060 BEFORE_POTENTIAL_GC ();
1062 TOP
= Fget (TOP
, v1
);
1063 AFTER_POTENTIAL_GC ();
1070 BEFORE_POTENTIAL_GC ();
1072 TOP
= Fsubstring (TOP
, v1
, v2
);
1073 AFTER_POTENTIAL_GC ();
1078 BEFORE_POTENTIAL_GC ();
1080 TOP
= Fconcat (2, &TOP
);
1081 AFTER_POTENTIAL_GC ();
1085 BEFORE_POTENTIAL_GC ();
1087 TOP
= Fconcat (3, &TOP
);
1088 AFTER_POTENTIAL_GC ();
1092 BEFORE_POTENTIAL_GC ();
1094 TOP
= Fconcat (4, &TOP
);
1095 AFTER_POTENTIAL_GC ();
1100 BEFORE_POTENTIAL_GC ();
1102 TOP
= Fconcat (op
, &TOP
);
1103 AFTER_POTENTIAL_GC ();
1112 XSETINT (v1
, XINT (v1
) - 1);
1117 BEFORE_POTENTIAL_GC ();
1119 AFTER_POTENTIAL_GC ();
1130 XSETINT (v1
, XINT (v1
) + 1);
1135 BEFORE_POTENTIAL_GC ();
1137 AFTER_POTENTIAL_GC ();
1145 BEFORE_POTENTIAL_GC ();
1147 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1
);
1148 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
);
1149 AFTER_POTENTIAL_GC ();
1150 if (FLOATP (v1
) || FLOATP (v2
))
1154 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1155 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1156 TOP
= (f1
== f2
? Qt
: Qnil
);
1159 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1166 BEFORE_POTENTIAL_GC ();
1168 TOP
= Fgtr (TOP
, v1
);
1169 AFTER_POTENTIAL_GC ();
1176 BEFORE_POTENTIAL_GC ();
1178 TOP
= Flss (TOP
, v1
);
1179 AFTER_POTENTIAL_GC ();
1186 BEFORE_POTENTIAL_GC ();
1188 TOP
= Fleq (TOP
, v1
);
1189 AFTER_POTENTIAL_GC ();
1196 BEFORE_POTENTIAL_GC ();
1198 TOP
= Fgeq (TOP
, v1
);
1199 AFTER_POTENTIAL_GC ();
1204 BEFORE_POTENTIAL_GC ();
1206 TOP
= Fminus (2, &TOP
);
1207 AFTER_POTENTIAL_GC ();
1216 XSETINT (v1
, - XINT (v1
));
1221 BEFORE_POTENTIAL_GC ();
1222 TOP
= Fminus (1, &TOP
);
1223 AFTER_POTENTIAL_GC ();
1229 BEFORE_POTENTIAL_GC ();
1231 TOP
= Fplus (2, &TOP
);
1232 AFTER_POTENTIAL_GC ();
1236 BEFORE_POTENTIAL_GC ();
1238 TOP
= Fmax (2, &TOP
);
1239 AFTER_POTENTIAL_GC ();
1243 BEFORE_POTENTIAL_GC ();
1245 TOP
= Fmin (2, &TOP
);
1246 AFTER_POTENTIAL_GC ();
1250 BEFORE_POTENTIAL_GC ();
1252 TOP
= Ftimes (2, &TOP
);
1253 AFTER_POTENTIAL_GC ();
1257 BEFORE_POTENTIAL_GC ();
1259 TOP
= Fquo (2, &TOP
);
1260 AFTER_POTENTIAL_GC ();
1266 BEFORE_POTENTIAL_GC ();
1268 TOP
= Frem (TOP
, v1
);
1269 AFTER_POTENTIAL_GC ();
1276 XSETFASTINT (v1
, PT
);
1282 BEFORE_POTENTIAL_GC ();
1283 TOP
= Fgoto_char (TOP
);
1284 AFTER_POTENTIAL_GC ();
1288 BEFORE_POTENTIAL_GC ();
1289 TOP
= Finsert (1, &TOP
);
1290 AFTER_POTENTIAL_GC ();
1295 BEFORE_POTENTIAL_GC ();
1297 TOP
= Finsert (op
, &TOP
);
1298 AFTER_POTENTIAL_GC ();
1304 XSETFASTINT (v1
, ZV
);
1312 XSETFASTINT (v1
, BEGV
);
1318 BEFORE_POTENTIAL_GC ();
1319 TOP
= Fchar_after (TOP
);
1320 AFTER_POTENTIAL_GC ();
1323 case Bfollowing_char
:
1326 BEFORE_POTENTIAL_GC ();
1327 v1
= Ffollowing_char ();
1328 AFTER_POTENTIAL_GC ();
1333 case Bpreceding_char
:
1336 BEFORE_POTENTIAL_GC ();
1337 v1
= Fprevious_char ();
1338 AFTER_POTENTIAL_GC ();
1343 case Bcurrent_column
:
1346 BEFORE_POTENTIAL_GC ();
1347 XSETFASTINT (v1
, current_column ());
1348 AFTER_POTENTIAL_GC ();
1354 BEFORE_POTENTIAL_GC ();
1355 TOP
= Findent_to (TOP
, Qnil
);
1356 AFTER_POTENTIAL_GC ();
1375 case Bcurrent_buffer
:
1376 PUSH (Fcurrent_buffer ());
1380 BEFORE_POTENTIAL_GC ();
1381 TOP
= Fset_buffer (TOP
);
1382 AFTER_POTENTIAL_GC ();
1385 case Binteractive_p
:
1386 PUSH (Finteractive_p ());
1390 BEFORE_POTENTIAL_GC ();
1391 TOP
= Fforward_char (TOP
);
1392 AFTER_POTENTIAL_GC ();
1396 BEFORE_POTENTIAL_GC ();
1397 TOP
= Fforward_word (TOP
);
1398 AFTER_POTENTIAL_GC ();
1401 case Bskip_chars_forward
:
1404 BEFORE_POTENTIAL_GC ();
1406 TOP
= Fskip_chars_forward (TOP
, v1
);
1407 AFTER_POTENTIAL_GC ();
1411 case Bskip_chars_backward
:
1414 BEFORE_POTENTIAL_GC ();
1416 TOP
= Fskip_chars_backward (TOP
, v1
);
1417 AFTER_POTENTIAL_GC ();
1422 BEFORE_POTENTIAL_GC ();
1423 TOP
= Fforward_line (TOP
);
1424 AFTER_POTENTIAL_GC ();
1431 BEFORE_POTENTIAL_GC ();
1432 CHECK_CHARACTER (TOP
);
1433 AFTER_POTENTIAL_GC ();
1435 if (NILP (BVAR (current_buffer
, enable_multibyte_characters
)))
1436 MAKE_CHAR_MULTIBYTE (c
);
1437 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (c
)]);
1441 case Bbuffer_substring
:
1444 BEFORE_POTENTIAL_GC ();
1446 TOP
= Fbuffer_substring (TOP
, v1
);
1447 AFTER_POTENTIAL_GC ();
1451 case Bdelete_region
:
1454 BEFORE_POTENTIAL_GC ();
1456 TOP
= Fdelete_region (TOP
, v1
);
1457 AFTER_POTENTIAL_GC ();
1461 case Bnarrow_to_region
:
1464 BEFORE_POTENTIAL_GC ();
1466 TOP
= Fnarrow_to_region (TOP
, v1
);
1467 AFTER_POTENTIAL_GC ();
1472 BEFORE_POTENTIAL_GC ();
1474 AFTER_POTENTIAL_GC ();
1478 BEFORE_POTENTIAL_GC ();
1479 TOP
= Fend_of_line (TOP
);
1480 AFTER_POTENTIAL_GC ();
1486 BEFORE_POTENTIAL_GC ();
1489 TOP
= Fset_marker (TOP
, v2
, v1
);
1490 AFTER_POTENTIAL_GC ();
1494 case Bmatch_beginning
:
1495 BEFORE_POTENTIAL_GC ();
1496 TOP
= Fmatch_beginning (TOP
);
1497 AFTER_POTENTIAL_GC ();
1501 BEFORE_POTENTIAL_GC ();
1502 TOP
= Fmatch_end (TOP
);
1503 AFTER_POTENTIAL_GC ();
1507 BEFORE_POTENTIAL_GC ();
1508 TOP
= Fupcase (TOP
);
1509 AFTER_POTENTIAL_GC ();
1513 BEFORE_POTENTIAL_GC ();
1514 TOP
= Fdowncase (TOP
);
1515 AFTER_POTENTIAL_GC ();
1518 case Bstringeqlsign
:
1521 BEFORE_POTENTIAL_GC ();
1523 TOP
= Fstring_equal (TOP
, v1
);
1524 AFTER_POTENTIAL_GC ();
1531 BEFORE_POTENTIAL_GC ();
1533 TOP
= Fstring_lessp (TOP
, v1
);
1534 AFTER_POTENTIAL_GC ();
1542 TOP
= Fequal (TOP
, v1
);
1549 BEFORE_POTENTIAL_GC ();
1551 TOP
= Fnthcdr (TOP
, v1
);
1552 AFTER_POTENTIAL_GC ();
1561 /* Exchange args and then do nth. */
1562 BEFORE_POTENTIAL_GC ();
1566 AFTER_POTENTIAL_GC ();
1569 while (--op
>= 0 && CONSP (v1
))
1576 BEFORE_POTENTIAL_GC ();
1578 TOP
= Felt (TOP
, v1
);
1579 AFTER_POTENTIAL_GC ();
1587 BEFORE_POTENTIAL_GC ();
1589 TOP
= Fmember (TOP
, v1
);
1590 AFTER_POTENTIAL_GC ();
1597 BEFORE_POTENTIAL_GC ();
1599 TOP
= Fassq (TOP
, v1
);
1600 AFTER_POTENTIAL_GC ();
1605 BEFORE_POTENTIAL_GC ();
1606 TOP
= Fnreverse (TOP
);
1607 AFTER_POTENTIAL_GC ();
1613 BEFORE_POTENTIAL_GC ();
1615 TOP
= Fsetcar (TOP
, v1
);
1616 AFTER_POTENTIAL_GC ();
1623 BEFORE_POTENTIAL_GC ();
1625 TOP
= Fsetcdr (TOP
, v1
);
1626 AFTER_POTENTIAL_GC ();
1634 TOP
= CAR_SAFE (v1
);
1642 TOP
= CDR_SAFE (v1
);
1647 BEFORE_POTENTIAL_GC ();
1649 TOP
= Fnconc (2, &TOP
);
1650 AFTER_POTENTIAL_GC ();
1654 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1658 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1661 #ifdef BYTE_CODE_SAFE
1663 BEFORE_POTENTIAL_GC ();
1664 error ("set-mark is an obsolete bytecode");
1665 AFTER_POTENTIAL_GC ();
1668 BEFORE_POTENTIAL_GC ();
1669 error ("scan-buffer is an obsolete bytecode");
1670 AFTER_POTENTIAL_GC ();
1679 #ifdef BYTE_CODE_SAFE
1684 if ((op
-= Bconstant
) >= const_length
)
1690 PUSH (vectorp
[op
- Bconstant
]);
1697 byte_stack_list
= byte_stack_list
->next
;
1699 /* Binds and unbinds are supposed to be compiled balanced. */
1700 if (SPECPDL_INDEX () != count
)
1701 #ifdef BYTE_CODE_SAFE
1702 error ("binding stack not balanced (serious byte compiler bug)");
1711 syms_of_bytecode (void)
1713 Qbytecode
= intern_c_string ("byte-code");
1714 staticpro (&Qbytecode
);
1716 defsubr (&Sbyte_code
);
1718 #ifdef BYTE_CODE_METER
1720 DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter
,
1721 doc
: /* A vector of vectors which holds a histogram of byte-code usage.
1722 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1723 opcode CODE has been executed.
1724 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1725 indicates how many times the byte opcodes CODE1 and CODE2 have been
1726 executed in succession. */);
1728 DEFVAR_BOOL ("byte-metering-on", byte_metering_on
,
1729 doc
: /* If non-nil, keep profiling information on byte code usage.
1730 The variable byte-code-meter indicates how often each byte opcode is used.
1731 If a symbol has a property named `byte-code-meter' whose value is an
1732 integer, it is incremented each time that symbol's function is called. */);
1734 byte_metering_on
= 0;
1735 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1736 Qbyte_code_meter
= intern_c_string ("byte-code-meter");
1737 staticpro (&Qbyte_code_meter
);
1741 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1742 Fmake_vector (make_number (256), make_number (0));