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