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 | ||
426 | Lisp_Object | |
0ee81a0c | 427 | exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, |
f66c7cf8 | 428 | Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) |
36f7ba0a | 429 | { |
d311d28c | 430 | ptrdiff_t count = SPECPDL_INDEX (); |
36f7ba0a | 431 | #ifdef BYTE_CODE_METER |
157fec2e | 432 | int volatile this_op = 0; |
36f7ba0a JB |
433 | int prev_op; |
434 | #endif | |
7ca1e8b7 | 435 | int op; |
4015b3c0 | 436 | /* Lisp_Object v1, v2; */ |
089b985f | 437 | Lisp_Object *vectorp; |
36f7ba0a | 438 | #ifdef BYTE_CODE_SAFE |
285d6d5d SM |
439 | ptrdiff_t const_length; |
440 | Lisp_Object *stacke; | |
441 | ptrdiff_t bytestr_length; | |
1be4d761 | 442 | #endif |
7ca1e8b7 GM |
443 | struct byte_stack stack; |
444 | Lisp_Object *top; | |
4015b3c0 | 445 | Lisp_Object result; |
adf2aa61 | 446 | enum handlertype type; |
36f7ba0a | 447 | |
603a0937 | 448 | #if 0 /* CHECK_FRAME_FONT */ |
ad7de7d7 GM |
449 | { |
450 | struct frame *f = SELECTED_FRAME (); | |
451 | if (FRAME_X_P (f) | |
452 | && FRAME_FONT (f)->direction != 0 | |
453 | && FRAME_FONT (f)->direction != 1) | |
1088b922 | 454 | emacs_abort (); |
ad7de7d7 GM |
455 | } |
456 | #endif | |
457 | ||
b7826503 | 458 | CHECK_STRING (bytestr); |
c616acb8 | 459 | CHECK_VECTOR (vector); |
f66c7cf8 | 460 | CHECK_NATNUM (maxdepth); |
36f7ba0a | 461 | |
0df1eac5 | 462 | #ifdef BYTE_CODE_SAFE |
77b37c05 | 463 | const_length = ASIZE (vector); |
0df1eac5 PE |
464 | #endif |
465 | ||
089b985f KH |
466 | if (STRING_MULTIBYTE (bytestr)) |
467 | /* BYTESTR must have been produced by Emacs 20.2 or the earlier | |
468 | because they produced a raw 8-bit string for byte-code and now | |
469 | such a byte-code string is loaded as multibyte while raw 8-bit | |
470 | characters converted to multibyte form. Thus, now we must | |
fbd98f82 | 471 | convert them back to the originally intended unibyte form. */ |
5274126b | 472 | bytestr = Fstring_as_unibyte (bytestr); |
089b985f | 473 | |
1be4d761 | 474 | #ifdef BYTE_CODE_SAFE |
d5db4077 | 475 | bytestr_length = SBYTES (bytestr); |
1be4d761 | 476 | #endif |
91f2d272 | 477 | vectorp = XVECTOR (vector)->contents; |
089b985f | 478 | |
7ca1e8b7 | 479 | stack.byte_string = bytestr; |
d5db4077 | 480 | stack.pc = stack.byte_string_start = SDATA (bytestr); |
99ec1647 | 481 | #if BYTE_MARK_STACK |
7ca1e8b7 | 482 | stack.constants = vector; |
99ec1647 | 483 | #endif |
663e2b3f | 484 | if (MAX_ALLOCA / word_size <= XFASTINT (maxdepth)) |
39b5db3b | 485 | memory_full (SIZE_MAX); |
38182d90 | 486 | top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top); |
36f7ba0a | 487 | |
7ca1e8b7 GM |
488 | #ifdef BYTE_CODE_SAFE |
489 | stacke = stack.bottom - 1 + XFASTINT (maxdepth); | |
490 | #endif | |
8e11578b | 491 | |
e2abe5a1 | 492 | if (INTEGERP (args_template)) |
b9598260 | 493 | { |
619e0f19 | 494 | ptrdiff_t at = XINT (args_template); |
2f221583 | 495 | bool rest = (at & 128) != 0; |
e2abe5a1 | 496 | int mandatory = at & 127; |
619e0f19 | 497 | ptrdiff_t nonrest = at >> 8; |
e2abe5a1 SM |
498 | eassert (mandatory <= nonrest); |
499 | if (nargs <= nonrest) | |
500 | { | |
619e0f19 | 501 | ptrdiff_t i; |
e2abe5a1 SM |
502 | for (i = 0 ; i < nargs; i++, args++) |
503 | PUSH (*args); | |
504 | if (nargs < mandatory) | |
505 | /* Too few arguments. */ | |
506 | Fsignal (Qwrong_number_of_arguments, | |
6c6f1994 | 507 | list2 (Fcons (make_number (mandatory), |
e2abe5a1 | 508 | rest ? Qand_rest : make_number (nonrest)), |
6c6f1994 | 509 | make_number (nargs))); |
e2abe5a1 SM |
510 | else |
511 | { | |
512 | for (; i < nonrest; i++) | |
513 | PUSH (Qnil); | |
514 | if (rest) | |
515 | PUSH (Qnil); | |
516 | } | |
517 | } | |
518 | else if (rest) | |
519 | { | |
f66c7cf8 | 520 | ptrdiff_t i; |
e2abe5a1 SM |
521 | for (i = 0 ; i < nonrest; i++, args++) |
522 | PUSH (*args); | |
523 | PUSH (Flist (nargs - nonrest, args)); | |
524 | } | |
525 | else | |
526 | /* Too many arguments. */ | |
b9598260 | 527 | Fsignal (Qwrong_number_of_arguments, |
6c6f1994 PE |
528 | list2 (Fcons (make_number (mandatory), make_number (nonrest)), |
529 | make_number (nargs))); | |
e2abe5a1 SM |
530 | } |
531 | else if (! NILP (args_template)) | |
532 | /* We should push some arguments on the stack. */ | |
533 | { | |
534 | error ("Unknown args template!"); | |
b9598260 SM |
535 | } |
536 | ||
36f7ba0a JB |
537 | while (1) |
538 | { | |
539 | #ifdef BYTE_CODE_SAFE | |
9e49c990 | 540 | if (top > stacke) |
1088b922 | 541 | emacs_abort (); |
7ca1e8b7 | 542 | else if (top < stack.bottom - 1) |
1088b922 | 543 | emacs_abort (); |
36f7ba0a JB |
544 | #endif |
545 | ||
36f7ba0a JB |
546 | #ifdef BYTE_CODE_METER |
547 | prev_op = this_op; | |
548 | this_op = op = FETCH; | |
549 | METER_CODE (prev_op, op); | |
36f7ba0a | 550 | #else |
3a4c8000 | 551 | #ifndef BYTE_CODE_THREADED |
4015b3c0 | 552 | op = FETCH; |
36f7ba0a | 553 | #endif |
3a4c8000 TT |
554 | #endif |
555 | ||
556 | /* The interpreter can be compiled one of two ways: as an | |
557 | ordinary switch-based interpreter, or as a threaded | |
558 | interpreter. The threaded interpreter relies on GCC's | |
559 | computed goto extension, so it is not available everywhere. | |
560 | Threading provides a performance boost. These macros are how | |
561 | we allow the code to be compiled both ways. */ | |
562 | #ifdef BYTE_CODE_THREADED | |
563 | /* The CASE macro introduces an instruction's body. It is | |
564 | either a label or a case label. */ | |
565 | #define CASE(OP) insn_ ## OP | |
566 | /* NEXT is invoked at the end of an instruction to go to the | |
567 | next instruction. It is either a computed goto, or a | |
568 | plain break. */ | |
569 | #define NEXT goto *(targets[op = FETCH]) | |
570 | /* FIRST is like NEXT, but is only used at the start of the | |
571 | interpreter body. In the switch-based interpreter it is the | |
572 | switch, so the threaded definition must include a semicolon. */ | |
573 | #define FIRST NEXT; | |
574 | /* Most cases are labeled with the CASE macro, above. | |
575 | CASE_DEFAULT is one exception; it is used if the interpreter | |
576 | being built requires a default case. The threaded | |
577 | interpreter does not, because the dispatch table is | |
578 | completely filled. */ | |
579 | #define CASE_DEFAULT | |
580 | /* This introduces an instruction that is known to call abort. */ | |
581 | #define CASE_ABORT CASE (Bstack_ref): CASE (default) | |
582 | #else | |
583 | /* See above for the meaning of the various defines. */ | |
584 | #define CASE(OP) case OP | |
585 | #define NEXT break | |
586 | #define FIRST switch (op) | |
587 | #define CASE_DEFAULT case 255: default: | |
588 | #define CASE_ABORT case 0 | |
589 | #endif | |
590 | ||
591 | #ifdef BYTE_CODE_THREADED | |
592 | ||
593 | /* A convenience define that saves us a lot of typing and makes | |
594 | the table clearer. */ | |
595 | #define LABEL(OP) [OP] = &&insn_ ## OP | |
36f7ba0a | 596 | |
31ff141c | 597 | #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) |
ffacb126 PE |
598 | # pragma GCC diagnostic push |
599 | # pragma GCC diagnostic ignored "-Woverride-init" | |
31ff141c PE |
600 | #elif defined __clang__ |
601 | # pragma GCC diagnostic push | |
602 | # pragma GCC diagnostic ignored "-Winitializer-overrides" | |
ffacb126 PE |
603 | #endif |
604 | ||
3a4c8000 TT |
605 | /* This is the dispatch table for the threaded interpreter. */ |
606 | static const void *const targets[256] = | |
4015b3c0 | 607 | { |
3a4c8000 TT |
608 | [0 ... (Bconstant - 1)] = &&insn_default, |
609 | [Bconstant ... 255] = &&insn_Bconstant, | |
610 | ||
611 | #define DEFINE(name, value) LABEL (name) , | |
612 | BYTE_CODES | |
613 | #undef DEFINE | |
614 | }; | |
ffacb126 | 615 | |
31ff141c | 616 | #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__ |
ffacb126 PE |
617 | # pragma GCC diagnostic pop |
618 | #endif | |
619 | ||
3a4c8000 TT |
620 | #endif |
621 | ||
622 | ||
623 | FIRST | |
624 | { | |
625 | CASE (Bvarref7): | |
36f7ba0a JB |
626 | op = FETCH2; |
627 | goto varref; | |
628 | ||
3a4c8000 TT |
629 | CASE (Bvarref): |
630 | CASE (Bvarref1): | |
631 | CASE (Bvarref2): | |
632 | CASE (Bvarref3): | |
633 | CASE (Bvarref4): | |
634 | CASE (Bvarref5): | |
36f7ba0a | 635 | op = op - Bvarref; |
4015b3c0 GM |
636 | goto varref; |
637 | ||
638 | /* This seems to be the most frequently executed byte-code | |
639 | among the Bvarref's, so avoid a goto here. */ | |
3a4c8000 | 640 | CASE (Bvarref6): |
4015b3c0 | 641 | op = FETCH; |
36f7ba0a | 642 | varref: |
4015b3c0 GM |
643 | { |
644 | Lisp_Object v1, v2; | |
645 | ||
646 | v1 = vectorp[op]; | |
647 | if (SYMBOLP (v1)) | |
648 | { | |
ce5b453a SM |
649 | if (XSYMBOL (v1)->redirect != SYMBOL_PLAINVAL |
650 | || (v2 = SYMBOL_VAL (XSYMBOL (v1)), | |
651 | EQ (v2, Qunbound))) | |
bf1de43e GM |
652 | { |
653 | BEFORE_POTENTIAL_GC (); | |
654 | v2 = Fsymbol_value (v1); | |
655 | AFTER_POTENTIAL_GC (); | |
656 | } | |
4015b3c0 GM |
657 | } |
658 | else | |
bf1de43e GM |
659 | { |
660 | BEFORE_POTENTIAL_GC (); | |
661 | v2 = Fsymbol_value (v1); | |
662 | AFTER_POTENTIAL_GC (); | |
663 | } | |
4015b3c0 | 664 | PUSH (v2); |
3a4c8000 | 665 | NEXT; |
4015b3c0 GM |
666 | } |
667 | ||
3a4c8000 | 668 | CASE (Bgotoifnil): |
21ed6de3 KR |
669 | { |
670 | Lisp_Object v1; | |
671 | MAYBE_GC (); | |
672 | op = FETCH2; | |
673 | v1 = POP; | |
674 | if (NILP (v1)) | |
675 | { | |
676 | BYTE_CODE_QUIT; | |
677 | CHECK_RANGE (op); | |
678 | stack.pc = stack.byte_string_start + op; | |
679 | } | |
3a4c8000 | 680 | NEXT; |
21ed6de3 | 681 | } |
36f7ba0a | 682 | |
3a4c8000 | 683 | CASE (Bcar): |
4015b3c0 GM |
684 | { |
685 | Lisp_Object v1; | |
686 | v1 = TOP; | |
1c470562 SM |
687 | if (CONSP (v1)) |
688 | TOP = XCAR (v1); | |
689 | else if (NILP (v1)) | |
690 | TOP = Qnil; | |
691 | else | |
692 | { | |
693 | BEFORE_POTENTIAL_GC (); | |
694 | wrong_type_argument (Qlistp, v1); | |
1c470562 | 695 | } |
3a4c8000 | 696 | NEXT; |
4015b3c0 GM |
697 | } |
698 | ||
3a4c8000 | 699 | CASE (Beq): |
4015b3c0 GM |
700 | { |
701 | Lisp_Object v1; | |
702 | v1 = POP; | |
703 | TOP = EQ (v1, TOP) ? Qt : Qnil; | |
3a4c8000 | 704 | NEXT; |
4015b3c0 GM |
705 | } |
706 | ||
3a4c8000 | 707 | CASE (Bmemq): |
4015b3c0 GM |
708 | { |
709 | Lisp_Object v1; | |
bf1de43e | 710 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
711 | v1 = POP; |
712 | TOP = Fmemq (TOP, v1); | |
bf1de43e | 713 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 714 | NEXT; |
4015b3c0 GM |
715 | } |
716 | ||
3a4c8000 | 717 | CASE (Bcdr): |
4015b3c0 GM |
718 | { |
719 | Lisp_Object v1; | |
720 | v1 = TOP; | |
1c470562 SM |
721 | if (CONSP (v1)) |
722 | TOP = XCDR (v1); | |
723 | else if (NILP (v1)) | |
724 | TOP = Qnil; | |
725 | else | |
726 | { | |
727 | BEFORE_POTENTIAL_GC (); | |
728 | wrong_type_argument (Qlistp, v1); | |
1c470562 | 729 | } |
3a4c8000 | 730 | NEXT; |
4015b3c0 | 731 | } |
36f7ba0a | 732 | |
3a4c8000 TT |
733 | CASE (Bvarset): |
734 | CASE (Bvarset1): | |
735 | CASE (Bvarset2): | |
736 | CASE (Bvarset3): | |
737 | CASE (Bvarset4): | |
738 | CASE (Bvarset5): | |
620cc5fa | 739 | op -= Bvarset; |
36f7ba0a JB |
740 | goto varset; |
741 | ||
3a4c8000 | 742 | CASE (Bvarset7): |
620cc5fa | 743 | op = FETCH2; |
4015b3c0 GM |
744 | goto varset; |
745 | ||
3a4c8000 | 746 | CASE (Bvarset6): |
4015b3c0 | 747 | op = FETCH; |
36f7ba0a | 748 | varset: |
620cc5fa GM |
749 | { |
750 | Lisp_Object sym, val; | |
8e11578b | 751 | |
620cc5fa | 752 | sym = vectorp[op]; |
bf1de43e | 753 | val = TOP; |
620cc5fa GM |
754 | |
755 | /* Inline the most common case. */ | |
756 | if (SYMBOLP (sym) | |
757 | && !EQ (val, Qunbound) | |
ce5b453a SM |
758 | && !XSYMBOL (sym)->redirect |
759 | && !SYMBOL_CONSTANT_P (sym)) | |
c644523b | 760 | SET_SYMBOL_VAL (XSYMBOL (sym), val); |
620cc5fa | 761 | else |
bf1de43e GM |
762 | { |
763 | BEFORE_POTENTIAL_GC (); | |
94b612ad | 764 | set_internal (sym, val, Qnil, 0); |
bf1de43e GM |
765 | AFTER_POTENTIAL_GC (); |
766 | } | |
620cc5fa | 767 | } |
3789dcdf | 768 | (void) POP; |
3a4c8000 | 769 | NEXT; |
36f7ba0a | 770 | |
3a4c8000 | 771 | CASE (Bdup): |
4015b3c0 GM |
772 | { |
773 | Lisp_Object v1; | |
774 | v1 = TOP; | |
775 | PUSH (v1); | |
3a4c8000 | 776 | NEXT; |
4015b3c0 GM |
777 | } |
778 | ||
779 | /* ------------------ */ | |
780 | ||
3a4c8000 | 781 | CASE (Bvarbind6): |
36f7ba0a JB |
782 | op = FETCH; |
783 | goto varbind; | |
784 | ||
3a4c8000 | 785 | CASE (Bvarbind7): |
36f7ba0a JB |
786 | op = FETCH2; |
787 | goto varbind; | |
788 | ||
3a4c8000 TT |
789 | CASE (Bvarbind): |
790 | CASE (Bvarbind1): | |
791 | CASE (Bvarbind2): | |
792 | CASE (Bvarbind3): | |
793 | CASE (Bvarbind4): | |
794 | CASE (Bvarbind5): | |
36f7ba0a JB |
795 | op -= Bvarbind; |
796 | varbind: | |
56b8eef5 GM |
797 | /* Specbind can signal and thus GC. */ |
798 | BEFORE_POTENTIAL_GC (); | |
9f62b5dd | 799 | dynwind_begin (); |
36f7ba0a | 800 | specbind (vectorp[op], POP); |
56b8eef5 | 801 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 802 | NEXT; |
36f7ba0a | 803 | |
3a4c8000 | 804 | CASE (Bcall6): |
36f7ba0a JB |
805 | op = FETCH; |
806 | goto docall; | |
807 | ||
3a4c8000 | 808 | CASE (Bcall7): |
36f7ba0a JB |
809 | op = FETCH2; |
810 | goto docall; | |
811 | ||
3a4c8000 TT |
812 | CASE (Bcall): |
813 | CASE (Bcall1): | |
814 | CASE (Bcall2): | |
815 | CASE (Bcall3): | |
816 | CASE (Bcall4): | |
817 | CASE (Bcall5): | |
36f7ba0a JB |
818 | op -= Bcall; |
819 | docall: | |
4015b3c0 | 820 | { |
fa9aabf6 | 821 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 822 | DISCARD (op); |
63639d44 | 823 | #ifdef BYTE_CODE_METER |
4015b3c0 GM |
824 | if (byte_metering_on && SYMBOLP (TOP)) |
825 | { | |
826 | Lisp_Object v1, v2; | |
827 | ||
828 | v1 = TOP; | |
829 | v2 = Fget (v1, Qbyte_code_meter); | |
830 | if (INTEGERP (v2) | |
f28e6371 | 831 | && XINT (v2) < MOST_POSITIVE_FIXNUM) |
4015b3c0 GM |
832 | { |
833 | XSETINT (v2, XINT (v2) + 1); | |
834 | Fput (v1, Qbyte_code_meter, v2); | |
835 | } | |
836 | } | |
63639d44 | 837 | #endif |
4015b3c0 GM |
838 | TOP = Ffuncall (op + 1, &TOP); |
839 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 840 | NEXT; |
4015b3c0 | 841 | } |
36f7ba0a | 842 | |
3a4c8000 | 843 | CASE (Bunbind6): |
36f7ba0a JB |
844 | op = FETCH; |
845 | goto dounbind; | |
846 | ||
3a4c8000 | 847 | CASE (Bunbind7): |
36f7ba0a JB |
848 | op = FETCH2; |
849 | goto dounbind; | |
850 | ||
3a4c8000 TT |
851 | CASE (Bunbind): |
852 | CASE (Bunbind1): | |
853 | CASE (Bunbind2): | |
854 | CASE (Bunbind3): | |
855 | CASE (Bunbind4): | |
856 | CASE (Bunbind5): | |
36f7ba0a JB |
857 | op -= Bunbind; |
858 | dounbind: | |
7ca1e8b7 | 859 | BEFORE_POTENTIAL_GC (); |
9f62b5dd BT |
860 | for (int i = 0; i < op; i++) |
861 | dynwind_end (); | |
7ca1e8b7 | 862 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 863 | NEXT; |
36f7ba0a | 864 | |
3a4c8000 | 865 | CASE (Bunbind_all): /* Obsolete. Never used. */ |
9f62b5dd | 866 | emacs_abort (); |
3a4c8000 | 867 | NEXT; |
36f7ba0a | 868 | |
3a4c8000 | 869 | CASE (Bgoto): |
14726871 | 870 | MAYBE_GC (); |
e12ea64e | 871 | BYTE_CODE_QUIT; |
36f7ba0a | 872 | op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ |
3d5fc37b | 873 | CHECK_RANGE (op); |
7ca1e8b7 | 874 | stack.pc = stack.byte_string_start + op; |
3a4c8000 | 875 | NEXT; |
36f7ba0a | 876 | |
3a4c8000 | 877 | CASE (Bgotoifnonnil): |
21ed6de3 KR |
878 | { |
879 | Lisp_Object v1; | |
880 | MAYBE_GC (); | |
881 | op = FETCH2; | |
882 | v1 = POP; | |
883 | if (!NILP (v1)) | |
884 | { | |
885 | BYTE_CODE_QUIT; | |
886 | CHECK_RANGE (op); | |
887 | stack.pc = stack.byte_string_start + op; | |
888 | } | |
3a4c8000 | 889 | NEXT; |
21ed6de3 | 890 | } |
36f7ba0a | 891 | |
3a4c8000 | 892 | CASE (Bgotoifnilelsepop): |
14726871 | 893 | MAYBE_GC (); |
36f7ba0a | 894 | op = FETCH2; |
921a8935 | 895 | if (NILP (TOP)) |
36f7ba0a | 896 | { |
e12ea64e | 897 | BYTE_CODE_QUIT; |
3d5fc37b | 898 | CHECK_RANGE (op); |
7ca1e8b7 | 899 | stack.pc = stack.byte_string_start + op; |
36f7ba0a | 900 | } |
63639d44 | 901 | else DISCARD (1); |
3a4c8000 | 902 | NEXT; |
36f7ba0a | 903 | |
3a4c8000 | 904 | CASE (Bgotoifnonnilelsepop): |
14726871 | 905 | MAYBE_GC (); |
36f7ba0a | 906 | op = FETCH2; |
921a8935 | 907 | if (!NILP (TOP)) |
36f7ba0a | 908 | { |
e12ea64e | 909 | BYTE_CODE_QUIT; |
3d5fc37b | 910 | CHECK_RANGE (op); |
7ca1e8b7 | 911 | stack.pc = stack.byte_string_start + op; |
36f7ba0a | 912 | } |
63639d44 | 913 | else DISCARD (1); |
3a4c8000 | 914 | NEXT; |
63639d44 | 915 | |
3a4c8000 | 916 | CASE (BRgoto): |
14726871 | 917 | MAYBE_GC (); |
e12ea64e | 918 | BYTE_CODE_QUIT; |
7ca1e8b7 | 919 | stack.pc += (int) *stack.pc - 127; |
3a4c8000 | 920 | NEXT; |
63639d44 | 921 | |
3a4c8000 | 922 | CASE (BRgotoifnil): |
21ed6de3 KR |
923 | { |
924 | Lisp_Object v1; | |
925 | MAYBE_GC (); | |
926 | v1 = POP; | |
927 | if (NILP (v1)) | |
928 | { | |
929 | BYTE_CODE_QUIT; | |
930 | stack.pc += (int) *stack.pc - 128; | |
931 | } | |
932 | stack.pc++; | |
3a4c8000 | 933 | NEXT; |
21ed6de3 | 934 | } |
63639d44 | 935 | |
3a4c8000 | 936 | CASE (BRgotoifnonnil): |
21ed6de3 KR |
937 | { |
938 | Lisp_Object v1; | |
939 | MAYBE_GC (); | |
940 | v1 = POP; | |
941 | if (!NILP (v1)) | |
942 | { | |
943 | BYTE_CODE_QUIT; | |
944 | stack.pc += (int) *stack.pc - 128; | |
945 | } | |
946 | stack.pc++; | |
3a4c8000 | 947 | NEXT; |
21ed6de3 | 948 | } |
63639d44 | 949 | |
3a4c8000 | 950 | CASE (BRgotoifnilelsepop): |
14726871 | 951 | MAYBE_GC (); |
7ca1e8b7 | 952 | op = *stack.pc++; |
63639d44 JB |
953 | if (NILP (TOP)) |
954 | { | |
e12ea64e | 955 | BYTE_CODE_QUIT; |
7ca1e8b7 | 956 | stack.pc += op - 128; |
63639d44 JB |
957 | } |
958 | else DISCARD (1); | |
3a4c8000 | 959 | NEXT; |
63639d44 | 960 | |
3a4c8000 | 961 | CASE (BRgotoifnonnilelsepop): |
14726871 | 962 | MAYBE_GC (); |
7ca1e8b7 | 963 | op = *stack.pc++; |
63639d44 JB |
964 | if (!NILP (TOP)) |
965 | { | |
e12ea64e | 966 | BYTE_CODE_QUIT; |
7ca1e8b7 | 967 | stack.pc += op - 128; |
63639d44 JB |
968 | } |
969 | else DISCARD (1); | |
3a4c8000 | 970 | NEXT; |
98bf0c8d | 971 | |
3a4c8000 | 972 | CASE (Breturn): |
4015b3c0 | 973 | result = POP; |
36f7ba0a JB |
974 | goto exit; |
975 | ||
3a4c8000 | 976 | CASE (Bdiscard): |
63639d44 | 977 | DISCARD (1); |
3a4c8000 | 978 | NEXT; |
36f7ba0a | 979 | |
3a4c8000 | 980 | CASE (Bconstant2): |
36f7ba0a | 981 | PUSH (vectorp[FETCH2]); |
3a4c8000 | 982 | NEXT; |
36f7ba0a | 983 | |
3a4c8000 | 984 | CASE (Bsave_excursion): |
9f62b5dd | 985 | dynwind_begin (); |
fa9aabf6 GM |
986 | record_unwind_protect (save_excursion_restore, |
987 | save_excursion_save ()); | |
3a4c8000 | 988 | NEXT; |
36f7ba0a | 989 | |
3a4c8000 TT |
990 | CASE (Bsave_current_buffer): /* Obsolete since ??. */ |
991 | CASE (Bsave_current_buffer_1): | |
9f62b5dd | 992 | dynwind_begin (); |
66322887 | 993 | record_unwind_current_buffer (); |
3a4c8000 | 994 | NEXT; |
3b841abc | 995 | |
3a4c8000 | 996 | CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ |
e0f57e65 | 997 | { |
9f62b5dd | 998 | dynwind_begin (); |
27e498e6 | 999 | record_unwind_protect (restore_window_configuration, |
e0f57e65 SM |
1000 | Fcurrent_window_configuration (Qnil)); |
1001 | BEFORE_POTENTIAL_GC (); | |
1002 | TOP = Fprogn (TOP); | |
9f62b5dd | 1003 | dynwind_end (); |
e0f57e65 | 1004 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1005 | NEXT; |
e0f57e65 | 1006 | } |
36f7ba0a | 1007 | |
3a4c8000 | 1008 | CASE (Bsave_restriction): |
9f62b5dd | 1009 | dynwind_begin (); |
fa9aabf6 GM |
1010 | record_unwind_protect (save_restriction_restore, |
1011 | save_restriction_save ()); | |
3a4c8000 | 1012 | NEXT; |
36f7ba0a | 1013 | |
adf2aa61 | 1014 | CASE (Bcatch): /* Obsolete since 24.4. */ |
4015b3c0 GM |
1015 | { |
1016 | Lisp_Object v1; | |
4015b3c0 | 1017 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1018 | v1 = POP; |
ca105506 | 1019 | TOP = internal_catch (TOP, eval_sub, v1); |
4015b3c0 | 1020 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1021 | NEXT; |
4015b3c0 | 1022 | } |
36f7ba0a | 1023 | |
adf2aa61 SM |
1024 | CASE (Bpushcatch): /* New in 24.4. */ |
1025 | type = CATCHER; | |
1026 | goto pushhandler; | |
1027 | CASE (Bpushconditioncase): /* New in 24.4. */ | |
1028 | { | |
1029 | extern EMACS_INT lisp_eval_depth; | |
1030 | extern int poll_suppress_count; | |
1031 | extern int interrupt_input_blocked; | |
1032 | struct handler *c; | |
1033 | Lisp_Object tag; | |
1034 | int dest; | |
1035 | ||
1036 | type = CONDITION_CASE; | |
1037 | pushhandler: | |
1038 | tag = POP; | |
1039 | dest = FETCH2; | |
1040 | ||
1041 | PUSH_HANDLER (c, tag, type); | |
1042 | c->bytecode_dest = dest; | |
1043 | c->bytecode_top = top; | |
157fec2e | 1044 | |
adf2aa61 SM |
1045 | if (sys_setjmp (c->jmp)) |
1046 | { | |
1047 | struct handler *c = handlerlist; | |
157fec2e | 1048 | int dest; |
adf2aa61 | 1049 | top = c->bytecode_top; |
157fec2e | 1050 | dest = c->bytecode_dest; |
adf2aa61 SM |
1051 | handlerlist = c->next; |
1052 | PUSH (c->val); | |
1053 | CHECK_RANGE (dest); | |
285d6d5d SM |
1054 | /* Might have been re-set by longjmp! */ |
1055 | stack.byte_string_start = SDATA (stack.byte_string); | |
adf2aa61 SM |
1056 | stack.pc = stack.byte_string_start + dest; |
1057 | } | |
157fec2e | 1058 | |
adf2aa61 SM |
1059 | NEXT; |
1060 | } | |
1061 | ||
1062 | CASE (Bpophandler): /* New in 24.4. */ | |
1063 | { | |
1064 | handlerlist = handlerlist->next; | |
1065 | NEXT; | |
1066 | } | |
1067 | ||
3a4c8000 | 1068 | CASE (Bunwind_protect): /* FIXME: avoid closure for lexbind. */ |
adf2aa61 SM |
1069 | { |
1070 | Lisp_Object handler = POP; | |
9f62b5dd | 1071 | dynwind_begin (); |
adf2aa61 SM |
1072 | /* Support for a function here is new in 24.4. */ |
1073 | record_unwind_protect (NILP (Ffunctionp (handler)) | |
1074 | ? unwind_body : bcall0, | |
1075 | handler); | |
1076 | NEXT; | |
1077 | } | |
36f7ba0a | 1078 | |
adf2aa61 | 1079 | CASE (Bcondition_case): /* Obsolete since 24.4. */ |
4015b3c0 | 1080 | { |
5c125a13 RS |
1081 | Lisp_Object handlers, body; |
1082 | handlers = POP; | |
1083 | body = POP; | |
4015b3c0 | 1084 | BEFORE_POTENTIAL_GC (); |
5c125a13 | 1085 | TOP = internal_lisp_condition_case (TOP, body, handlers); |
4015b3c0 | 1086 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1087 | NEXT; |
4015b3c0 | 1088 | } |
36f7ba0a | 1089 | |
3a4c8000 | 1090 | CASE (Btemp_output_buffer_setup): /* Obsolete since 24.1. */ |
4015b3c0 | 1091 | BEFORE_POTENTIAL_GC (); |
b7826503 | 1092 | CHECK_STRING (TOP); |
9f62b5dd | 1093 | dynwind_begin (); |
42a5b22f | 1094 | temp_output_buffer_setup (SSDATA (TOP)); |
4015b3c0 | 1095 | AFTER_POTENTIAL_GC (); |
36f7ba0a | 1096 | TOP = Vstandard_output; |
3a4c8000 | 1097 | NEXT; |
36f7ba0a | 1098 | |
3a4c8000 | 1099 | CASE (Btemp_output_buffer_show): /* Obsolete since 24.1. */ |
4015b3c0 GM |
1100 | { |
1101 | Lisp_Object v1; | |
4015b3c0 | 1102 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1103 | v1 = POP; |
4015b3c0 GM |
1104 | temp_output_buffer_show (TOP); |
1105 | TOP = v1; | |
1106 | /* pop binding of standard-output */ | |
9f62b5dd | 1107 | dynwind_end (); |
4015b3c0 | 1108 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1109 | NEXT; |
4015b3c0 | 1110 | } |
36f7ba0a | 1111 | |
3a4c8000 | 1112 | CASE (Bnth): |
4015b3c0 GM |
1113 | { |
1114 | Lisp_Object v1, v2; | |
d311d28c | 1115 | EMACS_INT n; |
bf1de43e | 1116 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1117 | v1 = POP; |
1118 | v2 = TOP; | |
b7826503 | 1119 | CHECK_NUMBER (v2); |
d311d28c | 1120 | n = XINT (v2); |
4015b3c0 | 1121 | immediate_quit = 1; |
d311d28c | 1122 | while (--n >= 0 && CONSP (v1)) |
14c5155a | 1123 | v1 = XCDR (v1); |
4015b3c0 | 1124 | immediate_quit = 0; |
14c5155a | 1125 | TOP = CAR (v1); |
1c470562 | 1126 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1127 | NEXT; |
4015b3c0 | 1128 | } |
36f7ba0a | 1129 | |
3a4c8000 | 1130 | CASE (Bsymbolp): |
617bd3f6 | 1131 | TOP = SYMBOLP (TOP) ? Qt : Qnil; |
3a4c8000 | 1132 | NEXT; |
36f7ba0a | 1133 | |
3a4c8000 | 1134 | CASE (Bconsp): |
36f7ba0a | 1135 | TOP = CONSP (TOP) ? Qt : Qnil; |
3a4c8000 | 1136 | NEXT; |
36f7ba0a | 1137 | |
3a4c8000 | 1138 | CASE (Bstringp): |
617bd3f6 | 1139 | TOP = STRINGP (TOP) ? Qt : Qnil; |
3a4c8000 | 1140 | NEXT; |
36f7ba0a | 1141 | |
3a4c8000 | 1142 | CASE (Blistp): |
921a8935 | 1143 | TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil; |
3a4c8000 | 1144 | NEXT; |
36f7ba0a | 1145 | |
3a4c8000 | 1146 | CASE (Bnot): |
921a8935 | 1147 | TOP = NILP (TOP) ? Qt : Qnil; |
3a4c8000 | 1148 | NEXT; |
36f7ba0a | 1149 | |
3a4c8000 | 1150 | CASE (Bcons): |
4015b3c0 GM |
1151 | { |
1152 | Lisp_Object v1; | |
1153 | v1 = POP; | |
1154 | TOP = Fcons (TOP, v1); | |
3a4c8000 | 1155 | NEXT; |
4015b3c0 | 1156 | } |
36f7ba0a | 1157 | |
3a4c8000 | 1158 | CASE (Blist1): |
6c6f1994 | 1159 | TOP = list1 (TOP); |
3a4c8000 | 1160 | NEXT; |
36f7ba0a | 1161 | |
3a4c8000 | 1162 | CASE (Blist2): |
4015b3c0 GM |
1163 | { |
1164 | Lisp_Object v1; | |
1165 | v1 = POP; | |
6c6f1994 | 1166 | TOP = list2 (TOP, v1); |
3a4c8000 | 1167 | NEXT; |
4015b3c0 | 1168 | } |
36f7ba0a | 1169 | |
3a4c8000 | 1170 | CASE (Blist3): |
63639d44 | 1171 | DISCARD (2); |
36f7ba0a | 1172 | TOP = Flist (3, &TOP); |
3a4c8000 | 1173 | NEXT; |
36f7ba0a | 1174 | |
3a4c8000 | 1175 | CASE (Blist4): |
63639d44 | 1176 | DISCARD (3); |
36f7ba0a | 1177 | TOP = Flist (4, &TOP); |
3a4c8000 | 1178 | NEXT; |
36f7ba0a | 1179 | |
3a4c8000 | 1180 | CASE (BlistN): |
63639d44 JB |
1181 | op = FETCH; |
1182 | DISCARD (op - 1); | |
1183 | TOP = Flist (op, &TOP); | |
3a4c8000 | 1184 | NEXT; |
63639d44 | 1185 | |
3a4c8000 | 1186 | CASE (Blength): |
bf1de43e | 1187 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1188 | TOP = Flength (TOP); |
bf1de43e | 1189 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1190 | NEXT; |
36f7ba0a | 1191 | |
3a4c8000 | 1192 | CASE (Baref): |
4015b3c0 GM |
1193 | { |
1194 | Lisp_Object v1; | |
bf1de43e | 1195 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1196 | v1 = POP; |
1197 | TOP = Faref (TOP, v1); | |
bf1de43e | 1198 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1199 | NEXT; |
4015b3c0 | 1200 | } |
36f7ba0a | 1201 | |
3a4c8000 | 1202 | CASE (Baset): |
4015b3c0 GM |
1203 | { |
1204 | Lisp_Object v1, v2; | |
bf1de43e | 1205 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1206 | v2 = POP; v1 = POP; |
1207 | TOP = Faset (TOP, v1, v2); | |
bf1de43e | 1208 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1209 | NEXT; |
4015b3c0 | 1210 | } |
36f7ba0a | 1211 | |
3a4c8000 | 1212 | CASE (Bsymbol_value): |
bf1de43e | 1213 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1214 | TOP = Fsymbol_value (TOP); |
bf1de43e | 1215 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1216 | NEXT; |
36f7ba0a | 1217 | |
3a4c8000 | 1218 | CASE (Bsymbol_function): |
bf1de43e | 1219 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1220 | TOP = Fsymbol_function (TOP); |
bf1de43e | 1221 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1222 | NEXT; |
36f7ba0a | 1223 | |
3a4c8000 | 1224 | CASE (Bset): |
4015b3c0 GM |
1225 | { |
1226 | Lisp_Object v1; | |
bf1de43e | 1227 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1228 | v1 = POP; |
1229 | TOP = Fset (TOP, v1); | |
bf1de43e | 1230 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1231 | NEXT; |
4015b3c0 | 1232 | } |
36f7ba0a | 1233 | |
3a4c8000 | 1234 | CASE (Bfset): |
4015b3c0 GM |
1235 | { |
1236 | Lisp_Object v1; | |
bf1de43e | 1237 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1238 | v1 = POP; |
1239 | TOP = Ffset (TOP, v1); | |
bf1de43e | 1240 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1241 | NEXT; |
4015b3c0 | 1242 | } |
36f7ba0a | 1243 | |
3a4c8000 | 1244 | CASE (Bget): |
4015b3c0 GM |
1245 | { |
1246 | Lisp_Object v1; | |
bf1de43e | 1247 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1248 | v1 = POP; |
1249 | TOP = Fget (TOP, v1); | |
bf1de43e | 1250 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1251 | NEXT; |
4015b3c0 | 1252 | } |
36f7ba0a | 1253 | |
3a4c8000 | 1254 | CASE (Bsubstring): |
4015b3c0 GM |
1255 | { |
1256 | Lisp_Object v1, v2; | |
fa9aabf6 | 1257 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1258 | v2 = POP; v1 = POP; |
4015b3c0 | 1259 | TOP = Fsubstring (TOP, v1, v2); |
fa9aabf6 | 1260 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1261 | NEXT; |
4015b3c0 | 1262 | } |
36f7ba0a | 1263 | |
3a4c8000 | 1264 | CASE (Bconcat2): |
bf1de43e | 1265 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1266 | DISCARD (1); |
36f7ba0a | 1267 | TOP = Fconcat (2, &TOP); |
bf1de43e | 1268 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1269 | NEXT; |
36f7ba0a | 1270 | |
3a4c8000 | 1271 | CASE (Bconcat3): |
bf1de43e | 1272 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1273 | DISCARD (2); |
36f7ba0a | 1274 | TOP = Fconcat (3, &TOP); |
bf1de43e | 1275 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1276 | NEXT; |
36f7ba0a | 1277 | |
3a4c8000 | 1278 | CASE (Bconcat4): |
bf1de43e | 1279 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1280 | DISCARD (3); |
36f7ba0a | 1281 | TOP = Fconcat (4, &TOP); |
bf1de43e | 1282 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1283 | NEXT; |
36f7ba0a | 1284 | |
3a4c8000 | 1285 | CASE (BconcatN): |
63639d44 | 1286 | op = FETCH; |
bf1de43e | 1287 | BEFORE_POTENTIAL_GC (); |
63639d44 JB |
1288 | DISCARD (op - 1); |
1289 | TOP = Fconcat (op, &TOP); | |
bf1de43e | 1290 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1291 | NEXT; |
63639d44 | 1292 | |
3a4c8000 | 1293 | CASE (Bsub1): |
4015b3c0 GM |
1294 | { |
1295 | Lisp_Object v1; | |
1296 | v1 = TOP; | |
1297 | if (INTEGERP (v1)) | |
1298 | { | |
1299 | XSETINT (v1, XINT (v1) - 1); | |
1300 | TOP = v1; | |
1301 | } | |
1302 | else | |
e494eee5 MB |
1303 | { |
1304 | BEFORE_POTENTIAL_GC (); | |
1305 | TOP = Fsub1 (v1); | |
1306 | AFTER_POTENTIAL_GC (); | |
1307 | } | |
3a4c8000 | 1308 | NEXT; |
4015b3c0 | 1309 | } |
36f7ba0a | 1310 | |
3a4c8000 | 1311 | CASE (Badd1): |
4015b3c0 GM |
1312 | { |
1313 | Lisp_Object v1; | |
1314 | v1 = TOP; | |
1315 | if (INTEGERP (v1)) | |
1316 | { | |
1317 | XSETINT (v1, XINT (v1) + 1); | |
1318 | TOP = v1; | |
1319 | } | |
1320 | else | |
bf1de43e GM |
1321 | { |
1322 | BEFORE_POTENTIAL_GC (); | |
1323 | TOP = Fadd1 (v1); | |
1324 | AFTER_POTENTIAL_GC (); | |
1325 | } | |
3a4c8000 | 1326 | NEXT; |
4015b3c0 | 1327 | } |
36f7ba0a | 1328 | |
3a4c8000 | 1329 | CASE (Beqlsign): |
4015b3c0 GM |
1330 | { |
1331 | Lisp_Object v1, v2; | |
f5941bf8 | 1332 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1333 | v2 = POP; v1 = TOP; |
b7826503 PJ |
1334 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1); |
1335 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2); | |
f5941bf8 | 1336 | AFTER_POTENTIAL_GC (); |
4015b3c0 GM |
1337 | if (FLOATP (v1) || FLOATP (v2)) |
1338 | { | |
1339 | double f1, f2; | |
1340 | ||
1341 | f1 = (FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1)); | |
1342 | f2 = (FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2)); | |
1343 | TOP = (f1 == f2 ? Qt : Qnil); | |
1344 | } | |
1345 | else | |
4015b3c0 | 1346 | TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil); |
3a4c8000 | 1347 | NEXT; |
4015b3c0 | 1348 | } |
36f7ba0a | 1349 | |
3a4c8000 | 1350 | CASE (Bgtr): |
4015b3c0 GM |
1351 | { |
1352 | Lisp_Object v1; | |
bf1de43e | 1353 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1354 | v1 = POP; |
ebb99847 | 1355 | TOP = arithcompare (TOP, v1, ARITH_GRTR); |
bf1de43e | 1356 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1357 | NEXT; |
4015b3c0 | 1358 | } |
36f7ba0a | 1359 | |
3a4c8000 | 1360 | CASE (Blss): |
4015b3c0 GM |
1361 | { |
1362 | Lisp_Object v1; | |
bf1de43e | 1363 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1364 | v1 = POP; |
ebb99847 | 1365 | TOP = arithcompare (TOP, v1, ARITH_LESS); |
bf1de43e | 1366 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1367 | NEXT; |
4015b3c0 | 1368 | } |
36f7ba0a | 1369 | |
3a4c8000 | 1370 | CASE (Bleq): |
4015b3c0 GM |
1371 | { |
1372 | Lisp_Object v1; | |
bf1de43e | 1373 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1374 | v1 = POP; |
ebb99847 | 1375 | TOP = arithcompare (TOP, v1, ARITH_LESS_OR_EQUAL); |
bf1de43e | 1376 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1377 | NEXT; |
4015b3c0 | 1378 | } |
36f7ba0a | 1379 | |
3a4c8000 | 1380 | CASE (Bgeq): |
4015b3c0 GM |
1381 | { |
1382 | Lisp_Object v1; | |
d9c1f6f9 | 1383 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1384 | v1 = POP; |
ebb99847 | 1385 | TOP = arithcompare (TOP, v1, ARITH_GRTR_OR_EQUAL); |
d9c1f6f9 | 1386 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1387 | NEXT; |
4015b3c0 | 1388 | } |
36f7ba0a | 1389 | |
3a4c8000 | 1390 | CASE (Bdiff): |
bf1de43e | 1391 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1392 | DISCARD (1); |
36f7ba0a | 1393 | TOP = Fminus (2, &TOP); |
bf1de43e | 1394 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1395 | NEXT; |
36f7ba0a | 1396 | |
3a4c8000 | 1397 | CASE (Bnegate): |
4015b3c0 GM |
1398 | { |
1399 | Lisp_Object v1; | |
1400 | v1 = TOP; | |
1401 | if (INTEGERP (v1)) | |
1402 | { | |
1403 | XSETINT (v1, - XINT (v1)); | |
1404 | TOP = v1; | |
1405 | } | |
1406 | else | |
bf1de43e GM |
1407 | { |
1408 | BEFORE_POTENTIAL_GC (); | |
1409 | TOP = Fminus (1, &TOP); | |
1410 | AFTER_POTENTIAL_GC (); | |
1411 | } | |
3a4c8000 | 1412 | NEXT; |
4015b3c0 | 1413 | } |
36f7ba0a | 1414 | |
3a4c8000 | 1415 | CASE (Bplus): |
bf1de43e | 1416 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1417 | DISCARD (1); |
36f7ba0a | 1418 | TOP = Fplus (2, &TOP); |
bf1de43e | 1419 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1420 | NEXT; |
36f7ba0a | 1421 | |
3a4c8000 | 1422 | CASE (Bmax): |
bf1de43e | 1423 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1424 | DISCARD (1); |
36f7ba0a | 1425 | TOP = Fmax (2, &TOP); |
bf1de43e | 1426 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1427 | NEXT; |
36f7ba0a | 1428 | |
3a4c8000 | 1429 | CASE (Bmin): |
bf1de43e | 1430 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1431 | DISCARD (1); |
36f7ba0a | 1432 | TOP = Fmin (2, &TOP); |
bf1de43e | 1433 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1434 | NEXT; |
36f7ba0a | 1435 | |
3a4c8000 | 1436 | CASE (Bmult): |
bf1de43e | 1437 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1438 | DISCARD (1); |
36f7ba0a | 1439 | TOP = Ftimes (2, &TOP); |
bf1de43e | 1440 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1441 | NEXT; |
36f7ba0a | 1442 | |
3a4c8000 | 1443 | CASE (Bquo): |
bf1de43e | 1444 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1445 | DISCARD (1); |
36f7ba0a | 1446 | TOP = Fquo (2, &TOP); |
bf1de43e | 1447 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1448 | NEXT; |
36f7ba0a | 1449 | |
3a4c8000 | 1450 | CASE (Brem): |
4015b3c0 GM |
1451 | { |
1452 | Lisp_Object v1; | |
bf1de43e | 1453 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1454 | v1 = POP; |
1455 | TOP = Frem (TOP, v1); | |
bf1de43e | 1456 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1457 | NEXT; |
4015b3c0 | 1458 | } |
36f7ba0a | 1459 | |
3a4c8000 | 1460 | CASE (Bpoint): |
4015b3c0 GM |
1461 | { |
1462 | Lisp_Object v1; | |
1463 | XSETFASTINT (v1, PT); | |
1464 | PUSH (v1); | |
3a4c8000 | 1465 | NEXT; |
4015b3c0 | 1466 | } |
36f7ba0a | 1467 | |
3a4c8000 | 1468 | CASE (Bgoto_char): |
4015b3c0 | 1469 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1470 | TOP = Fgoto_char (TOP); |
4015b3c0 | 1471 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1472 | NEXT; |
36f7ba0a | 1473 | |
3a4c8000 | 1474 | CASE (Binsert): |
4015b3c0 | 1475 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1476 | TOP = Finsert (1, &TOP); |
4015b3c0 | 1477 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1478 | NEXT; |
36f7ba0a | 1479 | |
3a4c8000 | 1480 | CASE (BinsertN): |
63639d44 | 1481 | op = FETCH; |
4015b3c0 | 1482 | BEFORE_POTENTIAL_GC (); |
fa9aabf6 | 1483 | DISCARD (op - 1); |
63639d44 | 1484 | TOP = Finsert (op, &TOP); |
4015b3c0 | 1485 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1486 | NEXT; |
63639d44 | 1487 | |
3a4c8000 | 1488 | CASE (Bpoint_max): |
4015b3c0 GM |
1489 | { |
1490 | Lisp_Object v1; | |
1491 | XSETFASTINT (v1, ZV); | |
1492 | PUSH (v1); | |
3a4c8000 | 1493 | NEXT; |
4015b3c0 | 1494 | } |
36f7ba0a | 1495 | |
3a4c8000 | 1496 | CASE (Bpoint_min): |
4015b3c0 GM |
1497 | { |
1498 | Lisp_Object v1; | |
1499 | XSETFASTINT (v1, BEGV); | |
1500 | PUSH (v1); | |
3a4c8000 | 1501 | NEXT; |
4015b3c0 | 1502 | } |
36f7ba0a | 1503 | |
3a4c8000 | 1504 | CASE (Bchar_after): |
bf1de43e | 1505 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1506 | TOP = Fchar_after (TOP); |
bf1de43e | 1507 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1508 | NEXT; |
36f7ba0a | 1509 | |
3a4c8000 | 1510 | CASE (Bfollowing_char): |
4015b3c0 GM |
1511 | { |
1512 | Lisp_Object v1; | |
bf1de43e | 1513 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1514 | v1 = Ffollowing_char (); |
bf1de43e | 1515 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1516 | PUSH (v1); |
3a4c8000 | 1517 | NEXT; |
4015b3c0 | 1518 | } |
36f7ba0a | 1519 | |
3a4c8000 | 1520 | CASE (Bpreceding_char): |
4015b3c0 GM |
1521 | { |
1522 | Lisp_Object v1; | |
bf1de43e | 1523 | BEFORE_POTENTIAL_GC (); |
4015b3c0 | 1524 | v1 = Fprevious_char (); |
bf1de43e | 1525 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1526 | PUSH (v1); |
3a4c8000 | 1527 | NEXT; |
4015b3c0 | 1528 | } |
36f7ba0a | 1529 | |
3a4c8000 | 1530 | CASE (Bcurrent_column): |
4015b3c0 GM |
1531 | { |
1532 | Lisp_Object v1; | |
96111f48 | 1533 | BEFORE_POTENTIAL_GC (); |
7831777b | 1534 | XSETFASTINT (v1, current_column ()); |
96111f48 | 1535 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1536 | PUSH (v1); |
3a4c8000 | 1537 | NEXT; |
4015b3c0 | 1538 | } |
36f7ba0a | 1539 | |
3a4c8000 | 1540 | CASE (Bindent_to): |
4015b3c0 | 1541 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1542 | TOP = Findent_to (TOP, Qnil); |
4015b3c0 | 1543 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1544 | NEXT; |
36f7ba0a | 1545 | |
3a4c8000 | 1546 | CASE (Beolp): |
36f7ba0a | 1547 | PUSH (Feolp ()); |
3a4c8000 | 1548 | NEXT; |
36f7ba0a | 1549 | |
3a4c8000 | 1550 | CASE (Beobp): |
36f7ba0a | 1551 | PUSH (Feobp ()); |
3a4c8000 | 1552 | NEXT; |
36f7ba0a | 1553 | |
3a4c8000 | 1554 | CASE (Bbolp): |
36f7ba0a | 1555 | PUSH (Fbolp ()); |
3a4c8000 | 1556 | NEXT; |
36f7ba0a | 1557 | |
3a4c8000 | 1558 | CASE (Bbobp): |
36f7ba0a | 1559 | PUSH (Fbobp ()); |
3a4c8000 | 1560 | NEXT; |
36f7ba0a | 1561 | |
3a4c8000 | 1562 | CASE (Bcurrent_buffer): |
36f7ba0a | 1563 | PUSH (Fcurrent_buffer ()); |
3a4c8000 | 1564 | NEXT; |
36f7ba0a | 1565 | |
3a4c8000 | 1566 | CASE (Bset_buffer): |
4015b3c0 | 1567 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1568 | TOP = Fset_buffer (TOP); |
4015b3c0 | 1569 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1570 | NEXT; |
36f7ba0a | 1571 | |
3a4c8000 | 1572 | CASE (Binteractive_p): /* Obsolete since 24.1. */ |
23ba2705 SM |
1573 | BEFORE_POTENTIAL_GC (); |
1574 | PUSH (call0 (intern ("interactive-p"))); | |
1575 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1576 | NEXT; |
36f7ba0a | 1577 | |
3a4c8000 | 1578 | CASE (Bforward_char): |
4015b3c0 | 1579 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1580 | TOP = Fforward_char (TOP); |
4015b3c0 | 1581 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1582 | NEXT; |
36f7ba0a | 1583 | |
3a4c8000 | 1584 | CASE (Bforward_word): |
4015b3c0 | 1585 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1586 | TOP = Fforward_word (TOP); |
4015b3c0 | 1587 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1588 | NEXT; |
36f7ba0a | 1589 | |
3a4c8000 | 1590 | CASE (Bskip_chars_forward): |
4015b3c0 GM |
1591 | { |
1592 | Lisp_Object v1; | |
4015b3c0 | 1593 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1594 | v1 = POP; |
4015b3c0 GM |
1595 | TOP = Fskip_chars_forward (TOP, v1); |
1596 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1597 | NEXT; |
4015b3c0 | 1598 | } |
36f7ba0a | 1599 | |
3a4c8000 | 1600 | CASE (Bskip_chars_backward): |
4015b3c0 GM |
1601 | { |
1602 | Lisp_Object v1; | |
4015b3c0 | 1603 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1604 | v1 = POP; |
4015b3c0 GM |
1605 | TOP = Fskip_chars_backward (TOP, v1); |
1606 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1607 | NEXT; |
4015b3c0 | 1608 | } |
36f7ba0a | 1609 | |
3a4c8000 | 1610 | CASE (Bforward_line): |
4015b3c0 | 1611 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1612 | TOP = Fforward_line (TOP); |
4015b3c0 | 1613 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1614 | NEXT; |
36f7ba0a | 1615 | |
3a4c8000 | 1616 | CASE (Bchar_syntax): |
9281d077 KH |
1617 | { |
1618 | int c; | |
1619 | ||
1620 | BEFORE_POTENTIAL_GC (); | |
1621 | CHECK_CHARACTER (TOP); | |
1622 | AFTER_POTENTIAL_GC (); | |
1623 | c = XFASTINT (TOP); | |
4b4deea2 | 1624 | if (NILP (BVAR (current_buffer, enable_multibyte_characters))) |
9281d077 | 1625 | MAKE_CHAR_MULTIBYTE (c); |
1fc71008 | 1626 | XSETFASTINT (TOP, syntax_code_spec[SYNTAX (c)]); |
8f924df7 | 1627 | } |
3a4c8000 | 1628 | NEXT; |
36f7ba0a | 1629 | |
3a4c8000 | 1630 | CASE (Bbuffer_substring): |
4015b3c0 GM |
1631 | { |
1632 | Lisp_Object v1; | |
4015b3c0 | 1633 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1634 | v1 = POP; |
4015b3c0 GM |
1635 | TOP = Fbuffer_substring (TOP, v1); |
1636 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1637 | NEXT; |
4015b3c0 | 1638 | } |
36f7ba0a | 1639 | |
3a4c8000 | 1640 | CASE (Bdelete_region): |
4015b3c0 GM |
1641 | { |
1642 | Lisp_Object v1; | |
4015b3c0 | 1643 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1644 | v1 = POP; |
4015b3c0 GM |
1645 | TOP = Fdelete_region (TOP, v1); |
1646 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1647 | NEXT; |
4015b3c0 | 1648 | } |
36f7ba0a | 1649 | |
3a4c8000 | 1650 | CASE (Bnarrow_to_region): |
4015b3c0 GM |
1651 | { |
1652 | Lisp_Object v1; | |
4015b3c0 | 1653 | BEFORE_POTENTIAL_GC (); |
bf1de43e | 1654 | v1 = POP; |
4015b3c0 GM |
1655 | TOP = Fnarrow_to_region (TOP, v1); |
1656 | AFTER_POTENTIAL_GC (); | |
3a4c8000 | 1657 | NEXT; |
4015b3c0 | 1658 | } |
36f7ba0a | 1659 | |
3a4c8000 | 1660 | CASE (Bwiden): |
4015b3c0 | 1661 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1662 | PUSH (Fwiden ()); |
4015b3c0 | 1663 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1664 | NEXT; |
36f7ba0a | 1665 | |
3a4c8000 | 1666 | CASE (Bend_of_line): |
4015b3c0 | 1667 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1668 | TOP = Fend_of_line (TOP); |
4015b3c0 | 1669 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1670 | NEXT; |
63639d44 | 1671 | |
3a4c8000 | 1672 | CASE (Bset_marker): |
4015b3c0 GM |
1673 | { |
1674 | Lisp_Object v1, v2; | |
bf1de43e | 1675 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1676 | v1 = POP; |
1677 | v2 = POP; | |
1678 | TOP = Fset_marker (TOP, v2, v1); | |
bf1de43e | 1679 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1680 | NEXT; |
4015b3c0 | 1681 | } |
63639d44 | 1682 | |
3a4c8000 | 1683 | CASE (Bmatch_beginning): |
bf1de43e | 1684 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1685 | TOP = Fmatch_beginning (TOP); |
bf1de43e | 1686 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1687 | NEXT; |
63639d44 | 1688 | |
3a4c8000 | 1689 | CASE (Bmatch_end): |
bf1de43e | 1690 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1691 | TOP = Fmatch_end (TOP); |
bf1de43e | 1692 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1693 | NEXT; |
63639d44 | 1694 | |
3a4c8000 | 1695 | CASE (Bupcase): |
bf1de43e | 1696 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1697 | TOP = Fupcase (TOP); |
bf1de43e | 1698 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1699 | NEXT; |
63639d44 | 1700 | |
3a4c8000 | 1701 | CASE (Bdowncase): |
bf1de43e | 1702 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1703 | TOP = Fdowncase (TOP); |
bf1de43e | 1704 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1705 | NEXT; |
63639d44 | 1706 | |
3a4c8000 | 1707 | CASE (Bstringeqlsign): |
4015b3c0 GM |
1708 | { |
1709 | Lisp_Object v1; | |
bf1de43e | 1710 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1711 | v1 = POP; |
1712 | TOP = Fstring_equal (TOP, v1); | |
bf1de43e | 1713 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1714 | NEXT; |
4015b3c0 | 1715 | } |
36f7ba0a | 1716 | |
3a4c8000 | 1717 | CASE (Bstringlss): |
4015b3c0 GM |
1718 | { |
1719 | Lisp_Object v1; | |
bf1de43e | 1720 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1721 | v1 = POP; |
1722 | TOP = Fstring_lessp (TOP, v1); | |
bf1de43e | 1723 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1724 | NEXT; |
4015b3c0 | 1725 | } |
36f7ba0a | 1726 | |
3a4c8000 | 1727 | CASE (Bequal): |
4015b3c0 GM |
1728 | { |
1729 | Lisp_Object v1; | |
1730 | v1 = POP; | |
1731 | TOP = Fequal (TOP, v1); | |
3a4c8000 | 1732 | NEXT; |
4015b3c0 | 1733 | } |
36f7ba0a | 1734 | |
3a4c8000 | 1735 | CASE (Bnthcdr): |
4015b3c0 GM |
1736 | { |
1737 | Lisp_Object v1; | |
bf1de43e | 1738 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1739 | v1 = POP; |
1740 | TOP = Fnthcdr (TOP, v1); | |
bf1de43e | 1741 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1742 | NEXT; |
4015b3c0 | 1743 | } |
36f7ba0a | 1744 | |
3a4c8000 | 1745 | CASE (Belt): |
4015b3c0 GM |
1746 | { |
1747 | Lisp_Object v1, v2; | |
1748 | if (CONSP (TOP)) | |
1749 | { | |
1750 | /* Exchange args and then do nth. */ | |
d311d28c | 1751 | EMACS_INT n; |
bf1de43e | 1752 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1753 | v2 = POP; |
1754 | v1 = TOP; | |
b7826503 | 1755 | CHECK_NUMBER (v2); |
f5941bf8 | 1756 | AFTER_POTENTIAL_GC (); |
d311d28c | 1757 | n = XINT (v2); |
4015b3c0 | 1758 | immediate_quit = 1; |
d311d28c | 1759 | while (--n >= 0 && CONSP (v1)) |
14c5155a | 1760 | v1 = XCDR (v1); |
4015b3c0 | 1761 | immediate_quit = 0; |
14c5155a | 1762 | TOP = CAR (v1); |
4015b3c0 GM |
1763 | } |
1764 | else | |
1765 | { | |
bf1de43e | 1766 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1767 | v1 = POP; |
1768 | TOP = Felt (TOP, v1); | |
bf1de43e | 1769 | AFTER_POTENTIAL_GC (); |
4015b3c0 | 1770 | } |
3a4c8000 | 1771 | NEXT; |
4015b3c0 | 1772 | } |
36f7ba0a | 1773 | |
3a4c8000 | 1774 | CASE (Bmember): |
4015b3c0 GM |
1775 | { |
1776 | Lisp_Object v1; | |
bf1de43e | 1777 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1778 | v1 = POP; |
1779 | TOP = Fmember (TOP, v1); | |
bf1de43e | 1780 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1781 | NEXT; |
4015b3c0 | 1782 | } |
36f7ba0a | 1783 | |
3a4c8000 | 1784 | CASE (Bassq): |
4015b3c0 GM |
1785 | { |
1786 | Lisp_Object v1; | |
bf1de43e | 1787 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1788 | v1 = POP; |
1789 | TOP = Fassq (TOP, v1); | |
bf1de43e | 1790 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1791 | NEXT; |
4015b3c0 | 1792 | } |
36f7ba0a | 1793 | |
3a4c8000 | 1794 | CASE (Bnreverse): |
bf1de43e | 1795 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1796 | TOP = Fnreverse (TOP); |
bf1de43e | 1797 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1798 | NEXT; |
36f7ba0a | 1799 | |
3a4c8000 | 1800 | CASE (Bsetcar): |
4015b3c0 GM |
1801 | { |
1802 | Lisp_Object v1; | |
bf1de43e | 1803 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1804 | v1 = POP; |
1805 | TOP = Fsetcar (TOP, v1); | |
bf1de43e | 1806 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1807 | NEXT; |
4015b3c0 | 1808 | } |
36f7ba0a | 1809 | |
3a4c8000 | 1810 | CASE (Bsetcdr): |
4015b3c0 GM |
1811 | { |
1812 | Lisp_Object v1; | |
bf1de43e | 1813 | BEFORE_POTENTIAL_GC (); |
4015b3c0 GM |
1814 | v1 = POP; |
1815 | TOP = Fsetcdr (TOP, v1); | |
bf1de43e | 1816 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1817 | NEXT; |
4015b3c0 | 1818 | } |
36f7ba0a | 1819 | |
3a4c8000 | 1820 | CASE (Bcar_safe): |
4015b3c0 GM |
1821 | { |
1822 | Lisp_Object v1; | |
1823 | v1 = TOP; | |
14c5155a | 1824 | TOP = CAR_SAFE (v1); |
3a4c8000 | 1825 | NEXT; |
4015b3c0 | 1826 | } |
36f7ba0a | 1827 | |
3a4c8000 | 1828 | CASE (Bcdr_safe): |
4015b3c0 GM |
1829 | { |
1830 | Lisp_Object v1; | |
1831 | v1 = TOP; | |
14c5155a | 1832 | TOP = CDR_SAFE (v1); |
3a4c8000 | 1833 | NEXT; |
4015b3c0 | 1834 | } |
36f7ba0a | 1835 | |
3a4c8000 | 1836 | CASE (Bnconc): |
bf1de43e | 1837 | BEFORE_POTENTIAL_GC (); |
63639d44 | 1838 | DISCARD (1); |
36f7ba0a | 1839 | TOP = Fnconc (2, &TOP); |
bf1de43e | 1840 | AFTER_POTENTIAL_GC (); |
3a4c8000 | 1841 | NEXT; |
36f7ba0a | 1842 | |
3a4c8000 | 1843 | CASE (Bnumberp): |
63639d44 | 1844 | TOP = (NUMBERP (TOP) ? Qt : Qnil); |
3a4c8000 | 1845 | NEXT; |
36f7ba0a | 1846 | |
3a4c8000 | 1847 | CASE (Bintegerp): |
617bd3f6 | 1848 | TOP = INTEGERP (TOP) ? Qt : Qnil; |
3a4c8000 | 1849 | NEXT; |
36f7ba0a JB |
1850 | |
1851 | #ifdef BYTE_CODE_SAFE | |
3a4c8000 TT |
1852 | /* These are intentionally written using 'case' syntax, |
1853 | because they are incompatible with the threaded | |
1854 | interpreter. */ | |
1855 | ||
36f7ba0a | 1856 | case Bset_mark: |
f5941bf8 | 1857 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1858 | error ("set-mark is an obsolete bytecode"); |
f5941bf8 | 1859 | AFTER_POTENTIAL_GC (); |
36f7ba0a JB |
1860 | break; |
1861 | case Bscan_buffer: | |
f5941bf8 | 1862 | BEFORE_POTENTIAL_GC (); |
36f7ba0a | 1863 | error ("scan-buffer is an obsolete bytecode"); |
f5941bf8 | 1864 | AFTER_POTENTIAL_GC (); |
36f7ba0a | 1865 | break; |
36f7ba0a JB |
1866 | #endif |
1867 | ||
3a4c8000 | 1868 | CASE_ABORT: |
876c194c SM |
1869 | /* Actually this is Bstack_ref with offset 0, but we use Bdup |
1870 | for that instead. */ | |
3a4c8000 | 1871 | /* CASE (Bstack_ref): */ |
adf2aa61 SM |
1872 | call3 (intern ("error"), |
1873 | build_string ("Invalid byte opcode: op=%s, ptr=%d"), | |
1874 | make_number (op), | |
1875 | make_number ((stack.pc - 1) - stack.byte_string_start)); | |
c96d71f7 | 1876 | |
b9598260 | 1877 | /* Handy byte-codes for lexical binding. */ |
3a4c8000 TT |
1878 | CASE (Bstack_ref1): |
1879 | CASE (Bstack_ref2): | |
1880 | CASE (Bstack_ref3): | |
1881 | CASE (Bstack_ref4): | |
1882 | CASE (Bstack_ref5): | |
3e21b6a7 SM |
1883 | { |
1884 | Lisp_Object *ptr = top - (op - Bstack_ref); | |
1885 | PUSH (*ptr); | |
3a4c8000 | 1886 | NEXT; |
3e21b6a7 | 1887 | } |
3a4c8000 | 1888 | CASE (Bstack_ref6): |
3e21b6a7 SM |
1889 | { |
1890 | Lisp_Object *ptr = top - (FETCH); | |
1891 | PUSH (*ptr); | |
3a4c8000 | 1892 | NEXT; |
3e21b6a7 | 1893 | } |
3a4c8000 | 1894 | CASE (Bstack_ref7): |
3e21b6a7 SM |
1895 | { |
1896 | Lisp_Object *ptr = top - (FETCH2); | |
1897 | PUSH (*ptr); | |
3a4c8000 | 1898 | NEXT; |
3e21b6a7 | 1899 | } |
3a4c8000 | 1900 | CASE (Bstack_set): |
2462470b | 1901 | /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */ |
3e21b6a7 SM |
1902 | { |
1903 | Lisp_Object *ptr = top - (FETCH); | |
1904 | *ptr = POP; | |
3a4c8000 | 1905 | NEXT; |
3e21b6a7 | 1906 | } |
3a4c8000 | 1907 | CASE (Bstack_set2): |
3e21b6a7 SM |
1908 | { |
1909 | Lisp_Object *ptr = top - (FETCH2); | |
1910 | *ptr = POP; | |
3a4c8000 | 1911 | NEXT; |
3e21b6a7 | 1912 | } |
3a4c8000 | 1913 | CASE (BdiscardN): |
b9598260 SM |
1914 | op = FETCH; |
1915 | if (op & 0x80) | |
1916 | { | |
1917 | op &= 0x7F; | |
1918 | top[-op] = TOP; | |
1919 | } | |
1920 | DISCARD (op); | |
3a4c8000 | 1921 | NEXT; |
c96d71f7 | 1922 | |
3a4c8000 TT |
1923 | CASE_DEFAULT |
1924 | CASE (Bconstant): | |
36f7ba0a JB |
1925 | #ifdef BYTE_CODE_SAFE |
1926 | if (op < Bconstant) | |
f5941bf8 | 1927 | { |
1088b922 | 1928 | emacs_abort (); |
f5941bf8 | 1929 | } |
36f7ba0a | 1930 | if ((op -= Bconstant) >= const_length) |
f5941bf8 | 1931 | { |
1088b922 | 1932 | emacs_abort (); |
f5941bf8 | 1933 | } |
36f7ba0a JB |
1934 | PUSH (vectorp[op]); |
1935 | #else | |
1936 | PUSH (vectorp[op - Bconstant]); | |
1937 | #endif | |
3a4c8000 | 1938 | NEXT; |
36f7ba0a JB |
1939 | } |
1940 | } | |
1941 | ||
1942 | exit: | |
7ca1e8b7 | 1943 | |
36f7ba0a | 1944 | /* Binds and unbinds are supposed to be compiled balanced. */ |
aed13378 | 1945 | if (SPECPDL_INDEX () != count) |
adf2aa61 SM |
1946 | { |
1947 | if (SPECPDL_INDEX () > count) | |
1948 | unbind_to (count, Qnil); | |
1949 | error ("binding stack not balanced (serious byte compiler bug)"); | |
1950 | } | |
8e11578b | 1951 | |
4015b3c0 | 1952 | return result; |
36f7ba0a JB |
1953 | } |
1954 | ||
dfcf069d | 1955 | void |
971de7fb | 1956 | syms_of_bytecode (void) |
36f7ba0a | 1957 | { |
fe6aa7a1 | 1958 | #include "bytecode.x" |
36f7ba0a JB |
1959 | |
1960 | #ifdef BYTE_CODE_METER | |
1961 | ||
29208e82 | 1962 | DEFVAR_LISP ("byte-code-meter", Vbyte_code_meter, |
39f624fa PJ |
1963 | doc: /* A vector of vectors which holds a histogram of byte-code usage. |
1964 | \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte | |
1965 | opcode CODE has been executed. | |
1966 | \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0, | |
1967 | indicates how many times the byte opcodes CODE1 and CODE2 have been | |
1968 | executed in succession. */); | |
8e11578b | 1969 | |
29208e82 | 1970 | DEFVAR_BOOL ("byte-metering-on", byte_metering_on, |
39f624fa PJ |
1971 | doc: /* If non-nil, keep profiling information on byte code usage. |
1972 | The variable byte-code-meter indicates how often each byte opcode is used. | |
1973 | If a symbol has a property named `byte-code-meter' whose value is an | |
1974 | integer, it is incremented each time that symbol's function is called. */); | |
36f7ba0a JB |
1975 | |
1976 | byte_metering_on = 0; | |
63639d44 | 1977 | Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0)); |
cd3520a4 | 1978 | DEFSYM (Qbyte_code_meter, "byte-code-meter"); |
36f7ba0a JB |
1979 | { |
1980 | int i = 256; | |
1981 | while (i--) | |
28be1ada DA |
1982 | ASET (Vbyte_code_meter, i, |
1983 | Fmake_vector (make_number (256), make_number (0))); | |
36f7ba0a JB |
1984 | } |
1985 | #endif | |
1986 | } |