1 /* Execution of byte code produced by bytecomp.el.
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 2000, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007, 2008, 2009, 2010, 2011 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 3 of the License, or
10 (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>. */
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.
40 #include "character.h"
44 #ifdef CHECK_FRAME_FONT
50 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
51 * debugging the byte compiler...)
53 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
55 /* #define BYTE_CODE_SAFE */
56 /* #define BYTE_CODE_METER */
59 #ifdef BYTE_CODE_METER
61 Lisp_Object 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) < MOST_POSITIVE_FIXNUM) \
73 METER_1 (this_code)++; \
75 && METER_2 (last_code, this_code) < MOST_POSITIVE_FIXNUM) \
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. */
241 const unsigned char *pc
;
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 const 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. */
273 mark_byte_stack (void)
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. */
287 eassert (stack
->top
);
289 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
292 mark_object (stack
->byte_string
);
293 mark_object (stack
->constants
);
298 /* Unmark objects in the stacks on byte_stack_list. Relocate program
299 counters. Called when GC has completed. */
302 unmark_byte_stack (void)
304 struct byte_stack
*stack
;
306 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
308 if (stack
->byte_string_start
!= SDATA (stack
->byte_string
))
310 int offset
= stack
->pc
- stack
->byte_string_start
;
311 stack
->byte_string_start
= SDATA (stack
->byte_string
);
312 stack
->pc
= stack
->byte_string_start
+ offset
;
318 /* Fetch the next byte from the bytecode stream */
320 #define FETCH *stack.pc++
322 /* Fetch two bytes from the bytecode stream and make a 16-bit number
325 #define FETCH2 (op = FETCH, op + (FETCH << 8))
327 /* Push x onto the execution stack. This used to be #define PUSH(x)
328 (*++stackp = (x)) This oddity is necessary because Alliant can't be
329 bothered to compile the preincrement operator properly, as of 4/91.
332 #define PUSH(x) (top++, *top = (x))
334 /* Pop a value off the execution stack. */
338 /* Discard n values from the execution stack. */
340 #define DISCARD(n) (top -= (n))
342 /* Get the value which is at the top of the execution stack, but don't
347 /* Actions that must be performed before and after calling a function
350 #define BEFORE_POTENTIAL_GC() stack.top = top
351 #define AFTER_POTENTIAL_GC() stack.top = NULL
353 /* Garbage collect if we have consed enough since the last time.
354 We do this at every branch, to avoid loops that never GC. */
357 if (consing_since_gc > gc_cons_threshold \
358 && consing_since_gc > gc_relative_threshold) \
360 BEFORE_POTENTIAL_GC (); \
361 Fgarbage_collect (); \
362 AFTER_POTENTIAL_GC (); \
366 /* Check for jumping out of range. */
368 #ifdef BYTE_CODE_SAFE
370 #define CHECK_RANGE(ARG) \
371 if (ARG >= bytestr_length) abort ()
373 #else /* not BYTE_CODE_SAFE */
375 #define CHECK_RANGE(ARG)
377 #endif /* not BYTE_CODE_SAFE */
379 /* A version of the QUIT macro which makes sure that the stack top is
380 set before signaling `quit'. */
382 #define BYTE_CODE_QUIT \
384 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
386 Lisp_Object flag = Vquit_flag; \
388 BEFORE_POTENTIAL_GC (); \
389 if (EQ (Vthrow_on_input, flag)) \
390 Fthrow (Vthrow_on_input, Qt); \
391 Fsignal (Qquit, Qnil); \
392 AFTER_POTENTIAL_GC (); \
394 ELSE_PENDING_SIGNALS \
398 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
399 doc
: /* Function used internally in byte-compiled code.
400 The first argument, BYTESTR, is a string of byte code;
401 the second, VECTOR, a vector of constants;
402 the third, MAXDEPTH, the maximum stack depth used in this function.
403 If the third argument is incorrect, Emacs may crash. */)
404 (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
)
406 int count
= SPECPDL_INDEX ();
407 #ifdef BYTE_CODE_METER
412 /* Lisp_Object v1, v2; */
413 Lisp_Object
*vectorp
;
414 #ifdef BYTE_CODE_SAFE
415 int const_length
= XVECTOR (vector
)->size
;
419 struct byte_stack stack
;
423 #if 0 /* CHECK_FRAME_FONT */
425 struct frame
*f
= SELECTED_FRAME ();
427 && FRAME_FONT (f
)->direction
!= 0
428 && FRAME_FONT (f
)->direction
!= 1)
433 CHECK_STRING (bytestr
);
434 CHECK_VECTOR (vector
);
435 CHECK_NUMBER (maxdepth
);
437 if (STRING_MULTIBYTE (bytestr
))
438 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
439 because they produced a raw 8-bit string for byte-code and now
440 such a byte-code string is loaded as multibyte while raw 8-bit
441 characters converted to multibyte form. Thus, now we must
442 convert them back to the originally intended unibyte form. */
443 bytestr
= Fstring_as_unibyte (bytestr
);
445 bytestr_length
= SBYTES (bytestr
);
446 vectorp
= XVECTOR (vector
)->contents
;
448 stack
.byte_string
= bytestr
;
449 stack
.pc
= stack
.byte_string_start
= SDATA (bytestr
);
450 stack
.constants
= vector
;
451 stack
.bottom
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
452 * sizeof (Lisp_Object
));
453 top
= stack
.bottom
- 1;
455 stack
.next
= byte_stack_list
;
456 byte_stack_list
= &stack
;
458 #ifdef BYTE_CODE_SAFE
459 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
464 #ifdef BYTE_CODE_SAFE
467 else if (top
< stack
.bottom
- 1)
471 #ifdef BYTE_CODE_METER
473 this_op
= op
= FETCH
;
474 METER_CODE (prev_op
, op
);
494 /* This seems to be the most frequently executed byte-code
495 among the Bvarref's, so avoid a goto here. */
505 if (XSYMBOL (v1
)->redirect
!= SYMBOL_PLAINVAL
506 || (v2
= SYMBOL_VAL (XSYMBOL (v1
)),
509 BEFORE_POTENTIAL_GC ();
510 v2
= Fsymbol_value (v1
);
511 AFTER_POTENTIAL_GC ();
516 BEFORE_POTENTIAL_GC ();
517 v2
= Fsymbol_value (v1
);
518 AFTER_POTENTIAL_GC ();
534 stack
.pc
= stack
.byte_string_start
+ op
;
551 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
558 BEFORE_POTENTIAL_GC ();
560 TOP
= Fmemq (TOP
, v1
);
561 AFTER_POTENTIAL_GC ();
590 Lisp_Object sym
, val
;
595 /* Inline the most common case. */
597 && !EQ (val
, Qunbound
)
598 && !XSYMBOL (sym
)->redirect
599 && !SYMBOL_CONSTANT_P (sym
))
600 XSYMBOL (sym
)->val
.value
= val
;
603 BEFORE_POTENTIAL_GC ();
604 set_internal (sym
, val
, Qnil
, 0);
605 AFTER_POTENTIAL_GC ();
619 /* ------------------ */
637 /* Specbind can signal and thus GC. */
638 BEFORE_POTENTIAL_GC ();
639 specbind (vectorp
[op
], POP
);
640 AFTER_POTENTIAL_GC ();
660 BEFORE_POTENTIAL_GC ();
662 #ifdef BYTE_CODE_METER
663 if (byte_metering_on
&& SYMBOLP (TOP
))
668 v2
= Fget (v1
, Qbyte_code_meter
);
670 && XINT (v2
) < MOST_POSITIVE_FIXNUM
)
672 XSETINT (v2
, XINT (v2
) + 1);
673 Fput (v1
, Qbyte_code_meter
, v2
);
677 TOP
= Ffuncall (op
+ 1, &TOP
);
678 AFTER_POTENTIAL_GC ();
698 BEFORE_POTENTIAL_GC ();
699 unbind_to (SPECPDL_INDEX () - op
, Qnil
);
700 AFTER_POTENTIAL_GC ();
704 /* To unbind back to the beginning of this frame. Not used yet,
705 but will be needed for tail-recursion elimination. */
706 BEFORE_POTENTIAL_GC ();
707 unbind_to (count
, Qnil
);
708 AFTER_POTENTIAL_GC ();
714 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
716 stack
.pc
= stack
.byte_string_start
+ op
;
729 stack
.pc
= stack
.byte_string_start
+ op
;
734 case Bgotoifnilelsepop
:
741 stack
.pc
= stack
.byte_string_start
+ op
;
746 case Bgotoifnonnilelsepop
:
753 stack
.pc
= stack
.byte_string_start
+ op
;
761 stack
.pc
+= (int) *stack
.pc
- 127;
772 stack
.pc
+= (int) *stack
.pc
- 128;
786 stack
.pc
+= (int) *stack
.pc
- 128;
792 case BRgotoifnilelsepop
:
798 stack
.pc
+= op
- 128;
803 case BRgotoifnonnilelsepop
:
809 stack
.pc
+= op
- 128;
823 PUSH (vectorp
[FETCH2
]);
826 case Bsave_excursion
:
827 record_unwind_protect (save_excursion_restore
,
828 save_excursion_save ());
831 case Bsave_current_buffer
:
832 case Bsave_current_buffer_1
:
833 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
836 case Bsave_window_excursion
:
837 BEFORE_POTENTIAL_GC ();
838 TOP
= Fsave_window_excursion (TOP
);
839 AFTER_POTENTIAL_GC ();
842 case Bsave_restriction
:
843 record_unwind_protect (save_restriction_restore
,
844 save_restriction_save ());
850 BEFORE_POTENTIAL_GC ();
852 TOP
= internal_catch (TOP
, Feval
, v1
);
853 AFTER_POTENTIAL_GC ();
857 case Bunwind_protect
:
858 record_unwind_protect (Fprogn
, POP
);
861 case Bcondition_case
:
863 Lisp_Object handlers
, body
;
866 BEFORE_POTENTIAL_GC ();
867 TOP
= internal_lisp_condition_case (TOP
, body
, handlers
);
868 AFTER_POTENTIAL_GC ();
872 case Btemp_output_buffer_setup
:
873 BEFORE_POTENTIAL_GC ();
875 temp_output_buffer_setup (SDATA (TOP
));
876 AFTER_POTENTIAL_GC ();
877 TOP
= Vstandard_output
;
880 case Btemp_output_buffer_show
:
883 BEFORE_POTENTIAL_GC ();
885 temp_output_buffer_show (TOP
);
887 /* pop binding of standard-output */
888 unbind_to (SPECPDL_INDEX () - 1, Qnil
);
889 AFTER_POTENTIAL_GC ();
896 BEFORE_POTENTIAL_GC ();
900 AFTER_POTENTIAL_GC ();
903 while (--op
>= 0 && CONSP (v1
))
911 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
915 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
919 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
923 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
927 TOP
= NILP (TOP
) ? Qt
: Qnil
;
934 TOP
= Fcons (TOP
, v1
);
939 TOP
= Fcons (TOP
, Qnil
);
946 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
952 TOP
= Flist (3, &TOP
);
957 TOP
= Flist (4, &TOP
);
963 TOP
= Flist (op
, &TOP
);
967 BEFORE_POTENTIAL_GC ();
969 AFTER_POTENTIAL_GC ();
975 BEFORE_POTENTIAL_GC ();
977 TOP
= Faref (TOP
, v1
);
978 AFTER_POTENTIAL_GC ();
985 BEFORE_POTENTIAL_GC ();
987 TOP
= Faset (TOP
, v1
, v2
);
988 AFTER_POTENTIAL_GC ();
993 BEFORE_POTENTIAL_GC ();
994 TOP
= Fsymbol_value (TOP
);
995 AFTER_POTENTIAL_GC ();
998 case Bsymbol_function
:
999 BEFORE_POTENTIAL_GC ();
1000 TOP
= Fsymbol_function (TOP
);
1001 AFTER_POTENTIAL_GC ();
1007 BEFORE_POTENTIAL_GC ();
1009 TOP
= Fset (TOP
, v1
);
1010 AFTER_POTENTIAL_GC ();
1017 BEFORE_POTENTIAL_GC ();
1019 TOP
= Ffset (TOP
, v1
);
1020 AFTER_POTENTIAL_GC ();
1027 BEFORE_POTENTIAL_GC ();
1029 TOP
= Fget (TOP
, v1
);
1030 AFTER_POTENTIAL_GC ();
1037 BEFORE_POTENTIAL_GC ();
1039 TOP
= Fsubstring (TOP
, v1
, v2
);
1040 AFTER_POTENTIAL_GC ();
1045 BEFORE_POTENTIAL_GC ();
1047 TOP
= Fconcat (2, &TOP
);
1048 AFTER_POTENTIAL_GC ();
1052 BEFORE_POTENTIAL_GC ();
1054 TOP
= Fconcat (3, &TOP
);
1055 AFTER_POTENTIAL_GC ();
1059 BEFORE_POTENTIAL_GC ();
1061 TOP
= Fconcat (4, &TOP
);
1062 AFTER_POTENTIAL_GC ();
1067 BEFORE_POTENTIAL_GC ();
1069 TOP
= Fconcat (op
, &TOP
);
1070 AFTER_POTENTIAL_GC ();
1079 XSETINT (v1
, XINT (v1
) - 1);
1084 BEFORE_POTENTIAL_GC ();
1086 AFTER_POTENTIAL_GC ();
1097 XSETINT (v1
, XINT (v1
) + 1);
1102 BEFORE_POTENTIAL_GC ();
1104 AFTER_POTENTIAL_GC ();
1112 BEFORE_POTENTIAL_GC ();
1114 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1
);
1115 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
);
1116 AFTER_POTENTIAL_GC ();
1117 if (FLOATP (v1
) || FLOATP (v2
))
1121 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1122 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1123 TOP
= (f1
== f2
? Qt
: Qnil
);
1126 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1133 BEFORE_POTENTIAL_GC ();
1135 TOP
= Fgtr (TOP
, v1
);
1136 AFTER_POTENTIAL_GC ();
1143 BEFORE_POTENTIAL_GC ();
1145 TOP
= Flss (TOP
, v1
);
1146 AFTER_POTENTIAL_GC ();
1153 BEFORE_POTENTIAL_GC ();
1155 TOP
= Fleq (TOP
, v1
);
1156 AFTER_POTENTIAL_GC ();
1163 BEFORE_POTENTIAL_GC ();
1165 TOP
= Fgeq (TOP
, v1
);
1166 AFTER_POTENTIAL_GC ();
1171 BEFORE_POTENTIAL_GC ();
1173 TOP
= Fminus (2, &TOP
);
1174 AFTER_POTENTIAL_GC ();
1183 XSETINT (v1
, - XINT (v1
));
1188 BEFORE_POTENTIAL_GC ();
1189 TOP
= Fminus (1, &TOP
);
1190 AFTER_POTENTIAL_GC ();
1196 BEFORE_POTENTIAL_GC ();
1198 TOP
= Fplus (2, &TOP
);
1199 AFTER_POTENTIAL_GC ();
1203 BEFORE_POTENTIAL_GC ();
1205 TOP
= Fmax (2, &TOP
);
1206 AFTER_POTENTIAL_GC ();
1210 BEFORE_POTENTIAL_GC ();
1212 TOP
= Fmin (2, &TOP
);
1213 AFTER_POTENTIAL_GC ();
1217 BEFORE_POTENTIAL_GC ();
1219 TOP
= Ftimes (2, &TOP
);
1220 AFTER_POTENTIAL_GC ();
1224 BEFORE_POTENTIAL_GC ();
1226 TOP
= Fquo (2, &TOP
);
1227 AFTER_POTENTIAL_GC ();
1233 BEFORE_POTENTIAL_GC ();
1235 TOP
= Frem (TOP
, v1
);
1236 AFTER_POTENTIAL_GC ();
1243 XSETFASTINT (v1
, PT
);
1249 BEFORE_POTENTIAL_GC ();
1250 TOP
= Fgoto_char (TOP
);
1251 AFTER_POTENTIAL_GC ();
1255 BEFORE_POTENTIAL_GC ();
1256 TOP
= Finsert (1, &TOP
);
1257 AFTER_POTENTIAL_GC ();
1262 BEFORE_POTENTIAL_GC ();
1264 TOP
= Finsert (op
, &TOP
);
1265 AFTER_POTENTIAL_GC ();
1271 XSETFASTINT (v1
, ZV
);
1279 XSETFASTINT (v1
, BEGV
);
1285 BEFORE_POTENTIAL_GC ();
1286 TOP
= Fchar_after (TOP
);
1287 AFTER_POTENTIAL_GC ();
1290 case Bfollowing_char
:
1293 BEFORE_POTENTIAL_GC ();
1294 v1
= Ffollowing_char ();
1295 AFTER_POTENTIAL_GC ();
1300 case Bpreceding_char
:
1303 BEFORE_POTENTIAL_GC ();
1304 v1
= Fprevious_char ();
1305 AFTER_POTENTIAL_GC ();
1310 case Bcurrent_column
:
1313 BEFORE_POTENTIAL_GC ();
1314 XSETFASTINT (v1
, (int) current_column ()); /* iftc */
1315 AFTER_POTENTIAL_GC ();
1321 BEFORE_POTENTIAL_GC ();
1322 TOP
= Findent_to (TOP
, Qnil
);
1323 AFTER_POTENTIAL_GC ();
1342 case Bcurrent_buffer
:
1343 PUSH (Fcurrent_buffer ());
1347 BEFORE_POTENTIAL_GC ();
1348 TOP
= Fset_buffer (TOP
);
1349 AFTER_POTENTIAL_GC ();
1352 case Binteractive_p
:
1353 PUSH (Finteractive_p ());
1357 BEFORE_POTENTIAL_GC ();
1358 TOP
= Fforward_char (TOP
);
1359 AFTER_POTENTIAL_GC ();
1363 BEFORE_POTENTIAL_GC ();
1364 TOP
= Fforward_word (TOP
);
1365 AFTER_POTENTIAL_GC ();
1368 case Bskip_chars_forward
:
1371 BEFORE_POTENTIAL_GC ();
1373 TOP
= Fskip_chars_forward (TOP
, v1
);
1374 AFTER_POTENTIAL_GC ();
1378 case Bskip_chars_backward
:
1381 BEFORE_POTENTIAL_GC ();
1383 TOP
= Fskip_chars_backward (TOP
, v1
);
1384 AFTER_POTENTIAL_GC ();
1389 BEFORE_POTENTIAL_GC ();
1390 TOP
= Fforward_line (TOP
);
1391 AFTER_POTENTIAL_GC ();
1398 BEFORE_POTENTIAL_GC ();
1399 CHECK_CHARACTER (TOP
);
1400 AFTER_POTENTIAL_GC ();
1402 if (NILP (current_buffer
->enable_multibyte_characters
))
1403 MAKE_CHAR_MULTIBYTE (c
);
1404 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (c
)]);
1408 case Bbuffer_substring
:
1411 BEFORE_POTENTIAL_GC ();
1413 TOP
= Fbuffer_substring (TOP
, v1
);
1414 AFTER_POTENTIAL_GC ();
1418 case Bdelete_region
:
1421 BEFORE_POTENTIAL_GC ();
1423 TOP
= Fdelete_region (TOP
, v1
);
1424 AFTER_POTENTIAL_GC ();
1428 case Bnarrow_to_region
:
1431 BEFORE_POTENTIAL_GC ();
1433 TOP
= Fnarrow_to_region (TOP
, v1
);
1434 AFTER_POTENTIAL_GC ();
1439 BEFORE_POTENTIAL_GC ();
1441 AFTER_POTENTIAL_GC ();
1445 BEFORE_POTENTIAL_GC ();
1446 TOP
= Fend_of_line (TOP
);
1447 AFTER_POTENTIAL_GC ();
1453 BEFORE_POTENTIAL_GC ();
1456 TOP
= Fset_marker (TOP
, v2
, v1
);
1457 AFTER_POTENTIAL_GC ();
1461 case Bmatch_beginning
:
1462 BEFORE_POTENTIAL_GC ();
1463 TOP
= Fmatch_beginning (TOP
);
1464 AFTER_POTENTIAL_GC ();
1468 BEFORE_POTENTIAL_GC ();
1469 TOP
= Fmatch_end (TOP
);
1470 AFTER_POTENTIAL_GC ();
1474 BEFORE_POTENTIAL_GC ();
1475 TOP
= Fupcase (TOP
);
1476 AFTER_POTENTIAL_GC ();
1480 BEFORE_POTENTIAL_GC ();
1481 TOP
= Fdowncase (TOP
);
1482 AFTER_POTENTIAL_GC ();
1485 case Bstringeqlsign
:
1488 BEFORE_POTENTIAL_GC ();
1490 TOP
= Fstring_equal (TOP
, v1
);
1491 AFTER_POTENTIAL_GC ();
1498 BEFORE_POTENTIAL_GC ();
1500 TOP
= Fstring_lessp (TOP
, v1
);
1501 AFTER_POTENTIAL_GC ();
1509 TOP
= Fequal (TOP
, v1
);
1516 BEFORE_POTENTIAL_GC ();
1518 TOP
= Fnthcdr (TOP
, v1
);
1519 AFTER_POTENTIAL_GC ();
1528 /* Exchange args and then do nth. */
1529 BEFORE_POTENTIAL_GC ();
1533 AFTER_POTENTIAL_GC ();
1536 while (--op
>= 0 && CONSP (v1
))
1543 BEFORE_POTENTIAL_GC ();
1545 TOP
= Felt (TOP
, v1
);
1546 AFTER_POTENTIAL_GC ();
1554 BEFORE_POTENTIAL_GC ();
1556 TOP
= Fmember (TOP
, v1
);
1557 AFTER_POTENTIAL_GC ();
1564 BEFORE_POTENTIAL_GC ();
1566 TOP
= Fassq (TOP
, v1
);
1567 AFTER_POTENTIAL_GC ();
1572 BEFORE_POTENTIAL_GC ();
1573 TOP
= Fnreverse (TOP
);
1574 AFTER_POTENTIAL_GC ();
1580 BEFORE_POTENTIAL_GC ();
1582 TOP
= Fsetcar (TOP
, v1
);
1583 AFTER_POTENTIAL_GC ();
1590 BEFORE_POTENTIAL_GC ();
1592 TOP
= Fsetcdr (TOP
, v1
);
1593 AFTER_POTENTIAL_GC ();
1601 TOP
= CAR_SAFE (v1
);
1609 TOP
= CDR_SAFE (v1
);
1614 BEFORE_POTENTIAL_GC ();
1616 TOP
= Fnconc (2, &TOP
);
1617 AFTER_POTENTIAL_GC ();
1621 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1625 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1628 #ifdef BYTE_CODE_SAFE
1630 BEFORE_POTENTIAL_GC ();
1631 error ("set-mark is an obsolete bytecode");
1632 AFTER_POTENTIAL_GC ();
1635 BEFORE_POTENTIAL_GC ();
1636 error ("scan-buffer is an obsolete bytecode");
1637 AFTER_POTENTIAL_GC ();
1646 #ifdef BYTE_CODE_SAFE
1651 if ((op
-= Bconstant
) >= const_length
)
1657 PUSH (vectorp
[op
- Bconstant
]);
1664 byte_stack_list
= byte_stack_list
->next
;
1666 /* Binds and unbinds are supposed to be compiled balanced. */
1667 if (SPECPDL_INDEX () != count
)
1668 #ifdef BYTE_CODE_SAFE
1669 error ("binding stack not balanced (serious byte compiler bug)");
1678 syms_of_bytecode (void)
1680 Qbytecode
= intern_c_string ("byte-code");
1681 staticpro (&Qbytecode
);
1683 defsubr (&Sbyte_code
);
1685 #ifdef BYTE_CODE_METER
1687 DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter
,
1688 doc
: /* A vector of vectors which holds a histogram of byte-code usage.
1689 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1690 opcode CODE has been executed.
1691 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1692 indicates how many times the byte opcodes CODE1 and CODE2 have been
1693 executed in succession. */);
1695 DEFVAR_BOOL ("byte-metering-on", byte_metering_on
,
1696 doc
: /* If non-nil, keep profiling information on byte code usage.
1697 The variable byte-code-meter indicates how often each byte opcode is used.
1698 If a symbol has a property named `byte-code-meter' whose value is an
1699 integer, it is incremented each time that symbol's function is called. */);
1701 byte_metering_on
= 0;
1702 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1703 Qbyte_code_meter
= intern_c_string ("byte-code-meter");
1704 staticpro (&Qbyte_code_meter
);
1708 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1709 Fmake_vector (make_number (256), make_number (0));