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
;
83 extern Lisp_Object Qand_optional
, Qand_rest
;
87 #define Bstack_ref 0 /* Actually, Bstack_ref+0 is not implemented: use dup. */
112 #define Bsymbol_value 0112
113 #define Bsymbol_function 0113
117 #define Bsubstring 0117
118 #define Bconcat2 0120
119 #define Bconcat3 0121
120 #define Bconcat4 0122
123 #define Beqlsign 0125
136 /* Was Bmark in v17. */
137 #define Bsave_current_buffer 0141 /* Obsolete. */
138 #define Bgoto_char 0142
140 #define Bpoint_max 0144
141 #define Bpoint_min 0145
142 #define Bchar_after 0146
143 #define Bfollowing_char 0147
144 #define Bpreceding_char 0150
145 #define Bcurrent_column 0151
146 #define Bindent_to 0152
147 #ifdef BYTE_CODE_SAFE
148 #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. */
158 #define Bread_char 0162 /* No longer generated as of v19 */
160 #ifdef BYTE_CODE_SAFE
161 #define Bset_mark 0163 /* this loser is no longer generated as of v18 */
163 #define Binteractive_p 0164 /* Obsolete since Emacs-24.1. */
165 #define Bforward_char 0165
166 #define Bforward_word 0166
167 #define Bskip_chars_forward 0167
168 #define Bskip_chars_backward 0170
169 #define Bforward_line 0171
170 #define Bchar_syntax 0172
171 #define Bbuffer_substring 0173
172 #define Bdelete_region 0174
173 #define Bnarrow_to_region 0175
175 #define Bend_of_line 0177
177 #define Bconstant2 0201
179 #define Bgotoifnil 0203
180 #define Bgotoifnonnil 0204
181 #define Bgotoifnilelsepop 0205
182 #define Bgotoifnonnilelsepop 0206
184 #define Bdiscard 0210
187 #define Bsave_excursion 0212
188 #define Bsave_window_excursion 0213 /* Obsolete since Emacs-24.1. */
189 #define Bsave_restriction 0214
192 #define Bunwind_protect 0216
193 #define Bcondition_case 0217
194 #define Btemp_output_buffer_setup 0220 /* Obsolete since Emacs-24.1. */
195 #define Btemp_output_buffer_show 0221 /* Obsolete since Emacs-24.1. */
197 #define Bunbind_all 0222 /* Obsolete. Never used. */
199 #define Bset_marker 0223
200 #define Bmatch_beginning 0224
201 #define Bmatch_end 0225
203 #define Bdowncase 0227
205 #define Bstringeqlsign 0230
206 #define Bstringlss 0231
212 #define Bnreverse 0237
215 #define Bcar_safe 0242
216 #define Bcdr_safe 0243
220 #define Bnumberp 0247
221 #define Bintegerp 0250
224 #define BRgotoifnil 0253
225 #define BRgotoifnonnil 0254
226 #define BRgotoifnilelsepop 0255
227 #define BRgotoifnonnilelsepop 0256
230 #define BconcatN 0260
231 #define BinsertN 0261
233 /* Bstack_ref is code 0. */
234 #define Bstack_set 0262
235 #define Bstack_set2 0263
236 #define BdiscardN 0266
238 #define Bconstant 0300
240 /* Whether to maintain a `top' and `bottom' field in the stack frame. */
241 #define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK)
243 /* Structure describing a value stack used during byte-code execution
248 /* Program counter. This points into the byte_string below
249 and is relocated when that string is relocated. */
250 const unsigned char *pc
;
252 /* Top and bottom of stack. The bottom points to an area of memory
253 allocated with alloca in Fbyte_code. */
254 #if BYTE_MAINTAIN_TOP
255 Lisp_Object
*top
, *bottom
;
258 /* The string containing the byte-code, and its current address.
259 Storing this here protects it from GC because mark_byte_stack
261 Lisp_Object byte_string
;
262 const unsigned char *byte_string_start
;
264 /* The vector of constants used during byte-code execution. Storing
265 this here protects it from GC because mark_byte_stack marks it. */
266 Lisp_Object constants
;
268 /* Next entry in byte_stack_list. */
269 struct byte_stack
*next
;
272 /* A list of currently active byte-code execution value stacks.
273 Fbyte_code adds an entry to the head of this list before it starts
274 processing byte-code, and it removed the entry again when it is
275 done. Signalling an error truncates the list analoguous to
278 struct byte_stack
*byte_stack_list
;
281 /* Mark objects on byte_stack_list. Called during GC. */
285 mark_byte_stack (void)
287 struct byte_stack
*stack
;
290 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
292 /* If STACK->top is null here, this means there's an opcode in
293 Fbyte_code that wasn't expected to GC, but did. To find out
294 which opcode this is, record the value of `stack', and walk
295 up the stack in a debugger, stopping in frames of Fbyte_code.
296 The culprit is found in the frame of Fbyte_code where the
297 address of its local variable `stack' is equal to the
298 recorded value of `stack' here. */
299 eassert (stack
->top
);
301 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
304 mark_object (stack
->byte_string
);
305 mark_object (stack
->constants
);
310 /* Unmark objects in the stacks on byte_stack_list. Relocate program
311 counters. Called when GC has completed. */
314 unmark_byte_stack (void)
316 struct byte_stack
*stack
;
318 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
320 if (stack
->byte_string_start
!= SDATA (stack
->byte_string
))
322 int offset
= stack
->pc
- stack
->byte_string_start
;
323 stack
->byte_string_start
= SDATA (stack
->byte_string
);
324 stack
->pc
= stack
->byte_string_start
+ offset
;
330 /* Fetch the next byte from the bytecode stream */
332 #define FETCH *stack.pc++
334 /* Fetch two bytes from the bytecode stream and make a 16-bit number
337 #define FETCH2 (op = FETCH, op + (FETCH << 8))
339 /* Push x onto the execution stack. This used to be #define PUSH(x)
340 (*++stackp = (x)) This oddity is necessary because Alliant can't be
341 bothered to compile the preincrement operator properly, as of 4/91.
344 #define PUSH(x) (top++, *top = (x))
346 /* Pop a value off the execution stack. */
350 /* Discard n values from the execution stack. */
352 #define DISCARD(n) (top -= (n))
354 /* Get the value which is at the top of the execution stack, but don't
359 /* Actions that must be performed before and after calling a function
362 #if !BYTE_MAINTAIN_TOP
363 #define BEFORE_POTENTIAL_GC() ((void)0)
364 #define AFTER_POTENTIAL_GC() ((void)0)
366 #define BEFORE_POTENTIAL_GC() stack.top = top
367 #define AFTER_POTENTIAL_GC() stack.top = NULL
370 /* Garbage collect if we have consed enough since the last time.
371 We do this at every branch, to avoid loops that never GC. */
375 if (consing_since_gc > gc_cons_threshold \
376 && consing_since_gc > gc_relative_threshold) \
378 BEFORE_POTENTIAL_GC (); \
379 Fgarbage_collect (); \
380 AFTER_POTENTIAL_GC (); \
384 /* Check for jumping out of range. */
386 #ifdef BYTE_CODE_SAFE
388 #define CHECK_RANGE(ARG) \
389 if (ARG >= bytestr_length) abort ()
391 #else /* not BYTE_CODE_SAFE */
393 #define CHECK_RANGE(ARG)
395 #endif /* not BYTE_CODE_SAFE */
397 /* A version of the QUIT macro which makes sure that the stack top is
398 set before signaling `quit'. */
400 #define BYTE_CODE_QUIT \
402 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
404 Lisp_Object flag = Vquit_flag; \
406 BEFORE_POTENTIAL_GC (); \
407 if (EQ (Vthrow_on_input, flag)) \
408 Fthrow (Vthrow_on_input, Qt); \
409 Fsignal (Qquit, Qnil); \
410 AFTER_POTENTIAL_GC (); \
412 ELSE_PENDING_SIGNALS \
416 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
417 doc
: /* Function used internally in byte-compiled code.
418 The first argument, BYTESTR, is a string of byte code;
419 the second, VECTOR, a vector of constants;
420 the third, MAXDEPTH, the maximum stack depth used in this function.
421 If the third argument is incorrect, Emacs may crash. */)
422 (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
)
424 return exec_byte_code (bytestr
, vector
, maxdepth
, Qnil
, 0, NULL
);
427 /* Execute the byte-code in BYTESTR. VECTOR is the constant vector, and
428 MAXDEPTH is the maximum stack depth used (if MAXDEPTH is incorrect,
429 emacs may crash!). If ARGS_TEMPLATE is non-nil, it should be a lisp
430 argument list (including &rest, &optional, etc.), and ARGS, of size
431 NARGS, should be a vector of the actual arguments. The arguments in
432 ARGS are pushed on the stack according to ARGS_TEMPLATE before
433 executing BYTESTR. */
436 exec_byte_code (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
,
437 Lisp_Object args_template
, int nargs
, Lisp_Object
*args
)
439 int count
= SPECPDL_INDEX ();
440 #ifdef BYTE_CODE_METER
445 /* Lisp_Object v1, v2; */
446 Lisp_Object
*vectorp
;
447 #ifdef BYTE_CODE_SAFE
448 int const_length
= XVECTOR (vector
)->size
;
452 struct byte_stack stack
;
456 #if 0 /* CHECK_FRAME_FONT */
458 struct frame
*f
= SELECTED_FRAME ();
460 && FRAME_FONT (f
)->direction
!= 0
461 && FRAME_FONT (f
)->direction
!= 1)
466 CHECK_STRING (bytestr
);
467 CHECK_VECTOR (vector
);
468 CHECK_NUMBER (maxdepth
);
470 if (STRING_MULTIBYTE (bytestr
))
471 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
472 because they produced a raw 8-bit string for byte-code and now
473 such a byte-code string is loaded as multibyte while raw 8-bit
474 characters converted to multibyte form. Thus, now we must
475 convert them back to the originally intended unibyte form. */
476 bytestr
= Fstring_as_unibyte (bytestr
);
478 #ifdef BYTE_CODE_SAFE
479 bytestr_length
= SBYTES (bytestr
);
481 vectorp
= XVECTOR (vector
)->contents
;
483 stack
.byte_string
= bytestr
;
484 stack
.pc
= stack
.byte_string_start
= SDATA (bytestr
);
485 stack
.constants
= vector
;
486 top
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
487 * sizeof (Lisp_Object
));
488 #if BYTE_MAINTAIN_TOP
493 stack
.next
= byte_stack_list
;
494 byte_stack_list
= &stack
;
496 #ifdef BYTE_CODE_SAFE
497 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
500 if (INTEGERP (args_template
))
502 int at
= XINT (args_template
);
504 int mandatory
= at
& 127;
505 int nonrest
= at
>> 8;
506 eassert (mandatory
<= nonrest
);
507 if (nargs
<= nonrest
)
510 for (i
= 0 ; i
< nargs
; i
++, args
++)
512 if (nargs
< mandatory
)
513 /* Too few arguments. */
514 Fsignal (Qwrong_number_of_arguments
,
515 Fcons (Fcons (make_number (mandatory
),
516 rest
? Qand_rest
: make_number (nonrest
)),
517 Fcons (make_number (nargs
), Qnil
)));
520 for (; i
< nonrest
; i
++)
529 for (i
= 0 ; i
< nonrest
; i
++, args
++)
531 PUSH (Flist (nargs
- nonrest
, args
));
534 /* Too many arguments. */
535 Fsignal (Qwrong_number_of_arguments
,
536 Fcons (Fcons (make_number (mandatory
),
537 make_number (nonrest
)),
538 Fcons (make_number (nargs
), Qnil
)));
540 else if (! NILP (args_template
))
541 /* We should push some arguments on the stack. */
543 error ("Unknown args template!");
548 #ifdef BYTE_CODE_SAFE
551 else if (top
< stack
.bottom
- 1)
555 #ifdef BYTE_CODE_METER
557 this_op
= op
= FETCH
;
558 METER_CODE (prev_op
, op
);
578 /* This seems to be the most frequently executed byte-code
579 among the Bvarref's, so avoid a goto here. */
589 if (XSYMBOL (v1
)->redirect
!= SYMBOL_PLAINVAL
590 || (v2
= SYMBOL_VAL (XSYMBOL (v1
)),
593 BEFORE_POTENTIAL_GC ();
594 v2
= Fsymbol_value (v1
);
595 AFTER_POTENTIAL_GC ();
600 BEFORE_POTENTIAL_GC ();
601 v2
= Fsymbol_value (v1
);
602 AFTER_POTENTIAL_GC ();
618 stack
.pc
= stack
.byte_string_start
+ op
;
633 BEFORE_POTENTIAL_GC ();
634 wrong_type_argument (Qlistp
, v1
);
635 AFTER_POTENTIAL_GC ();
644 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
651 BEFORE_POTENTIAL_GC ();
653 TOP
= Fmemq (TOP
, v1
);
654 AFTER_POTENTIAL_GC ();
668 BEFORE_POTENTIAL_GC ();
669 wrong_type_argument (Qlistp
, v1
);
670 AFTER_POTENTIAL_GC ();
693 Lisp_Object sym
, val
;
698 /* Inline the most common case. */
700 && !EQ (val
, Qunbound
)
701 && !XSYMBOL (sym
)->redirect
702 && !SYMBOL_CONSTANT_P (sym
))
703 XSYMBOL (sym
)->val
.value
= val
;
706 BEFORE_POTENTIAL_GC ();
707 set_internal (sym
, val
, Qnil
, 0);
708 AFTER_POTENTIAL_GC ();
722 /* ------------------ */
740 /* Specbind can signal and thus GC. */
741 BEFORE_POTENTIAL_GC ();
742 specbind (vectorp
[op
], POP
);
743 AFTER_POTENTIAL_GC ();
763 BEFORE_POTENTIAL_GC ();
765 #ifdef BYTE_CODE_METER
766 if (byte_metering_on
&& SYMBOLP (TOP
))
771 v2
= Fget (v1
, Qbyte_code_meter
);
773 && XINT (v2
) < MOST_POSITIVE_FIXNUM
)
775 XSETINT (v2
, XINT (v2
) + 1);
776 Fput (v1
, Qbyte_code_meter
, v2
);
780 TOP
= Ffuncall (op
+ 1, &TOP
);
781 AFTER_POTENTIAL_GC ();
801 BEFORE_POTENTIAL_GC ();
802 unbind_to (SPECPDL_INDEX () - op
, Qnil
);
803 AFTER_POTENTIAL_GC ();
806 case Bunbind_all
: /* Obsolete. Never used. */
807 /* To unbind back to the beginning of this frame. Not used yet,
808 but will be needed for tail-recursion elimination. */
809 BEFORE_POTENTIAL_GC ();
810 unbind_to (count
, Qnil
);
811 AFTER_POTENTIAL_GC ();
817 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
819 stack
.pc
= stack
.byte_string_start
+ op
;
832 stack
.pc
= stack
.byte_string_start
+ op
;
837 case Bgotoifnilelsepop
:
844 stack
.pc
= stack
.byte_string_start
+ op
;
849 case Bgotoifnonnilelsepop
:
856 stack
.pc
= stack
.byte_string_start
+ op
;
864 stack
.pc
+= (int) *stack
.pc
- 127;
875 stack
.pc
+= (int) *stack
.pc
- 128;
889 stack
.pc
+= (int) *stack
.pc
- 128;
895 case BRgotoifnilelsepop
:
901 stack
.pc
+= op
- 128;
906 case BRgotoifnonnilelsepop
:
912 stack
.pc
+= op
- 128;
926 PUSH (vectorp
[FETCH2
]);
929 case Bsave_excursion
:
930 record_unwind_protect (save_excursion_restore
,
931 save_excursion_save ());
934 case Bsave_current_buffer
: /* Obsolete since ??. */
935 case Bsave_current_buffer_1
:
936 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
939 case Bsave_window_excursion
: /* Obsolete since 24.1. */
941 register int count1
= SPECPDL_INDEX ();
942 record_unwind_protect (Fset_window_configuration
,
943 Fcurrent_window_configuration (Qnil
));
944 BEFORE_POTENTIAL_GC ();
946 unbind_to (count1
, TOP
);
947 AFTER_POTENTIAL_GC ();
951 case Bsave_restriction
:
952 record_unwind_protect (save_restriction_restore
,
953 save_restriction_save ());
956 case Bcatch
: /* FIXME: ill-suited for lexbind */
959 BEFORE_POTENTIAL_GC ();
961 TOP
= internal_catch (TOP
, eval_sub
, v1
);
962 AFTER_POTENTIAL_GC ();
966 case Bunwind_protect
: /* FIXME: avoid closure for lexbind */
967 record_unwind_protect (Fprogn
, POP
);
970 case Bcondition_case
: /* FIXME: ill-suited for lexbind */
972 Lisp_Object handlers
, body
;
975 BEFORE_POTENTIAL_GC ();
976 TOP
= internal_lisp_condition_case (TOP
, body
, handlers
);
977 AFTER_POTENTIAL_GC ();
981 case Btemp_output_buffer_setup
: /* Obsolete since 24.1. */
982 BEFORE_POTENTIAL_GC ();
984 temp_output_buffer_setup (SSDATA (TOP
));
985 AFTER_POTENTIAL_GC ();
986 TOP
= Vstandard_output
;
989 case Btemp_output_buffer_show
: /* Obsolete since 24.1. */
992 BEFORE_POTENTIAL_GC ();
994 temp_output_buffer_show (TOP
);
996 /* pop binding of standard-output */
997 unbind_to (SPECPDL_INDEX () - 1, Qnil
);
998 AFTER_POTENTIAL_GC ();
1005 BEFORE_POTENTIAL_GC ();
1011 while (--op
>= 0 && CONSP (v1
))
1015 AFTER_POTENTIAL_GC ();
1020 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
1024 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
1028 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
1032 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
1036 TOP
= NILP (TOP
) ? Qt
: Qnil
;
1043 TOP
= Fcons (TOP
, v1
);
1048 TOP
= Fcons (TOP
, Qnil
);
1055 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
1061 TOP
= Flist (3, &TOP
);
1066 TOP
= Flist (4, &TOP
);
1072 TOP
= Flist (op
, &TOP
);
1076 BEFORE_POTENTIAL_GC ();
1077 TOP
= Flength (TOP
);
1078 AFTER_POTENTIAL_GC ();
1084 BEFORE_POTENTIAL_GC ();
1086 TOP
= Faref (TOP
, v1
);
1087 AFTER_POTENTIAL_GC ();
1094 BEFORE_POTENTIAL_GC ();
1096 TOP
= Faset (TOP
, v1
, v2
);
1097 AFTER_POTENTIAL_GC ();
1102 BEFORE_POTENTIAL_GC ();
1103 TOP
= Fsymbol_value (TOP
);
1104 AFTER_POTENTIAL_GC ();
1107 case Bsymbol_function
:
1108 BEFORE_POTENTIAL_GC ();
1109 TOP
= Fsymbol_function (TOP
);
1110 AFTER_POTENTIAL_GC ();
1116 BEFORE_POTENTIAL_GC ();
1118 TOP
= Fset (TOP
, v1
);
1119 AFTER_POTENTIAL_GC ();
1126 BEFORE_POTENTIAL_GC ();
1128 TOP
= Ffset (TOP
, v1
);
1129 AFTER_POTENTIAL_GC ();
1136 BEFORE_POTENTIAL_GC ();
1138 TOP
= Fget (TOP
, v1
);
1139 AFTER_POTENTIAL_GC ();
1146 BEFORE_POTENTIAL_GC ();
1148 TOP
= Fsubstring (TOP
, v1
, v2
);
1149 AFTER_POTENTIAL_GC ();
1154 BEFORE_POTENTIAL_GC ();
1156 TOP
= Fconcat (2, &TOP
);
1157 AFTER_POTENTIAL_GC ();
1161 BEFORE_POTENTIAL_GC ();
1163 TOP
= Fconcat (3, &TOP
);
1164 AFTER_POTENTIAL_GC ();
1168 BEFORE_POTENTIAL_GC ();
1170 TOP
= Fconcat (4, &TOP
);
1171 AFTER_POTENTIAL_GC ();
1176 BEFORE_POTENTIAL_GC ();
1178 TOP
= Fconcat (op
, &TOP
);
1179 AFTER_POTENTIAL_GC ();
1188 XSETINT (v1
, XINT (v1
) - 1);
1193 BEFORE_POTENTIAL_GC ();
1195 AFTER_POTENTIAL_GC ();
1206 XSETINT (v1
, XINT (v1
) + 1);
1211 BEFORE_POTENTIAL_GC ();
1213 AFTER_POTENTIAL_GC ();
1221 BEFORE_POTENTIAL_GC ();
1223 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1
);
1224 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
);
1225 AFTER_POTENTIAL_GC ();
1226 if (FLOATP (v1
) || FLOATP (v2
))
1230 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1231 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1232 TOP
= (f1
== f2
? Qt
: Qnil
);
1235 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1242 BEFORE_POTENTIAL_GC ();
1244 TOP
= Fgtr (TOP
, v1
);
1245 AFTER_POTENTIAL_GC ();
1252 BEFORE_POTENTIAL_GC ();
1254 TOP
= Flss (TOP
, v1
);
1255 AFTER_POTENTIAL_GC ();
1262 BEFORE_POTENTIAL_GC ();
1264 TOP
= Fleq (TOP
, v1
);
1265 AFTER_POTENTIAL_GC ();
1272 BEFORE_POTENTIAL_GC ();
1274 TOP
= Fgeq (TOP
, v1
);
1275 AFTER_POTENTIAL_GC ();
1280 BEFORE_POTENTIAL_GC ();
1282 TOP
= Fminus (2, &TOP
);
1283 AFTER_POTENTIAL_GC ();
1292 XSETINT (v1
, - XINT (v1
));
1297 BEFORE_POTENTIAL_GC ();
1298 TOP
= Fminus (1, &TOP
);
1299 AFTER_POTENTIAL_GC ();
1305 BEFORE_POTENTIAL_GC ();
1307 TOP
= Fplus (2, &TOP
);
1308 AFTER_POTENTIAL_GC ();
1312 BEFORE_POTENTIAL_GC ();
1314 TOP
= Fmax (2, &TOP
);
1315 AFTER_POTENTIAL_GC ();
1319 BEFORE_POTENTIAL_GC ();
1321 TOP
= Fmin (2, &TOP
);
1322 AFTER_POTENTIAL_GC ();
1326 BEFORE_POTENTIAL_GC ();
1328 TOP
= Ftimes (2, &TOP
);
1329 AFTER_POTENTIAL_GC ();
1333 BEFORE_POTENTIAL_GC ();
1335 TOP
= Fquo (2, &TOP
);
1336 AFTER_POTENTIAL_GC ();
1342 BEFORE_POTENTIAL_GC ();
1344 TOP
= Frem (TOP
, v1
);
1345 AFTER_POTENTIAL_GC ();
1352 XSETFASTINT (v1
, PT
);
1358 BEFORE_POTENTIAL_GC ();
1359 TOP
= Fgoto_char (TOP
);
1360 AFTER_POTENTIAL_GC ();
1364 BEFORE_POTENTIAL_GC ();
1365 TOP
= Finsert (1, &TOP
);
1366 AFTER_POTENTIAL_GC ();
1371 BEFORE_POTENTIAL_GC ();
1373 TOP
= Finsert (op
, &TOP
);
1374 AFTER_POTENTIAL_GC ();
1380 XSETFASTINT (v1
, ZV
);
1388 XSETFASTINT (v1
, BEGV
);
1394 BEFORE_POTENTIAL_GC ();
1395 TOP
= Fchar_after (TOP
);
1396 AFTER_POTENTIAL_GC ();
1399 case Bfollowing_char
:
1402 BEFORE_POTENTIAL_GC ();
1403 v1
= Ffollowing_char ();
1404 AFTER_POTENTIAL_GC ();
1409 case Bpreceding_char
:
1412 BEFORE_POTENTIAL_GC ();
1413 v1
= Fprevious_char ();
1414 AFTER_POTENTIAL_GC ();
1419 case Bcurrent_column
:
1422 BEFORE_POTENTIAL_GC ();
1423 XSETFASTINT (v1
, current_column ());
1424 AFTER_POTENTIAL_GC ();
1430 BEFORE_POTENTIAL_GC ();
1431 TOP
= Findent_to (TOP
, Qnil
);
1432 AFTER_POTENTIAL_GC ();
1451 case Bcurrent_buffer
:
1452 PUSH (Fcurrent_buffer ());
1456 BEFORE_POTENTIAL_GC ();
1457 TOP
= Fset_buffer (TOP
);
1458 AFTER_POTENTIAL_GC ();
1461 case Binteractive_p
: /* Obsolete since 24.1. */
1462 PUSH (Finteractive_p ());
1466 BEFORE_POTENTIAL_GC ();
1467 TOP
= Fforward_char (TOP
);
1468 AFTER_POTENTIAL_GC ();
1472 BEFORE_POTENTIAL_GC ();
1473 TOP
= Fforward_word (TOP
);
1474 AFTER_POTENTIAL_GC ();
1477 case Bskip_chars_forward
:
1480 BEFORE_POTENTIAL_GC ();
1482 TOP
= Fskip_chars_forward (TOP
, v1
);
1483 AFTER_POTENTIAL_GC ();
1487 case Bskip_chars_backward
:
1490 BEFORE_POTENTIAL_GC ();
1492 TOP
= Fskip_chars_backward (TOP
, v1
);
1493 AFTER_POTENTIAL_GC ();
1498 BEFORE_POTENTIAL_GC ();
1499 TOP
= Fforward_line (TOP
);
1500 AFTER_POTENTIAL_GC ();
1507 BEFORE_POTENTIAL_GC ();
1508 CHECK_CHARACTER (TOP
);
1509 AFTER_POTENTIAL_GC ();
1511 if (NILP (BVAR (current_buffer
, enable_multibyte_characters
)))
1512 MAKE_CHAR_MULTIBYTE (c
);
1513 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (c
)]);
1517 case Bbuffer_substring
:
1520 BEFORE_POTENTIAL_GC ();
1522 TOP
= Fbuffer_substring (TOP
, v1
);
1523 AFTER_POTENTIAL_GC ();
1527 case Bdelete_region
:
1530 BEFORE_POTENTIAL_GC ();
1532 TOP
= Fdelete_region (TOP
, v1
);
1533 AFTER_POTENTIAL_GC ();
1537 case Bnarrow_to_region
:
1540 BEFORE_POTENTIAL_GC ();
1542 TOP
= Fnarrow_to_region (TOP
, v1
);
1543 AFTER_POTENTIAL_GC ();
1548 BEFORE_POTENTIAL_GC ();
1550 AFTER_POTENTIAL_GC ();
1554 BEFORE_POTENTIAL_GC ();
1555 TOP
= Fend_of_line (TOP
);
1556 AFTER_POTENTIAL_GC ();
1562 BEFORE_POTENTIAL_GC ();
1565 TOP
= Fset_marker (TOP
, v2
, v1
);
1566 AFTER_POTENTIAL_GC ();
1570 case Bmatch_beginning
:
1571 BEFORE_POTENTIAL_GC ();
1572 TOP
= Fmatch_beginning (TOP
);
1573 AFTER_POTENTIAL_GC ();
1577 BEFORE_POTENTIAL_GC ();
1578 TOP
= Fmatch_end (TOP
);
1579 AFTER_POTENTIAL_GC ();
1583 BEFORE_POTENTIAL_GC ();
1584 TOP
= Fupcase (TOP
);
1585 AFTER_POTENTIAL_GC ();
1589 BEFORE_POTENTIAL_GC ();
1590 TOP
= Fdowncase (TOP
);
1591 AFTER_POTENTIAL_GC ();
1594 case Bstringeqlsign
:
1597 BEFORE_POTENTIAL_GC ();
1599 TOP
= Fstring_equal (TOP
, v1
);
1600 AFTER_POTENTIAL_GC ();
1607 BEFORE_POTENTIAL_GC ();
1609 TOP
= Fstring_lessp (TOP
, v1
);
1610 AFTER_POTENTIAL_GC ();
1618 TOP
= Fequal (TOP
, v1
);
1625 BEFORE_POTENTIAL_GC ();
1627 TOP
= Fnthcdr (TOP
, v1
);
1628 AFTER_POTENTIAL_GC ();
1637 /* Exchange args and then do nth. */
1638 BEFORE_POTENTIAL_GC ();
1642 AFTER_POTENTIAL_GC ();
1645 while (--op
>= 0 && CONSP (v1
))
1652 BEFORE_POTENTIAL_GC ();
1654 TOP
= Felt (TOP
, v1
);
1655 AFTER_POTENTIAL_GC ();
1663 BEFORE_POTENTIAL_GC ();
1665 TOP
= Fmember (TOP
, v1
);
1666 AFTER_POTENTIAL_GC ();
1673 BEFORE_POTENTIAL_GC ();
1675 TOP
= Fassq (TOP
, v1
);
1676 AFTER_POTENTIAL_GC ();
1681 BEFORE_POTENTIAL_GC ();
1682 TOP
= Fnreverse (TOP
);
1683 AFTER_POTENTIAL_GC ();
1689 BEFORE_POTENTIAL_GC ();
1691 TOP
= Fsetcar (TOP
, v1
);
1692 AFTER_POTENTIAL_GC ();
1699 BEFORE_POTENTIAL_GC ();
1701 TOP
= Fsetcdr (TOP
, v1
);
1702 AFTER_POTENTIAL_GC ();
1710 TOP
= CAR_SAFE (v1
);
1718 TOP
= CDR_SAFE (v1
);
1723 BEFORE_POTENTIAL_GC ();
1725 TOP
= Fnconc (2, &TOP
);
1726 AFTER_POTENTIAL_GC ();
1730 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1734 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1737 #ifdef BYTE_CODE_SAFE
1739 BEFORE_POTENTIAL_GC ();
1740 error ("set-mark is an obsolete bytecode");
1741 AFTER_POTENTIAL_GC ();
1744 BEFORE_POTENTIAL_GC ();
1745 error ("scan-buffer is an obsolete bytecode");
1746 AFTER_POTENTIAL_GC ();
1751 /* Actually this is Bstack_ref with offset 0, but we use Bdup
1752 for that instead. */
1753 /* case Bstack_ref: */
1756 /* Handy byte-codes for lexical binding. */
1763 Lisp_Object
*ptr
= top
- (op
- Bstack_ref
);
1769 Lisp_Object
*ptr
= top
- (FETCH
);
1775 Lisp_Object
*ptr
= top
- (FETCH2
);
1779 /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */
1782 Lisp_Object
*ptr
= top
- (FETCH
);
1788 Lisp_Object
*ptr
= top
- (FETCH2
);
1804 #ifdef BYTE_CODE_SAFE
1809 if ((op
-= Bconstant
) >= const_length
)
1815 PUSH (vectorp
[op
- Bconstant
]);
1822 byte_stack_list
= byte_stack_list
->next
;
1824 /* Binds and unbinds are supposed to be compiled balanced. */
1825 if (SPECPDL_INDEX () != count
)
1826 #ifdef BYTE_CODE_SAFE
1827 error ("binding stack not balanced (serious byte compiler bug)");
1836 syms_of_bytecode (void)
1838 Qbytecode
= intern_c_string ("byte-code");
1839 staticpro (&Qbytecode
);
1841 defsubr (&Sbyte_code
);
1843 #ifdef BYTE_CODE_METER
1845 DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter
,
1846 doc
: /* A vector of vectors which holds a histogram of byte-code usage.
1847 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1848 opcode CODE has been executed.
1849 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1850 indicates how many times the byte opcodes CODE1 and CODE2 have been
1851 executed in succession. */);
1853 DEFVAR_BOOL ("byte-metering-on", byte_metering_on
,
1854 doc
: /* If non-nil, keep profiling information on byte code usage.
1855 The variable byte-code-meter indicates how often each byte opcode is used.
1856 If a symbol has a property named `byte-code-meter' whose value is an
1857 integer, it is incremented each time that symbol's function is called. */);
1859 byte_metering_on
= 0;
1860 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1861 Qbyte_code_meter
= intern_c_string ("byte-code-meter");
1862 staticpro (&Qbyte_code_meter
);
1866 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1867 Fmake_vector (make_number (256), make_number (0));