Commit | Line | Data |
---|---|---|
36f7ba0a | 1 | /* Execution of byte code produced by bytecomp.el. |
ba318903 | 2 | Copyright (C) 1985-1988, 1993, 2000-2014 Free Software Foundation, |
ab422c4d | 3 | Inc. |
36f7ba0a JB |
4 | |
5 | This file is part of GNU Emacs. | |
6 | ||
9ec0b715 | 7 | GNU Emacs is free software: you can redistribute it and/or modify |
36f7ba0a | 8 | it under the terms of the GNU General Public License as published by |
9ec0b715 GM |
9 | the Free Software Foundation, either version 3 of the License, or |
10 | (at your option) any later version. | |
36f7ba0a JB |
11 | |
12 | GNU Emacs is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
9ec0b715 | 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
36f7ba0a | 19 | |
9ec0b715 | 20 | /* |
63639d44 | 21 | hacked on by jwz@lucid.com 17-jun-91 |
36f7ba0a JB |
22 | o added a compile-time switch to turn on simple sanity checking; |
23 | o put back the obsolete byte-codes for error-detection; | |
8e11578b | 24 | o added a new instruction, unbind_all, which I will use for |
36f7ba0a | 25 | tail-recursion elimination; |
63639d44 | 26 | o made temp_output_buffer_show be called with the right number |
36f7ba0a JB |
27 | of args; |
28 | o made the new bytecodes be called with args in the right order; | |
29 | o added metering support. | |
30 | ||
31 | by Hallvard: | |
3ffbe76b | 32 | o added relative jump instructions; |
36f7ba0a JB |
33 | o all conditionals now only do QUIT if they jump. |
34 | */ | |
35 | ||
18160b98 | 36 | #include <config.h> |
0328b6de | 37 | |
36f7ba0a | 38 | #include "lisp.h" |
83be827a | 39 | #include "character.h" |
e5560ff7 | 40 | #include "buffer.h" |
36f7ba0a | 41 | #include "syntax.h" |
3f6abfd7 | 42 | #include "window.h" |
36f7ba0a | 43 | |
ad7de7d7 GM |
44 | #ifdef CHECK_FRAME_FONT |
45 | #include "frame.h" | |
46 | #include "xterm.h" | |
47 | #endif | |
48 | ||
63639d44 | 49 | /* |
8e11578b | 50 | * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for |
63639d44 JB |
51 | * debugging the byte compiler...) |
52 | * | |
8e11578b | 53 | * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. |
36f7ba0a | 54 | */ |
63639d44 JB |
55 | /* #define BYTE_CODE_SAFE */ |
56 | /* #define BYTE_CODE_METER */ | |
36f7ba0a | 57 | |
3a4c8000 TT |
58 | /* If BYTE_CODE_THREADED is defined, then the interpreter will be |
59 | indirect threaded, using GCC's computed goto extension. This code, | |
60 | as currently implemented, is incompatible with BYTE_CODE_SAFE and | |
61 | BYTE_CODE_METER. */ | |
29abe551 PE |
62 | #if (defined __GNUC__ && !defined __STRICT_ANSI__ \ |
63 | && !defined BYTE_CODE_SAFE && !defined BYTE_CODE_METER) | |
3a4c8000 TT |
64 | #define BYTE_CODE_THREADED |
65 | #endif | |
66 | ||
36f7ba0a JB |
67 | \f |
68 | #ifdef BYTE_CODE_METER | |
69 | ||
29208e82 | 70 | Lisp_Object Qbyte_code_meter; |
defd4196 PE |
71 | #define METER_2(code1, code2) AREF (AREF (Vbyte_code_meter, code1), code2) |
72 | #define METER_1(code) METER_2 (0, code) | |
63639d44 | 73 | |
2e3bf02a GM |
74 | #define METER_CODE(last_code, this_code) \ |
75 | { \ | |
76 | if (byte_metering_on) \ | |
77 | { \ | |
defd4196 PE |
78 | if (XFASTINT (METER_1 (this_code)) < MOST_POSITIVE_FIXNUM) \ |
79 | XSETFASTINT (METER_1 (this_code), \ | |
80 | XFASTINT (METER_1 (this_code)) + 1); \ | |
2e3bf02a | 81 | if (last_code \ |
defd4196 PE |
82 | && (XFASTINT (METER_2 (last_code, this_code)) \ |
83 | < MOST_POSITIVE_FIXNUM)) \ | |
84 | XSETFASTINT (METER_2 (last_code, this_code), \ | |
85 | XFASTINT (METER_2 (last_code, this_code)) + 1); \ | |
2e3bf02a | 86 | } \ |
63639d44 | 87 | } |
36f7ba0a | 88 | |
615f2d59 | 89 | #endif /* BYTE_CODE_METER */ |
36f7ba0a JB |
90 | \f |
91 | ||
36f7ba0a JB |
92 | /* Byte codes: */ |
93 | ||
3a4c8000 TT |
94 | #define BYTE_CODES \ |
95 | DEFINE (Bstack_ref, 0) /* Actually, Bstack_ref+0 is not implemented: use dup. */ \ | |
96 | DEFINE (Bstack_ref1, 1) \ | |
97 | DEFINE (Bstack_ref2, 2) \ | |
98 | DEFINE (Bstack_ref3, 3) \ | |
99 | DEFINE (Bstack_ref4, 4) \ | |
100 | DEFINE (Bstack_ref5, 5) \ | |
101 | DEFINE (Bstack_ref6, 6) \ | |
102 | DEFINE (Bstack_ref7, 7) \ | |
103 | DEFINE (Bvarref, 010) \ | |
104 | DEFINE (Bvarref1, 011) \ | |
105 | DEFINE (Bvarref2, 012) \ | |
106 | DEFINE (Bvarref3, 013) \ | |
107 | DEFINE (Bvarref4, 014) \ | |
108 | DEFINE (Bvarref5, 015) \ | |
109 | DEFINE (Bvarref6, 016) \ | |
110 | DEFINE (Bvarref7, 017) \ | |
111 | DEFINE (Bvarset, 020) \ | |
112 | DEFINE (Bvarset1, 021) \ | |
113 | DEFINE (Bvarset2, 022) \ | |
114 | DEFINE (Bvarset3, 023) \ | |
115 | DEFINE (Bvarset4, 024) \ | |
116 | DEFINE (Bvarset5, 025) \ | |
117 | DEFINE (Bvarset6, 026) \ | |
118 | DEFINE (Bvarset7, 027) \ | |
119 | DEFINE (Bvarbind, 030) \ | |
120 | DEFINE (Bvarbind1, 031) \ | |
121 | DEFINE (Bvarbind2, 032) \ | |
122 | DEFINE (Bvarbind3, 033) \ | |
123 | DEFINE (Bvarbind4, 034) \ | |
124 | DEFINE (Bvarbind5, 035) \ | |
125 | DEFINE (Bvarbind6, 036) \ | |
126 | DEFINE (Bvarbind7, 037) \ | |
127 | DEFINE (Bcall, 040) \ | |
128 | DEFINE (Bcall1, 041) \ | |
129 | DEFINE (Bcall2, 042) \ | |
130 | DEFINE (Bcall3, 043) \ | |
131 | DEFINE (Bcall4, 044) \ | |
132 | DEFINE (Bcall5, 045) \ | |
133 | DEFINE (Bcall6, 046) \ | |
134 | DEFINE (Bcall7, 047) \ | |
135 | DEFINE (Bunbind, 050) \ | |
136 | DEFINE (Bunbind1, 051) \ | |
137 | DEFINE (Bunbind2, 052) \ | |
138 | DEFINE (Bunbind3, 053) \ | |
139 | DEFINE (Bunbind4, 054) \ | |
140 | DEFINE (Bunbind5, 055) \ | |
141 | DEFINE (Bunbind6, 056) \ | |
142 | DEFINE (Bunbind7, 057) \ | |
143 | \ | |
adf2aa61 SM |
144 | DEFINE (Bpophandler, 060) \ |
145 | DEFINE (Bpushconditioncase, 061) \ | |
146 | DEFINE (Bpushcatch, 062) \ | |
147 | \ | |
3a4c8000 TT |
148 | DEFINE (Bnth, 070) \ |
149 | DEFINE (Bsymbolp, 071) \ | |
150 | DEFINE (Bconsp, 072) \ | |
151 | DEFINE (Bstringp, 073) \ | |
152 | DEFINE (Blistp, 074) \ | |
153 | DEFINE (Beq, 075) \ | |
154 | DEFINE (Bmemq, 076) \ | |
155 | DEFINE (Bnot, 077) \ | |
156 | DEFINE (Bcar, 0100) \ | |
157 | DEFINE (Bcdr, 0101) \ | |
158 | DEFINE (Bcons, 0102) \ | |
159 | DEFINE (Blist1, 0103) \ | |
160 | DEFINE (Blist2, 0104) \ | |
161 | DEFINE (Blist3, 0105) \ | |
162 | DEFINE (Blist4, 0106) \ | |
163 | DEFINE (Blength, 0107) \ | |
164 | DEFINE (Baref, 0110) \ | |
165 | DEFINE (Baset, 0111) \ | |
166 | DEFINE (Bsymbol_value, 0112) \ | |
167 | DEFINE (Bsymbol_function, 0113) \ | |
168 | DEFINE (Bset, 0114) \ | |
169 | DEFINE (Bfset, 0115) \ | |
170 | DEFINE (Bget, 0116) \ | |
171 | DEFINE (Bsubstring, 0117) \ | |
172 | DEFINE (Bconcat2, 0120) \ | |
173 | DEFINE (Bconcat3, 0121) \ | |
174 | DEFINE (Bconcat4, 0122) \ | |
175 | DEFINE (Bsub1, 0123) \ | |
176 | DEFINE (Badd1, 0124) \ | |
177 | DEFINE (Beqlsign, 0125) \ | |
178 | DEFINE (Bgtr, 0126) \ | |
179 | DEFINE (Blss, 0127) \ | |
180 | DEFINE (Bleq, 0130) \ | |
181 | DEFINE (Bgeq, 0131) \ | |
182 | DEFINE (Bdiff, 0132) \ | |
183 | DEFINE (Bnegate, 0133) \ | |
184 | DEFINE (Bplus, 0134) \ | |
185 | DEFINE (Bmax, 0135) \ | |
186 | DEFINE (Bmin, 0136) \ | |
187 | DEFINE (Bmult, 0137) \ | |
188 | \ | |
189 | DEFINE (Bpoint, 0140) \ | |
190 | /* Was Bmark in v17. */ \ | |
191 | DEFINE (Bsave_current_buffer, 0141) /* Obsolete. */ \ | |
192 | DEFINE (Bgoto_char, 0142) \ | |
193 | DEFINE (Binsert, 0143) \ | |
194 | DEFINE (Bpoint_max, 0144) \ | |
195 | DEFINE (Bpoint_min, 0145) \ | |
196 | DEFINE (Bchar_after, 0146) \ | |
197 | DEFINE (Bfollowing_char, 0147) \ | |
198 | DEFINE (Bpreceding_char, 0150) \ | |
199 | DEFINE (Bcurrent_column, 0151) \ | |
200 | DEFINE (Bindent_to, 0152) \ | |
201 | DEFINE (Beolp, 0154) \ | |
202 | DEFINE (Beobp, 0155) \ | |
203 | DEFINE (Bbolp, 0156) \ | |
204 | DEFINE (Bbobp, 0157) \ | |
205 | DEFINE (Bcurrent_buffer, 0160) \ | |
206 | DEFINE (Bset_buffer, 0161) \ | |
207 | DEFINE (Bsave_current_buffer_1, 0162) /* Replacing Bsave_current_buffer. */ \ | |
208 | DEFINE (Binteractive_p, 0164) /* Obsolete since Emacs-24.1. */ \ | |
209 | \ | |
210 | DEFINE (Bforward_char, 0165) \ | |
211 | DEFINE (Bforward_word, 0166) \ | |
212 | DEFINE (Bskip_chars_forward, 0167) \ | |
213 | DEFINE (Bskip_chars_backward, 0170) \ | |
214 | DEFINE (Bforward_line, 0171) \ | |
215 | DEFINE (Bchar_syntax, 0172) \ | |
216 | DEFINE (Bbuffer_substring, 0173) \ | |
217 | DEFINE (Bdelete_region, 0174) \ | |
218 | DEFINE (Bnarrow_to_region, 0175) \ | |
219 | DEFINE (Bwiden, 0176) \ | |
220 | DEFINE (Bend_of_line, 0177) \ | |
221 | \ | |
222 | DEFINE (Bconstant2, 0201) \ | |
223 | DEFINE (Bgoto, 0202) \ | |
224 | DEFINE (Bgotoifnil, 0203) \ | |
225 | DEFINE (Bgotoifnonnil, 0204) \ | |
226 | DEFINE (Bgotoifnilelsepop, 0205) \ | |
227 | DEFINE (Bgotoifnonnilelsepop, 0206) \ | |
228 | DEFINE (Breturn, 0207) \ | |
229 | DEFINE (Bdiscard, 0210) \ | |
230 | DEFINE (Bdup, 0211) \ | |
231 | \ | |
232 | DEFINE (Bsave_excursion, 0212) \ | |
233 | DEFINE (Bsave_window_excursion, 0213) /* Obsolete since Emacs-24.1. */ \ | |
234 | DEFINE (Bsave_restriction, 0214) \ | |
235 | DEFINE (Bcatch, 0215) \ | |
236 | \ | |
237 | DEFINE (Bunwind_protect, 0216) \ | |
238 | DEFINE (Bcondition_case, 0217) \ | |
239 | DEFINE (Btemp_output_buffer_setup, 0220) /* Obsolete since Emacs-24.1. */ \ | |
240 | DEFINE (Btemp_output_buffer_show, 0221) /* Obsolete since Emacs-24.1. */ \ | |
241 | \ | |
242 | DEFINE (Bunbind_all, 0222) /* Obsolete. Never used. */ \ | |
243 | \ | |
244 | DEFINE (Bset_marker, 0223) \ | |
245 | DEFINE (Bmatch_beginning, 0224) \ | |
246 | DEFINE (Bmatch_end, 0225) \ | |
247 | DEFINE (Bupcase, 0226) \ | |
248 | DEFINE (Bdowncase, 0227) \ | |
249 | \ | |
250 | DEFINE (Bstringeqlsign, 0230) \ | |
251 | DEFINE (Bstringlss, 0231) \ | |
252 | DEFINE (Bequal, 0232) \ | |
253 | DEFINE (Bnthcdr, 0233) \ | |
254 | DEFINE (Belt, 0234) \ | |
255 | DEFINE (Bmember, 0235) \ | |
256 | DEFINE (Bassq, 0236) \ | |
257 | DEFINE (Bnreverse, 0237) \ | |
258 | DEFINE (Bsetcar, 0240) \ | |
259 | DEFINE (Bsetcdr, 0241) \ | |
260 | DEFINE (Bcar_safe, 0242) \ | |
261 | DEFINE (Bcdr_safe, 0243) \ | |
262 | DEFINE (Bnconc, 0244) \ | |
263 | DEFINE (Bquo, 0245) \ | |
264 | DEFINE (Brem, 0246) \ | |
265 | DEFINE (Bnumberp, 0247) \ | |
266 | DEFINE (Bintegerp, 0250) \ | |
267 | \ | |
268 | DEFINE (BRgoto, 0252) \ | |
269 | DEFINE (BRgotoifnil, 0253) \ | |
270 | DEFINE (BRgotoifnonnil, 0254) \ | |
271 | DEFINE (BRgotoifnilelsepop, 0255) \ | |
272 | DEFINE (BRgotoifnonnilelsepop, 0256) \ | |
273 | \ | |
274 | DEFINE (BlistN, 0257) \ | |
275 | DEFINE (BconcatN, 0260) \ | |
276 | DEFINE (BinsertN, 0261) \ | |
277 | \ | |
278 | /* Bstack_ref is code 0. */ \ | |
279 | DEFINE (Bstack_set, 0262) \ | |
280 | DEFINE (Bstack_set2, 0263) \ | |
281 | DEFINE (BdiscardN, 0266) \ | |
282 | \ | |
283 | DEFINE (Bconstant, 0300) | |
284 | ||
285 | enum byte_code_op | |
286 | { | |
287 | #define DEFINE(name, value) name = value, | |
288 | BYTE_CODES | |
289 | #undef DEFINE | |
290 | ||
615f2d59 | 291 | #ifdef BYTE_CODE_SAFE |
3a4c8000 | 292 | Bscan_buffer = 0153, /* No longer generated as of v18. */ |
29abe551 | 293 | Bset_mark = 0163, /* this loser is no longer generated as of v18 */ |
615f2d59 | 294 | #endif |
3a4c8000 | 295 | }; |
4015b3c0 | 296 | \f |
7ca1e8b7 GM |
297 | /* Structure describing a value stack used during byte-code execution |
298 | in Fbyte_code. */ | |
299 | ||
300 | struct byte_stack | |
301 | { | |
302 | /* Program counter. This points into the byte_string below | |
303 | and is relocated when that string is relocated. */ | |
33b6c007 | 304 | const unsigned char *pc; |
7ca1e8b7 | 305 | |
7ca1e8b7 GM |
306 | /* The string containing the byte-code, and its current address. |
307 | Storing this here protects it from GC because mark_byte_stack | |
308 | marks it. */ | |
309 | Lisp_Object byte_string; | |
33b6c007 | 310 | const unsigned char *byte_string_start; |
7ca1e8b7 | 311 | |
99ec1647 | 312 | #if BYTE_MARK_STACK |
7ca1e8b7 GM |
313 | /* The vector of constants used during byte-code execution. Storing |
314 | this here protects it from GC because mark_byte_stack marks it. */ | |
315 | Lisp_Object constants; | |
99ec1647 | 316 | #endif |
7ca1e8b7 | 317 | }; |
36f7ba0a | 318 | \f |
99ec1647 | 319 | /* Fetch the next byte from the bytecode stream. */ |
36f7ba0a | 320 | |
9da43ddc SM |
321 | #ifdef BYTE_CODE_SAFE |
322 | #define FETCH (eassert (stack.byte_string_start == SDATA (stack.byte_string)), *stack.pc++) | |
323 | #else | |
7ca1e8b7 | 324 | #define FETCH *stack.pc++ |
9da43ddc | 325 | #endif |
36f7ba0a | 326 | |
4015b3c0 | 327 | /* Fetch two bytes from the bytecode stream and make a 16-bit number |
99ec1647 | 328 | out of them. */ |
36f7ba0a JB |
329 | |
330 | #define FETCH2 (op = FETCH, op + (FETCH << 8)) | |
331 | ||
4015b3c0 GM |
332 | /* Push x onto the execution stack. This used to be #define PUSH(x) |
333 | (*++stackp = (x)) This oddity is necessary because Alliant can't be | |
334 | bothered to compile the preincrement operator properly, as of 4/91. | |
335 | -JimB */ | |
7ca1e8b7 GM |
336 | |
337 | #define PUSH(x) (top++, *top = (x)) | |
36f7ba0a JB |
338 | |
339 | /* Pop a value off the execution stack. */ | |
340 | ||
7ca1e8b7 | 341 | #define POP (*top--) |
36f7ba0a JB |
342 | |
343 | /* Discard n values from the execution stack. */ | |
344 | ||
7ca1e8b7 GM |
345 | #define DISCARD(n) (top -= (n)) |
346 | ||
347 | /* Get the value which is at the top of the execution stack, but don't | |
99ec1647 | 348 | pop it. */ |
7ca1e8b7 GM |
349 | |
350 | #define TOP (*top) | |
36f7ba0a | 351 | |
4015b3c0 | 352 | /* Actions that must be performed before and after calling a function |
7ca1e8b7 | 353 | that might GC. */ |
36f7ba0a | 354 | |
b286858c SM |
355 | #define BEFORE_POTENTIAL_GC() ((void)0) |
356 | #define AFTER_POTENTIAL_GC() ((void)0) | |
36f7ba0a | 357 | |
14726871 RS |
358 | /* Garbage collect if we have consed enough since the last time. |
359 | We do this at every branch, to avoid loops that never GC. */ | |
360 | ||
765e61e3 DA |
361 | #define MAYBE_GC() \ |
362 | do { \ | |
363 | BEFORE_POTENTIAL_GC (); \ | |
364 | maybe_gc (); \ | |
365 | AFTER_POTENTIAL_GC (); \ | |
7914961c | 366 | } while (0) |
5e7ed093 | 367 | |
3d5fc37b | 368 | /* Check for jumping out of range. */ |
7ca1e8b7 GM |
369 | |
370 | #ifdef BYTE_CODE_SAFE | |
371 | ||
4015b3c0 | 372 | #define CHECK_RANGE(ARG) \ |
1088b922 | 373 | if (ARG >= bytestr_length) emacs_abort () |
3d5fc37b | 374 | |
4015b3c0 | 375 | #else /* not BYTE_CODE_SAFE */ |
7ca1e8b7 GM |
376 | |
377 | #define CHECK_RANGE(ARG) | |
378 | ||
4015b3c0 | 379 | #endif /* not BYTE_CODE_SAFE */ |
7ca1e8b7 | 380 | |
e12ea64e GM |
381 | /* A version of the QUIT macro which makes sure that the stack top is |
382 | set before signaling `quit'. */ | |
383 | ||
384 | #define BYTE_CODE_QUIT \ | |
385 | do { \ | |
386 | if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \ | |
387 | { \ | |
731475e7 | 388 | Lisp_Object flag = Vquit_flag; \ |
e12ea64e GM |
389 | Vquit_flag = Qnil; \ |
390 | BEFORE_POTENTIAL_GC (); \ | |
731475e7 | 391 | if (EQ (Vthrow_on_input, flag)) \ |
a8f0f551 | 392 | Fthrow (Vthrow_on_input, Qt); \ |
e12ea64e | 393 | Fsignal (Qquit, Qnil); \ |
892a8eb5 | 394 | AFTER_POTENTIAL_GC (); \ |
e12ea64e | 395 | } \ |
0caaedb1 PE |
396 | else if (pending_signals) \ |
397 | process_pending_signals (); \ | |
e12ea64e GM |
398 | } while (0) |
399 | ||
7ca1e8b7 | 400 | |
36f7ba0a | 401 | DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, |
39f624fa PJ |
402 | doc: /* Function used internally in byte-compiled code. |
403 | The first argument, BYTESTR, is a string of byte code; | |
404 | the second, VECTOR, a vector of constants; | |
405 | the third, MAXDEPTH, the maximum stack depth used in this function. | |
406 | If the third argument is incorrect, Emacs may crash. */) | |
5842a27b | 407 | (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth) |
b9598260 | 408 | { |
7200d79c | 409 | return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL); |
b9598260 SM |
410 | } |
411 | ||
adf2aa61 SM |
412 | static void |
413 | bcall0 (Lisp_Object f) | |
414 | { | |
415 | Ffuncall (1, &f); | |
416 | } | |
417 | ||
b9598260 SM |
418 | /* Execute the byte-code in BYTESTR. VECTOR is the constant vector, and |
419 | MAXDEPTH is the maximum stack depth used (if MAXDEPTH is incorrect, | |
420 | emacs may crash!). If ARGS_TEMPLATE is non-nil, it should be a lisp | |
421 | argument list (including &rest, &optional, etc.), and ARGS, of size | |
422 | NARGS, should be a vector of the actual arguments. The arguments in | |
423 | ARGS are pushed on the stack according to ARGS_TEMPLATE before | |
424 | executing BYTESTR. */ | |
425 | ||
f99f5844 | 426 | /* {{coccinelle:skip_start}} */ |
b9598260 | 427 | Lisp_Object |
0ee81a0c | 428 | exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, |
f66c7cf8 | 429 | Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) |
36f7ba0a | 430 | { |
d311d28c | 431 | ptrdiff_t count = SPECPDL_INDEX (); |
36f7ba0a | 432 | #ifdef BYTE_CODE_METER |
157fec2e | 433 | int volatile this_op = 0; |
36f7ba0a JB |
434 | int prev_op; |
435 | #endif | |
7ca1e8b7 | 436 | int op; |
4015b3c0 | 437 | /* Lisp_Object v1, v2; */ |
089b985f | 438 | Lisp_Object *vectorp; |
36f7ba0a | 439 | #ifdef BYTE_CODE_SAFE |
285d6d5d SM |
440 | ptrdiff_t const_length; |
441 | Lisp_Object *stacke; | |
442 | ptrdiff_t bytestr_length; | |
1be4d761 | 443 | #endif |
7ca1e8b7 GM |
444 | struct byte_stack stack; |
445 | Lisp_Object *top; | |
4015b3c0 | 446 | Lisp_Object result; |
adf2aa61 | 447 | enum handlertype type; |
36f7ba0a | 448 | |
603a0937 | 449 | #if 0 /* CHECK_FRAME_FONT */ |
ad7de7d7 GM |
450 | { |
451 | struct frame *f = SELECTED_FRAME (); | |
452 | if (FRAME_X_P (f) | |
453 | && FRAME_FONT (f)->direction != 0 | |
454 | && FRAME_FONT (f)->direction != 1) | |
1088b922 | 455 | emacs_abort (); |
ad7de7d7 GM |
456 | } |
457 | #endif | |
458 | ||
b7826503 | 459 | CHECK_STRING (bytestr); |
c616acb8 | 460 | CHECK_VECTOR (vector); |
f66c7cf8 | 461 | CHECK_NATNUM (maxdepth); |
36f7ba0a | 462 | |
0df1eac5 | 463 | #ifdef BYTE_CODE_SAFE |
77b37c05 | 464 | const_length = ASIZE (vector); |
0df1eac5 PE |
465 | #endif |
466 | ||
089b985f KH |
467 | if (STRING_MULTIBYTE (bytestr)) |
468 | /* BYTESTR must have been produced by Emacs 20.2 or the earlier | |
469 | because they produced a raw 8-bit string for byte-code and now | |
470 | such a byte-code string is loaded as multibyte while raw 8-bit | |
471 | characters converted to multibyte form. Thus, now we must | |
fbd98f82 | 472 | convert them back to the originally intended unibyte form. */ |
5274126b | 473 | bytestr = Fstring_as_unibyte (bytestr); |
089b985f | 474 | |
1be4d761 | 475 | #ifdef BYTE_CODE_SAFE |
d5db4077 | 476 | bytestr_length = SBYTES (bytestr); |
1be4d761 | 477 | #endif |
91f2d272 | 478 | vectorp = XVECTOR (vector)->contents; |
089b985f | 479 | |
7ca1e8b7 | 480 | stack.byte_string = bytestr; |
d5db4077 | 481 | stack.pc = stack.byte_string_start = SDATA (bytestr); |
99ec1647 | 482 | #if BYTE_MARK_STACK |
7ca1e8b7 | 483 | stack.constants = vector; |
99ec1647 | 484 | #endif |
663e2b3f | 485 | if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) |
39b5db3b | 486 | memory_full (SIZE_MAX); |
38182d90 | 487 | top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); |
36f7ba0a | 488 | |
7ca1e8b7 GM |
489 | #ifdef BYTE_CODE_SAFE |
490 | stacke = stack.bottom - 1 + XFASTINT (maxdepth); | |
491 | #endif | |
8e11578b | 492 | |
e2abe5a1 | 493 | if (INTEGERP (args_template)) |
b9598260 | 494 | { |
619e0f19 | 495 | ptrdiff_t at = XINT (args_template); |
2f221583 | 496 | bool rest = (at & 128) != 0; |
e2abe5a1 | 497 | int mandatory = at & 127; |
619e0f19 | 498 | ptrdiff_t nonrest = at >> 8; |
e2abe5a1 SM |
499 | eassert (mandatory <= nonrest); |
500 | if (nargs <= nonrest) | |
501 | { | |
619e0f19 | 502 | ptrdiff_t i; |
e2abe5a1 SM |
503 | for (i = 0 ; i < nargs; i++, args++) |
504 | PUSH (*args); | |
505 | if (nargs < mandatory) | |
506 | /* Too few arguments. */ | |
507 | Fsignal (Qwrong_number_of_arguments, | |
6c6f1994 | 508 | list2 (Fcons (make_number (mandatory), |
e2abe5a1 | 509 | rest ? Qand_rest : make_number (nonrest)), |
6c6f1994 | 510 | make_number (nargs))); |
e2abe5a1 SM |
511 | else |
512 | { | |
513 | for (; i < nonrest; i++) | |
514 | PUSH (Qnil); | |
515 | if (rest) | |
516 | PUSH (Qnil); | |
517 | } | |
518 | } | |
519 | else if (rest) | |
520 | { | |
f66c7cf8 | 521 | ptrdiff_t i; |
e2abe5a1 SM |
522 | for (i = 0 ; i < nonrest; i++, args++) |
523 | PUSH (*args); | |
524 | PUSH (Flist (nargs - nonrest, args)); | |
525 | } | |
526 | else | |
527 | /* Too many arguments. */ | |
b9598260 | 528 | Fsignal (Qwrong_number_of_arguments, |
6c6f1994 PE |
529 | list2 (Fcons (make_number (mandatory), make_number (nonrest)), |
530 | make_number (nargs))); | |
e2abe5a1 SM |
531 | } |
532 | else if (! NILP (args_template)) | |
533 | /* We should push some arguments on the stack. */ | |
534 | { | |
535 | error ("Unknown args template!"); | |
b9598260 SM |
536 | } |
537 | ||
36f7ba0a JB |
538 | while (1) |
539 | { | |
540 | #ifdef BYTE_CODE_SAFE | |
9e49c990 | 541 | if (top > stacke) |
1088b922 | 542 | emacs_abort (); |
7ca1e8b7 | 543 | else if (top < stack.bottom - 1) |
1088b922 | 544 | emacs_abort (); |
36f7ba0a JB |
545 | #endif |
546 | ||
36f7ba0a JB |
547 | #ifdef BYTE_CODE_METER |
548 | prev_op = this_op; | |
549 | this_op = op = FETCH; | |
550 | METER_CODE (prev_op, op); | |
36f7ba0a | 551 | #else |
3a4c8000 | 552 | #ifndef BYTE_CODE_THREADED |
4015b3c0 | 553 | op = FETCH; |
36f7ba0a | 554 | #endif |
3a4c8000 TT |
555 | #endif |
556 | ||
557 | /* The interpreter can be compiled one of two ways: as an | |
558 | ordinary switch-based interpreter, or as a threaded | |
559 | interpreter. The threaded interpreter relies on GCC's | |
560 | computed goto extension, so it is not available everywhere. | |
561 | Threading provides a performance boost. These macros are how | |
562 | we allow the code to be compiled both ways. */ | |
563 | #ifdef BYTE_CODE_THREADED | |
564 | /* The CASE macro introduces an instruction's body. It is | |
565 | either a label or a case label. */ | |
566 | #define CASE(OP) insn_ ## OP | |
567 | /* NEXT is invoked at the end of an instruction to go to the | |
568 | next instruction. It is either a computed goto, or a | |
569 | plain break. */ | |
570 | #define NEXT goto *(targets[op = FETCH]) | |
571 | /* FIRST is like NEXT, but is only used at the start of the | |
572 | interpreter body. In the switch-based interpreter it is the | |
573 | switch, so the threaded definition must include a semicolon. */ | |
574 | #define FIRST NEXT; | |
575 | /* Most cases are labeled with the CASE macro, above. | |
576 | CASE_DEFAULT is one exception; it is used if the interpreter | |
577 | being built requires a default case. The threaded | |
578 | interpreter does not, because the dispatch table is | |
579 | completely filled. */ | |
580 | #define CASE_DEFAULT | |
581 | /* This introduces an instruction that is known to call abort. */ | |
582 | #define CASE_ABORT CASE (Bstack_ref): CASE (default) | |
583 | #else | |
584 | /* See above for the meaning of the various defines. */ | |
585 | #define CASE(OP) case OP | |
586 | #define NEXT break | |
587 | #define FIRST switch (op) | |
588 | #define CASE_DEFAULT case 255: default: | |
589 | #define CASE_ABORT case 0 | |
590 | #endif | |
591 | ||
592 | #ifdef BYTE_CODE_THREADED | |
593 | ||
594 | /* A convenience define that saves us a lot of typing and makes | |
595 | the table clearer. */ | |
596 | #define LABEL(OP) [OP] = &&insn_ ## OP | |
36f7ba0a | 597 | |
31ff141c | 598 | #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) |
ffacb126 PE |
599 | # pragma GCC diagnostic push |
600 | # pragma GCC diagnostic ignored "-Woverride-init" | |
31ff141c PE |
601 | #elif defined __clang__ |
602 | # pragma GCC diagnostic push | |
603 | # pragma GCC diagnostic ignored "-Winitializer-overrides" | |
ffacb126 PE |
604 | #endif |
605 | ||
3a4c8000 TT |
606 | /* This is the dispatch table for the threaded interpreter. */ |
607 | static const void *const targets[256] = | |
4015b3c0 | 608 | { |
3a4c8000 TT |
609 | [0 ... (Bconstant - 1)] = &&insn_default, |
610 | [Bconstant ... 255] = &&insn_Bconstant, | |
611 | ||
612 | #define DEFINE(name, value) LABEL (name) , | |
613 | BYTE_CODES | |
614 | #undef DEFINE | |
615 | }; | |
ffacb126 | 616 | |
31ff141c | 617 | #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__ |
ffacb126 PE |
618 | # pragma GCC diagnostic pop |
619 | #endif | |
620 | ||
3a4c8000 TT |
621 | #endif |
622 | ||
623 | ||
624 | FIRST | |
625 | { | |
626 | CASE (Bvarref7): | |
36f7ba0a JB |
627 | op = FETCH2; |
628 | goto varref; | |
629 | ||
3a4c8000 TT |
630 | CASE (Bvarref): |
631 | CASE (Bvarref1): | |
632 | CASE (Bvarref2): | |
633 | CASE (Bvarref3): | |
634 | CASE (Bvarref4): | |
635 | CASE (Bvarref5): | |
36f7ba0a | 636 | op = op - Bvarref; |
4015b3c0 GM |
637 | goto varref; |
638 | ||
639 | /* This seems to be the most frequently executed byte-code | |
640 | among the Bvarref's, so avoid a goto here. */ | |
3a4c8000 | 641 | CASE (Bvarref6): |
4015b3c0 | 642 | op = FETCH; |
36f7ba0a | 643 | varref: |
4015b3c0 GM |
644 | { |
645 | Lisp_Object v1, v2; | |
646 | ||
647 | v1 = vectorp[op]; | |
648 | if (SYMBOLP (v1)) | |
649 | { | |
844e0de1 | 650 | if (SYMBOL_REDIRECT (XSYMBOL (v1)) != SYMBOL_PLAINVAL |
ce5b453a SM |
651 | || (v2 = SYMBOL_VAL (XSYMBOL (v1)), |
652 | EQ (v2, Qunbound))) | |
bf1de43e GM |
653 | { |
654 | BEFORE_POTENTIAL_GC (); | |
655 | v2 = Fsymbol_value (v1); | |
656 | AFTER_POTENTIAL_GC (); | |
657 | } | |
4015b3c0 GM |
658 | } |
659 | else | |
bf1de43e GM |
660 | { |
661 | BEFORE_POTENTIAL_GC (); | |
662 | v2 = Fsymbol_value (v1); | |
663 | AFTER_POTENTIAL_GC (); | |
664 | } | |
4015b3c0 | 665 | PUSH (v2); |
3a4c8000 | 666 | NEXT; |
4015b3c0 GM |
667 | } |
668 | ||
3a4c8000 | 669 | CASE (Bgotoifnil): |
21ed6de3 KR |
670 | { |
671 | Lisp_Object v1; | |
672 | MAYBE_GC (); | |
673 | op = FETCH2; | |
674 | v1 = POP; | |
675 | if (NILP (v1)) | |
676 | { | |
677 | BYTE_CODE_QUIT; | |
678 | CHECK_RANGE (op); | |
679 | stack.pc = stack.byte_string_start + op; | |
680 | } | |
3a4c8000 | 681 | NEXT; |
21ed6de3 | 682 | } |
36f7ba0a | 683 | |
3a4c8000 | 684 | CASE (Bcar): |
4015b3c0 GM |
685 | { |
686 | Lisp_Object v1; | |
687 | v1 = TOP; | |
1c470562 SM |
688 | if (CONSP (v1)) |
689 | TOP = XCAR (v1); | |
690 | else if (NILP (v1)) | |
691 | TOP = Qnil; | |
692 | else | |
693 | { | |
694 | BEFORE_POTENTIAL_GC (); | |
695 | wrong_type_argument (Qlistp, v1); | |
1c470562 | 696 | } |
3a4c8000 | 697 | NEXT; |
4015b3c0 GM |
698 | } |
699 | ||
3a4c8000 | 700 | CASE (Beq): |
4015b3c0 GM |
701 | { |
702 | Lisp_Object v1; | |
703 | v1 = POP; | |
704 | TOP = EQ (v1, TOP) ? Qt : Qnil; | |
3a4c8000 | 705 | NEXT; |
4015b3c0 GM |
706 | } |
707 | ||
3a4c8000 | 708 | CASE (Bmemq): |
4015b3c0 GM |
709 | { |
710 | Lisp_Object v1; | |
bf1de43e | 711 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
712 | v1 = POP; |
713 | TOP = Fmemq (TOP, v1); | |
bf1de43e | 714 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 715 | NEXT; |
4015b3c0 GM |
716 | } |
717 | ||
3a4c8000 | 718 | CASE (Bcdr): |
4015b3c0 GM |
719 | { |
720 | Lisp_Object v1; | |
721 | v1 = TOP; | |
1c470562 SM |
722 | if (CONSP (v1)) |
723 | TOP = XCDR (v1); | |
724 | else if (NILP (v1)) | |
725 | TOP = Qnil; | |
726 | else | |
727 | { | |
728 | BEFORE_POTENTIAL_GC (); | |
729 | wrong_type_argument (Qlistp, v1); | |
1c470562 | 730 | } |
3a4c8000 | 731 | NEXT; |
4015b3c0 | 732 | } |
36f7ba0a | 733 | |
3a4c8000 TT |
734 | CASE (Bvarset): |
735 | CASE (Bvarset1): | |
736 | CASE (Bvarset2): | |
737 | CASE (Bvarset3): | |
738 | CASE (Bvarset4): | |
739 | CASE (Bvarset5): | |
620cc5fa | 740 | op -= Bvarset; |
36f7ba0a JB |
741 | goto varset; |
742 | ||
3a4c8000 | 743 | CASE (Bvarset7): |
620cc5fa | 744 | op = FETCH2; |
4015b3c0 GM |
745 | goto varset; |
746 | ||
3a4c8000 | 747 | CASE (Bvarset6): |
4015b3c0 | 748 | op = FETCH; |
36f7ba0a | 749 | varset: |
620cc5fa GM |
750 | { |
751 | Lisp_Object sym, val; | |
8e11578b | 752 | |
620cc5fa | 753 | sym = vectorp[op]; |
bf1de43e | 754 | val = TOP; |
620cc5fa GM |
755 | |
756 | /* Inline the most common case. */ | |
757 | if (SYMBOLP (sym) | |
758 | && !EQ (val, Qunbound) | |
844e0de1 | 759 | && !SYMBOL_REDIRECT (XSYMBOL (sym)) |
ce5b453a | 760 | && !SYMBOL_CONSTANT_P (sym)) |
c644523b | 761 | SET_SYMBOL_VAL (XSYMBOL (sym), val); |
620cc5fa | 762 | else |
bf1de43e GM |
763 | { |
764 | BEFORE_POTENTIAL_GC (); | |
94b612ad | 765 | set_internal (sym, val, Qnil, 0); |
bf1de43e GM |
766 | AFTER_POTENTIAL_GC (); |
767 | } | |
620cc5fa | 768 | } |
3789dcdf | 769 | (void) POP; |
3a4c8000 | 770 | NEXT; |
36f7ba0a | 771 | |
3a4c8000 | 772 | CASE (Bdup): |
4015b3c0 GM |
773 | { |
774 | Lisp_Object v1; | |
775 | v1 = TOP; | |
776 | PUSH (v1); | |
3a4c8000 | 777 | NEXT; |
4015b3c0 GM |
778 | } |
779 | ||
780 | /* ------------------ */ | |
781 | ||
3a4c8000 | 782 | CASE (Bvarbind6): |
36f7ba0a JB |
783 | op = FETCH; |
784 | goto varbind; | |
785 | ||
3a4c8000 | 786 | CASE (Bvarbind7): |
36f7ba0a JB |
787 | op = FETCH2; |
788 | goto varbind; | |
789 | ||
3a4c8000 TT |
790 | CASE (Bvarbind): |
791 | CASE (Bvarbind1): | |
792 | CASE (Bvarbind2): | |
793 | CASE (Bvarbind3): | |
794 | CASE (Bvarbind4): | |
795 | CASE (Bvarbind5): | |
36f7ba0a JB |
796 | op -= Bvarbind; |
797 | varbind: | |
56b8eef5 GM |
798 | /* Specbind can signal and thus GC. */ |
799 | BEFORE_POTENTIAL_GC (); | |
9f62b5dd | 800 | dynwind_begin (); |
36f7ba0a | 801 | specbind (vectorp[op], POP); |
56b8eef5 | 802 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 803 | NEXT; |
36f7ba0a | 804 | |
3a4c8000 | 805 | CASE (Bcall6): |
36f7ba0a JB |
806 | op = FETCH; |
807 | goto docall; | |
808 | ||
3a4c8000 | 809 | CASE (Bcall7): |
36f7ba0a JB |
810 | op = FETCH2; |
811 | goto docall; | |
812 | ||
3a4c8000 TT |
813 | CASE (Bcall): |
814 | CASE (Bcall1): | |
815 | CASE (Bcall2): | |
816 | CASE (Bcall3): | |
817 | CASE (Bcall4): | |
818 | CASE (Bcall5): | |
36f7ba0a JB |
819 | op -= Bcall; |
820 | docall: | |
4015b3c0 | 821 | { |
fa9aabf6 | 822 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 823 | DISCARD (op); |
63639d44 | 824 | #ifdef BYTE_CODE_METER |
4015b3c0 GM |
825 | if (byte_metering_on && SYMBOLP (TOP)) |
826 | { | |
827 | Lisp_Object v1, v2; | |
828 | ||
829 | v1 = TOP; | |
830 | v2 = Fget (v1, Qbyte_code_meter); | |
831 | if (INTEGERP (v2) | |
f28e6371 | 832 | && XINT (v2) < MOST_POSITIVE_FIXNUM) |
4015b3c0 GM |
833 | { |
834 | XSETINT (v2, XINT (v2) + 1); | |
835 | Fput (v1, Qbyte_code_meter, v2); | |
836 | } | |
837 | } | |
63639d44 | 838 | #endif |
4015b3c0 GM |
839 | TOP = Ffuncall (op + 1, &TOP); |
840 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 841 | NEXT; |
4015b3c0 | 842 | } |
36f7ba0a | 843 | |
3a4c8000 | 844 | CASE (Bunbind6): |
36f7ba0a JB |
845 | op = FETCH; |
846 | goto dounbind; | |
847 | ||
3a4c8000 | 848 | CASE (Bunbind7): |
36f7ba0a JB |
849 | op = FETCH2; |
850 | goto dounbind; | |
851 | ||
3a4c8000 TT |
852 | CASE (Bunbind): |
853 | CASE (Bunbind1): | |
854 | CASE (Bunbind2): | |
855 | CASE (Bunbind3): | |
856 | CASE (Bunbind4): | |
857 | CASE (Bunbind5): | |
36f7ba0a JB |
858 | op -= Bunbind; |
859 | dounbind: | |
7ca1e8b7 | 860 | BEFORE_POTENTIAL_GC (); |
9f62b5dd BT |
861 | for (int i = 0; i < op; i++) |
862 | dynwind_end (); | |
7ca1e8b7 | 863 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 864 | NEXT; |
36f7ba0a | 865 | |
3a4c8000 | 866 | CASE (Bunbind_all): /* Obsolete. Never used. */ |
9f62b5dd | 867 | emacs_abort (); |
3a4c8000 | 868 | NEXT; |
36f7ba0a | 869 | |
3a4c8000 | 870 | CASE (Bgoto): |
14726871 | 871 | MAYBE_GC (); |
e12ea64e | 872 | BYTE_CODE_QUIT; |
36f7ba0a | 873 | op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ |
3d5fc37b | 874 | CHECK_RANGE (op); |
7ca1e8b7 | 875 | stack.pc = stack.byte_string_start + op; |
3a4c8000 | 876 | NEXT; |
36f7ba0a | 877 | |
3a4c8000 | 878 | CASE (Bgotoifnonnil): |
21ed6de3 KR |
879 | { |
880 | Lisp_Object v1; | |
881 | MAYBE_GC (); | |
882 | op = FETCH2; | |
883 | v1 = POP; | |
884 | if (!NILP (v1)) | |
885 | { | |
886 | BYTE_CODE_QUIT; | |
887 | CHECK_RANGE (op); | |
888 | stack.pc = stack.byte_string_start + op; | |
889 | } | |
3a4c8000 | 890 | NEXT; |
21ed6de3 | 891 | } |
36f7ba0a | 892 | |
3a4c8000 | 893 | CASE (Bgotoifnilelsepop): |
14726871 | 894 | MAYBE_GC (); |
36f7ba0a | 895 | op = FETCH2; |
921a8935 | 896 | if (NILP (TOP)) |
36f7ba0a | 897 | { |
e12ea64e | 898 | BYTE_CODE_QUIT; |
3d5fc37b | 899 | CHECK_RANGE (op); |
7ca1e8b7 | 900 | stack.pc = stack.byte_string_start + op; |
36f7ba0a | 901 | } |
63639d44 | 902 | else DISCARD (1); |
3a4c8000 | 903 | NEXT; |
36f7ba0a | 904 | |
3a4c8000 | 905 | CASE (Bgotoifnonnilelsepop): |
14726871 | 906 | MAYBE_GC (); |
36f7ba0a | 907 | op = FETCH2; |
921a8935 | 908 | if (!NILP (TOP)) |
36f7ba0a | 909 | { |
e12ea64e | 910 | BYTE_CODE_QUIT; |
3d5fc37b | 911 | CHECK_RANGE (op); |
7ca1e8b7 | 912 | stack.pc = stack.byte_string_start + op; |
36f7ba0a | 913 | } |
63639d44 | 914 | else DISCARD (1); |
3a4c8000 | 915 | NEXT; |
63639d44 | 916 | |
3a4c8000 | 917 | CASE (BRgoto): |
14726871 | 918 | MAYBE_GC (); |
e12ea64e | 919 | BYTE_CODE_QUIT; |
7ca1e8b7 | 920 | stack.pc += (int) *stack.pc - 127; |
3a4c8000 | 921 | NEXT; |
63639d44 | 922 | |
3a4c8000 | 923 | CASE (BRgotoifnil): |
21ed6de3 KR |
924 | { |
925 | Lisp_Object v1; | |
926 | MAYBE_GC (); | |
927 | v1 = POP; | |
928 | if (NILP (v1)) | |
929 | { | |
930 | BYTE_CODE_QUIT; | |
931 | stack.pc += (int) *stack.pc - 128; | |
932 | } | |
933 | stack.pc++; | |
3a4c8000 | 934 | NEXT; |
21ed6de3 | 935 | } |
63639d44 | 936 | |
3a4c8000 | 937 | CASE (BRgotoifnonnil): |
21ed6de3 KR |
938 | { |
939 | Lisp_Object v1; | |
940 | MAYBE_GC (); | |
941 | v1 = POP; | |
942 | if (!NILP (v1)) | |
943 | { | |
944 | BYTE_CODE_QUIT; | |
945 | stack.pc += (int) *stack.pc - 128; | |
946 | } | |
947 | stack.pc++; | |
3a4c8000 | 948 | NEXT; |
21ed6de3 | 949 | } |
63639d44 | 950 | |
3a4c8000 | 951 | CASE (BRgotoifnilelsepop): |
14726871 | 952 | MAYBE_GC (); |
7ca1e8b7 | 953 | op = *stack.pc++; |
63639d44 JB |
954 | if (NILP (TOP)) |
955 | { | |
e12ea64e | 956 | BYTE_CODE_QUIT; |
7ca1e8b7 | 957 | stack.pc += op - 128; |
63639d44 JB |
958 | } |
959 | else DISCARD (1); | |
3a4c8000 | 960 | NEXT; |
63639d44 | 961 | |
3a4c8000 | 962 | CASE (BRgotoifnonnilelsepop): |
14726871 | 963 | MAYBE_GC (); |
7ca1e8b7 | 964 | op = *stack.pc++; |
63639d44 JB |
965 | if (!NILP (TOP)) |
966 | { | |
e12ea64e | 967 | BYTE_CODE_QUIT; |
7ca1e8b7 | 968 | stack.pc += op - 128; |
63639d44 JB |
969 | } |
970 | else DISCARD (1); | |
3a4c8000 | 971 | NEXT; |
98bf0c8d | 972 | |
3a4c8000 | 973 | CASE (Breturn): |
4015b3c0 | 974 | result = POP; |
36f7ba0a JB |
975 | goto exit; |
976 | ||
3a4c8000 | 977 | CASE (Bdiscard): |
63639d44 | 978 | DISCARD (1); |
3a4c8000 | 979 | NEXT; |
36f7ba0a | 980 | |
3a4c8000 | 981 | CASE (Bconstant2): |
36f7ba0a | 982 | PUSH (vectorp[FETCH2]); |
3a4c8000 | 983 | NEXT; |
36f7ba0a | 984 | |
3a4c8000 | 985 | CASE (Bsave_excursion): |
9f62b5dd | 986 | dynwind_begin (); |
fa9aabf6 GM |
987 | record_unwind_protect (save_excursion_restore, |
988 | save_excursion_save ()); | |
3a4c8000 | 989 | NEXT; |
36f7ba0a | 990 | |
3a4c8000 TT |
991 | CASE (Bsave_current_buffer): /* Obsolete since ??. */ |
992 | CASE (Bsave_current_buffer_1): | |
9f62b5dd | 993 | dynwind_begin (); |
66322887 | 994 | record_unwind_current_buffer (); |
3a4c8000 | 995 | NEXT; |
3b841abc | 996 | |
3a4c8000 | 997 | CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ |
e0f57e65 | 998 | { |
9f62b5dd | 999 | dynwind_begin (); |
27e498e6 | 1000 | record_unwind_protect (restore_window_configuration, |
e0f57e65 SM |
1001 | Fcurrent_window_configuration (Qnil)); |
1002 | BEFORE_POTENTIAL_GC (); | |
1003 | TOP = Fprogn (TOP); | |
9f62b5dd | 1004 | dynwind_end (); |
e0f57e65 | 1005 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1006 | NEXT; |
e0f57e65 | 1007 | } |
36f7ba0a | 1008 | |
3a4c8000 | 1009 | CASE (Bsave_restriction): |
9f62b5dd | 1010 | dynwind_begin (); |
fa9aabf6 GM |
1011 | record_unwind_protect (save_restriction_restore, |
1012 | save_restriction_save ()); | |
3a4c8000 | 1013 | NEXT; |
36f7ba0a | 1014 | |
adf2aa61 | 1015 | CASE (Bcatch): /* Obsolete since 24.4. */ |
4015b3c0 GM |
1016 | { |
1017 | Lisp_Object v1; | |
4015b3c0 | 1018 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1019 | v1 = POP; |
ca105506 | 1020 | TOP = internal_catch (TOP, eval_sub, v1); |
4015b3c0 | 1021 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1022 | NEXT; |
4015b3c0 | 1023 | } |
36f7ba0a | 1024 | |
adf2aa61 | 1025 | CASE (Bpushcatch): /* New in 24.4. */ |
0c72d233 RT |
1026 | emacs_abort (); |
1027 | NEXT; | |
157fec2e | 1028 | |
0c72d233 RT |
1029 | CASE (Bpushconditioncase): /* New in 24.4. */ |
1030 | emacs_abort (); | |
1031 | NEXT; | |
adf2aa61 SM |
1032 | |
1033 | CASE (Bpophandler): /* New in 24.4. */ | |
0c72d233 RT |
1034 | emacs_abort (); |
1035 | NEXT; | |
adf2aa61 | 1036 | |
3a4c8000 | 1037 | CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */ |
adf2aa61 SM |
1038 | { |
1039 | Lisp_Object handler = POP; | |
9f62b5dd | 1040 | dynwind_begin (); |
adf2aa61 SM |
1041 | /* Support for a function here is new in 24.4. */ |
1042 | record_unwind_protect (NILP (Ffunctionp (handler)) | |
1043 | ? unwind_body : bcall0, | |
1044 | handler); | |
1045 | NEXT; | |
1046 | } | |
36f7ba0a | 1047 | |
adf2aa61 | 1048 | CASE (Bcondition_case): /* Obsolete since 24.4. */ |
4015b3c0 | 1049 | { |
5c125a13 RS |
1050 | Lisp_Object handlers, body; |
1051 | handlers = POP; | |
1052 | body = POP; | |
4015b3c0 | 1053 | BEFORE_POTENTIAL_GC (); |
5c125a13 | 1054 | TOP = internal_lisp_condition_case (TOP, body, handlers); |
4015b3c0 | 1055 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1056 | NEXT; |
4015b3c0 | 1057 | } |
36f7ba0a | 1058 | |
3a4c8000 | 1059 | CASE (Btemp_output_buffer_setup): /* Obsolete since 24.1. */ |
4015b3c0 | 1060 | BEFORE_POTENTIAL_GC (); |
b7826503 | 1061 | CHECK_STRING (TOP); |
9f62b5dd | 1062 | dynwind_begin (); |
42a5b22f | 1063 | temp_output_buffer_setup (SSDATA (TOP)); |
4015b3c0 | 1064 | AFTER_POTENTIAL_GC (); |
36f7ba0a | 1065 | TOP = Vstandard_output; |
3a4c8000 | 1066 | NEXT; |
36f7ba0a | 1067 | |
3a4c8000 | 1068 | CASE (Btemp_output_buffer_show): /* Obsolete since 24.1. */ |
4015b3c0 GM |
1069 | { |
1070 | Lisp_Object v1; | |
4015b3c0 | 1071 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1072 | v1 = POP; |
4015b3c0 GM |
1073 | temp_output_buffer_show (TOP); |
1074 | TOP = v1; | |
1075 | /* pop binding of standard-output */ | |
9f62b5dd | 1076 | dynwind_end (); |
4015b3c0 | 1077 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1078 | NEXT; |
4015b3c0 | 1079 | } |
36f7ba0a | 1080 | |
3a4c8000 | 1081 | CASE (Bnth): |
4015b3c0 GM |
1082 | { |
1083 | Lisp_Object v1, v2; | |
d311d28c | 1084 | EMACS_INT n; |
bf1de43e | 1085 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1086 | v1 = POP; |
1087 | v2 = TOP; | |
b7826503 | 1088 | CHECK_NUMBER (v2); |
d311d28c | 1089 | n = XINT (v2); |
4015b3c0 | 1090 | immediate_quit = 1; |
d311d28c | 1091 | while (--n >= 0 && CONSP (v1)) |
14c5155a | 1092 | v1 = XCDR (v1); |
4015b3c0 | 1093 | immediate_quit = 0; |
14c5155a | 1094 | TOP = CAR (v1); |
1c470562 | 1095 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1096 | NEXT; |
4015b3c0 | 1097 | } |
36f7ba0a | 1098 | |
3a4c8000 | 1099 | CASE (Bsymbolp): |
617bd3f6 | 1100 | TOP = SYMBOLP (TOP) ? Qt : Qnil; |
3a4c8000 | 1101 | NEXT; |
36f7ba0a | 1102 | |
3a4c8000 | 1103 | CASE (Bconsp): |
36f7ba0a | 1104 | TOP = CONSP (TOP) ? Qt : Qnil; |
3a4c8000 | 1105 | NEXT; |
36f7ba0a | 1106 | |
3a4c8000 | 1107 | CASE (Bstringp): |
617bd3f6 | 1108 | TOP = STRINGP (TOP) ? Qt : Qnil; |
3a4c8000 | 1109 | NEXT; |
36f7ba0a | 1110 | |
3a4c8000 | 1111 | CASE (Blistp): |
921a8935 | 1112 | TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil; |
3a4c8000 | 1113 | NEXT; |
36f7ba0a | 1114 | |
3a4c8000 | 1115 | CASE (Bnot): |
921a8935 | 1116 | TOP = NILP (TOP) ? Qt : Qnil; |
3a4c8000 | 1117 | NEXT; |
36f7ba0a | 1118 | |
3a4c8000 | 1119 | CASE (Bcons): |
4015b3c0 GM |
1120 | { |
1121 | Lisp_Object v1; | |
1122 | v1 = POP; | |
1123 | TOP = Fcons (TOP, v1); | |
3a4c8000 | 1124 | NEXT; |
4015b3c0 | 1125 | } |
36f7ba0a | 1126 | |
3a4c8000 | 1127 | CASE (Blist1): |
6c6f1994 | 1128 | TOP = list1 (TOP); |
3a4c8000 | 1129 | NEXT; |
36f7ba0a | 1130 | |
3a4c8000 | 1131 | CASE (Blist2): |
4015b3c0 GM |
1132 | { |
1133 | Lisp_Object v1; | |
1134 | v1 = POP; | |
6c6f1994 | 1135 | TOP = list2 (TOP, v1); |
3a4c8000 | 1136 | NEXT; |
4015b3c0 | 1137 | } |
36f7ba0a | 1138 | |
3a4c8000 | 1139 | CASE (Blist3): |
63639d44 | 1140 | DISCARD (2); |
36f7ba0a | 1141 | TOP = Flist (3, &TOP); |
3a4c8000 | 1142 | NEXT; |
36f7ba0a | 1143 | |
3a4c8000 | 1144 | CASE (Blist4): |
63639d44 | 1145 | DISCARD (3); |
36f7ba0a | 1146 | TOP = Flist (4, &TOP); |
3a4c8000 | 1147 | NEXT; |
36f7ba0a | 1148 | |
3a4c8000 | 1149 | CASE (BlistN): |
63639d44 JB |
1150 | op = FETCH; |
1151 | DISCARD (op - 1); | |
1152 | TOP = Flist (op, &TOP); | |
3a4c8000 | 1153 | NEXT; |
63639d44 | 1154 | |
3a4c8000 | 1155 | CASE (Blength): |
bf1de43e | 1156 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1157 | TOP = Flength (TOP); |
bf1de43e | 1158 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1159 | NEXT; |
36f7ba0a | 1160 | |
3a4c8000 | 1161 | CASE (Baref): |
4015b3c0 GM |
1162 | { |
1163 | Lisp_Object v1; | |
bf1de43e | 1164 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1165 | v1 = POP; |
1166 | TOP = Faref (TOP, v1); | |
bf1de43e | 1167 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1168 | NEXT; |
4015b3c0 | 1169 | } |
36f7ba0a | 1170 | |
3a4c8000 | 1171 | CASE (Baset): |
4015b3c0 GM |
1172 | { |
1173 | Lisp_Object v1, v2; | |
bf1de43e | 1174 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1175 | v2 = POP; v1 = POP; |
1176 | TOP = Faset (TOP, v1, v2); | |
bf1de43e | 1177 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1178 | NEXT; |
4015b3c0 | 1179 | } |
36f7ba0a | 1180 | |
3a4c8000 | 1181 | CASE (Bsymbol_value): |
bf1de43e | 1182 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1183 | TOP = Fsymbol_value (TOP); |
bf1de43e | 1184 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1185 | NEXT; |
36f7ba0a | 1186 | |
3a4c8000 | 1187 | CASE (Bsymbol_function): |
bf1de43e | 1188 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1189 | TOP = Fsymbol_function (TOP); |
bf1de43e | 1190 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1191 | NEXT; |
36f7ba0a | 1192 | |
3a4c8000 | 1193 | CASE (Bset): |
4015b3c0 GM |
1194 | { |
1195 | Lisp_Object v1; | |
bf1de43e | 1196 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1197 | v1 = POP; |
1198 | TOP = Fset (TOP, v1); | |
bf1de43e | 1199 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1200 | NEXT; |
4015b3c0 | 1201 | } |
36f7ba0a | 1202 | |
3a4c8000 | 1203 | CASE (Bfset): |
4015b3c0 GM |
1204 | { |
1205 | Lisp_Object v1; | |
bf1de43e | 1206 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1207 | v1 = POP; |
1208 | TOP = Ffset (TOP, v1); | |
bf1de43e | 1209 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1210 | NEXT; |
4015b3c0 | 1211 | } |
36f7ba0a | 1212 | |
3a4c8000 | 1213 | CASE (Bget): |
4015b3c0 GM |
1214 | { |
1215 | Lisp_Object v1; | |
bf1de43e | 1216 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1217 | v1 = POP; |
1218 | TOP = Fget (TOP, v1); | |
bf1de43e | 1219 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1220 | NEXT; |
4015b3c0 | 1221 | } |
36f7ba0a | 1222 | |
3a4c8000 | 1223 | CASE (Bsubstring): |
4015b3c0 GM |
1224 | { |
1225 | Lisp_Object v1, v2; | |
fa9aabf6 | 1226 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1227 | v2 = POP; v1 = POP; |
4015b3c0 | 1228 | TOP = Fsubstring (TOP, v1, v2); |
fa9aabf6 | 1229 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1230 | NEXT; |
4015b3c0 | 1231 | } |
36f7ba0a | 1232 | |
3a4c8000 | 1233 | CASE (Bconcat2): |
bf1de43e | 1234 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1235 | DISCARD (1); |
36f7ba0a | 1236 | TOP = Fconcat (2, &TOP); |
bf1de43e | 1237 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1238 | NEXT; |
36f7ba0a | 1239 | |
3a4c8000 | 1240 | CASE (Bconcat3): |
bf1de43e | 1241 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1242 | DISCARD (2); |
36f7ba0a | 1243 | TOP = Fconcat (3, &TOP); |
bf1de43e | 1244 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1245 | NEXT; |
36f7ba0a | 1246 | |
3a4c8000 | 1247 | CASE (Bconcat4): |
bf1de43e | 1248 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1249 | DISCARD (3); |
36f7ba0a | 1250 | TOP = Fconcat (4, &TOP); |
bf1de43e | 1251 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1252 | NEXT; |
36f7ba0a | 1253 | |
3a4c8000 | 1254 | CASE (BconcatN): |
63639d44 | 1255 | op = FETCH; |
bf1de43e | 1256 | BEFORE_POTENTIAL_GC (); |
63639d44 JB |
1257 | DISCARD (op - 1); |
1258 | TOP = Fconcat (op, &TOP); | |
bf1de43e | 1259 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1260 | NEXT; |
63639d44 | 1261 | |
3a4c8000 | 1262 | CASE (Bsub1): |
4015b3c0 GM |
1263 | { |
1264 | Lisp_Object v1; | |
1265 | v1 = TOP; | |
1266 | if (INTEGERP (v1)) | |
1267 | { | |
1268 | XSETINT (v1, XINT (v1) - 1); | |
1269 | TOP = v1; | |
1270 | } | |
1271 | else | |
e494eee5 MB |
1272 | { |
1273 | BEFORE_POTENTIAL_GC (); | |
1274 | TOP = Fsub1 (v1); | |
1275 | AFTER_POTENTIAL_GC (); | |
1276 | } | |
3a4c8000 | 1277 | NEXT; |
4015b3c0 | 1278 | } |
36f7ba0a | 1279 | |
3a4c8000 | 1280 | CASE (Badd1): |
4015b3c0 GM |
1281 | { |
1282 | Lisp_Object v1; | |
1283 | v1 = TOP; | |
1284 | if (INTEGERP (v1)) | |
1285 | { | |
1286 | XSETINT (v1, XINT (v1) + 1); | |
1287 | TOP = v1; | |
1288 | } | |
1289 | else | |
bf1de43e GM |
1290 | { |
1291 | BEFORE_POTENTIAL_GC (); | |
1292 | TOP = Fadd1 (v1); | |
1293 | AFTER_POTENTIAL_GC (); | |
1294 | } | |
3a4c8000 | 1295 | NEXT; |
4015b3c0 | 1296 | } |
36f7ba0a | 1297 | |
3a4c8000 | 1298 | CASE (Beqlsign): |
4015b3c0 GM |
1299 | { |
1300 | Lisp_Object v1, v2; | |
f5941bf8 | 1301 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1302 | v2 = POP; v1 = TOP; |
b7826503 PJ |
1303 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1); |
1304 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2); | |
f5941bf8 | 1305 | AFTER_POTENTIAL_GC (); |
4015b3c0 GM |
1306 | if (FLOATP (v1) || FLOATP (v2)) |
1307 | { | |
1308 | double f1, f2; | |
1309 | ||
1310 | f1 = (FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1)); | |
1311 | f2 = (FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2)); | |
1312 | TOP = (f1 == f2 ? Qt : Qnil); | |
1313 | } | |
1314 | else | |
4015b3c0 | 1315 | TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil); |
3a4c8000 | 1316 | NEXT; |
4015b3c0 | 1317 | } |
36f7ba0a | 1318 | |
3a4c8000 | 1319 | CASE (Bgtr): |
4015b3c0 GM |
1320 | { |
1321 | Lisp_Object v1; | |
bf1de43e | 1322 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1323 | v1 = POP; |
ebb99847 | 1324 | TOP = arithcompare (TOP, v1, ARITH_GRTR); |
bf1de43e | 1325 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1326 | NEXT; |
4015b3c0 | 1327 | } |
36f7ba0a | 1328 | |
3a4c8000 | 1329 | CASE (Blss): |
4015b3c0 GM |
1330 | { |
1331 | Lisp_Object v1; | |
bf1de43e | 1332 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1333 | v1 = POP; |
ebb99847 | 1334 | TOP = arithcompare (TOP, v1, ARITH_LESS); |
bf1de43e | 1335 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1336 | NEXT; |
4015b3c0 | 1337 | } |
36f7ba0a | 1338 | |
3a4c8000 | 1339 | CASE (Bleq): |
4015b3c0 GM |
1340 | { |
1341 | Lisp_Object v1; | |
bf1de43e | 1342 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1343 | v1 = POP; |
ebb99847 | 1344 | TOP = arithcompare (TOP, v1, ARITH_LESS_OR_EQUAL); |
bf1de43e | 1345 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1346 | NEXT; |
4015b3c0 | 1347 | } |
36f7ba0a | 1348 | |
3a4c8000 | 1349 | CASE (Bgeq): |
4015b3c0 GM |
1350 | { |
1351 | Lisp_Object v1; | |
d9c1f6f9 | 1352 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1353 | v1 = POP; |
ebb99847 | 1354 | TOP = arithcompare (TOP, v1, ARITH_GRTR_OR_EQUAL); |
d9c1f6f9 | 1355 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1356 | NEXT; |
4015b3c0 | 1357 | } |
36f7ba0a | 1358 | |
3a4c8000 | 1359 | CASE (Bdiff): |
bf1de43e | 1360 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1361 | DISCARD (1); |
36f7ba0a | 1362 | TOP = Fminus (2, &TOP); |
bf1de43e | 1363 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1364 | NEXT; |
36f7ba0a | 1365 | |
3a4c8000 | 1366 | CASE (Bnegate): |
4015b3c0 GM |
1367 | { |
1368 | Lisp_Object v1; | |
1369 | v1 = TOP; | |
1370 | if (INTEGERP (v1)) | |
1371 | { | |
1372 | XSETINT (v1, - XINT (v1)); | |
1373 | TOP = v1; | |
1374 | } | |
1375 | else | |
bf1de43e GM |
1376 | { |
1377 | BEFORE_POTENTIAL_GC (); | |
1378 | TOP = Fminus (1, &TOP); | |
1379 | AFTER_POTENTIAL_GC (); | |
1380 | } | |
3a4c8000 | 1381 | NEXT; |
4015b3c0 | 1382 | } |
36f7ba0a | 1383 | |
3a4c8000 | 1384 | CASE (Bplus): |
bf1de43e | 1385 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1386 | DISCARD (1); |
36f7ba0a | 1387 | TOP = Fplus (2, &TOP); |
bf1de43e | 1388 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1389 | NEXT; |
36f7ba0a | 1390 | |
3a4c8000 | 1391 | CASE (Bmax): |
bf1de43e | 1392 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1393 | DISCARD (1); |
36f7ba0a | 1394 | TOP = Fmax (2, &TOP); |
bf1de43e | 1395 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1396 | NEXT; |
36f7ba0a | 1397 | |
3a4c8000 | 1398 | CASE (Bmin): |
bf1de43e | 1399 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1400 | DISCARD (1); |
36f7ba0a | 1401 | TOP = Fmin (2, &TOP); |
bf1de43e | 1402 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1403 | NEXT; |
36f7ba0a | 1404 | |
3a4c8000 | 1405 | CASE (Bmult): |
bf1de43e | 1406 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1407 | DISCARD (1); |
36f7ba0a | 1408 | TOP = Ftimes (2, &TOP); |
bf1de43e | 1409 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1410 | NEXT; |
36f7ba0a | 1411 | |
3a4c8000 | 1412 | CASE (Bquo): |
bf1de43e | 1413 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1414 | DISCARD (1); |
36f7ba0a | 1415 | TOP = Fquo (2, &TOP); |
bf1de43e | 1416 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1417 | NEXT; |
36f7ba0a | 1418 | |
3a4c8000 | 1419 | CASE (Brem): |
4015b3c0 GM |
1420 | { |
1421 | Lisp_Object v1; | |
bf1de43e | 1422 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1423 | v1 = POP; |
1424 | TOP = Frem (TOP, v1); | |
bf1de43e | 1425 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1426 | NEXT; |
4015b3c0 | 1427 | } |
36f7ba0a | 1428 | |
3a4c8000 | 1429 | CASE (Bpoint): |
4015b3c0 GM |
1430 | { |
1431 | Lisp_Object v1; | |
1432 | XSETFASTINT (v1, PT); | |
1433 | PUSH (v1); | |
3a4c8000 | 1434 | NEXT; |
4015b3c0 | 1435 | } |
36f7ba0a | 1436 | |
3a4c8000 | 1437 | CASE (Bgoto_char): |
4015b3c0 | 1438 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1439 | TOP = Fgoto_char (TOP); |
4015b3c0 | 1440 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1441 | NEXT; |
36f7ba0a | 1442 | |
3a4c8000 | 1443 | CASE (Binsert): |
4015b3c0 | 1444 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1445 | TOP = Finsert (1, &TOP); |
4015b3c0 | 1446 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1447 | NEXT; |
36f7ba0a | 1448 | |
3a4c8000 | 1449 | CASE (BinsertN): |
63639d44 | 1450 | op = FETCH; |
4015b3c0 | 1451 | BEFORE_POTENTIAL_GC (); |
fa9aabf6 | 1452 | DISCARD (op - 1); |
63639d44 | 1453 | TOP = Finsert (op, &TOP); |
4015b3c0 | 1454 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1455 | NEXT; |
63639d44 | 1456 | |
3a4c8000 | 1457 | CASE (Bpoint_max): |
4015b3c0 GM |
1458 | { |
1459 | Lisp_Object v1; | |
1460 | XSETFASTINT (v1, ZV); | |
1461 | PUSH (v1); | |
3a4c8000 | 1462 | NEXT; |
4015b3c0 | 1463 | } |
36f7ba0a | 1464 | |
3a4c8000 | 1465 | CASE (Bpoint_min): |
4015b3c0 GM |
1466 | { |
1467 | Lisp_Object v1; | |
1468 | XSETFASTINT (v1, BEGV); | |
1469 | PUSH (v1); | |
3a4c8000 | 1470 | NEXT; |
4015b3c0 | 1471 | } |
36f7ba0a | 1472 | |
3a4c8000 | 1473 | CASE (Bchar_after): |
bf1de43e | 1474 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1475 | TOP = Fchar_after (TOP); |
bf1de43e | 1476 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1477 | NEXT; |
36f7ba0a | 1478 | |
3a4c8000 | 1479 | CASE (Bfollowing_char): |
4015b3c0 GM |
1480 | { |
1481 | Lisp_Object v1; | |
bf1de43e | 1482 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1483 | v1 = Ffollowing_char (); |
bf1de43e | 1484 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1485 | PUSH (v1); |
3a4c8000 | 1486 | NEXT; |
4015b3c0 | 1487 | } |
36f7ba0a | 1488 | |
3a4c8000 | 1489 | CASE (Bpreceding_char): |
4015b3c0 GM |
1490 | { |
1491 | Lisp_Object v1; | |
bf1de43e | 1492 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1493 | v1 = Fprevious_char (); |
bf1de43e | 1494 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1495 | PUSH (v1); |
3a4c8000 | 1496 | NEXT; |
4015b3c0 | 1497 | } |
36f7ba0a | 1498 | |
3a4c8000 | 1499 | CASE (Bcurrent_column): |
4015b3c0 GM |
1500 | { |
1501 | Lisp_Object v1; | |
96111f48 | 1502 | BEFORE_POTENTIAL_GC (); |
7831777b | 1503 | XSETFASTINT (v1, current_column ()); |
96111f48 | 1504 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1505 | PUSH (v1); |
3a4c8000 | 1506 | NEXT; |
4015b3c0 | 1507 | } |
36f7ba0a | 1508 | |
3a4c8000 | 1509 | CASE (Bindent_to): |
4015b3c0 | 1510 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1511 | TOP = Findent_to (TOP, Qnil); |
4015b3c0 | 1512 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1513 | NEXT; |
36f7ba0a | 1514 | |
3a4c8000 | 1515 | CASE (Beolp): |
36f7ba0a | 1516 | PUSH (Feolp ()); |
3a4c8000 | 1517 | NEXT; |
36f7ba0a | 1518 | |
3a4c8000 | 1519 | CASE (Beobp): |
36f7ba0a | 1520 | PUSH (Feobp ()); |
3a4c8000 | 1521 | NEXT; |
36f7ba0a | 1522 | |
3a4c8000 | 1523 | CASE (Bbolp): |
36f7ba0a | 1524 | PUSH (Fbolp ()); |
3a4c8000 | 1525 | NEXT; |
36f7ba0a | 1526 | |
3a4c8000 | 1527 | CASE (Bbobp): |
36f7ba0a | 1528 | PUSH (Fbobp ()); |
3a4c8000 | 1529 | NEXT; |
36f7ba0a | 1530 | |
3a4c8000 | 1531 | CASE (Bcurrent_buffer): |
36f7ba0a | 1532 | PUSH (Fcurrent_buffer ()); |
3a4c8000 | 1533 | NEXT; |
36f7ba0a | 1534 | |
3a4c8000 | 1535 | CASE (Bset_buffer): |
4015b3c0 | 1536 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1537 | TOP = Fset_buffer (TOP); |
4015b3c0 | 1538 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1539 | NEXT; |
36f7ba0a | 1540 | |
3a4c8000 | 1541 | CASE (Binteractive_p): /* Obsolete since 24.1. */ |
23ba2705 SM |
1542 | BEFORE_POTENTIAL_GC (); |
1543 | PUSH (call0 (intern ("interactive-p"))); | |
1544 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1545 | NEXT; |
36f7ba0a | 1546 | |
3a4c8000 | 1547 | CASE (Bforward_char): |
4015b3c0 | 1548 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1549 | TOP = Fforward_char (TOP); |
4015b3c0 | 1550 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1551 | NEXT; |
36f7ba0a | 1552 | |
3a4c8000 | 1553 | CASE (Bforward_word): |
4015b3c0 | 1554 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1555 | TOP = Fforward_word (TOP); |
4015b3c0 | 1556 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1557 | NEXT; |
36f7ba0a | 1558 | |
3a4c8000 | 1559 | CASE (Bskip_chars_forward): |
4015b3c0 GM |
1560 | { |
1561 | Lisp_Object v1; | |
4015b3c0 | 1562 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1563 | v1 = POP; |
4015b3c0 GM |
1564 | TOP = Fskip_chars_forward (TOP, v1); |
1565 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1566 | NEXT; |
4015b3c0 | 1567 | } |
36f7ba0a | 1568 | |
3a4c8000 | 1569 | CASE (Bskip_chars_backward): |
4015b3c0 GM |
1570 | { |
1571 | Lisp_Object v1; | |
4015b3c0 | 1572 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1573 | v1 = POP; |
4015b3c0 GM |
1574 | TOP = Fskip_chars_backward (TOP, v1); |
1575 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1576 | NEXT; |
4015b3c0 | 1577 | } |
36f7ba0a | 1578 | |
3a4c8000 | 1579 | CASE (Bforward_line): |
4015b3c0 | 1580 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1581 | TOP = Fforward_line (TOP); |
4015b3c0 | 1582 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1583 | NEXT; |
36f7ba0a | 1584 | |
3a4c8000 | 1585 | CASE (Bchar_syntax): |
9281d077 KH |
1586 | { |
1587 | int c; | |
1588 | ||
1589 | BEFORE_POTENTIAL_GC (); | |
1590 | CHECK_CHARACTER (TOP); | |
1591 | AFTER_POTENTIAL_GC (); | |
1592 | c = XFASTINT (TOP); | |
4b4deea2 | 1593 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) |
9281d077 | 1594 | MAKE_CHAR_MULTIBYTE (c); |
1fc71008 | 1595 | XSETFASTINT (TOP, syntax_code_spec[SYNTAX (c)]); |
8f924df7 | 1596 | } |
3a4c8000 | 1597 | NEXT; |
36f7ba0a | 1598 | |
3a4c8000 | 1599 | CASE (Bbuffer_substring): |
4015b3c0 GM |
1600 | { |
1601 | Lisp_Object v1; | |
4015b3c0 | 1602 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1603 | v1 = POP; |
4015b3c0 GM |
1604 | TOP = Fbuffer_substring (TOP, v1); |
1605 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1606 | NEXT; |
4015b3c0 | 1607 | } |
36f7ba0a | 1608 | |
3a4c8000 | 1609 | CASE (Bdelete_region): |
4015b3c0 GM |
1610 | { |
1611 | Lisp_Object v1; | |
4015b3c0 | 1612 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1613 | v1 = POP; |
4015b3c0 GM |
1614 | TOP = Fdelete_region (TOP, v1); |
1615 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1616 | NEXT; |
4015b3c0 | 1617 | } |
36f7ba0a | 1618 | |
3a4c8000 | 1619 | CASE (Bnarrow_to_region): |
4015b3c0 GM |
1620 | { |
1621 | Lisp_Object v1; | |
4015b3c0 | 1622 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1623 | v1 = POP; |
4015b3c0 GM |
1624 | TOP = Fnarrow_to_region (TOP, v1); |
1625 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1626 | NEXT; |
4015b3c0 | 1627 | } |
36f7ba0a | 1628 | |
3a4c8000 | 1629 | CASE (Bwiden): |
4015b3c0 | 1630 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1631 | PUSH (Fwiden ()); |
4015b3c0 | 1632 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1633 | NEXT; |
36f7ba0a | 1634 | |
3a4c8000 | 1635 | CASE (Bend_of_line): |
4015b3c0 | 1636 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1637 | TOP = Fend_of_line (TOP); |
4015b3c0 | 1638 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1639 | NEXT; |
63639d44 | 1640 | |
3a4c8000 | 1641 | CASE (Bset_marker): |
4015b3c0 GM |
1642 | { |
1643 | Lisp_Object v1, v2; | |
bf1de43e | 1644 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1645 | v1 = POP; |
1646 | v2 = POP; | |
1647 | TOP = Fset_marker (TOP, v2, v1); | |
bf1de43e | 1648 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1649 | NEXT; |
4015b3c0 | 1650 | } |
63639d44 | 1651 | |
3a4c8000 | 1652 | CASE (Bmatch_beginning): |
bf1de43e | 1653 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1654 | TOP = Fmatch_beginning (TOP); |
bf1de43e | 1655 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1656 | NEXT; |
63639d44 | 1657 | |
3a4c8000 | 1658 | CASE (Bmatch_end): |
bf1de43e | 1659 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1660 | TOP = Fmatch_end (TOP); |
bf1de43e | 1661 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1662 | NEXT; |
63639d44 | 1663 | |
3a4c8000 | 1664 | CASE (Bupcase): |
bf1de43e | 1665 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1666 | TOP = Fupcase (TOP); |
bf1de43e | 1667 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1668 | NEXT; |
63639d44 | 1669 | |
3a4c8000 | 1670 | CASE (Bdowncase): |
bf1de43e | 1671 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1672 | TOP = Fdowncase (TOP); |
bf1de43e | 1673 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1674 | NEXT; |
63639d44 | 1675 | |
3a4c8000 | 1676 | CASE (Bstringeqlsign): |
4015b3c0 GM |
1677 | { |
1678 | Lisp_Object v1; | |
bf1de43e | 1679 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1680 | v1 = POP; |
1681 | TOP = Fstring_equal (TOP, v1); | |
bf1de43e | 1682 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1683 | NEXT; |
4015b3c0 | 1684 | } |
36f7ba0a | 1685 | |
3a4c8000 | 1686 | CASE (Bstringlss): |
4015b3c0 GM |
1687 | { |
1688 | Lisp_Object v1; | |
bf1de43e | 1689 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1690 | v1 = POP; |
1691 | TOP = Fstring_lessp (TOP, v1); | |
bf1de43e | 1692 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1693 | NEXT; |
4015b3c0 | 1694 | } |
36f7ba0a | 1695 | |
3a4c8000 | 1696 | CASE (Bequal): |
4015b3c0 GM |
1697 | { |
1698 | Lisp_Object v1; | |
1699 | v1 = POP; | |
1700 | TOP = Fequal (TOP, v1); | |
3a4c8000 | 1701 | NEXT; |
4015b3c0 | 1702 | } |
36f7ba0a | 1703 | |
3a4c8000 | 1704 | CASE (Bnthcdr): |
4015b3c0 GM |
1705 | { |
1706 | Lisp_Object v1; | |
bf1de43e | 1707 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1708 | v1 = POP; |
1709 | TOP = Fnthcdr (TOP, v1); | |
bf1de43e | 1710 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1711 | NEXT; |
4015b3c0 | 1712 | } |
36f7ba0a | 1713 | |
3a4c8000 | 1714 | CASE (Belt): |
4015b3c0 GM |
1715 | { |
1716 | Lisp_Object v1, v2; | |
1717 | if (CONSP (TOP)) | |
1718 | { | |
1719 | /* Exchange args and then do nth. */ | |
d311d28c | 1720 | EMACS_INT n; |
bf1de43e | 1721 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1722 | v2 = POP; |
1723 | v1 = TOP; | |
b7826503 | 1724 | CHECK_NUMBER (v2); |
f5941bf8 | 1725 | AFTER_POTENTIAL_GC (); |
d311d28c | 1726 | n = XINT (v2); |
4015b3c0 | 1727 | immediate_quit = 1; |
d311d28c | 1728 | while (--n >= 0 && CONSP (v1)) |
14c5155a | 1729 | v1 = XCDR (v1); |
4015b3c0 | 1730 | immediate_quit = 0; |
14c5155a | 1731 | TOP = CAR (v1); |
4015b3c0 GM |
1732 | } |
1733 | else | |
1734 | { | |
bf1de43e | 1735 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1736 | v1 = POP; |
1737 | TOP = Felt (TOP, v1); | |
bf1de43e | 1738 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1739 | } |
3a4c8000 | 1740 | NEXT; |
4015b3c0 | 1741 | } |
36f7ba0a | 1742 | |
3a4c8000 | 1743 | CASE (Bmember): |
4015b3c0 GM |
1744 | { |
1745 | Lisp_Object v1; | |
bf1de43e | 1746 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1747 | v1 = POP; |
1748 | TOP = Fmember (TOP, v1); | |
bf1de43e | 1749 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1750 | NEXT; |
4015b3c0 | 1751 | } |
36f7ba0a | 1752 | |
3a4c8000 | 1753 | CASE (Bassq): |
4015b3c0 GM |
1754 | { |
1755 | Lisp_Object v1; | |
bf1de43e | 1756 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1757 | v1 = POP; |
1758 | TOP = Fassq (TOP, v1); | |
bf1de43e | 1759 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1760 | NEXT; |
4015b3c0 | 1761 | } |
36f7ba0a | 1762 | |
3a4c8000 | 1763 | CASE (Bnreverse): |
bf1de43e | 1764 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1765 | TOP = Fnreverse (TOP); |
bf1de43e | 1766 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1767 | NEXT; |
36f7ba0a | 1768 | |
3a4c8000 | 1769 | CASE (Bsetcar): |
4015b3c0 GM |
1770 | { |
1771 | Lisp_Object v1; | |
bf1de43e | 1772 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1773 | v1 = POP; |
1774 | TOP = Fsetcar (TOP, v1); | |
bf1de43e | 1775 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1776 | NEXT; |
4015b3c0 | 1777 | } |
36f7ba0a | 1778 | |
3a4c8000 | 1779 | CASE (Bsetcdr): |
4015b3c0 GM |
1780 | { |
1781 | Lisp_Object v1; | |
bf1de43e | 1782 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1783 | v1 = POP; |
1784 | TOP = Fsetcdr (TOP, v1); | |
bf1de43e | 1785 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1786 | NEXT; |
4015b3c0 | 1787 | } |
36f7ba0a | 1788 | |
3a4c8000 | 1789 | CASE (Bcar_safe): |
4015b3c0 GM |
1790 | { |
1791 | Lisp_Object v1; | |
1792 | v1 = TOP; | |
14c5155a | 1793 | TOP = CAR_SAFE (v1); |
3a4c8000 | 1794 | NEXT; |
4015b3c0 | 1795 | } |
36f7ba0a | 1796 | |
3a4c8000 | 1797 | CASE (Bcdr_safe): |
4015b3c0 GM |
1798 | { |
1799 | Lisp_Object v1; | |
1800 | v1 = TOP; | |
14c5155a | 1801 | TOP = CDR_SAFE (v1); |
3a4c8000 | 1802 | NEXT; |
4015b3c0 | 1803 | } |
36f7ba0a | 1804 | |
3a4c8000 | 1805 | CASE (Bnconc): |
bf1de43e | 1806 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1807 | DISCARD (1); |
36f7ba0a | 1808 | TOP = Fnconc (2, &TOP); |
bf1de43e | 1809 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1810 | NEXT; |
36f7ba0a | 1811 | |
3a4c8000 | 1812 | CASE (Bnumberp): |
63639d44 | 1813 | TOP = (NUMBERP (TOP) ? Qt : Qnil); |
3a4c8000 | 1814 | NEXT; |
36f7ba0a | 1815 | |
3a4c8000 | 1816 | CASE (Bintegerp): |
617bd3f6 | 1817 | TOP = INTEGERP (TOP) ? Qt : Qnil; |
3a4c8000 | 1818 | NEXT; |
36f7ba0a JB |
1819 | |
1820 | #ifdef BYTE_CODE_SAFE | |
3a4c8000 TT |
1821 | /* These are intentionally written using 'case' syntax, |
1822 | because they are incompatible with the threaded | |
1823 | interpreter. */ | |
1824 | ||
36f7ba0a | 1825 | case Bset_mark: |
f5941bf8 | 1826 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1827 | error ("set-mark is an obsolete bytecode"); |
f5941bf8 | 1828 | AFTER_POTENTIAL_GC (); |
36f7ba0a JB |
1829 | break; |
1830 | case Bscan_buffer: | |
f5941bf8 | 1831 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1832 | error ("scan-buffer is an obsolete bytecode"); |
f5941bf8 | 1833 | AFTER_POTENTIAL_GC (); |
36f7ba0a | 1834 | break; |
36f7ba0a JB |
1835 | #endif |
1836 | ||
3a4c8000 | 1837 | CASE_ABORT: |
876c194c SM |
1838 | /* Actually this is Bstack_ref with offset 0, but we use Bdup |
1839 | for that instead. */ | |
3a4c8000 | 1840 | /* CASE (Bstack_ref): */ |
adf2aa61 SM |
1841 | call3 (intern ("error"), |
1842 | build_string ("Invalid byte opcode: op=%s, ptr=%d"), | |
1843 | make_number (op), | |
1844 | make_number ((stack.pc - 1) - stack.byte_string_start)); | |
c96d71f7 | 1845 | |
b9598260 | 1846 | /* Handy byte-codes for lexical binding. */ |
3a4c8000 TT |
1847 | CASE (Bstack_ref1): |
1848 | CASE (Bstack_ref2): | |
1849 | CASE (Bstack_ref3): | |
1850 | CASE (Bstack_ref4): | |
1851 | CASE (Bstack_ref5): | |
3e21b6a7 SM |
1852 | { |
1853 | Lisp_Object *ptr = top - (op - Bstack_ref); | |
1854 | PUSH (*ptr); | |
3a4c8000 | 1855 | NEXT; |
3e21b6a7 | 1856 | } |
3a4c8000 | 1857 | CASE (Bstack_ref6): |
3e21b6a7 SM |
1858 | { |
1859 | Lisp_Object *ptr = top - (FETCH); | |
1860 | PUSH (*ptr); | |
3a4c8000 | 1861 | NEXT; |
3e21b6a7 | 1862 | } |
3a4c8000 | 1863 | CASE (Bstack_ref7): |
3e21b6a7 SM |
1864 | { |
1865 | Lisp_Object *ptr = top - (FETCH2); | |
1866 | PUSH (*ptr); | |
3a4c8000 | 1867 | NEXT; |
3e21b6a7 | 1868 | } |
3a4c8000 | 1869 | CASE (Bstack_set): |
2462470b | 1870 | /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */ |
3e21b6a7 SM |
1871 | { |
1872 | Lisp_Object *ptr = top - (FETCH); | |
1873 | *ptr = POP; | |
3a4c8000 | 1874 | NEXT; |
3e21b6a7 | 1875 | } |
3a4c8000 | 1876 | CASE (Bstack_set2): |
3e21b6a7 SM |
1877 | { |
1878 | Lisp_Object *ptr = top - (FETCH2); | |
1879 | *ptr = POP; | |
3a4c8000 | 1880 | NEXT; |
3e21b6a7 | 1881 | } |
3a4c8000 | 1882 | CASE (BdiscardN): |
b9598260 SM |
1883 | op = FETCH; |
1884 | if (op & 0x80) | |
1885 | { | |
1886 | op &= 0x7F; | |
1887 | top[-op] = TOP; | |
1888 | } | |
1889 | DISCARD (op); | |
3a4c8000 | 1890 | NEXT; |
c96d71f7 | 1891 | |
3a4c8000 TT |
1892 | CASE_DEFAULT |
1893 | CASE (Bconstant): | |
36f7ba0a JB |
1894 | #ifdef BYTE_CODE_SAFE |
1895 | if (op < Bconstant) | |
f5941bf8 | 1896 | { |
1088b922 | 1897 | emacs_abort (); |
f5941bf8 | 1898 | } |
36f7ba0a | 1899 | if ((op -= Bconstant) >= const_length) |
f5941bf8 | 1900 | { |
1088b922 | 1901 | emacs_abort (); |
f5941bf8 | 1902 | } |
36f7ba0a JB |
1903 | PUSH (vectorp[op]); |
1904 | #else | |
1905 | PUSH (vectorp[op - Bconstant]); | |
1906 | #endif | |
3a4c8000 | 1907 | NEXT; |
36f7ba0a JB |
1908 | } |
1909 | } | |
1910 | ||
1911 | exit: | |
4015b3c0 | 1912 | return result; |
36f7ba0a | 1913 | } |
f99f5844 | 1914 | /* {{coccinelle:skip_end}} */ |
36f7ba0a | 1915 | |
dfcf069d | 1916 | void |
971de7fb | 1917 | syms_of_bytecode (void) |
36f7ba0a | 1918 | { |
fe6aa7a1 | 1919 | #include "bytecode.x" |
36f7ba0a JB |
1920 | |
1921 | #ifdef BYTE_CODE_METER | |
1922 | ||
29208e82 | 1923 | DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter, |
39f624fa PJ |
1924 | doc: /* A vector of vectors which holds a histogram of byte-code usage. |
1925 | \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte | |
1926 | opcode CODE has been executed. | |
1927 | \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0, | |
1928 | indicates how many times the byte opcodes CODE1 and CODE2 have been | |
1929 | executed in succession. */); | |
8e11578b | 1930 | |
29208e82 | 1931 | DEFVAR_BOOL ("byte-metering-on", byte_metering_on, |
39f624fa PJ |
1932 | doc: /* If non-nil, keep profiling information on byte code usage. |
1933 | The variable byte-code-meter indicates how often each byte opcode is used. | |
1934 | If a symbol has a property named `byte-code-meter' whose value is an | |
1935 | integer, it is incremented each time that symbol's function is called. */); | |
36f7ba0a JB |
1936 | |
1937 | byte_metering_on = 0; | |
63639d44 | 1938 | Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0)); |
cd3520a4 | 1939 | DEFSYM (Qbyte_code_meter, "byte-code-meter"); |
36f7ba0a JB |
1940 | { |
1941 | int i = 256; | |
1942 | while (i--) | |
28be1ada DA |
1943 | ASET (Vbyte_code_meter, i, |
1944 | Fmake_vector (make_number (256), make_number (0))); | |
36f7ba0a JB |
1945 | } |
1946 | #endif | |
1947 | } |