1 /* Execution of byte code produced by bytecomp.el.
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 2000 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 2, or (at your option)
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; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
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.
42 #ifdef CHECK_FRAME_FONT
48 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
49 * debugging the byte compiler...)
51 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
53 /* #define BYTE_CODE_SAFE */
54 /* #define BYTE_CODE_METER */
57 #ifdef BYTE_CODE_METER
59 Lisp_Object Vbyte_code_meter
, 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) != ((1<<VALBITS)-1)) \
73 METER_1 (this_code)++; \
75 && METER_2 (last_code, this_code) != ((1<<VALBITS)-1))\
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. */
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 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. */
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. */
290 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
291 if (!XMARKBIT (*obj
))
297 if (!XMARKBIT (stack
->byte_string
))
299 mark_object (&stack
->byte_string
);
300 XMARK (stack
->byte_string
);
303 if (!XMARKBIT (stack
->constants
))
305 mark_object (&stack
->constants
);
306 XMARK (stack
->constants
);
312 /* Unmark objects in the stacks on byte_stack_list. Relocate program
313 counters. Called when GC has completed. */
318 struct byte_stack
*stack
;
321 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
323 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
326 XUNMARK (stack
->byte_string
);
327 XUNMARK (stack
->constants
);
329 if (stack
->byte_string_start
!= XSTRING (stack
->byte_string
)->data
)
331 int offset
= stack
->pc
- stack
->byte_string_start
;
332 stack
->byte_string_start
= XSTRING (stack
->byte_string
)->data
;
333 stack
->pc
= stack
->byte_string_start
+ offset
;
339 /* Fetch the next byte from the bytecode stream */
341 #define FETCH *stack.pc++
343 /* Fetch two bytes from the bytecode stream and make a 16-bit number
346 #define FETCH2 (op = FETCH, op + (FETCH << 8))
348 /* Push x onto the execution stack. This used to be #define PUSH(x)
349 (*++stackp = (x)) This oddity is necessary because Alliant can't be
350 bothered to compile the preincrement operator properly, as of 4/91.
353 #define PUSH(x) (top++, *top = (x))
355 /* Pop a value off the execution stack. */
359 /* Discard n values from the execution stack. */
361 #define DISCARD(n) (top -= (n))
363 /* Get the value which is at the top of the execution stack, but don't
368 /* Actions that must be performed before and after calling a function
371 #define BEFORE_POTENTIAL_GC() stack.top = top
372 #define AFTER_POTENTIAL_GC() stack.top = NULL
374 /* Garbage collect if we have consed enough since the last time.
375 We do this at every branch, to avoid loops that never GC. */
378 if (consing_since_gc > gc_cons_threshold) \
380 BEFORE_POTENTIAL_GC (); \
381 Fgarbage_collect (); \
382 AFTER_POTENTIAL_GC (); \
386 /* Check for jumping out of range. */
388 #ifdef BYTE_CODE_SAFE
390 #define CHECK_RANGE(ARG) \
391 if (ARG >= bytestr_length) abort ()
393 #else /* not BYTE_CODE_SAFE */
395 #define CHECK_RANGE(ARG)
397 #endif /* not BYTE_CODE_SAFE */
400 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
401 "Function used internally in byte-compiled code.\n\
402 The first argument, BYTESTR, is a string of byte code;\n\
403 the second, VECTOR, a vector of constants;\n\
404 the third, MAXDEPTH, the maximum stack depth used in this function.\n\
405 If the third argument is incorrect, Emacs may crash.")
406 (bytestr
, vector
, maxdepth
)
407 Lisp_Object bytestr
, vector
, maxdepth
;
409 int count
= specpdl_ptr
- specpdl
;
410 #ifdef BYTE_CODE_METER
415 /* Lisp_Object v1, v2; */
416 Lisp_Object
*vectorp
;
417 #ifdef BYTE_CODE_SAFE
418 int const_length
= XVECTOR (vector
)->size
;
422 struct byte_stack stack
;
426 #ifdef CHECK_FRAME_FONT
428 struct frame
*f
= SELECTED_FRAME ();
430 && FRAME_FONT (f
)->direction
!= 0
431 && FRAME_FONT (f
)->direction
!= 1)
436 CHECK_STRING (bytestr
, 0);
437 if (!VECTORP (vector
))
438 vector
= wrong_type_argument (Qvectorp
, vector
);
439 CHECK_NUMBER (maxdepth
, 2);
441 if (STRING_MULTIBYTE (bytestr
))
442 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
443 because they produced a raw 8-bit string for byte-code and now
444 such a byte-code string is loaded as multibyte while raw 8-bit
445 characters converted to multibyte form. Thus, now we must
446 convert them back to the original unibyte form. */
447 bytestr
= Fstring_as_unibyte (bytestr
);
449 bytestr_length
= STRING_BYTES (XSTRING (bytestr
));
450 vectorp
= XVECTOR (vector
)->contents
;
452 stack
.byte_string
= bytestr
;
453 stack
.pc
= stack
.byte_string_start
= XSTRING (bytestr
)->data
;
454 stack
.constants
= vector
;
455 stack
.bottom
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
456 * sizeof (Lisp_Object
));
457 top
= stack
.bottom
- 1;
459 stack
.next
= byte_stack_list
;
460 byte_stack_list
= &stack
;
462 #ifdef BYTE_CODE_SAFE
463 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
468 #ifdef BYTE_CODE_SAFE
471 else if (top
< stack
.bottom
- 1)
475 #ifdef BYTE_CODE_METER
477 this_op
= op
= FETCH
;
478 METER_CODE (prev_op
, op
);
498 /* This seems to be the most frequently executed byte-code
499 among the Bvarref's, so avoid a goto here. */
509 v2
= XSYMBOL (v1
)->value
;
510 if (MISCP (v2
) || EQ (v2
, Qunbound
))
512 BEFORE_POTENTIAL_GC ();
513 v2
= Fsymbol_value (v1
);
514 AFTER_POTENTIAL_GC ();
519 BEFORE_POTENTIAL_GC ();
520 v2
= Fsymbol_value (v1
);
521 AFTER_POTENTIAL_GC ();
534 stack
.pc
= stack
.byte_string_start
+ op
;
548 BEFORE_POTENTIAL_GC ();
549 Fcar (wrong_type_argument (Qlistp
, v1
));
550 AFTER_POTENTIAL_GC ();
559 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
566 BEFORE_POTENTIAL_GC ();
568 TOP
= Fmemq (TOP
, v1
);
569 AFTER_POTENTIAL_GC ();
583 BEFORE_POTENTIAL_GC ();
584 Fcdr (wrong_type_argument (Qlistp
, v1
));
585 AFTER_POTENTIAL_GC ();
607 Lisp_Object sym
, val
;
612 /* Inline the most common case. */
614 && !EQ (val
, Qunbound
)
615 && !MISCP (XSYMBOL (sym
)->value
)
616 /* I think this should either be checked in the byte
617 compiler, or there should be a flag indicating that
618 a symbol might be constant in Lisp_Symbol, instead
619 of checking this here over and over again. --gerd. */
622 && !(XSYMBOL (sym
)->name
->data
[0] == ':'
623 && EQ (XSYMBOL (sym
)->obarray
, initial_obarray
)
625 XSYMBOL (sym
)->value
= val
;
628 BEFORE_POTENTIAL_GC ();
629 set_internal (sym
, val
, current_buffer
, 0);
630 AFTER_POTENTIAL_GC ();
644 /* ------------------ */
662 /* Specbind can signal and thus GC. */
663 BEFORE_POTENTIAL_GC ();
664 specbind (vectorp
[op
], POP
);
665 AFTER_POTENTIAL_GC ();
685 BEFORE_POTENTIAL_GC ();
687 #ifdef BYTE_CODE_METER
688 if (byte_metering_on
&& SYMBOLP (TOP
))
693 v2
= Fget (v1
, Qbyte_code_meter
);
695 && XINT (v2
) != ((1<<VALBITS
)-1))
697 XSETINT (v2
, XINT (v2
) + 1);
698 Fput (v1
, Qbyte_code_meter
, v2
);
702 TOP
= Ffuncall (op
+ 1, &TOP
);
703 AFTER_POTENTIAL_GC ();
723 BEFORE_POTENTIAL_GC ();
724 unbind_to (specpdl_ptr
- specpdl
- op
, Qnil
);
725 AFTER_POTENTIAL_GC ();
729 /* To unbind back to the beginning of this frame. Not used yet,
730 but will be needed for tail-recursion elimination. */
731 BEFORE_POTENTIAL_GC ();
732 unbind_to (count
, Qnil
);
733 AFTER_POTENTIAL_GC ();
739 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
741 stack
.pc
= stack
.byte_string_start
+ op
;
751 stack
.pc
= stack
.byte_string_start
+ op
;
755 case Bgotoifnilelsepop
:
762 stack
.pc
= stack
.byte_string_start
+ op
;
767 case Bgotoifnonnilelsepop
:
774 stack
.pc
= stack
.byte_string_start
+ op
;
782 stack
.pc
+= (int) *stack
.pc
- 127;
790 stack
.pc
+= (int) *stack
.pc
- 128;
800 stack
.pc
+= (int) *stack
.pc
- 128;
805 case BRgotoifnilelsepop
:
811 stack
.pc
+= op
- 128;
816 case BRgotoifnonnilelsepop
:
822 stack
.pc
+= op
- 128;
836 PUSH (vectorp
[FETCH2
]);
839 case Bsave_excursion
:
840 record_unwind_protect (save_excursion_restore
,
841 save_excursion_save ());
844 case Bsave_current_buffer
:
845 case Bsave_current_buffer_1
:
846 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
849 case Bsave_window_excursion
:
850 BEFORE_POTENTIAL_GC ();
851 TOP
= Fsave_window_excursion (TOP
);
852 AFTER_POTENTIAL_GC ();
855 case Bsave_restriction
:
856 record_unwind_protect (save_restriction_restore
,
857 save_restriction_save ());
863 BEFORE_POTENTIAL_GC ();
865 TOP
= internal_catch (TOP
, Feval
, v1
);
866 AFTER_POTENTIAL_GC ();
870 case Bunwind_protect
:
871 /* The function record_unwind_protect can GC. */
872 BEFORE_POTENTIAL_GC ();
873 record_unwind_protect (0, POP
);
874 AFTER_POTENTIAL_GC ();
875 (specpdl_ptr
- 1)->symbol
= Qnil
;
878 case Bcondition_case
:
882 v1
= Fcons (POP
, v1
);
883 BEFORE_POTENTIAL_GC ();
884 TOP
= Fcondition_case (Fcons (TOP
, v1
));
885 AFTER_POTENTIAL_GC ();
889 case Btemp_output_buffer_setup
:
890 BEFORE_POTENTIAL_GC ();
891 temp_output_buffer_setup (XSTRING (TOP
)->data
);
892 AFTER_POTENTIAL_GC ();
893 TOP
= Vstandard_output
;
896 case Btemp_output_buffer_show
:
899 BEFORE_POTENTIAL_GC ();
901 temp_output_buffer_show (TOP
);
903 /* pop binding of standard-output */
904 unbind_to (specpdl_ptr
- specpdl
- 1, Qnil
);
905 AFTER_POTENTIAL_GC ();
912 BEFORE_POTENTIAL_GC ();
915 CHECK_NUMBER (v2
, 0);
916 AFTER_POTENTIAL_GC ();
926 BEFORE_POTENTIAL_GC ();
927 v1
= wrong_type_argument (Qlistp
, v1
);
928 AFTER_POTENTIAL_GC ();
940 BEFORE_POTENTIAL_GC ();
941 Fcar (wrong_type_argument (Qlistp
, v1
));
942 AFTER_POTENTIAL_GC ();
948 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
952 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
956 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
960 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
964 TOP
= NILP (TOP
) ? Qt
: Qnil
;
971 TOP
= Fcons (TOP
, v1
);
976 TOP
= Fcons (TOP
, Qnil
);
983 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
989 TOP
= Flist (3, &TOP
);
994 TOP
= Flist (4, &TOP
);
1000 TOP
= Flist (op
, &TOP
);
1004 BEFORE_POTENTIAL_GC ();
1005 TOP
= Flength (TOP
);
1006 AFTER_POTENTIAL_GC ();
1012 BEFORE_POTENTIAL_GC ();
1014 TOP
= Faref (TOP
, v1
);
1015 AFTER_POTENTIAL_GC ();
1022 BEFORE_POTENTIAL_GC ();
1024 TOP
= Faset (TOP
, v1
, v2
);
1025 AFTER_POTENTIAL_GC ();
1030 BEFORE_POTENTIAL_GC ();
1031 TOP
= Fsymbol_value (TOP
);
1032 AFTER_POTENTIAL_GC ();
1035 case Bsymbol_function
:
1036 BEFORE_POTENTIAL_GC ();
1037 TOP
= Fsymbol_function (TOP
);
1038 AFTER_POTENTIAL_GC ();
1044 BEFORE_POTENTIAL_GC ();
1046 TOP
= Fset (TOP
, v1
);
1047 AFTER_POTENTIAL_GC ();
1054 BEFORE_POTENTIAL_GC ();
1056 TOP
= Ffset (TOP
, v1
);
1057 AFTER_POTENTIAL_GC ();
1064 BEFORE_POTENTIAL_GC ();
1066 TOP
= Fget (TOP
, v1
);
1067 AFTER_POTENTIAL_GC ();
1074 BEFORE_POTENTIAL_GC ();
1076 TOP
= Fsubstring (TOP
, v1
, v2
);
1077 AFTER_POTENTIAL_GC ();
1082 BEFORE_POTENTIAL_GC ();
1084 TOP
= Fconcat (2, &TOP
);
1085 AFTER_POTENTIAL_GC ();
1089 BEFORE_POTENTIAL_GC ();
1091 TOP
= Fconcat (3, &TOP
);
1092 AFTER_POTENTIAL_GC ();
1096 BEFORE_POTENTIAL_GC ();
1098 TOP
= Fconcat (4, &TOP
);
1099 AFTER_POTENTIAL_GC ();
1104 BEFORE_POTENTIAL_GC ();
1106 TOP
= Fconcat (op
, &TOP
);
1107 AFTER_POTENTIAL_GC ();
1116 XSETINT (v1
, XINT (v1
) - 1);
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
, 0);
1148 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
, 0);
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 ();
1197 TOP
= Fgeq (TOP
, v1
);
1202 BEFORE_POTENTIAL_GC ();
1204 TOP
= Fminus (2, &TOP
);
1205 AFTER_POTENTIAL_GC ();
1214 XSETINT (v1
, - XINT (v1
));
1219 BEFORE_POTENTIAL_GC ();
1220 TOP
= Fminus (1, &TOP
);
1221 AFTER_POTENTIAL_GC ();
1227 BEFORE_POTENTIAL_GC ();
1229 TOP
= Fplus (2, &TOP
);
1230 AFTER_POTENTIAL_GC ();
1234 BEFORE_POTENTIAL_GC ();
1236 TOP
= Fmax (2, &TOP
);
1237 AFTER_POTENTIAL_GC ();
1241 BEFORE_POTENTIAL_GC ();
1243 TOP
= Fmin (2, &TOP
);
1244 AFTER_POTENTIAL_GC ();
1248 BEFORE_POTENTIAL_GC ();
1250 TOP
= Ftimes (2, &TOP
);
1251 AFTER_POTENTIAL_GC ();
1255 BEFORE_POTENTIAL_GC ();
1257 TOP
= Fquo (2, &TOP
);
1258 AFTER_POTENTIAL_GC ();
1264 BEFORE_POTENTIAL_GC ();
1266 TOP
= Frem (TOP
, v1
);
1267 AFTER_POTENTIAL_GC ();
1274 XSETFASTINT (v1
, PT
);
1280 BEFORE_POTENTIAL_GC ();
1281 TOP
= Fgoto_char (TOP
);
1282 AFTER_POTENTIAL_GC ();
1286 BEFORE_POTENTIAL_GC ();
1287 TOP
= Finsert (1, &TOP
);
1288 AFTER_POTENTIAL_GC ();
1293 BEFORE_POTENTIAL_GC ();
1295 TOP
= Finsert (op
, &TOP
);
1296 AFTER_POTENTIAL_GC ();
1302 XSETFASTINT (v1
, ZV
);
1310 XSETFASTINT (v1
, BEGV
);
1316 BEFORE_POTENTIAL_GC ();
1317 TOP
= Fchar_after (TOP
);
1318 AFTER_POTENTIAL_GC ();
1321 case Bfollowing_char
:
1324 BEFORE_POTENTIAL_GC ();
1325 v1
= Ffollowing_char ();
1326 AFTER_POTENTIAL_GC ();
1331 case Bpreceding_char
:
1334 BEFORE_POTENTIAL_GC ();
1335 v1
= Fprevious_char ();
1336 AFTER_POTENTIAL_GC ();
1341 case Bcurrent_column
:
1344 XSETFASTINT (v1
, current_column ());
1350 BEFORE_POTENTIAL_GC ();
1351 TOP
= Findent_to (TOP
, Qnil
);
1352 AFTER_POTENTIAL_GC ();
1371 case Bcurrent_buffer
:
1372 PUSH (Fcurrent_buffer ());
1376 BEFORE_POTENTIAL_GC ();
1377 TOP
= Fset_buffer (TOP
);
1378 AFTER_POTENTIAL_GC ();
1381 case Binteractive_p
:
1382 PUSH (Finteractive_p ());
1386 BEFORE_POTENTIAL_GC ();
1387 TOP
= Fforward_char (TOP
);
1388 AFTER_POTENTIAL_GC ();
1392 BEFORE_POTENTIAL_GC ();
1393 TOP
= Fforward_word (TOP
);
1394 AFTER_POTENTIAL_GC ();
1397 case Bskip_chars_forward
:
1400 BEFORE_POTENTIAL_GC ();
1402 TOP
= Fskip_chars_forward (TOP
, v1
);
1403 AFTER_POTENTIAL_GC ();
1407 case Bskip_chars_backward
:
1410 BEFORE_POTENTIAL_GC ();
1412 TOP
= Fskip_chars_backward (TOP
, v1
);
1413 AFTER_POTENTIAL_GC ();
1418 BEFORE_POTENTIAL_GC ();
1419 TOP
= Fforward_line (TOP
);
1420 AFTER_POTENTIAL_GC ();
1424 BEFORE_POTENTIAL_GC ();
1425 CHECK_NUMBER (TOP
, 0);
1426 AFTER_POTENTIAL_GC ();
1427 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (XINT (TOP
))]);
1430 case Bbuffer_substring
:
1433 BEFORE_POTENTIAL_GC ();
1435 TOP
= Fbuffer_substring (TOP
, v1
);
1436 AFTER_POTENTIAL_GC ();
1440 case Bdelete_region
:
1443 BEFORE_POTENTIAL_GC ();
1445 TOP
= Fdelete_region (TOP
, v1
);
1446 AFTER_POTENTIAL_GC ();
1450 case Bnarrow_to_region
:
1453 BEFORE_POTENTIAL_GC ();
1455 TOP
= Fnarrow_to_region (TOP
, v1
);
1456 AFTER_POTENTIAL_GC ();
1461 BEFORE_POTENTIAL_GC ();
1463 AFTER_POTENTIAL_GC ();
1467 BEFORE_POTENTIAL_GC ();
1468 TOP
= Fend_of_line (TOP
);
1469 AFTER_POTENTIAL_GC ();
1475 BEFORE_POTENTIAL_GC ();
1478 TOP
= Fset_marker (TOP
, v2
, v1
);
1479 AFTER_POTENTIAL_GC ();
1483 case Bmatch_beginning
:
1484 BEFORE_POTENTIAL_GC ();
1485 TOP
= Fmatch_beginning (TOP
);
1486 AFTER_POTENTIAL_GC ();
1490 BEFORE_POTENTIAL_GC ();
1491 TOP
= Fmatch_end (TOP
);
1492 AFTER_POTENTIAL_GC ();
1496 BEFORE_POTENTIAL_GC ();
1497 TOP
= Fupcase (TOP
);
1498 AFTER_POTENTIAL_GC ();
1502 BEFORE_POTENTIAL_GC ();
1503 TOP
= Fdowncase (TOP
);
1504 AFTER_POTENTIAL_GC ();
1507 case Bstringeqlsign
:
1510 BEFORE_POTENTIAL_GC ();
1512 TOP
= Fstring_equal (TOP
, v1
);
1513 AFTER_POTENTIAL_GC ();
1520 BEFORE_POTENTIAL_GC ();
1522 TOP
= Fstring_lessp (TOP
, v1
);
1523 AFTER_POTENTIAL_GC ();
1531 TOP
= Fequal (TOP
, v1
);
1538 BEFORE_POTENTIAL_GC ();
1540 TOP
= Fnthcdr (TOP
, v1
);
1541 AFTER_POTENTIAL_GC ();
1550 /* Exchange args and then do nth. */
1551 BEFORE_POTENTIAL_GC ();
1554 CHECK_NUMBER (v2
, 0);
1555 AFTER_POTENTIAL_GC ();
1562 else if (!NILP (v1
))
1565 BEFORE_POTENTIAL_GC ();
1566 v1
= wrong_type_argument (Qlistp
, v1
);
1567 AFTER_POTENTIAL_GC ();
1579 BEFORE_POTENTIAL_GC ();
1580 Fcar (wrong_type_argument (Qlistp
, v1
));
1581 AFTER_POTENTIAL_GC ();
1586 BEFORE_POTENTIAL_GC ();
1588 TOP
= Felt (TOP
, v1
);
1589 AFTER_POTENTIAL_GC ();
1597 BEFORE_POTENTIAL_GC ();
1599 TOP
= Fmember (TOP
, v1
);
1600 AFTER_POTENTIAL_GC ();
1607 BEFORE_POTENTIAL_GC ();
1609 TOP
= Fassq (TOP
, v1
);
1610 AFTER_POTENTIAL_GC ();
1615 BEFORE_POTENTIAL_GC ();
1616 TOP
= Fnreverse (TOP
);
1617 AFTER_POTENTIAL_GC ();
1623 BEFORE_POTENTIAL_GC ();
1625 TOP
= Fsetcar (TOP
, v1
);
1626 AFTER_POTENTIAL_GC ();
1633 BEFORE_POTENTIAL_GC ();
1635 TOP
= Fsetcdr (TOP
, v1
);
1636 AFTER_POTENTIAL_GC ();
1663 BEFORE_POTENTIAL_GC ();
1665 TOP
= Fnconc (2, &TOP
);
1666 AFTER_POTENTIAL_GC ();
1670 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1674 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1677 #ifdef BYTE_CODE_SAFE
1679 BEFORE_POTENTIAL_GC ();
1680 error ("set-mark is an obsolete bytecode");
1681 AFTER_POTENTIAL_GC ();
1684 BEFORE_POTENTIAL_GC ();
1685 error ("scan-buffer is an obsolete bytecode");
1686 AFTER_POTENTIAL_GC ();
1695 #ifdef BYTE_CODE_SAFE
1700 if ((op
-= Bconstant
) >= const_length
)
1706 PUSH (vectorp
[op
- Bconstant
]);
1713 byte_stack_list
= byte_stack_list
->next
;
1715 /* Binds and unbinds are supposed to be compiled balanced. */
1716 if (specpdl_ptr
- specpdl
!= count
)
1717 #ifdef BYTE_CODE_SAFE
1718 error ("binding stack not balanced (serious byte compiler bug)");
1729 Qbytecode
= intern ("byte-code");
1730 staticpro (&Qbytecode
);
1732 defsubr (&Sbyte_code
);
1734 #ifdef BYTE_CODE_METER
1736 DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter
,
1737 "A vector of vectors which holds a histogram of byte-code usage.\n\
1738 (aref (aref byte-code-meter 0) CODE) indicates how many times the byte\n\
1739 opcode CODE has been executed.\n\
1740 (aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,\n\
1741 indicates how many times the byte opcodes CODE1 and CODE2 have been\n\
1742 executed in succession.");
1743 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on
,
1744 "If non-nil, keep profiling information on byte code usage.\n\
1745 The variable byte-code-meter indicates how often each byte opcode is used.\n\
1746 If a symbol has a property named `byte-code-meter' whose value is an\n\
1747 integer, it is incremented each time that symbol's function is called.");
1749 byte_metering_on
= 0;
1750 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1751 Qbyte_code_meter
= intern ("byte-code-meter");
1752 staticpro (&Qbyte_code_meter
);
1756 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1757 Fmake_vector (make_number (256), make_number (0));