0
|
1 /* Execution of byte code produced by bytecomp.el.
|
|
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Mule 2.0, FSF 19.30. */
|
|
22
|
70
|
23 /* This file has been Mule-ized. */
|
|
24
|
|
25
|
0
|
26 /* Authorship:
|
|
27
|
|
28 FSF: long ago.
|
|
29
|
149
|
30 hacked on by jwz@netscape.com 17-jun-91
|
0
|
31 o added a compile-time switch to turn on simple sanity checking;
|
|
32 o put back the obsolete byte-codes for error-detection;
|
173
|
33 o added a new instruction, unbind_all, which I will use for
|
0
|
34 tail-recursion elimination;
|
|
35 o made temp_output_buffer_show be called with the right number
|
|
36 of args;
|
|
37 o made the new bytecodes be called with args in the right order;
|
|
38 o added metering support.
|
|
39
|
|
40 by Hallvard:
|
|
41 o added relative jump instructions;
|
|
42 o all conditionals now only do QUIT if they jump.
|
70
|
43
|
|
44 Ben Wing: some changes for Mule, June 1995.
|
0
|
45 */
|
|
46
|
|
47 #include <config.h>
|
|
48 #include "lisp.h"
|
|
49 #include "buffer.h"
|
|
50 #include "syntax.h"
|
|
51
|
|
52 /*
|
173
|
53 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
|
0
|
54 * debugging the byte compiler...) Somewhat surprisingly, defining this
|
|
55 * makes Fbyte_code about 8% slower.
|
|
56 *
|
173
|
57 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
|
0
|
58 */
|
255
|
59 /* This isn't defined in FSF Emacs and isn't defined in XEmacs v19 */
|
|
60 #ifdef DEBUG_XEMACS
|
70
|
61 #define BYTE_CODE_SAFE
|
255
|
62 #endif
|
0
|
63 /* #define BYTE_CODE_METER */
|
|
64
|
|
65
|
|
66 #ifdef BYTE_CODE_METER
|
|
67
|
|
68 Lisp_Object Vbyte_code_meter, Qbyte_code_meter;
|
|
69 int byte_metering_on;
|
|
70
|
|
71 #define METER_2(code1, code2) \
|
173
|
72 XINT (XVECTOR_DATA (XVECTOR_DATA (Vbyte_code_meter)[(code1)])[(code2)])
|
0
|
73
|
|
74 #define METER_1(code) METER_2 (0, (code))
|
|
75
|
|
76 #define METER_CODE(last_code, this_code) \
|
|
77 { \
|
|
78 if (byte_metering_on) \
|
|
79 { \
|
|
80 if (METER_1 (this_code) != ((1<<VALBITS)-1)) \
|
|
81 METER_1 (this_code)++; \
|
|
82 if (last_code \
|
|
83 && METER_2 (last_code, this_code) != ((1<<VALBITS)-1))\
|
|
84 METER_2 (last_code, this_code)++; \
|
|
85 } \
|
|
86 }
|
|
87
|
|
88 #endif /* no BYTE_CODE_METER */
|
|
89
|
|
90
|
|
91 Lisp_Object Qbyte_code;
|
|
92
|
|
93 /* Byte codes: */
|
|
94
|
|
95 #define Bvarref 010
|
|
96 #define Bvarset 020
|
|
97 #define Bvarbind 030
|
|
98 #define Bcall 040
|
|
99 #define Bunbind 050
|
|
100
|
|
101 #define Bnth 070
|
|
102 #define Bsymbolp 071
|
|
103 #define Bconsp 072
|
|
104 #define Bstringp 073
|
|
105 #define Blistp 074
|
70
|
106 #define Bold_eq 075
|
|
107 #define Bold_memq 076
|
0
|
108 #define Bnot 077
|
|
109 #define Bcar 0100
|
|
110 #define Bcdr 0101
|
|
111 #define Bcons 0102
|
|
112 #define Blist1 0103
|
|
113 #define Blist2 0104
|
|
114 #define Blist3 0105
|
|
115 #define Blist4 0106
|
|
116 #define Blength 0107
|
|
117 #define Baref 0110
|
|
118 #define Baset 0111
|
|
119 #define Bsymbol_value 0112
|
|
120 #define Bsymbol_function 0113
|
|
121 #define Bset 0114
|
|
122 #define Bfset 0115
|
|
123 #define Bget 0116
|
|
124 #define Bsubstring 0117
|
|
125 #define Bconcat2 0120
|
|
126 #define Bconcat3 0121
|
|
127 #define Bconcat4 0122
|
|
128 #define Bsub1 0123
|
|
129 #define Badd1 0124
|
|
130 #define Beqlsign 0125
|
|
131 #define Bgtr 0126
|
|
132 #define Blss 0127
|
|
133 #define Bleq 0130
|
|
134 #define Bgeq 0131
|
|
135 #define Bdiff 0132
|
|
136 #define Bnegate 0133
|
|
137 #define Bplus 0134
|
|
138 #define Bmax 0135
|
|
139 #define Bmin 0136
|
|
140 #define Bmult 0137
|
|
141
|
|
142 #define Bpoint 0140
|
70
|
143 #define Beq 0141 /* was Bmark, but no longer generated as of v18 */
|
0
|
144 #define Bgoto_char 0142
|
|
145 #define Binsert 0143
|
|
146 #define Bpoint_max 0144
|
|
147 #define Bpoint_min 0145
|
|
148 #define Bchar_after 0146
|
|
149 #define Bfollowing_char 0147
|
|
150 #define Bpreceding_char 0150
|
|
151 #define Bcurrent_column 0151
|
|
152 #define Bindent_to 0152
|
70
|
153 #define Bequal 0153 /* was Bscan_buffer, but no longer generated as of v18 */
|
0
|
154 #define Beolp 0154
|
|
155 #define Beobp 0155
|
|
156 #define Bbolp 0156
|
|
157 #define Bbobp 0157
|
|
158 #define Bcurrent_buffer 0160
|
|
159 #define Bset_buffer 0161
|
161
|
160 #define Bsave_current_buffer 0162 /* was Bread_char, but no longer
|
|
161 generated as of v19 */
|
70
|
162 #define Bmemq 0163 /* was Bset_mark, but no longer generated as of v18 */
|
0
|
163 #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */
|
|
164
|
|
165 #define Bforward_char 0165
|
|
166 #define Bforward_word 0166
|
|
167 #define Bskip_chars_forward 0167
|
|
168 #define Bskip_chars_backward 0170
|
|
169 #define Bforward_line 0171
|
|
170 #define Bchar_syntax 0172
|
|
171 #define Bbuffer_substring 0173
|
|
172 #define Bdelete_region 0174
|
|
173 #define Bnarrow_to_region 0175
|
|
174 #define Bwiden 0176
|
|
175 #define Bend_of_line 0177
|
|
176
|
|
177 #define Bconstant2 0201
|
|
178 #define Bgoto 0202
|
|
179 #define Bgotoifnil 0203
|
|
180 #define Bgotoifnonnil 0204
|
|
181 #define Bgotoifnilelsepop 0205
|
|
182 #define Bgotoifnonnilelsepop 0206
|
|
183 #define Breturn 0207
|
|
184 #define Bdiscard 0210
|
|
185 #define Bdup 0211
|
|
186
|
|
187 #define Bsave_excursion 0212
|
|
188 #define Bsave_window_excursion 0213
|
|
189 #define Bsave_restriction 0214
|
|
190 #define Bcatch 0215
|
|
191
|
|
192 #define Bunwind_protect 0216
|
|
193 #define Bcondition_case 0217
|
|
194 #define Btemp_output_buffer_setup 0220
|
|
195 #define Btemp_output_buffer_show 0221
|
|
196
|
|
197 #define Bunbind_all 0222
|
|
198
|
|
199 #define Bset_marker 0223
|
|
200 #define Bmatch_beginning 0224
|
|
201 #define Bmatch_end 0225
|
|
202 #define Bupcase 0226
|
|
203 #define Bdowncase 0227
|
|
204
|
|
205 #define Bstringeqlsign 0230
|
|
206 #define Bstringlss 0231
|
70
|
207 #define Bold_equal 0232
|
0
|
208 #define Bnthcdr 0233
|
|
209 #define Belt 0234
|
70
|
210 #define Bold_member 0235
|
|
211 #define Bold_assq 0236
|
0
|
212 #define Bnreverse 0237
|
|
213 #define Bsetcar 0240
|
|
214 #define Bsetcdr 0241
|
|
215 #define Bcar_safe 0242
|
|
216 #define Bcdr_safe 0243
|
|
217 #define Bnconc 0244
|
|
218 #define Bquo 0245
|
|
219 #define Brem 0246
|
|
220 #define Bnumberp 0247
|
|
221 #define Bintegerp 0250
|
|
222
|
|
223 #define BRgoto 0252
|
|
224 #define BRgotoifnil 0253
|
|
225 #define BRgotoifnonnil 0254
|
|
226 #define BRgotoifnilelsepop 0255
|
|
227 #define BRgotoifnonnilelsepop 0256
|
|
228
|
|
229 #define BlistN 0257
|
|
230 #define BconcatN 0260
|
|
231 #define BinsertN 0261
|
70
|
232 #define Bmember 0266 /* new in v20 */
|
|
233 #define Bassq 0267 /* new in v20 */
|
0
|
234
|
|
235 #define Bconstant 0300
|
|
236 #define CONSTANTLIM 0100
|
|
237
|
|
238 /* Fetch the next byte from the bytecode stream */
|
|
239
|
|
240 #define FETCH (massaged_code[pc++])
|
|
241
|
|
242 /* Fetch two bytes from the bytecode stream
|
|
243 and make a 16-bit number out of them */
|
|
244
|
|
245 #define FETCH2 (op = FETCH, op + (FETCH << 8))
|
|
246
|
|
247 /* Push x onto the execution stack. */
|
|
248
|
|
249 /* This used to be #define PUSH(x) (*++stackp = (x))
|
|
250 This oddity is necessary because Alliant can't be bothered to
|
|
251 compile the preincrement operator properly, as of 4/91. -JimB */
|
|
252 #define PUSH(x) (stackp++, *stackp = (x))
|
|
253
|
|
254 /* Pop a value off the execution stack. */
|
|
255
|
|
256 #define POP (*stackp--)
|
|
257
|
|
258 /* Discard n values from the execution stack. */
|
|
259
|
|
260 #define DISCARD(n) (stackp -= (n))
|
|
261
|
|
262 /* Get the value which is at the top of the execution stack,
|
|
263 but don't pop it. */
|
|
264
|
|
265 #define TOP (*stackp)
|
|
266
|
20
|
267 DEFUN ("byte-code", Fbyte_code, 3, 3, 0, /*
|
0
|
268 Function used internally in byte-compiled code.
|
|
269 The first argument is a string of byte code; the second, a vector of constants;
|
|
270 the third, the maximum stack depth used in this function.
|
|
271 If the third argument is incorrect, Emacs may crash.
|
20
|
272 */
|
|
273 (bytestr, vector, maxdepth))
|
0
|
274 {
|
|
275 /* This function can GC */
|
|
276 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
277 int speccount = specpdl_depth ();
|
|
278 #ifdef BYTE_CODE_METER
|
|
279 int this_op = 0;
|
|
280 int prev_op;
|
|
281 #endif
|
|
282 REGISTER int op;
|
|
283 int pc;
|
|
284 Lisp_Object *stack;
|
|
285 REGISTER Lisp_Object *stackp;
|
|
286 Lisp_Object *stacke;
|
|
287 REGISTER Lisp_Object v1, v2;
|
173
|
288 REGISTER Lisp_Object *vectorp = XVECTOR_DATA (vector);
|
0
|
289 #ifdef BYTE_CODE_SAFE
|
173
|
290 REGISTER int const_length = XVECTOR_LENGTH (vector);
|
0
|
291 #endif
|
|
292 REGISTER Emchar *massaged_code;
|
|
293 int massaged_code_len;
|
|
294
|
|
295 CHECK_STRING (bytestr);
|
|
296 if (!VECTORP (vector))
|
|
297 vector = wrong_type_argument (Qvectorp, vector);
|
|
298 CHECK_NATNUM (maxdepth);
|
|
299
|
185
|
300 stackp = alloca_array (Lisp_Object, XINT (maxdepth));
|
0
|
301 memset (stackp, 0, XINT (maxdepth) * sizeof (Lisp_Object));
|
|
302 GCPRO3 (bytestr, vector, *stackp);
|
|
303 gcpro3.nvars = XINT (maxdepth);
|
|
304
|
|
305 --stackp;
|
|
306 stack = stackp;
|
|
307 stacke = stackp + XINT (maxdepth);
|
|
308
|
|
309 /* Initialize the pc-register and convert the string into a fixed-width
|
|
310 format for easier processing. */
|
185
|
311 massaged_code = alloca_array (Emchar,
|
|
312 1 + string_char_length (XSTRING (bytestr)));
|
0
|
313 massaged_code_len =
|
16
|
314 convert_bufbyte_string_into_emchar_string (XSTRING_DATA (bytestr),
|
|
315 XSTRING_LENGTH (bytestr),
|
0
|
316 massaged_code);
|
|
317 massaged_code[massaged_code_len] = 0;
|
|
318 pc = 0;
|
173
|
319
|
0
|
320 while (1)
|
|
321 {
|
|
322 #ifdef BYTE_CODE_SAFE
|
|
323 if (stackp > stacke)
|
173
|
324 error ("Byte code stack overflow (byte compiler bug), pc %d, depth %ld",
|
|
325 pc, (long) (stacke - stackp));
|
0
|
326 if (stackp < stack)
|
|
327 error ("Byte code stack underflow (byte compiler bug), pc %d",
|
|
328 pc);
|
|
329 #endif
|
|
330
|
|
331 #ifdef BYTE_CODE_METER
|
|
332 prev_op = this_op;
|
|
333 this_op = op = FETCH;
|
|
334 METER_CODE (prev_op, op);
|
|
335 switch (op)
|
|
336 #else
|
|
337 switch (op = FETCH)
|
|
338 #endif
|
|
339 {
|
|
340 case Bvarref+6:
|
|
341 op = FETCH;
|
|
342 goto varref;
|
|
343
|
|
344 case Bvarref+7:
|
|
345 op = FETCH2;
|
|
346 goto varref;
|
|
347
|
|
348 case Bvarref: case Bvarref+1: case Bvarref+2: case Bvarref+3:
|
|
349 case Bvarref+4: case Bvarref+5:
|
|
350 op = op - Bvarref;
|
|
351 varref:
|
|
352 v1 = vectorp[op];
|
|
353 if (!SYMBOLP (v1))
|
|
354 v2 = Fsymbol_value (v1);
|
|
355 else
|
|
356 {
|
|
357 v2 = XSYMBOL (v1)->value;
|
|
358 if (SYMBOL_VALUE_MAGIC_P (v2))
|
|
359 v2 = Fsymbol_value (v1);
|
|
360 }
|
|
361 PUSH (v2);
|
|
362 break;
|
|
363
|
|
364 case Bvarset+6:
|
|
365 op = FETCH;
|
|
366 goto varset;
|
|
367
|
|
368 case Bvarset+7:
|
|
369 op = FETCH2;
|
|
370 goto varset;
|
|
371
|
|
372 case Bvarset: case Bvarset+1: case Bvarset+2: case Bvarset+3:
|
|
373 case Bvarset+4: case Bvarset+5:
|
|
374 op -= Bvarset;
|
|
375 varset:
|
|
376 Fset (vectorp[op], POP);
|
|
377 break;
|
|
378
|
|
379 case Bvarbind+6:
|
|
380 op = FETCH;
|
|
381 goto varbind;
|
|
382
|
|
383 case Bvarbind+7:
|
|
384 op = FETCH2;
|
|
385 goto varbind;
|
|
386
|
|
387 case Bvarbind: case Bvarbind+1: case Bvarbind+2: case Bvarbind+3:
|
|
388 case Bvarbind+4: case Bvarbind+5:
|
|
389 op -= Bvarbind;
|
|
390 varbind:
|
|
391 specbind (vectorp[op], POP);
|
|
392 break;
|
|
393
|
|
394 case Bcall+6:
|
|
395 op = FETCH;
|
|
396 goto docall;
|
|
397
|
|
398 case Bcall+7:
|
|
399 op = FETCH2;
|
|
400 goto docall;
|
|
401
|
|
402 case Bcall: case Bcall+1: case Bcall+2: case Bcall+3:
|
|
403 case Bcall+4: case Bcall+5:
|
|
404 op -= Bcall;
|
|
405 docall:
|
|
406 DISCARD (op);
|
|
407 #ifdef BYTE_CODE_METER
|
|
408 if (byte_metering_on && SYMBOLP (TOP))
|
|
409 {
|
|
410 v1 = TOP;
|
|
411 v2 = Fget (v1, Qbyte_code_meter, Qnil);
|
|
412 if (INTP (v2)
|
|
413 && XINT (v2) != ((1<<VALBITS)-1))
|
|
414 {
|
|
415 XSETINT (v2, XINT (v2) + 1);
|
|
416 Fput (v1, Qbyte_code_meter, v2);
|
|
417 }
|
|
418 }
|
16
|
419 #endif /* BYTE_CODE_METER */
|
0
|
420 TOP = Ffuncall (op + 1, &TOP);
|
|
421 break;
|
|
422
|
|
423 case Bunbind+6:
|
|
424 op = FETCH;
|
|
425 goto dounbind;
|
|
426
|
|
427 case Bunbind+7:
|
|
428 op = FETCH2;
|
|
429 goto dounbind;
|
|
430
|
|
431 case Bunbind: case Bunbind+1: case Bunbind+2: case Bunbind+3:
|
|
432 case Bunbind+4: case Bunbind+5:
|
|
433 op -= Bunbind;
|
|
434 dounbind:
|
|
435 unbind_to (specpdl_depth () - op, Qnil);
|
|
436 break;
|
|
437
|
|
438 case Bunbind_all:
|
|
439 /* To unbind back to the beginning of this frame. Not used yet,
|
|
440 but will be needed for tail-recursion elimination. */
|
|
441 unbind_to (speccount, Qnil);
|
|
442 break;
|
|
443
|
|
444 case Bgoto:
|
|
445 QUIT;
|
|
446 op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */
|
|
447 pc = op;
|
|
448 break;
|
|
449
|
|
450 case Bgotoifnil:
|
|
451 op = FETCH2;
|
|
452 if (NILP (POP))
|
|
453 {
|
|
454 QUIT;
|
|
455 pc = op;
|
|
456 }
|
|
457 break;
|
|
458
|
|
459 case Bgotoifnonnil:
|
|
460 op = FETCH2;
|
|
461 if (!NILP (POP))
|
|
462 {
|
|
463 QUIT;
|
|
464 pc = op;
|
|
465 }
|
|
466 break;
|
|
467
|
|
468 case Bgotoifnilelsepop:
|
|
469 op = FETCH2;
|
|
470 if (NILP (TOP))
|
|
471 {
|
|
472 QUIT;
|
|
473 pc = op;
|
|
474 }
|
|
475 else DISCARD (1);
|
|
476 break;
|
|
477
|
|
478 case Bgotoifnonnilelsepop:
|
|
479 op = FETCH2;
|
|
480 if (!NILP (TOP))
|
|
481 {
|
|
482 QUIT;
|
|
483 pc = op;
|
|
484 }
|
|
485 else DISCARD (1);
|
|
486 break;
|
|
487
|
|
488 case BRgoto:
|
|
489 QUIT;
|
|
490 pc += massaged_code[pc] - 127;
|
|
491 break;
|
|
492
|
|
493 case BRgotoifnil:
|
|
494 if (NILP (POP))
|
|
495 {
|
|
496 QUIT;
|
|
497 pc += massaged_code[pc] - 128;
|
|
498 }
|
|
499 pc++;
|
|
500 break;
|
|
501
|
|
502 case BRgotoifnonnil:
|
|
503 if (!NILP (POP))
|
|
504 {
|
|
505 QUIT;
|
|
506 pc += massaged_code[pc] - 128;
|
|
507 }
|
|
508 pc++;
|
|
509 break;
|
|
510
|
|
511 case BRgotoifnilelsepop:
|
|
512 op = FETCH;
|
|
513 if (NILP (TOP))
|
|
514 {
|
|
515 QUIT;
|
|
516 pc += op - 128;
|
|
517 }
|
|
518 else DISCARD (1);
|
|
519 break;
|
|
520
|
|
521 case BRgotoifnonnilelsepop:
|
|
522 op = FETCH;
|
|
523 if (!NILP (TOP))
|
|
524 {
|
|
525 QUIT;
|
|
526 pc += op - 128;
|
|
527 }
|
|
528 else DISCARD (1);
|
|
529 break;
|
|
530
|
|
531 case Breturn:
|
|
532 v1 = POP;
|
|
533 goto exit;
|
|
534
|
|
535 case Bdiscard:
|
|
536 DISCARD (1);
|
|
537 break;
|
|
538
|
|
539 case Bdup:
|
|
540 v1 = TOP;
|
|
541 PUSH (v1);
|
|
542 break;
|
|
543
|
|
544 case Bconstant2:
|
|
545 PUSH (vectorp[FETCH2]);
|
|
546 break;
|
|
547
|
|
548 case Bsave_excursion:
|
|
549 record_unwind_protect (save_excursion_restore,
|
|
550 save_excursion_save ());
|
|
551 break;
|
|
552
|
|
553 case Bsave_window_excursion:
|
|
554 {
|
|
555 int count = specpdl_depth ();
|
|
556 record_unwind_protect (save_window_excursion_unwind,
|
|
557 Fcurrent_window_configuration (Qnil));
|
|
558 TOP = Fprogn (TOP);
|
|
559 unbind_to (count, Qnil);
|
|
560 break;
|
|
561 }
|
|
562
|
|
563 case Bsave_restriction:
|
|
564 record_unwind_protect (save_restriction_restore,
|
|
565 save_restriction_save ());
|
|
566 break;
|
|
567
|
|
568 case Bcatch:
|
|
569 v1 = POP;
|
|
570 TOP = internal_catch (TOP, Feval, v1, 0);
|
|
571 break;
|
|
572
|
|
573 case Bunwind_protect:
|
|
574 record_unwind_protect (Fprogn, POP);
|
|
575 break;
|
|
576
|
|
577 case Bcondition_case:
|
|
578 v1 = POP; /* handlers */
|
|
579 v2 = POP; /* bodyform */
|
|
580 TOP = Fcondition_case_3 (v2, TOP, v1);
|
|
581 break;
|
|
582
|
|
583 case Btemp_output_buffer_setup:
|
16
|
584 temp_output_buffer_setup ((char *) XSTRING_DATA (TOP));
|
0
|
585 TOP = Vstandard_output;
|
|
586 break;
|
|
587
|
|
588 case Btemp_output_buffer_show:
|
|
589 v1 = POP;
|
|
590 temp_output_buffer_show (TOP, Qnil);
|
|
591 TOP = v1;
|
|
592 /* GAG ME!! */
|
|
593 /* pop binding of standard-output */
|
|
594 unbind_to (specpdl_depth() - 1, Qnil);
|
|
595 break;
|
|
596
|
|
597 case Bnth:
|
|
598 v1 = POP;
|
|
599 v2 = TOP;
|
|
600 /* nth_entry: */
|
|
601 CHECK_INT (v2);
|
|
602 op = XINT (v2);
|
|
603 while (--op >= 0)
|
|
604 {
|
|
605 if (CONSP (v1))
|
|
606 v1 = XCDR (v1);
|
|
607 else if (!NILP (v1))
|
|
608 {
|
|
609 v1 = wrong_type_argument (Qlistp, v1);
|
|
610 op++;
|
|
611 }
|
|
612 QUIT;
|
|
613 }
|
|
614 goto docar;
|
|
615
|
|
616 case Bsymbolp:
|
|
617 TOP = ((SYMBOLP (TOP)) ? Qt : Qnil);
|
|
618 break;
|
|
619
|
|
620 case Bconsp:
|
|
621 TOP = ((CONSP (TOP)) ? Qt : Qnil);
|
|
622 break;
|
|
623
|
|
624 case Bstringp:
|
|
625 TOP = ((STRINGP (TOP)) ? Qt : Qnil);
|
|
626 break;
|
|
627
|
|
628 case Blistp:
|
|
629 TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil;
|
|
630 break;
|
|
631
|
|
632 case Beq:
|
|
633 v1 = POP;
|
70
|
634 TOP = ((EQ_WITH_EBOLA_NOTICE (v1, TOP)) ? Qt : Qnil);
|
|
635 break;
|
|
636
|
|
637 case Bold_eq:
|
|
638 v1 = POP;
|
0
|
639 TOP = ((HACKEQ_UNSAFE (v1, TOP)) ? Qt : Qnil);
|
|
640 break;
|
|
641
|
|
642 case Bmemq:
|
|
643 v1 = POP;
|
|
644 TOP = Fmemq (TOP, v1);
|
|
645 break;
|
|
646
|
70
|
647 case Bold_memq:
|
|
648 v1 = POP;
|
|
649 TOP = Fold_memq (TOP, v1);
|
|
650 break;
|
|
651
|
0
|
652 case Bnot:
|
|
653 TOP = NILP (TOP) ? Qt : Qnil;
|
|
654 break;
|
|
655
|
|
656 case Bcar:
|
|
657 v1 = TOP;
|
|
658 docar:
|
|
659 if (CONSP (v1)) TOP = XCAR (v1);
|
|
660 else if (NILP (v1)) TOP = Qnil;
|
|
661 else Fcar (wrong_type_argument (Qlistp, v1));
|
|
662 break;
|
|
663
|
|
664 case Bcdr:
|
|
665 v1 = TOP;
|
|
666 if (CONSP (v1)) TOP = XCDR (v1);
|
|
667 else if (NILP (v1)) TOP = Qnil;
|
|
668 else Fcdr (wrong_type_argument (Qlistp, v1));
|
|
669 break;
|
|
670
|
|
671 case Bcons:
|
|
672 v1 = POP;
|
|
673 TOP = Fcons (TOP, v1);
|
|
674 break;
|
|
675
|
|
676 case Blist1:
|
|
677 TOP = Fcons (TOP, Qnil);
|
|
678 break;
|
|
679
|
|
680 case Blist2:
|
|
681 v1 = POP;
|
|
682 TOP = Fcons (TOP, Fcons (v1, Qnil));
|
|
683 break;
|
|
684
|
|
685 case Blist3:
|
|
686 DISCARD (2);
|
|
687 TOP = Flist (3, &TOP);
|
|
688 break;
|
|
689
|
|
690 case Blist4:
|
|
691 DISCARD (3);
|
|
692 TOP = Flist (4, &TOP);
|
|
693 break;
|
|
694
|
|
695 case BlistN:
|
|
696 op = FETCH;
|
|
697 DISCARD (op - 1);
|
|
698 TOP = Flist (op, &TOP);
|
|
699 break;
|
|
700
|
|
701 case Blength:
|
|
702 TOP = Flength (TOP);
|
|
703 break;
|
|
704
|
|
705 case Baref:
|
|
706 v1 = POP;
|
|
707 TOP = Faref (TOP, v1);
|
|
708 break;
|
|
709
|
|
710 case Baset:
|
|
711 v2 = POP; v1 = POP;
|
|
712 TOP = Faset (TOP, v1, v2);
|
|
713 break;
|
|
714
|
|
715 case Bsymbol_value:
|
|
716 TOP = Fsymbol_value (TOP);
|
|
717 break;
|
|
718
|
|
719 case Bsymbol_function:
|
|
720 TOP = Fsymbol_function (TOP);
|
|
721 break;
|
|
722
|
|
723 case Bset:
|
|
724 v1 = POP;
|
|
725 TOP = Fset (TOP, v1);
|
|
726 break;
|
|
727
|
|
728 case Bfset:
|
|
729 v1 = POP;
|
|
730 TOP = Ffset (TOP, v1);
|
|
731 break;
|
|
732
|
|
733 case Bget:
|
|
734 v1 = POP;
|
|
735 TOP = Fget (TOP, v1, Qnil);
|
|
736 break;
|
|
737
|
|
738 case Bsubstring:
|
|
739 v2 = POP; v1 = POP;
|
|
740 TOP = Fsubstring (TOP, v1, v2);
|
|
741 break;
|
|
742
|
|
743 case Bconcat2:
|
|
744 DISCARD (1);
|
|
745 TOP = Fconcat (2, &TOP);
|
|
746 break;
|
|
747
|
|
748 case Bconcat3:
|
|
749 DISCARD (2);
|
|
750 TOP = Fconcat (3, &TOP);
|
|
751 break;
|
|
752
|
|
753 case Bconcat4:
|
|
754 DISCARD (3);
|
|
755 TOP = Fconcat (4, &TOP);
|
|
756 break;
|
|
757
|
|
758 case BconcatN:
|
|
759 op = FETCH;
|
|
760 DISCARD (op - 1);
|
|
761 TOP = Fconcat (op, &TOP);
|
|
762 break;
|
|
763
|
|
764 case Bsub1:
|
|
765 v1 = TOP;
|
|
766 if (INTP (v1))
|
|
767 {
|
|
768 XSETINT (v1, XINT (v1) - 1);
|
|
769 TOP = v1;
|
|
770 }
|
|
771 else
|
|
772 TOP = Fsub1 (v1);
|
|
773 break;
|
|
774
|
|
775 case Badd1:
|
|
776 v1 = TOP;
|
|
777 if (INTP (v1))
|
|
778 {
|
|
779 XSETINT (v1, XINT (v1) + 1);
|
|
780 TOP = v1;
|
|
781 }
|
|
782 else
|
|
783 TOP = Fadd1 (v1);
|
|
784 break;
|
|
785
|
|
786 case Beqlsign:
|
|
787 v2 = POP; v1 = TOP;
|
|
788 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (v1);
|
|
789 CHECK_INT_OR_FLOAT_COERCE_CHAR_OR_MARKER (v2);
|
|
790 #ifdef LISP_FLOAT_TYPE
|
|
791 if (FLOATP (v1) || FLOATP (v2))
|
|
792 {
|
|
793 double f1, f2;
|
|
794
|
|
795 f1 = (FLOATP (v1) ? float_data (XFLOAT (v1)) : XINT (v1));
|
|
796 f2 = (FLOATP (v2) ? float_data (XFLOAT (v2)) : XINT (v2));
|
|
797 TOP = (f1 == f2 ? Qt : Qnil);
|
|
798 }
|
|
799 else
|
16
|
800 #endif /* LISP_FLOAT_TYPE */
|
0
|
801 TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil);
|
|
802 break;
|
|
803
|
|
804 case Bgtr:
|
|
805 v1 = POP;
|
|
806 TOP = Fgtr (TOP, v1);
|
|
807 break;
|
|
808
|
|
809 case Blss:
|
|
810 v1 = POP;
|
|
811 TOP = Flss (TOP, v1);
|
|
812 break;
|
|
813
|
|
814 case Bleq:
|
|
815 v1 = POP;
|
|
816 TOP = Fleq (TOP, v1);
|
|
817 break;
|
|
818
|
|
819 case Bgeq:
|
|
820 v1 = POP;
|
|
821 TOP = Fgeq (TOP, v1);
|
|
822 break;
|
|
823
|
|
824 case Bdiff:
|
|
825 DISCARD (1);
|
|
826 TOP = Fminus (2, &TOP);
|
|
827 break;
|
|
828
|
|
829 case Bnegate:
|
|
830 v1 = TOP;
|
|
831 if (INTP (v1))
|
|
832 {
|
|
833 XSETINT (v1, - XINT (v1));
|
|
834 TOP = v1;
|
|
835 }
|
|
836 else
|
|
837 TOP = Fminus (1, &TOP);
|
|
838 break;
|
|
839
|
|
840 case Bplus:
|
|
841 DISCARD (1);
|
|
842 TOP = Fplus (2, &TOP);
|
|
843 break;
|
|
844
|
|
845 case Bmax:
|
|
846 DISCARD (1);
|
|
847 TOP = Fmax (2, &TOP);
|
|
848 break;
|
|
849
|
|
850 case Bmin:
|
|
851 DISCARD (1);
|
|
852 TOP = Fmin (2, &TOP);
|
|
853 break;
|
|
854
|
|
855 case Bmult:
|
|
856 DISCARD (1);
|
|
857 TOP = Ftimes (2, &TOP);
|
|
858 break;
|
|
859
|
|
860 case Bquo:
|
|
861 DISCARD (1);
|
|
862 TOP = Fquo (2, &TOP);
|
|
863 break;
|
|
864
|
|
865 case Brem:
|
|
866 v1 = POP;
|
|
867 TOP = Frem (TOP, v1);
|
|
868 break;
|
|
869
|
|
870 case Bpoint:
|
|
871 v1 = make_int (BUF_PT (current_buffer));
|
|
872 PUSH (v1);
|
|
873 break;
|
|
874
|
|
875 case Bgoto_char:
|
223
|
876 TOP = Fgoto_char (TOP, Qnil);
|
0
|
877 break;
|
|
878
|
|
879 case Binsert:
|
|
880 TOP = Finsert (1, &TOP);
|
|
881 break;
|
|
882
|
|
883 case BinsertN:
|
|
884 op = FETCH;
|
|
885 DISCARD (op - 1);
|
|
886 TOP = Finsert (op, &TOP);
|
|
887 break;
|
|
888
|
|
889 case Bpoint_max:
|
|
890 v1 = make_int (BUF_ZV (current_buffer));
|
|
891 PUSH (v1);
|
|
892 break;
|
|
893
|
|
894 case Bpoint_min:
|
|
895 v1 = make_int (BUF_BEGV (current_buffer));
|
|
896 PUSH (v1);
|
|
897 break;
|
|
898
|
|
899 case Bchar_after:
|
223
|
900 TOP = Fchar_after (TOP, Qnil);
|
0
|
901 break;
|
|
902
|
|
903 case Bfollowing_char:
|
223
|
904 v1 = Ffollowing_char (Qnil);
|
0
|
905 PUSH (v1);
|
|
906 break;
|
|
907
|
|
908 case Bpreceding_char:
|
223
|
909 v1 = Fpreceding_char (Qnil);
|
0
|
910 PUSH (v1);
|
|
911 break;
|
|
912
|
|
913 case Bcurrent_column:
|
|
914 v1 = make_int (current_column (current_buffer));
|
|
915 PUSH (v1);
|
|
916 break;
|
|
917
|
|
918 case Bindent_to:
|
223
|
919 TOP = Findent_to (TOP, Qnil, Qnil);
|
0
|
920 break;
|
|
921
|
|
922 case Beolp:
|
223
|
923 PUSH (Feolp (Qnil));
|
0
|
924 break;
|
|
925
|
|
926 case Beobp:
|
223
|
927 PUSH (Feobp (Qnil));
|
0
|
928 break;
|
|
929
|
|
930 case Bbolp:
|
223
|
931 PUSH (Fbolp (Qnil));
|
0
|
932 break;
|
|
933
|
|
934 case Bbobp:
|
223
|
935 PUSH (Fbobp (Qnil));
|
0
|
936 break;
|
|
937
|
|
938 case Bcurrent_buffer:
|
|
939 PUSH (Fcurrent_buffer ());
|
|
940 break;
|
|
941
|
|
942 case Bset_buffer:
|
|
943 TOP = Fset_buffer (TOP);
|
|
944 break;
|
|
945
|
161
|
946 case Bsave_current_buffer:
|
169
|
947 record_unwind_protect (save_current_buffer_restore,
|
|
948 Fcurrent_buffer ());
|
|
949 break;
|
0
|
950
|
|
951 case Binteractive_p:
|
|
952 PUSH (Finteractive_p ());
|
|
953 break;
|
|
954
|
|
955 case Bforward_char:
|
223
|
956 TOP = Fforward_char (TOP, Qnil);
|
0
|
957 break;
|
|
958
|
|
959 case Bforward_word:
|
223
|
960 TOP = Fforward_word (TOP, Qnil);
|
0
|
961 break;
|
|
962
|
|
963 case Bskip_chars_forward:
|
|
964 v1 = POP;
|
223
|
965 TOP = Fskip_chars_forward (TOP, v1, Qnil);
|
0
|
966 break;
|
|
967
|
|
968 case Bskip_chars_backward:
|
|
969 v1 = POP;
|
223
|
970 TOP = Fskip_chars_backward (TOP, v1, Qnil);
|
0
|
971 break;
|
|
972
|
|
973 case Bforward_line:
|
223
|
974 TOP = Fforward_line (TOP, Qnil);
|
0
|
975 break;
|
|
976
|
|
977 case Bchar_syntax:
|
195
|
978 #if 0
|
0
|
979 CHECK_CHAR_COERCE_INT (TOP);
|
|
980 TOP = make_char (syntax_code_spec
|
16
|
981 [(int) SYNTAX
|
70
|
982 (XCHAR_TABLE
|
|
983 (current_buffer->mirror_syntax_table),
|
|
984 XCHAR (TOP))]);
|
195
|
985 #endif
|
|
986 /*v1 = POP;*/
|
|
987 TOP = Fchar_syntax(TOP, Qnil);
|
0
|
988 break;
|
|
989
|
|
990 case Bbuffer_substring:
|
|
991 v1 = POP;
|
223
|
992 TOP = Fbuffer_substring (TOP, v1, Qnil);
|
0
|
993 break;
|
|
994
|
|
995 case Bdelete_region:
|
|
996 v1 = POP;
|
223
|
997 TOP = Fdelete_region (TOP, v1, Qnil);
|
0
|
998 break;
|
|
999
|
|
1000 case Bnarrow_to_region:
|
|
1001 v1 = POP;
|
223
|
1002 TOP = Fnarrow_to_region (TOP, v1, Qnil);
|
0
|
1003 break;
|
|
1004
|
|
1005 case Bwiden:
|
223
|
1006 PUSH (Fwiden (Qnil));
|
0
|
1007 break;
|
|
1008
|
|
1009 case Bend_of_line:
|
223
|
1010 TOP = Fend_of_line (TOP, Qnil);
|
0
|
1011 break;
|
|
1012
|
|
1013 case Bset_marker:
|
|
1014 v1 = POP;
|
|
1015 v2 = POP;
|
|
1016 TOP = Fset_marker (TOP, v2, v1);
|
|
1017 break;
|
|
1018
|
|
1019 case Bmatch_beginning:
|
|
1020 TOP = Fmatch_beginning (TOP);
|
|
1021 break;
|
|
1022
|
|
1023 case Bmatch_end:
|
|
1024 TOP = Fmatch_end (TOP);
|
|
1025 break;
|
|
1026
|
|
1027 case Bupcase:
|
223
|
1028 TOP = Fupcase (TOP, Qnil);
|
0
|
1029 break;
|
|
1030
|
|
1031 case Bdowncase:
|
223
|
1032 TOP = Fdowncase (TOP, Qnil);
|
0
|
1033 break;
|
|
1034
|
|
1035 case Bstringeqlsign:
|
|
1036 v1 = POP;
|
|
1037 TOP = Fstring_equal (TOP, v1);
|
|
1038 break;
|
|
1039
|
|
1040 case Bstringlss:
|
|
1041 v1 = POP;
|
|
1042 TOP = Fstring_lessp (TOP, v1);
|
|
1043 break;
|
|
1044
|
|
1045 case Bequal:
|
|
1046 v1 = POP;
|
|
1047 TOP = Fequal (TOP, v1);
|
|
1048 break;
|
|
1049
|
70
|
1050 case Bold_equal:
|
|
1051 v1 = POP;
|
|
1052 TOP = Fold_equal (TOP, v1);
|
|
1053 break;
|
|
1054
|
0
|
1055 case Bnthcdr:
|
|
1056 v1 = POP;
|
|
1057 TOP = Fnthcdr (TOP, v1);
|
|
1058 break;
|
|
1059
|
|
1060 case Belt:
|
|
1061 #if 0
|
|
1062 /* probably this code is OK, but nth_entry is commented
|
|
1063 out above --ben */
|
207
|
1064 /* #### will not work if cons type is an lrecord. */
|
185
|
1065 if (XTYPE (TOP) == Lisp_Type_Cons)
|
0
|
1066 {
|
|
1067 /* Exchange args and then do nth. */
|
|
1068 v2 = POP;
|
|
1069 v1 = TOP;
|
|
1070 goto nth_entry;
|
|
1071 }
|
|
1072 #endif
|
|
1073 v1 = POP;
|
|
1074 TOP = Felt (TOP, v1);
|
|
1075 break;
|
|
1076
|
|
1077 case Bmember:
|
|
1078 v1 = POP;
|
|
1079 TOP = Fmember (TOP, v1);
|
|
1080 break;
|
|
1081
|
70
|
1082 case Bold_member:
|
|
1083 v1 = POP;
|
|
1084 TOP = Fold_member (TOP, v1);
|
|
1085 break;
|
|
1086
|
0
|
1087 case Bassq:
|
|
1088 v1 = POP;
|
|
1089 TOP = Fassq (TOP, v1);
|
|
1090 break;
|
|
1091
|
70
|
1092 case Bold_assq:
|
|
1093 v1 = POP;
|
|
1094 TOP = Fold_assq (TOP, v1);
|
|
1095 break;
|
|
1096
|
0
|
1097 case Bnreverse:
|
|
1098 TOP = Fnreverse (TOP);
|
|
1099 break;
|
|
1100
|
|
1101 case Bsetcar:
|
|
1102 v1 = POP;
|
|
1103 TOP = Fsetcar (TOP, v1);
|
|
1104 break;
|
|
1105
|
|
1106 case Bsetcdr:
|
|
1107 v1 = POP;
|
|
1108 TOP = Fsetcdr (TOP, v1);
|
|
1109 break;
|
|
1110
|
|
1111 case Bcar_safe:
|
|
1112 v1 = TOP;
|
|
1113 if (CONSP (v1))
|
|
1114 TOP = XCAR (v1);
|
|
1115 else
|
|
1116 TOP = Qnil;
|
|
1117 break;
|
|
1118
|
|
1119 case Bcdr_safe:
|
|
1120 v1 = TOP;
|
|
1121 if (CONSP (v1))
|
|
1122 TOP = XCDR (v1);
|
|
1123 else
|
|
1124 TOP = Qnil;
|
|
1125 break;
|
|
1126
|
|
1127 case Bnconc:
|
|
1128 DISCARD (1);
|
|
1129 TOP = Fnconc (2, &TOP);
|
|
1130 break;
|
|
1131
|
|
1132 case Bnumberp:
|
|
1133 TOP = ((INT_OR_FLOATP (TOP)) ? Qt : Qnil);
|
|
1134 break;
|
|
1135
|
|
1136 case Bintegerp:
|
|
1137 TOP = ((INTP (TOP)) ? Qt : Qnil);
|
|
1138 break;
|
|
1139
|
|
1140 default:
|
|
1141 #ifdef BYTE_CODE_SAFE
|
|
1142 if (op < Bconstant)
|
|
1143 error ("unknown bytecode %d (byte compiler bug)", op);
|
|
1144 if ((op -= Bconstant) >= const_length)
|
|
1145 error ("no constant number %d (byte compiler bug)", op);
|
|
1146 PUSH (vectorp[op]);
|
|
1147 #else
|
|
1148 PUSH (vectorp[op - Bconstant]);
|
|
1149 #endif
|
|
1150 }
|
|
1151 }
|
|
1152
|
|
1153 exit:
|
|
1154 UNGCPRO;
|
|
1155 /* Binds and unbinds are supposed to be compiled balanced. */
|
|
1156 if (specpdl_depth() != speccount)
|
|
1157 /* FSF: abort() if BYTE_CODE_SAFE not defined */
|
|
1158 error ("binding stack not balanced (serious byte compiler bug)");
|
|
1159 return v1;
|
|
1160 }
|
|
1161
|
|
1162 void
|
|
1163 syms_of_bytecode (void)
|
|
1164 {
|
|
1165 defsymbol (&Qbyte_code, "byte-code");
|
20
|
1166 DEFSUBR (Fbyte_code);
|
0
|
1167 #ifdef BYTE_CODE_METER
|
|
1168 defsymbol (&Qbyte_code_meter, "byte-code-meter");
|
|
1169 #endif
|
|
1170 }
|
|
1171
|
|
1172 void
|
|
1173 vars_of_bytecode (void)
|
|
1174 {
|
|
1175 #ifdef BYTE_CODE_METER
|
|
1176
|
|
1177 DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter /*
|
|
1178 A vector of vectors which holds a histogram of byte-code usage.
|
|
1179 (aref (aref byte-code-meter 0) CODE) indicates how many times the byte
|
|
1180 opcode CODE has been executed.
|
|
1181 (aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
|
|
1182 indicates how many times the byte opcodes CODE1 and CODE2 have been
|
|
1183 executed in succession.
|
|
1184 */ );
|
|
1185 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on /*
|
|
1186 If non-nil, keep profiling information on byte code usage.
|
|
1187 The variable byte-code-meter indicates how often each byte opcode is used.
|
|
1188 If a symbol has a property named `byte-code-meter' whose value is an
|
|
1189 integer, it is incremented each time that symbol's function is called.
|
|
1190 */ );
|
|
1191
|
|
1192 byte_metering_on = 0;
|
|
1193 Vbyte_code_meter = make_vector (256, Qzero);
|
|
1194 {
|
|
1195 int i = 256;
|
|
1196 while (i--)
|
173
|
1197 XVECTOR_DATA (Vbyte_code_meter)[i] =
|
0
|
1198 make_vector (256, Qzero);
|
|
1199 }
|
|
1200 #endif
|
|
1201 }
|