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
;
86 #define Bstack_ref 0 /* Actually, Bstack_ref+0 is not implemented: use dup. */
111 #define Bsymbol_value 0112
112 #define Bsymbol_function 0113
116 #define Bsubstring 0117
117 #define Bconcat2 0120
118 #define Bconcat3 0121
119 #define Bconcat4 0122
122 #define Beqlsign 0125
135 /* Was Bmark in v17. */
136 #define Bsave_current_buffer 0141 /* Obsolete. */
137 #define Bgoto_char 0142
139 #define Bpoint_max 0144
140 #define Bpoint_min 0145
141 #define Bchar_after 0146
142 #define Bfollowing_char 0147
143 #define Bpreceding_char 0150
144 #define Bcurrent_column 0151
145 #define Bindent_to 0152
146 #ifdef BYTE_CODE_SAFE
147 #define Bscan_buffer 0153 /* No longer generated as of v18 */
153 #define Bcurrent_buffer 0160
154 #define Bset_buffer 0161
155 #define Bsave_current_buffer_1 0162 /* Replacing Bsave_current_buffer. */
157 #define Bread_char 0162 /* No longer generated as of v19 */
159 #ifdef BYTE_CODE_SAFE
160 #define Bset_mark 0163 /* this loser is no longer generated as of v18 */
162 #define Binteractive_p 0164 /* Obsolete since Emacs-24.1. */
164 #define Bforward_char 0165
165 #define Bforward_word 0166
166 #define Bskip_chars_forward 0167
167 #define Bskip_chars_backward 0170
168 #define Bforward_line 0171
169 #define Bchar_syntax 0172
170 #define Bbuffer_substring 0173
171 #define Bdelete_region 0174
172 #define Bnarrow_to_region 0175
174 #define Bend_of_line 0177
176 #define Bconstant2 0201
178 #define Bgotoifnil 0203
179 #define Bgotoifnonnil 0204
180 #define Bgotoifnilelsepop 0205
181 #define Bgotoifnonnilelsepop 0206
183 #define Bdiscard 0210
186 #define Bsave_excursion 0212
187 #define Bsave_window_excursion 0213 /* Obsolete since Emacs-24.1. */
188 #define Bsave_restriction 0214
191 #define Bunwind_protect 0216
192 #define Bcondition_case 0217
193 #define Btemp_output_buffer_setup 0220 /* Obsolete since Emacs-24.1. */
194 #define Btemp_output_buffer_show 0221 /* Obsolete since Emacs-24.1. */
196 #define Bunbind_all 0222 /* Obsolete. Never used. */
198 #define Bset_marker 0223
199 #define Bmatch_beginning 0224
200 #define Bmatch_end 0225
202 #define Bdowncase 0227
204 #define Bstringeqlsign 0230
205 #define Bstringlss 0231
211 #define Bnreverse 0237
214 #define Bcar_safe 0242
215 #define Bcdr_safe 0243
219 #define Bnumberp 0247
220 #define Bintegerp 0250
223 #define BRgotoifnil 0253
224 #define BRgotoifnonnil 0254
225 #define BRgotoifnilelsepop 0255
226 #define BRgotoifnonnilelsepop 0256
229 #define BconcatN 0260
230 #define BinsertN 0261
232 /* Bstack_ref is code 0. */
233 #define Bstack_set 0262
234 #define Bstack_set2 0263
235 #define BdiscardN 0266
237 #define Bconstant 0300
239 /* Whether to maintain a `top' and `bottom' field in the stack frame. */
240 #define BYTE_MAINTAIN_TOP (BYTE_CODE_SAFE || BYTE_MARK_STACK)
242 /* Structure describing a value stack used during byte-code execution
247 /* Program counter. This points into the byte_string below
248 and is relocated when that string is relocated. */
249 const unsigned char *pc
;
251 /* Top and bottom of stack. The bottom points to an area of memory
252 allocated with alloca in Fbyte_code. */
253 #if BYTE_MAINTAIN_TOP
254 Lisp_Object
*top
, *bottom
;
257 /* The string containing the byte-code, and its current address.
258 Storing this here protects it from GC because mark_byte_stack
260 Lisp_Object byte_string
;
261 const unsigned char *byte_string_start
;
263 /* The vector of constants used during byte-code execution. Storing
264 this here protects it from GC because mark_byte_stack marks it. */
265 Lisp_Object constants
;
267 /* Next entry in byte_stack_list. */
268 struct byte_stack
*next
;
271 /* A list of currently active byte-code execution value stacks.
272 Fbyte_code adds an entry to the head of this list before it starts
273 processing byte-code, and it removed the entry again when it is
274 done. Signalling an error truncates the list analoguous to
277 struct byte_stack
*byte_stack_list
;
280 /* Mark objects on byte_stack_list. Called during GC. */
284 mark_byte_stack (void)
286 struct byte_stack
*stack
;
289 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
291 /* If STACK->top is null here, this means there's an opcode in
292 Fbyte_code that wasn't expected to GC, but did. To find out
293 which opcode this is, record the value of `stack', and walk
294 up the stack in a debugger, stopping in frames of Fbyte_code.
295 The culprit is found in the frame of Fbyte_code where the
296 address of its local variable `stack' is equal to the
297 recorded value of `stack' here. */
298 eassert (stack
->top
);
300 for (obj
= stack
->bottom
; obj
<= stack
->top
; ++obj
)
303 mark_object (stack
->byte_string
);
304 mark_object (stack
->constants
);
309 /* Unmark objects in the stacks on byte_stack_list. Relocate program
310 counters. Called when GC has completed. */
313 unmark_byte_stack (void)
315 struct byte_stack
*stack
;
317 for (stack
= byte_stack_list
; stack
; stack
= stack
->next
)
319 if (stack
->byte_string_start
!= SDATA (stack
->byte_string
))
321 int offset
= stack
->pc
- stack
->byte_string_start
;
322 stack
->byte_string_start
= SDATA (stack
->byte_string
);
323 stack
->pc
= stack
->byte_string_start
+ offset
;
329 /* Fetch the next byte from the bytecode stream */
331 #define FETCH *stack.pc++
333 /* Fetch two bytes from the bytecode stream and make a 16-bit number
336 #define FETCH2 (op = FETCH, op + (FETCH << 8))
338 /* Push x onto the execution stack. This used to be #define PUSH(x)
339 (*++stackp = (x)) This oddity is necessary because Alliant can't be
340 bothered to compile the preincrement operator properly, as of 4/91.
343 #define PUSH(x) (top++, *top = (x))
345 /* Pop a value off the execution stack. */
349 /* Discard n values from the execution stack. */
351 #define DISCARD(n) (top -= (n))
353 /* Get the value which is at the top of the execution stack, but don't
358 /* Actions that must be performed before and after calling a function
361 #if !BYTE_MAINTAIN_TOP
362 #define BEFORE_POTENTIAL_GC() ((void)0)
363 #define AFTER_POTENTIAL_GC() ((void)0)
365 #define BEFORE_POTENTIAL_GC() stack.top = top
366 #define AFTER_POTENTIAL_GC() stack.top = NULL
369 /* Garbage collect if we have consed enough since the last time.
370 We do this at every branch, to avoid loops that never GC. */
374 if (consing_since_gc > gc_cons_threshold \
375 && consing_since_gc > gc_relative_threshold) \
377 BEFORE_POTENTIAL_GC (); \
378 Fgarbage_collect (); \
379 AFTER_POTENTIAL_GC (); \
383 /* Check for jumping out of range. */
385 #ifdef BYTE_CODE_SAFE
387 #define CHECK_RANGE(ARG) \
388 if (ARG >= bytestr_length) abort ()
390 #else /* not BYTE_CODE_SAFE */
392 #define CHECK_RANGE(ARG)
394 #endif /* not BYTE_CODE_SAFE */
396 /* A version of the QUIT macro which makes sure that the stack top is
397 set before signaling `quit'. */
399 #define BYTE_CODE_QUIT \
401 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
403 Lisp_Object flag = Vquit_flag; \
405 BEFORE_POTENTIAL_GC (); \
406 if (EQ (Vthrow_on_input, flag)) \
407 Fthrow (Vthrow_on_input, Qt); \
408 Fsignal (Qquit, Qnil); \
409 AFTER_POTENTIAL_GC (); \
411 ELSE_PENDING_SIGNALS \
415 DEFUN ("byte-code", Fbyte_code
, Sbyte_code
, 3, 3, 0,
416 doc
: /* Function used internally in byte-compiled code.
417 The first argument, BYTESTR, is a string of byte code;
418 the second, VECTOR, a vector of constants;
419 the third, MAXDEPTH, the maximum stack depth used in this function.
420 If the third argument is incorrect, Emacs may crash. */)
421 (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
)
423 return exec_byte_code (bytestr
, vector
, maxdepth
, Qnil
, 0, NULL
);
426 /* Execute the byte-code in BYTESTR. VECTOR is the constant vector, and
427 MAXDEPTH is the maximum stack depth used (if MAXDEPTH is incorrect,
428 emacs may crash!). If ARGS_TEMPLATE is non-nil, it should be a lisp
429 argument list (including &rest, &optional, etc.), and ARGS, of size
430 NARGS, should be a vector of the actual arguments. The arguments in
431 ARGS are pushed on the stack according to ARGS_TEMPLATE before
432 executing BYTESTR. */
435 exec_byte_code (Lisp_Object bytestr
, Lisp_Object vector
, Lisp_Object maxdepth
,
436 Lisp_Object args_template
, int nargs
, Lisp_Object
*args
)
438 int count
= SPECPDL_INDEX ();
439 #ifdef BYTE_CODE_METER
444 /* Lisp_Object v1, v2; */
445 Lisp_Object
*vectorp
;
446 #ifdef BYTE_CODE_SAFE
447 int const_length
= XVECTOR (vector
)->size
;
451 struct byte_stack stack
;
455 #if 0 /* CHECK_FRAME_FONT */
457 struct frame
*f
= SELECTED_FRAME ();
459 && FRAME_FONT (f
)->direction
!= 0
460 && FRAME_FONT (f
)->direction
!= 1)
465 CHECK_STRING (bytestr
);
466 CHECK_VECTOR (vector
);
467 CHECK_NUMBER (maxdepth
);
469 if (STRING_MULTIBYTE (bytestr
))
470 /* BYTESTR must have been produced by Emacs 20.2 or the earlier
471 because they produced a raw 8-bit string for byte-code and now
472 such a byte-code string is loaded as multibyte while raw 8-bit
473 characters converted to multibyte form. Thus, now we must
474 convert them back to the originally intended unibyte form. */
475 bytestr
= Fstring_as_unibyte (bytestr
);
477 #ifdef BYTE_CODE_SAFE
478 bytestr_length
= SBYTES (bytestr
);
480 vectorp
= XVECTOR (vector
)->contents
;
482 stack
.byte_string
= bytestr
;
483 stack
.pc
= stack
.byte_string_start
= SDATA (bytestr
);
484 stack
.constants
= vector
;
485 top
= (Lisp_Object
*) alloca (XFASTINT (maxdepth
)
486 * sizeof (Lisp_Object
));
487 #if BYTE_MAINTAIN_TOP
492 stack
.next
= byte_stack_list
;
493 byte_stack_list
= &stack
;
495 #ifdef BYTE_CODE_SAFE
496 stacke
= stack
.bottom
- 1 + XFASTINT (maxdepth
);
499 if (INTEGERP (args_template
))
501 int at
= XINT (args_template
);
503 int mandatory
= at
& 127;
504 int nonrest
= at
>> 8;
505 eassert (mandatory
<= nonrest
);
506 if (nargs
<= nonrest
)
509 for (i
= 0 ; i
< nargs
; i
++, args
++)
511 if (nargs
< mandatory
)
512 /* Too few arguments. */
513 Fsignal (Qwrong_number_of_arguments
,
514 Fcons (Fcons (make_number (mandatory
),
515 rest
? Qand_rest
: make_number (nonrest
)),
516 Fcons (make_number (nargs
), Qnil
)));
519 for (; i
< nonrest
; i
++)
528 for (i
= 0 ; i
< nonrest
; i
++, args
++)
530 PUSH (Flist (nargs
- nonrest
, args
));
533 /* Too many arguments. */
534 Fsignal (Qwrong_number_of_arguments
,
535 Fcons (Fcons (make_number (mandatory
),
536 make_number (nonrest
)),
537 Fcons (make_number (nargs
), Qnil
)));
539 else if (! NILP (args_template
))
540 /* We should push some arguments on the stack. */
542 error ("Unknown args template!");
547 #ifdef BYTE_CODE_SAFE
550 else if (top
< stack
.bottom
- 1)
554 #ifdef BYTE_CODE_METER
556 this_op
= op
= FETCH
;
557 METER_CODE (prev_op
, op
);
577 /* This seems to be the most frequently executed byte-code
578 among the Bvarref's, so avoid a goto here. */
588 if (XSYMBOL (v1
)->redirect
!= SYMBOL_PLAINVAL
589 || (v2
= SYMBOL_VAL (XSYMBOL (v1
)),
592 BEFORE_POTENTIAL_GC ();
593 v2
= Fsymbol_value (v1
);
594 AFTER_POTENTIAL_GC ();
599 BEFORE_POTENTIAL_GC ();
600 v2
= Fsymbol_value (v1
);
601 AFTER_POTENTIAL_GC ();
617 stack
.pc
= stack
.byte_string_start
+ op
;
632 BEFORE_POTENTIAL_GC ();
633 wrong_type_argument (Qlistp
, v1
);
634 AFTER_POTENTIAL_GC ();
643 TOP
= EQ (v1
, TOP
) ? Qt
: Qnil
;
650 BEFORE_POTENTIAL_GC ();
652 TOP
= Fmemq (TOP
, v1
);
653 AFTER_POTENTIAL_GC ();
667 BEFORE_POTENTIAL_GC ();
668 wrong_type_argument (Qlistp
, v1
);
669 AFTER_POTENTIAL_GC ();
692 Lisp_Object sym
, val
;
697 /* Inline the most common case. */
699 && !EQ (val
, Qunbound
)
700 && !XSYMBOL (sym
)->redirect
701 && !SYMBOL_CONSTANT_P (sym
))
702 XSYMBOL (sym
)->val
.value
= val
;
705 BEFORE_POTENTIAL_GC ();
706 set_internal (sym
, val
, Qnil
, 0);
707 AFTER_POTENTIAL_GC ();
721 /* ------------------ */
739 /* Specbind can signal and thus GC. */
740 BEFORE_POTENTIAL_GC ();
741 specbind (vectorp
[op
], POP
);
742 AFTER_POTENTIAL_GC ();
762 BEFORE_POTENTIAL_GC ();
764 #ifdef BYTE_CODE_METER
765 if (byte_metering_on
&& SYMBOLP (TOP
))
770 v2
= Fget (v1
, Qbyte_code_meter
);
772 && XINT (v2
) < MOST_POSITIVE_FIXNUM
)
774 XSETINT (v2
, XINT (v2
) + 1);
775 Fput (v1
, Qbyte_code_meter
, v2
);
779 TOP
= Ffuncall (op
+ 1, &TOP
);
780 AFTER_POTENTIAL_GC ();
800 BEFORE_POTENTIAL_GC ();
801 unbind_to (SPECPDL_INDEX () - op
, Qnil
);
802 AFTER_POTENTIAL_GC ();
805 case Bunbind_all
: /* Obsolete. Never used. */
806 /* To unbind back to the beginning of this frame. Not used yet,
807 but will be needed for tail-recursion elimination. */
808 BEFORE_POTENTIAL_GC ();
809 unbind_to (count
, Qnil
);
810 AFTER_POTENTIAL_GC ();
816 op
= FETCH2
; /* pc = FETCH2 loses since FETCH2 contains pc++ */
818 stack
.pc
= stack
.byte_string_start
+ op
;
831 stack
.pc
= stack
.byte_string_start
+ op
;
836 case Bgotoifnilelsepop
:
843 stack
.pc
= stack
.byte_string_start
+ op
;
848 case Bgotoifnonnilelsepop
:
855 stack
.pc
= stack
.byte_string_start
+ op
;
863 stack
.pc
+= (int) *stack
.pc
- 127;
874 stack
.pc
+= (int) *stack
.pc
- 128;
888 stack
.pc
+= (int) *stack
.pc
- 128;
894 case BRgotoifnilelsepop
:
900 stack
.pc
+= op
- 128;
905 case BRgotoifnonnilelsepop
:
911 stack
.pc
+= op
- 128;
925 PUSH (vectorp
[FETCH2
]);
928 case Bsave_excursion
:
929 record_unwind_protect (save_excursion_restore
,
930 save_excursion_save ());
933 case Bsave_current_buffer
: /* Obsolete since ??. */
934 case Bsave_current_buffer_1
:
935 record_unwind_protect (set_buffer_if_live
, Fcurrent_buffer ());
938 case Bsave_window_excursion
: /* Obsolete since 24.1. */
940 register int count1
= SPECPDL_INDEX ();
941 record_unwind_protect (Fset_window_configuration
,
942 Fcurrent_window_configuration (Qnil
));
943 BEFORE_POTENTIAL_GC ();
945 unbind_to (count1
, TOP
);
946 AFTER_POTENTIAL_GC ();
950 case Bsave_restriction
:
951 record_unwind_protect (save_restriction_restore
,
952 save_restriction_save ());
955 case Bcatch
: /* FIXME: ill-suited for lexbind */
958 BEFORE_POTENTIAL_GC ();
960 TOP
= internal_catch (TOP
, eval_sub
, v1
);
961 AFTER_POTENTIAL_GC ();
965 case Bunwind_protect
: /* FIXME: avoid closure for lexbind */
966 record_unwind_protect (Fprogn
, POP
);
969 case Bcondition_case
: /* FIXME: ill-suited for lexbind */
971 Lisp_Object handlers
, body
;
974 BEFORE_POTENTIAL_GC ();
975 TOP
= internal_lisp_condition_case (TOP
, body
, handlers
);
976 AFTER_POTENTIAL_GC ();
980 case Btemp_output_buffer_setup
: /* Obsolete since 24.1. */
981 BEFORE_POTENTIAL_GC ();
983 temp_output_buffer_setup (SSDATA (TOP
));
984 AFTER_POTENTIAL_GC ();
985 TOP
= Vstandard_output
;
988 case Btemp_output_buffer_show
: /* Obsolete since 24.1. */
991 BEFORE_POTENTIAL_GC ();
993 temp_output_buffer_show (TOP
);
995 /* pop binding of standard-output */
996 unbind_to (SPECPDL_INDEX () - 1, Qnil
);
997 AFTER_POTENTIAL_GC ();
1004 BEFORE_POTENTIAL_GC ();
1010 while (--op
>= 0 && CONSP (v1
))
1014 AFTER_POTENTIAL_GC ();
1019 TOP
= SYMBOLP (TOP
) ? Qt
: Qnil
;
1023 TOP
= CONSP (TOP
) ? Qt
: Qnil
;
1027 TOP
= STRINGP (TOP
) ? Qt
: Qnil
;
1031 TOP
= CONSP (TOP
) || NILP (TOP
) ? Qt
: Qnil
;
1035 TOP
= NILP (TOP
) ? Qt
: Qnil
;
1042 TOP
= Fcons (TOP
, v1
);
1047 TOP
= Fcons (TOP
, Qnil
);
1054 TOP
= Fcons (TOP
, Fcons (v1
, Qnil
));
1060 TOP
= Flist (3, &TOP
);
1065 TOP
= Flist (4, &TOP
);
1071 TOP
= Flist (op
, &TOP
);
1075 BEFORE_POTENTIAL_GC ();
1076 TOP
= Flength (TOP
);
1077 AFTER_POTENTIAL_GC ();
1083 BEFORE_POTENTIAL_GC ();
1085 TOP
= Faref (TOP
, v1
);
1086 AFTER_POTENTIAL_GC ();
1093 BEFORE_POTENTIAL_GC ();
1095 TOP
= Faset (TOP
, v1
, v2
);
1096 AFTER_POTENTIAL_GC ();
1101 BEFORE_POTENTIAL_GC ();
1102 TOP
= Fsymbol_value (TOP
);
1103 AFTER_POTENTIAL_GC ();
1106 case Bsymbol_function
:
1107 BEFORE_POTENTIAL_GC ();
1108 TOP
= Fsymbol_function (TOP
);
1109 AFTER_POTENTIAL_GC ();
1115 BEFORE_POTENTIAL_GC ();
1117 TOP
= Fset (TOP
, v1
);
1118 AFTER_POTENTIAL_GC ();
1125 BEFORE_POTENTIAL_GC ();
1127 TOP
= Ffset (TOP
, v1
);
1128 AFTER_POTENTIAL_GC ();
1135 BEFORE_POTENTIAL_GC ();
1137 TOP
= Fget (TOP
, v1
);
1138 AFTER_POTENTIAL_GC ();
1145 BEFORE_POTENTIAL_GC ();
1147 TOP
= Fsubstring (TOP
, v1
, v2
);
1148 AFTER_POTENTIAL_GC ();
1153 BEFORE_POTENTIAL_GC ();
1155 TOP
= Fconcat (2, &TOP
);
1156 AFTER_POTENTIAL_GC ();
1160 BEFORE_POTENTIAL_GC ();
1162 TOP
= Fconcat (3, &TOP
);
1163 AFTER_POTENTIAL_GC ();
1167 BEFORE_POTENTIAL_GC ();
1169 TOP
= Fconcat (4, &TOP
);
1170 AFTER_POTENTIAL_GC ();
1175 BEFORE_POTENTIAL_GC ();
1177 TOP
= Fconcat (op
, &TOP
);
1178 AFTER_POTENTIAL_GC ();
1187 XSETINT (v1
, XINT (v1
) - 1);
1192 BEFORE_POTENTIAL_GC ();
1194 AFTER_POTENTIAL_GC ();
1205 XSETINT (v1
, XINT (v1
) + 1);
1210 BEFORE_POTENTIAL_GC ();
1212 AFTER_POTENTIAL_GC ();
1220 BEFORE_POTENTIAL_GC ();
1222 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1
);
1223 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2
);
1224 AFTER_POTENTIAL_GC ();
1225 if (FLOATP (v1
) || FLOATP (v2
))
1229 f1
= (FLOATP (v1
) ? XFLOAT_DATA (v1
) : XINT (v1
));
1230 f2
= (FLOATP (v2
) ? XFLOAT_DATA (v2
) : XINT (v2
));
1231 TOP
= (f1
== f2
? Qt
: Qnil
);
1234 TOP
= (XINT (v1
) == XINT (v2
) ? Qt
: Qnil
);
1241 BEFORE_POTENTIAL_GC ();
1243 TOP
= Fgtr (TOP
, v1
);
1244 AFTER_POTENTIAL_GC ();
1251 BEFORE_POTENTIAL_GC ();
1253 TOP
= Flss (TOP
, v1
);
1254 AFTER_POTENTIAL_GC ();
1261 BEFORE_POTENTIAL_GC ();
1263 TOP
= Fleq (TOP
, v1
);
1264 AFTER_POTENTIAL_GC ();
1271 BEFORE_POTENTIAL_GC ();
1273 TOP
= Fgeq (TOP
, v1
);
1274 AFTER_POTENTIAL_GC ();
1279 BEFORE_POTENTIAL_GC ();
1281 TOP
= Fminus (2, &TOP
);
1282 AFTER_POTENTIAL_GC ();
1291 XSETINT (v1
, - XINT (v1
));
1296 BEFORE_POTENTIAL_GC ();
1297 TOP
= Fminus (1, &TOP
);
1298 AFTER_POTENTIAL_GC ();
1304 BEFORE_POTENTIAL_GC ();
1306 TOP
= Fplus (2, &TOP
);
1307 AFTER_POTENTIAL_GC ();
1311 BEFORE_POTENTIAL_GC ();
1313 TOP
= Fmax (2, &TOP
);
1314 AFTER_POTENTIAL_GC ();
1318 BEFORE_POTENTIAL_GC ();
1320 TOP
= Fmin (2, &TOP
);
1321 AFTER_POTENTIAL_GC ();
1325 BEFORE_POTENTIAL_GC ();
1327 TOP
= Ftimes (2, &TOP
);
1328 AFTER_POTENTIAL_GC ();
1332 BEFORE_POTENTIAL_GC ();
1334 TOP
= Fquo (2, &TOP
);
1335 AFTER_POTENTIAL_GC ();
1341 BEFORE_POTENTIAL_GC ();
1343 TOP
= Frem (TOP
, v1
);
1344 AFTER_POTENTIAL_GC ();
1351 XSETFASTINT (v1
, PT
);
1357 BEFORE_POTENTIAL_GC ();
1358 TOP
= Fgoto_char (TOP
);
1359 AFTER_POTENTIAL_GC ();
1363 BEFORE_POTENTIAL_GC ();
1364 TOP
= Finsert (1, &TOP
);
1365 AFTER_POTENTIAL_GC ();
1370 BEFORE_POTENTIAL_GC ();
1372 TOP
= Finsert (op
, &TOP
);
1373 AFTER_POTENTIAL_GC ();
1379 XSETFASTINT (v1
, ZV
);
1387 XSETFASTINT (v1
, BEGV
);
1393 BEFORE_POTENTIAL_GC ();
1394 TOP
= Fchar_after (TOP
);
1395 AFTER_POTENTIAL_GC ();
1398 case Bfollowing_char
:
1401 BEFORE_POTENTIAL_GC ();
1402 v1
= Ffollowing_char ();
1403 AFTER_POTENTIAL_GC ();
1408 case Bpreceding_char
:
1411 BEFORE_POTENTIAL_GC ();
1412 v1
= Fprevious_char ();
1413 AFTER_POTENTIAL_GC ();
1418 case Bcurrent_column
:
1421 BEFORE_POTENTIAL_GC ();
1422 XSETFASTINT (v1
, current_column ());
1423 AFTER_POTENTIAL_GC ();
1429 BEFORE_POTENTIAL_GC ();
1430 TOP
= Findent_to (TOP
, Qnil
);
1431 AFTER_POTENTIAL_GC ();
1450 case Bcurrent_buffer
:
1451 PUSH (Fcurrent_buffer ());
1455 BEFORE_POTENTIAL_GC ();
1456 TOP
= Fset_buffer (TOP
);
1457 AFTER_POTENTIAL_GC ();
1460 case Binteractive_p
: /* Obsolete since 24.1. */
1461 PUSH (Finteractive_p ());
1465 BEFORE_POTENTIAL_GC ();
1466 TOP
= Fforward_char (TOP
);
1467 AFTER_POTENTIAL_GC ();
1471 BEFORE_POTENTIAL_GC ();
1472 TOP
= Fforward_word (TOP
);
1473 AFTER_POTENTIAL_GC ();
1476 case Bskip_chars_forward
:
1479 BEFORE_POTENTIAL_GC ();
1481 TOP
= Fskip_chars_forward (TOP
, v1
);
1482 AFTER_POTENTIAL_GC ();
1486 case Bskip_chars_backward
:
1489 BEFORE_POTENTIAL_GC ();
1491 TOP
= Fskip_chars_backward (TOP
, v1
);
1492 AFTER_POTENTIAL_GC ();
1497 BEFORE_POTENTIAL_GC ();
1498 TOP
= Fforward_line (TOP
);
1499 AFTER_POTENTIAL_GC ();
1506 BEFORE_POTENTIAL_GC ();
1507 CHECK_CHARACTER (TOP
);
1508 AFTER_POTENTIAL_GC ();
1510 if (NILP (BVAR (current_buffer
, enable_multibyte_characters
)))
1511 MAKE_CHAR_MULTIBYTE (c
);
1512 XSETFASTINT (TOP
, syntax_code_spec
[(int) SYNTAX (c
)]);
1516 case Bbuffer_substring
:
1519 BEFORE_POTENTIAL_GC ();
1521 TOP
= Fbuffer_substring (TOP
, v1
);
1522 AFTER_POTENTIAL_GC ();
1526 case Bdelete_region
:
1529 BEFORE_POTENTIAL_GC ();
1531 TOP
= Fdelete_region (TOP
, v1
);
1532 AFTER_POTENTIAL_GC ();
1536 case Bnarrow_to_region
:
1539 BEFORE_POTENTIAL_GC ();
1541 TOP
= Fnarrow_to_region (TOP
, v1
);
1542 AFTER_POTENTIAL_GC ();
1547 BEFORE_POTENTIAL_GC ();
1549 AFTER_POTENTIAL_GC ();
1553 BEFORE_POTENTIAL_GC ();
1554 TOP
= Fend_of_line (TOP
);
1555 AFTER_POTENTIAL_GC ();
1561 BEFORE_POTENTIAL_GC ();
1564 TOP
= Fset_marker (TOP
, v2
, v1
);
1565 AFTER_POTENTIAL_GC ();
1569 case Bmatch_beginning
:
1570 BEFORE_POTENTIAL_GC ();
1571 TOP
= Fmatch_beginning (TOP
);
1572 AFTER_POTENTIAL_GC ();
1576 BEFORE_POTENTIAL_GC ();
1577 TOP
= Fmatch_end (TOP
);
1578 AFTER_POTENTIAL_GC ();
1582 BEFORE_POTENTIAL_GC ();
1583 TOP
= Fupcase (TOP
);
1584 AFTER_POTENTIAL_GC ();
1588 BEFORE_POTENTIAL_GC ();
1589 TOP
= Fdowncase (TOP
);
1590 AFTER_POTENTIAL_GC ();
1593 case Bstringeqlsign
:
1596 BEFORE_POTENTIAL_GC ();
1598 TOP
= Fstring_equal (TOP
, v1
);
1599 AFTER_POTENTIAL_GC ();
1606 BEFORE_POTENTIAL_GC ();
1608 TOP
= Fstring_lessp (TOP
, v1
);
1609 AFTER_POTENTIAL_GC ();
1617 TOP
= Fequal (TOP
, v1
);
1624 BEFORE_POTENTIAL_GC ();
1626 TOP
= Fnthcdr (TOP
, v1
);
1627 AFTER_POTENTIAL_GC ();
1636 /* Exchange args and then do nth. */
1637 BEFORE_POTENTIAL_GC ();
1641 AFTER_POTENTIAL_GC ();
1644 while (--op
>= 0 && CONSP (v1
))
1651 BEFORE_POTENTIAL_GC ();
1653 TOP
= Felt (TOP
, v1
);
1654 AFTER_POTENTIAL_GC ();
1662 BEFORE_POTENTIAL_GC ();
1664 TOP
= Fmember (TOP
, v1
);
1665 AFTER_POTENTIAL_GC ();
1672 BEFORE_POTENTIAL_GC ();
1674 TOP
= Fassq (TOP
, v1
);
1675 AFTER_POTENTIAL_GC ();
1680 BEFORE_POTENTIAL_GC ();
1681 TOP
= Fnreverse (TOP
);
1682 AFTER_POTENTIAL_GC ();
1688 BEFORE_POTENTIAL_GC ();
1690 TOP
= Fsetcar (TOP
, v1
);
1691 AFTER_POTENTIAL_GC ();
1698 BEFORE_POTENTIAL_GC ();
1700 TOP
= Fsetcdr (TOP
, v1
);
1701 AFTER_POTENTIAL_GC ();
1709 TOP
= CAR_SAFE (v1
);
1717 TOP
= CDR_SAFE (v1
);
1722 BEFORE_POTENTIAL_GC ();
1724 TOP
= Fnconc (2, &TOP
);
1725 AFTER_POTENTIAL_GC ();
1729 TOP
= (NUMBERP (TOP
) ? Qt
: Qnil
);
1733 TOP
= INTEGERP (TOP
) ? Qt
: Qnil
;
1736 #ifdef BYTE_CODE_SAFE
1738 BEFORE_POTENTIAL_GC ();
1739 error ("set-mark is an obsolete bytecode");
1740 AFTER_POTENTIAL_GC ();
1743 BEFORE_POTENTIAL_GC ();
1744 error ("scan-buffer is an obsolete bytecode");
1745 AFTER_POTENTIAL_GC ();
1750 /* Actually this is Bstack_ref with offset 0, but we use Bdup
1751 for that instead. */
1752 /* case Bstack_ref: */
1755 /* Handy byte-codes for lexical binding. */
1762 Lisp_Object
*ptr
= top
- (op
- Bstack_ref
);
1768 Lisp_Object
*ptr
= top
- (FETCH
);
1774 Lisp_Object
*ptr
= top
- (FETCH2
);
1778 /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */
1781 Lisp_Object
*ptr
= top
- (FETCH
);
1787 Lisp_Object
*ptr
= top
- (FETCH2
);
1803 #ifdef BYTE_CODE_SAFE
1808 if ((op
-= Bconstant
) >= const_length
)
1814 PUSH (vectorp
[op
- Bconstant
]);
1821 byte_stack_list
= byte_stack_list
->next
;
1823 /* Binds and unbinds are supposed to be compiled balanced. */
1824 if (SPECPDL_INDEX () != count
)
1825 #ifdef BYTE_CODE_SAFE
1826 error ("binding stack not balanced (serious byte compiler bug)");
1835 syms_of_bytecode (void)
1837 Qbytecode
= intern_c_string ("byte-code");
1838 staticpro (&Qbytecode
);
1840 defsubr (&Sbyte_code
);
1842 #ifdef BYTE_CODE_METER
1844 DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter
,
1845 doc
: /* A vector of vectors which holds a histogram of byte-code usage.
1846 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1847 opcode CODE has been executed.
1848 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1849 indicates how many times the byte opcodes CODE1 and CODE2 have been
1850 executed in succession. */);
1852 DEFVAR_BOOL ("byte-metering-on", byte_metering_on
,
1853 doc
: /* If non-nil, keep profiling information on byte code usage.
1854 The variable byte-code-meter indicates how often each byte opcode is used.
1855 If a symbol has a property named `byte-code-meter' whose value is an
1856 integer, it is incremented each time that symbol's function is called. */);
1858 byte_metering_on
= 0;
1859 Vbyte_code_meter
= Fmake_vector (make_number (256), make_number (0));
1860 Qbyte_code_meter
= intern_c_string ("byte-code-meter");
1861 staticpro (&Qbyte_code_meter
);
1865 XVECTOR (Vbyte_code_meter
)->contents
[i
] =
1866 Fmake_vector (make_number (256), make_number (0));