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
232 /* Whether to maintain a `top' and `bottom' field in the stack frame. */
233 #define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK)
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 #if BYTE_MAINTAIN_TOP
247 Lisp_Object
*top
, *bottom
;
250 /* The string containing the byte-code, and its current address.
251 Storing this here protects it from GC because mark_byte_stack
253 Lisp_Object byte_string
;
254 const unsigned char *byte_string_start
;
256 /* The vector of constants used during byte-code execution. Storing
257 this here protects it from GC because mark_byte_stack marks it. */
258 Lisp_Object constants
;
260 /* Next entry in byte_stack_list. */
261 struct byte_stack
*next
;
264 /* A list of currently active byte-code execution value stacks.
265 Fbyte_code adds an entry to the head of this list before it starts
266 processing byte-code, and it removed the entry again when it is
267 done. Signalling an error truncates the list analoguous to
270 struct byte_stack
*byte_stack_list
;
273 /* Mark objects on byte_stack_list. Called during GC. */
277 mark_byte_stack (void)
279 struct byte_stack
*stack
;
282 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
284 /* If STACK->top is null here, this means there's an opcode in
285 Fbyte_code that wasn't expected to GC, but did. To find out
286 which opcode this is, record the value of `stack', and walk
287 up the stack in a debugger, stopping in frames of Fbyte_code.
288 The culprit is found in the frame of Fbyte_code where the
289 address of its local variable `stack' is equal to the
290 recorded value of `stack' here. */
291 eassert (stack
->top
);
293 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
296 mark_object (stack
->byte_string
);
297 mark_object (stack
->constants
);
302 /* Unmark objects in the stacks on byte_stack_list. Relocate program
303 counters. Called when GC has completed. */
306 unmark_byte_stack (void)
308 struct byte_stack
*stack
;
310 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
312 if (stack
->byte_string_start
!= SDATA (stack
->byte_string
))
314 int offset
= stack
->pc
- stack
->byte_string_start
;
315 stack
->byte_string_start
= SDATA (stack
->byte_string
);
316 stack
->pc
= stack
->byte_string_start
+ offset
;
322 /* Fetch the next byte from the bytecode stream */
324 #define FETCH *stack.pc++
326 /* Fetch two bytes from the bytecode stream and make a 16-bit number
329 #define FETCH2 (op = FETCH, op + (FETCH << 8))
331 /* Push x onto the execution stack. This used to be #define PUSH(x)
332 (*++stackp = (x)) This oddity is necessary because Alliant can't be
333 bothered to compile the preincrement operator properly, as of 4/91.
336 #define PUSH(x) (top++, *top = (x))
338 /* Pop a value off the execution stack. */
342 /* Discard n values from the execution stack. */
344 #define DISCARD(n) (top -= (n))
346 /* Get the value which is at the top of the execution stack, but don't
351 /* Actions that must be performed before and after calling a function
354 #if !BYTE_MAINTAIN_TOP
355 #define BEFORE_POTENTIAL_GC() ((void)0)
356 #define AFTER_POTENTIAL_GC() ((void)0)
358 #define BEFORE_POTENTIAL_GC() stack.top = top
359 #define AFTER_POTENTIAL_GC() stack.top = NULL
362 /* Garbage collect if we have consed enough since the last time.
363 We do this at every branch, to avoid loops that never GC. */
366 if (consing_since_gc > gc_cons_threshold \
367 && consing_since_gc > gc_relative_threshold) \
369 BEFORE_POTENTIAL_GC (); \
370 Fgarbage_collect (); \
371 AFTER_POTENTIAL_GC (); \
375 /* Check for jumping out of range. */
377 #ifdef BYTE_CODE_SAFE
379 #define CHECK_RANGE(ARG) \
380 if (ARG >= bytestr_length) abort ()
382 #else /* not BYTE_CODE_SAFE */
384 #define CHECK_RANGE(ARG)
386 #endif /* not BYTE_CODE_SAFE */
388 /* A version of the QUIT macro which makes sure that the stack top is
389 set before signaling `quit'. */
391 #define BYTE_CODE_QUIT \
393 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
395 Lisp_Object flag = Vquit_flag; \
397 BEFORE_POTENTIAL_GC (); \
398 if (EQ (Vthrow_on_input, flag)) \
399 Fthrow (Vthrow_on_input, Qt); \
400 Fsignal (Qquit, Qnil); \
401 AFTER_POTENTIAL_GC (); \
403 ELSE_PENDING_SIGNALS \
407 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
408 doc
: /* Function used internally in byte-compiled code.
409 The first argument, BYTESTR, is a string of byte code;
410 the second, VECTOR, a vector of constants;
411 the third, MAXDEPTH, the maximum stack depth used in this function.
412 If the third argument is incorrect, Emacs may crash. */)
413 (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
)
415 int count
= SPECPDL_INDEX ();
416 #ifdef BYTE_CODE_METER
421 /* Lisp_Object v1, v2; */
422 Lisp_Object
*vectorp
;
423 #ifdef BYTE_CODE_SAFE
424 int const_length
= XVECTOR (vector
)->size
;
428 struct byte_stack stack
;
432 #if 0 /* CHECK_FRAME_FONT */
434 struct frame
*f
= SELECTED_FRAME ();
436 && FRAME_FONT (f
)->direction
!= 0
437 && FRAME_FONT (f
)->direction
!= 1)
442 CHECK_STRING (bytestr
);
443 CHECK_VECTOR (vector
);
444 CHECK_NUMBER (maxdepth
);
446 if (STRING_MULTIBYTE (bytestr
))
447 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
448 because they produced a raw 8-bit string for byte-code and now
449 such a byte-code string is loaded as multibyte while raw 8-bit
450 characters converted to multibyte form. Thus, now we must
451 convert them back to the originally intended unibyte form. */
452 bytestr
= Fstring_as_unibyte (bytestr
);
454 bytestr_length
= SBYTES (bytestr
);
455 vectorp
= XVECTOR (vector
)->contents
;
457 stack
.byte_string
= bytestr
;
458 stack
.pc
= stack
.byte_string_start
= SDATA (bytestr
);
459 stack
.constants
= vector
;
460 top
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
461 * sizeof (Lisp_Object
));
462 #if BYTE_MAINTAIN_TOP
467 stack
.next
= byte_stack_list
;
468 byte_stack_list
= &stack
;
470 #ifdef BYTE_CODE_SAFE
471 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
476 #ifdef BYTE_CODE_SAFE
479 else if (top
< stack
.bottom
- 1)
483 #ifdef BYTE_CODE_METER
485 this_op
= op
= FETCH
;
486 METER_CODE (prev_op
, op
);
506 /* This seems to be the most frequently executed byte-code
507 among the Bvarref's, so avoid a goto here. */
517 if (XSYMBOL (v1
)->redirect
!= SYMBOL_PLAINVAL
518 || (v2
= SYMBOL_VAL (XSYMBOL (v1
)),
521 BEFORE_POTENTIAL_GC ();
522 v2
= Fsymbol_value (v1
);
523 AFTER_POTENTIAL_GC ();
528 BEFORE_POTENTIAL_GC ();
529 v2
= Fsymbol_value (v1
);
530 AFTER_POTENTIAL_GC ();
546 stack
.pc
= stack
.byte_string_start
+ op
;
563 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
570 BEFORE_POTENTIAL_GC ();
572 TOP
= Fmemq (TOP
, v1
);
573 AFTER_POTENTIAL_GC ();
602 Lisp_Object sym
, val
;
607 /* Inline the most common case. */
609 && !EQ (val
, Qunbound
)
610 && !XSYMBOL (sym
)->redirect
611 && !SYMBOL_CONSTANT_P (sym
))
612 XSYMBOL (sym
)->val
.value
= val
;
615 BEFORE_POTENTIAL_GC ();
616 set_internal (sym
, val
, Qnil
, 0);
617 AFTER_POTENTIAL_GC ();
631 /* ------------------ */
649 /* Specbind can signal and thus GC. */
650 BEFORE_POTENTIAL_GC ();
651 specbind (vectorp
[op
], POP
);
652 AFTER_POTENTIAL_GC ();
672 BEFORE_POTENTIAL_GC ();
674 #ifdef BYTE_CODE_METER
675 if (byte_metering_on
&& SYMBOLP (TOP
))
680 v2
= Fget (v1
, Qbyte_code_meter
);
682 && XINT (v2
) < MOST_POSITIVE_FIXNUM
)
684 XSETINT (v2
, XINT (v2
) + 1);
685 Fput (v1
, Qbyte_code_meter
, v2
);
689 TOP
= Ffuncall (op
+ 1, &TOP
);
690 AFTER_POTENTIAL_GC ();
710 BEFORE_POTENTIAL_GC ();
711 unbind_to (SPECPDL_INDEX () - op
, Qnil
);
712 AFTER_POTENTIAL_GC ();
716 /* To unbind back to the beginning of this frame. Not used yet,
717 but will be needed for tail-recursion elimination. */
718 BEFORE_POTENTIAL_GC ();
719 unbind_to (count
, Qnil
);
720 AFTER_POTENTIAL_GC ();
726 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
728 stack
.pc
= stack
.byte_string_start
+ op
;
741 stack
.pc
= stack
.byte_string_start
+ op
;
746 case Bgotoifnilelsepop
:
753 stack
.pc
= stack
.byte_string_start
+ op
;
758 case Bgotoifnonnilelsepop
:
765 stack
.pc
= stack
.byte_string_start
+ op
;
773 stack
.pc
+= (int) *stack
.pc
- 127;
784 stack
.pc
+= (int) *stack
.pc
- 128;
798 stack
.pc
+= (int) *stack
.pc
- 128;
804 case BRgotoifnilelsepop
:
810 stack
.pc
+= op
- 128;
815 case BRgotoifnonnilelsepop
:
821 stack
.pc
+= op
- 128;
835 PUSH (vectorp
[FETCH2
]);
838 case Bsave_excursion
:
839 record_unwind_protect (save_excursion_restore
,
840 save_excursion_save ());
843 case Bsave_current_buffer
:
844 case Bsave_current_buffer_1
:
845 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
848 case Bsave_window_excursion
:
849 BEFORE_POTENTIAL_GC ();
850 TOP
= Fsave_window_excursion (TOP
);
851 AFTER_POTENTIAL_GC ();
854 case Bsave_restriction
:
855 record_unwind_protect (save_restriction_restore
,
856 save_restriction_save ());
862 BEFORE_POTENTIAL_GC ();
864 TOP
= internal_catch (TOP
, Feval
, v1
);
865 AFTER_POTENTIAL_GC ();
869 case Bunwind_protect
:
870 record_unwind_protect (Fprogn
, POP
);
873 case Bcondition_case
:
875 Lisp_Object handlers
, body
;
878 BEFORE_POTENTIAL_GC ();
879 TOP
= internal_lisp_condition_case (TOP
, body
, handlers
);
880 AFTER_POTENTIAL_GC ();
884 case Btemp_output_buffer_setup
:
885 BEFORE_POTENTIAL_GC ();
887 temp_output_buffer_setup (SSDATA (TOP
));
888 AFTER_POTENTIAL_GC ();
889 TOP
= Vstandard_output
;
892 case Btemp_output_buffer_show
:
895 BEFORE_POTENTIAL_GC ();
897 temp_output_buffer_show (TOP
);
899 /* pop binding of standard-output */
900 unbind_to (SPECPDL_INDEX () - 1, Qnil
);
901 AFTER_POTENTIAL_GC ();
908 BEFORE_POTENTIAL_GC ();
912 AFTER_POTENTIAL_GC ();
915 while (--op
>= 0 && CONSP (v1
))
923 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
927 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
931 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
935 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
939 TOP
= NILP (TOP
) ? Qt
: Qnil
;
946 TOP
= Fcons (TOP
, v1
);
951 TOP
= Fcons (TOP
, Qnil
);
958 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
964 TOP
= Flist (3, &TOP
);
969 TOP
= Flist (4, &TOP
);
975 TOP
= Flist (op
, &TOP
);
979 BEFORE_POTENTIAL_GC ();
981 AFTER_POTENTIAL_GC ();
987 BEFORE_POTENTIAL_GC ();
989 TOP
= Faref (TOP
, v1
);
990 AFTER_POTENTIAL_GC ();
997 BEFORE_POTENTIAL_GC ();
999 TOP
= Faset (TOP
, v1
, v2
);
1000 AFTER_POTENTIAL_GC ();
1005 BEFORE_POTENTIAL_GC ();
1006 TOP
= Fsymbol_value (TOP
);
1007 AFTER_POTENTIAL_GC ();
1010 case Bsymbol_function
:
1011 BEFORE_POTENTIAL_GC ();
1012 TOP
= Fsymbol_function (TOP
);
1013 AFTER_POTENTIAL_GC ();
1019 BEFORE_POTENTIAL_GC ();
1021 TOP
= Fset (TOP
, v1
);
1022 AFTER_POTENTIAL_GC ();
1029 BEFORE_POTENTIAL_GC ();
1031 TOP
= Ffset (TOP
, v1
);
1032 AFTER_POTENTIAL_GC ();
1039 BEFORE_POTENTIAL_GC ();
1041 TOP
= Fget (TOP
, v1
);
1042 AFTER_POTENTIAL_GC ();
1049 BEFORE_POTENTIAL_GC ();
1051 TOP
= Fsubstring (TOP
, v1
, v2
);
1052 AFTER_POTENTIAL_GC ();
1057 BEFORE_POTENTIAL_GC ();
1059 TOP
= Fconcat (2, &TOP
);
1060 AFTER_POTENTIAL_GC ();
1064 BEFORE_POTENTIAL_GC ();
1066 TOP
= Fconcat (3, &TOP
);
1067 AFTER_POTENTIAL_GC ();
1071 BEFORE_POTENTIAL_GC ();
1073 TOP
= Fconcat (4, &TOP
);
1074 AFTER_POTENTIAL_GC ();
1079 BEFORE_POTENTIAL_GC ();
1081 TOP
= Fconcat (op
, &TOP
);
1082 AFTER_POTENTIAL_GC ();
1091 XSETINT (v1
, XINT (v1
) - 1);
1096 BEFORE_POTENTIAL_GC ();
1098 AFTER_POTENTIAL_GC ();
1109 XSETINT (v1
, XINT (v1
) + 1);
1114 BEFORE_POTENTIAL_GC ();
1116 AFTER_POTENTIAL_GC ();
1124 BEFORE_POTENTIAL_GC ();
1126 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1
);
1127 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
);
1128 AFTER_POTENTIAL_GC ();
1129 if (FLOATP (v1
) || FLOATP (v2
))
1133 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1134 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1135 TOP
= (f1
== f2
? Qt
: Qnil
);
1138 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1145 BEFORE_POTENTIAL_GC ();
1147 TOP
= Fgtr (TOP
, v1
);
1148 AFTER_POTENTIAL_GC ();
1155 BEFORE_POTENTIAL_GC ();
1157 TOP
= Flss (TOP
, v1
);
1158 AFTER_POTENTIAL_GC ();
1165 BEFORE_POTENTIAL_GC ();
1167 TOP
= Fleq (TOP
, v1
);
1168 AFTER_POTENTIAL_GC ();
1175 BEFORE_POTENTIAL_GC ();
1177 TOP
= Fgeq (TOP
, v1
);
1178 AFTER_POTENTIAL_GC ();
1183 BEFORE_POTENTIAL_GC ();
1185 TOP
= Fminus (2, &TOP
);
1186 AFTER_POTENTIAL_GC ();
1195 XSETINT (v1
, - XINT (v1
));
1200 BEFORE_POTENTIAL_GC ();
1201 TOP
= Fminus (1, &TOP
);
1202 AFTER_POTENTIAL_GC ();
1208 BEFORE_POTENTIAL_GC ();
1210 TOP
= Fplus (2, &TOP
);
1211 AFTER_POTENTIAL_GC ();
1215 BEFORE_POTENTIAL_GC ();
1217 TOP
= Fmax (2, &TOP
);
1218 AFTER_POTENTIAL_GC ();
1222 BEFORE_POTENTIAL_GC ();
1224 TOP
= Fmin (2, &TOP
);
1225 AFTER_POTENTIAL_GC ();
1229 BEFORE_POTENTIAL_GC ();
1231 TOP
= Ftimes (2, &TOP
);
1232 AFTER_POTENTIAL_GC ();
1236 BEFORE_POTENTIAL_GC ();
1238 TOP
= Fquo (2, &TOP
);
1239 AFTER_POTENTIAL_GC ();
1245 BEFORE_POTENTIAL_GC ();
1247 TOP
= Frem (TOP
, v1
);
1248 AFTER_POTENTIAL_GC ();
1255 XSETFASTINT (v1
, PT
);
1261 BEFORE_POTENTIAL_GC ();
1262 TOP
= Fgoto_char (TOP
);
1263 AFTER_POTENTIAL_GC ();
1267 BEFORE_POTENTIAL_GC ();
1268 TOP
= Finsert (1, &TOP
);
1269 AFTER_POTENTIAL_GC ();
1274 BEFORE_POTENTIAL_GC ();
1276 TOP
= Finsert (op
, &TOP
);
1277 AFTER_POTENTIAL_GC ();
1283 XSETFASTINT (v1
, ZV
);
1291 XSETFASTINT (v1
, BEGV
);
1297 BEFORE_POTENTIAL_GC ();
1298 TOP
= Fchar_after (TOP
);
1299 AFTER_POTENTIAL_GC ();
1302 case Bfollowing_char
:
1305 BEFORE_POTENTIAL_GC ();
1306 v1
= Ffollowing_char ();
1307 AFTER_POTENTIAL_GC ();
1312 case Bpreceding_char
:
1315 BEFORE_POTENTIAL_GC ();
1316 v1
= Fprevious_char ();
1317 AFTER_POTENTIAL_GC ();
1322 case Bcurrent_column
:
1325 BEFORE_POTENTIAL_GC ();
1326 XSETFASTINT (v1
, current_column ());
1327 AFTER_POTENTIAL_GC ();
1333 BEFORE_POTENTIAL_GC ();
1334 TOP
= Findent_to (TOP
, Qnil
);
1335 AFTER_POTENTIAL_GC ();
1354 case Bcurrent_buffer
:
1355 PUSH (Fcurrent_buffer ());
1359 BEFORE_POTENTIAL_GC ();
1360 TOP
= Fset_buffer (TOP
);
1361 AFTER_POTENTIAL_GC ();
1364 case Binteractive_p
:
1365 PUSH (Finteractive_p ());
1369 BEFORE_POTENTIAL_GC ();
1370 TOP
= Fforward_char (TOP
);
1371 AFTER_POTENTIAL_GC ();
1375 BEFORE_POTENTIAL_GC ();
1376 TOP
= Fforward_word (TOP
);
1377 AFTER_POTENTIAL_GC ();
1380 case Bskip_chars_forward
:
1383 BEFORE_POTENTIAL_GC ();
1385 TOP
= Fskip_chars_forward (TOP
, v1
);
1386 AFTER_POTENTIAL_GC ();
1390 case Bskip_chars_backward
:
1393 BEFORE_POTENTIAL_GC ();
1395 TOP
= Fskip_chars_backward (TOP
, v1
);
1396 AFTER_POTENTIAL_GC ();
1401 BEFORE_POTENTIAL_GC ();
1402 TOP
= Fforward_line (TOP
);
1403 AFTER_POTENTIAL_GC ();
1410 BEFORE_POTENTIAL_GC ();
1411 CHECK_CHARACTER (TOP
);
1412 AFTER_POTENTIAL_GC ();
1414 if (NILP (BVAR (current_buffer
, enable_multibyte_characters
)))
1415 MAKE_CHAR_MULTIBYTE (c
);
1416 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (c
)]);
1420 case Bbuffer_substring
:
1423 BEFORE_POTENTIAL_GC ();
1425 TOP
= Fbuffer_substring (TOP
, v1
);
1426 AFTER_POTENTIAL_GC ();
1430 case Bdelete_region
:
1433 BEFORE_POTENTIAL_GC ();
1435 TOP
= Fdelete_region (TOP
, v1
);
1436 AFTER_POTENTIAL_GC ();
1440 case Bnarrow_to_region
:
1443 BEFORE_POTENTIAL_GC ();
1445 TOP
= Fnarrow_to_region (TOP
, v1
);
1446 AFTER_POTENTIAL_GC ();
1451 BEFORE_POTENTIAL_GC ();
1453 AFTER_POTENTIAL_GC ();
1457 BEFORE_POTENTIAL_GC ();
1458 TOP
= Fend_of_line (TOP
);
1459 AFTER_POTENTIAL_GC ();
1465 BEFORE_POTENTIAL_GC ();
1468 TOP
= Fset_marker (TOP
, v2
, v1
);
1469 AFTER_POTENTIAL_GC ();
1473 case Bmatch_beginning
:
1474 BEFORE_POTENTIAL_GC ();
1475 TOP
= Fmatch_beginning (TOP
);
1476 AFTER_POTENTIAL_GC ();
1480 BEFORE_POTENTIAL_GC ();
1481 TOP
= Fmatch_end (TOP
);
1482 AFTER_POTENTIAL_GC ();
1486 BEFORE_POTENTIAL_GC ();
1487 TOP
= Fupcase (TOP
);
1488 AFTER_POTENTIAL_GC ();
1492 BEFORE_POTENTIAL_GC ();
1493 TOP
= Fdowncase (TOP
);
1494 AFTER_POTENTIAL_GC ();
1497 case Bstringeqlsign
:
1500 BEFORE_POTENTIAL_GC ();
1502 TOP
= Fstring_equal (TOP
, v1
);
1503 AFTER_POTENTIAL_GC ();
1510 BEFORE_POTENTIAL_GC ();
1512 TOP
= Fstring_lessp (TOP
, v1
);
1513 AFTER_POTENTIAL_GC ();
1521 TOP
= Fequal (TOP
, v1
);
1528 BEFORE_POTENTIAL_GC ();
1530 TOP
= Fnthcdr (TOP
, v1
);
1531 AFTER_POTENTIAL_GC ();
1540 /* Exchange args and then do nth. */
1541 BEFORE_POTENTIAL_GC ();
1545 AFTER_POTENTIAL_GC ();
1548 while (--op
>= 0 && CONSP (v1
))
1555 BEFORE_POTENTIAL_GC ();
1557 TOP
= Felt (TOP
, v1
);
1558 AFTER_POTENTIAL_GC ();
1566 BEFORE_POTENTIAL_GC ();
1568 TOP
= Fmember (TOP
, v1
);
1569 AFTER_POTENTIAL_GC ();
1576 BEFORE_POTENTIAL_GC ();
1578 TOP
= Fassq (TOP
, v1
);
1579 AFTER_POTENTIAL_GC ();
1584 BEFORE_POTENTIAL_GC ();
1585 TOP
= Fnreverse (TOP
);
1586 AFTER_POTENTIAL_GC ();
1592 BEFORE_POTENTIAL_GC ();
1594 TOP
= Fsetcar (TOP
, v1
);
1595 AFTER_POTENTIAL_GC ();
1602 BEFORE_POTENTIAL_GC ();
1604 TOP
= Fsetcdr (TOP
, v1
);
1605 AFTER_POTENTIAL_GC ();
1613 TOP
= CAR_SAFE (v1
);
1621 TOP
= CDR_SAFE (v1
);
1626 BEFORE_POTENTIAL_GC ();
1628 TOP
= Fnconc (2, &TOP
);
1629 AFTER_POTENTIAL_GC ();
1633 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1637 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1640 #ifdef BYTE_CODE_SAFE
1642 BEFORE_POTENTIAL_GC ();
1643 error ("set-mark is an obsolete bytecode");
1644 AFTER_POTENTIAL_GC ();
1647 BEFORE_POTENTIAL_GC ();
1648 error ("scan-buffer is an obsolete bytecode");
1649 AFTER_POTENTIAL_GC ();
1658 #ifdef BYTE_CODE_SAFE
1663 if ((op
-= Bconstant
) >= const_length
)
1669 PUSH (vectorp
[op
- Bconstant
]);
1676 byte_stack_list
= byte_stack_list
->next
;
1678 /* Binds and unbinds are supposed to be compiled balanced. */
1679 if (SPECPDL_INDEX () != count
)
1680 #ifdef BYTE_CODE_SAFE
1681 error ("binding stack not balanced (serious byte compiler bug)");
1690 syms_of_bytecode (void)
1692 Qbytecode
= intern_c_string ("byte-code");
1693 staticpro (&Qbytecode
);
1695 defsubr (&Sbyte_code
);
1697 #ifdef BYTE_CODE_METER
1699 DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter
,
1700 doc
: /* A vector of vectors which holds a histogram of byte-code usage.
1701 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1702 opcode CODE has been executed.
1703 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1704 indicates how many times the byte opcodes CODE1 and CODE2 have been
1705 executed in succession. */);
1707 DEFVAR_BOOL ("byte-metering-on", byte_metering_on
,
1708 doc
: /* If non-nil, keep profiling information on byte code usage.
1709 The variable byte-code-meter indicates how often each byte opcode is used.
1710 If a symbol has a property named `byte-code-meter' whose value is an
1711 integer, it is incremented each time that symbol's function is called. */);
1713 byte_metering_on
= 0;
1714 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1715 Qbyte_code_meter
= intern_c_string ("byte-code-meter");
1716 staticpro (&Qbyte_code_meter
);
1720 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1721 Fmake_vector (make_number (256), make_number (0));