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