Mercurial > emacs
annotate src/bytecode.c @ 16784:79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 30 Dec 1996 05:59:42 +0000 |
| parents | 25e8123eb6c5 |
| children | 9e0f59154164 |
| 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 | |
| 16628 | 254 /* Garbage collect if we have consed enough since the last time. |
| 255 We do this at every branch, to avoid loops that never GC. */ | |
| 256 | |
| 257 #define MAYBE_GC() \ | |
| 258 if (consing_since_gc > gc_cons_threshold) \ | |
| 259 Fgarbage_collect (); | |
| 260 | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
261 /* Check for jumping out of range. */ |
|
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
262 #define CHECK_RANGE(ARG) \ |
|
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
263 if (ARG >= bytestr_length) abort () |
|
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
264 |
| 310 | 265 DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, |
| 266 "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
|
267 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
|
268 the second, VECTOR, a vector of constants;\n\ |
|
bf43ef5a139c
(Fbyte_code): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
12575
diff
changeset
|
269 the third, MAXDEPTH, the maximum stack depth used in this function.\n\ |
| 310 | 270 If the third argument is incorrect, Emacs may crash.") |
| 271 (bytestr, vector, maxdepth) | |
| 272 Lisp_Object bytestr, vector, maxdepth; | |
| 273 { | |
| 274 struct gcpro gcpro1, gcpro2, gcpro3; | |
| 275 int count = specpdl_ptr - specpdl; | |
| 276 #ifdef BYTE_CODE_METER | |
| 277 int this_op = 0; | |
| 278 int prev_op; | |
| 279 #endif | |
| 280 register int op; | |
| 281 unsigned char *pc; | |
| 282 Lisp_Object *stack; | |
| 283 register Lisp_Object *stackp; | |
| 284 Lisp_Object *stacke; | |
| 285 register Lisp_Object v1, v2; | |
| 286 register Lisp_Object *vectorp = XVECTOR (vector)->contents; | |
| 287 #ifdef BYTE_CODE_SAFE | |
| 288 register int const_length = XVECTOR (vector)->size; | |
| 289 #endif | |
| 290 /* Copy of BYTESTR, saved so we can tell if BYTESTR was relocated. */ | |
| 291 Lisp_Object string_saved; | |
| 292 /* Cached address of beginning of string, | |
| 293 valid if BYTESTR equals STRING_SAVED. */ | |
| 294 register unsigned char *strbeg; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
295 int bytestr_length = XSTRING (bytestr)->size; |
| 310 | 296 |
| 297 CHECK_STRING (bytestr, 0); | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
298 if (!VECTORP (vector)) |
| 310 | 299 vector = wrong_type_argument (Qvectorp, vector); |
| 300 CHECK_NUMBER (maxdepth, 2); | |
| 301 | |
| 302 stackp = (Lisp_Object *) alloca (XFASTINT (maxdepth) * sizeof (Lisp_Object)); | |
| 303 bzero (stackp, XFASTINT (maxdepth) * sizeof (Lisp_Object)); | |
| 304 GCPRO3 (bytestr, vector, *stackp); | |
| 305 gcpro3.nvars = XFASTINT (maxdepth); | |
| 306 | |
| 307 --stackp; | |
| 308 stack = stackp; | |
| 309 stacke = stackp + XFASTINT (maxdepth); | |
| 310 | |
| 311 /* Initialize the saved pc-pointer for fetching from the string. */ | |
| 312 string_saved = bytestr; | |
| 313 pc = XSTRING (string_saved)->data; | |
| 314 | |
| 315 while (1) | |
| 316 { | |
| 317 #ifdef BYTE_CODE_SAFE | |
| 318 if (stackp > stacke) | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
319 error ("Byte code stack overflow (byte compiler bug), pc %d, depth %d", |
| 310 | 320 pc - XSTRING (string_saved)->data, stacke - stackp); |
| 321 if (stackp < stack) | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
322 error ("Byte code stack underflow (byte compiler bug), pc %d", |
| 310 | 323 pc - XSTRING (string_saved)->data); |
| 324 #endif | |
| 325 | |
|
1503
3ad82148830b
* bytecode.c (Fbyte_code): Use EQ to compare string_saved with
Jim Blandy <jimb@redhat.com>
parents:
959
diff
changeset
|
326 if (! EQ (string_saved, bytestr)) |
| 310 | 327 { |
| 328 pc = pc - XSTRING (string_saved)->data + XSTRING (bytestr)->data; | |
| 329 string_saved = bytestr; | |
| 330 } | |
| 331 | |
| 332 #ifdef BYTE_CODE_METER | |
| 333 prev_op = this_op; | |
| 334 this_op = op = FETCH; | |
| 335 METER_CODE (prev_op, op); | |
| 336 switch (op) | |
| 337 #else | |
| 338 switch (op = FETCH) | |
| 339 #endif | |
| 340 { | |
| 341 case Bvarref+6: | |
| 342 op = FETCH; | |
| 343 goto varref; | |
| 344 | |
| 345 case Bvarref+7: | |
| 346 op = FETCH2; | |
| 347 goto varref; | |
| 348 | |
| 349 case Bvarref: case Bvarref+1: case Bvarref+2: case Bvarref+3: | |
| 350 case Bvarref+4: case Bvarref+5: | |
| 351 op = op - Bvarref; | |
| 352 varref: | |
| 353 v1 = vectorp[op]; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
354 if (!SYMBOLP (v1)) |
| 310 | 355 v2 = Fsymbol_value (v1); |
| 356 else | |
| 357 { | |
| 358 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
|
359 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
|
360 v2 = Fsymbol_value (v1); |
| 310 | 361 } |
| 362 PUSH (v2); | |
| 363 break; | |
| 364 | |
| 365 case Bvarset+6: | |
| 366 op = FETCH; | |
| 367 goto varset; | |
| 368 | |
| 369 case Bvarset+7: | |
| 370 op = FETCH2; | |
| 371 goto varset; | |
| 372 | |
| 373 case Bvarset: case Bvarset+1: case Bvarset+2: case Bvarset+3: | |
| 374 case Bvarset+4: case Bvarset+5: | |
| 375 op -= Bvarset; | |
| 376 varset: | |
| 377 Fset (vectorp[op], POP); | |
| 378 break; | |
| 379 | |
| 380 case Bvarbind+6: | |
| 381 op = FETCH; | |
| 382 goto varbind; | |
| 383 | |
| 384 case Bvarbind+7: | |
| 385 op = FETCH2; | |
| 386 goto varbind; | |
| 387 | |
| 388 case Bvarbind: case Bvarbind+1: case Bvarbind+2: case Bvarbind+3: | |
| 389 case Bvarbind+4: case Bvarbind+5: | |
| 390 op -= Bvarbind; | |
| 391 varbind: | |
| 392 specbind (vectorp[op], POP); | |
| 393 break; | |
| 394 | |
| 395 case Bcall+6: | |
| 396 op = FETCH; | |
| 397 goto docall; | |
| 398 | |
| 399 case Bcall+7: | |
| 400 op = FETCH2; | |
| 401 goto docall; | |
| 402 | |
| 403 case Bcall: case Bcall+1: case Bcall+2: case Bcall+3: | |
| 404 case Bcall+4: case Bcall+5: | |
| 405 op -= Bcall; | |
| 406 docall: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
407 DISCARD (op); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
408 #ifdef BYTE_CODE_METER |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
409 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
|
410 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
411 v1 = TOP; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
412 v2 = Fget (v1, Qbyte_code_meter); |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
413 if (INTEGERP (v2) |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
414 && 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
|
415 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
416 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
|
417 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
|
418 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
419 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
420 #endif |
| 310 | 421 TOP = Ffuncall (op + 1, &TOP); |
| 422 break; | |
| 423 | |
| 424 case Bunbind+6: | |
| 425 op = FETCH; | |
| 426 goto dounbind; | |
| 427 | |
| 428 case Bunbind+7: | |
| 429 op = FETCH2; | |
| 430 goto dounbind; | |
| 431 | |
| 432 case Bunbind: case Bunbind+1: case Bunbind+2: case Bunbind+3: | |
| 433 case Bunbind+4: case Bunbind+5: | |
| 434 op -= Bunbind; | |
| 435 dounbind: | |
| 436 unbind_to (specpdl_ptr - specpdl - op, Qnil); | |
| 437 break; | |
| 438 | |
| 439 case Bunbind_all: | |
| 440 /* 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
|
441 but will be needed for tail-recursion elimination. */ |
| 310 | 442 unbind_to (count, Qnil); |
| 443 break; | |
| 444 | |
| 445 case Bgoto: | |
| 16628 | 446 MAYBE_GC (); |
| 310 | 447 QUIT; |
| 448 op = FETCH2; /* pc = FETCH2 loses since FETCH2 contains pc++ */ | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
449 CHECK_RANGE (op); |
| 310 | 450 pc = XSTRING (string_saved)->data + op; |
| 451 break; | |
| 452 | |
| 453 case Bgotoifnil: | |
| 16628 | 454 MAYBE_GC (); |
| 310 | 455 op = FETCH2; |
| 944 | 456 if (NILP (POP)) |
| 310 | 457 { |
| 458 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
459 CHECK_RANGE (op); |
| 310 | 460 pc = XSTRING (string_saved)->data + op; |
| 461 } | |
| 462 break; | |
| 463 | |
| 464 case Bgotoifnonnil: | |
| 16628 | 465 MAYBE_GC (); |
| 310 | 466 op = FETCH2; |
| 944 | 467 if (!NILP (POP)) |
| 310 | 468 { |
| 469 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
470 CHECK_RANGE (op); |
| 310 | 471 pc = XSTRING (string_saved)->data + op; |
| 472 } | |
| 473 break; | |
| 474 | |
| 475 case Bgotoifnilelsepop: | |
| 16628 | 476 MAYBE_GC (); |
| 310 | 477 op = FETCH2; |
| 944 | 478 if (NILP (TOP)) |
| 310 | 479 { |
| 480 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
481 CHECK_RANGE (op); |
| 310 | 482 pc = XSTRING (string_saved)->data + op; |
| 483 } | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
484 else DISCARD (1); |
| 396 | 485 break; |
| 486 | |
| 934 | 487 case Bgotoifnonnilelsepop: |
| 16628 | 488 MAYBE_GC (); |
| 934 | 489 op = FETCH2; |
| 944 | 490 if (!NILP (TOP)) |
| 396 | 491 { |
| 492 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
493 CHECK_RANGE (op); |
| 934 | 494 pc = XSTRING (string_saved)->data + op; |
| 396 | 495 } |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
496 else DISCARD (1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
497 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
498 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
499 case BRgoto: |
| 16628 | 500 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
501 QUIT; |
|
15873
77950cb46314
(Fbyte_code): For relative gotos, force signed arithmetic.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
502 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
|
503 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
504 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
505 case BRgotoifnil: |
| 16628 | 506 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
507 if (NILP (POP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
508 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
509 QUIT; |
|
15873
77950cb46314
(Fbyte_code): For relative gotos, force signed arithmetic.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
510 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
|
511 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
512 pc++; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
513 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
514 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
515 case BRgotoifnonnil: |
| 16628 | 516 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
517 if (!NILP (POP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
518 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
519 QUIT; |
|
15873
77950cb46314
(Fbyte_code): For relative gotos, force signed arithmetic.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
520 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
|
521 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
522 pc++; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
523 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
524 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
525 case BRgotoifnilelsepop: |
| 16628 | 526 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
527 op = *pc++; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
528 if (NILP (TOP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
529 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
530 QUIT; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
531 pc += op - 128; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
532 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
533 else DISCARD (1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
534 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
535 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
536 case BRgotoifnonnilelsepop: |
| 16628 | 537 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
538 op = *pc++; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
539 if (!NILP (TOP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
540 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
541 QUIT; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
542 pc += op - 128; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
543 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
544 else DISCARD (1); |
| 396 | 545 break; |
| 546 | |
| 310 | 547 case Breturn: |
| 548 v1 = POP; | |
| 549 goto exit; | |
| 550 | |
| 551 case Bdiscard: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
552 DISCARD (1); |
| 310 | 553 break; |
| 554 | |
| 555 case Bdup: | |
| 556 v1 = TOP; | |
| 557 PUSH (v1); | |
| 558 break; | |
| 559 | |
| 560 case Bconstant2: | |
| 561 PUSH (vectorp[FETCH2]); | |
| 562 break; | |
| 563 | |
| 564 case Bsave_excursion: | |
| 565 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
| 566 break; | |
| 567 | |
|
16292
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
568 case Bsave_current_buffer: |
|
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
569 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
|
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
570 break; |
|
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
571 |
| 310 | 572 case Bsave_window_excursion: |
| 573 TOP = Fsave_window_excursion (TOP); | |
| 574 break; | |
| 575 | |
| 576 case Bsave_restriction: | |
| 577 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | |
| 578 break; | |
| 579 | |
| 580 case Bcatch: | |
| 581 v1 = POP; | |
| 582 TOP = internal_catch (TOP, Feval, v1); | |
| 583 break; | |
| 584 | |
| 585 case Bunwind_protect: | |
| 586 record_unwind_protect (0, POP); | |
| 587 (specpdl_ptr - 1)->symbol = Qnil; | |
| 588 break; | |
| 589 | |
| 590 case Bcondition_case: | |
| 591 v1 = POP; | |
| 592 v1 = Fcons (POP, v1); | |
| 593 TOP = Fcondition_case (Fcons (TOP, v1)); | |
| 594 break; | |
| 595 | |
| 596 case Btemp_output_buffer_setup: | |
| 597 temp_output_buffer_setup (XSTRING (TOP)->data); | |
| 598 TOP = Vstandard_output; | |
| 599 break; | |
| 600 | |
| 601 case Btemp_output_buffer_show: | |
| 602 v1 = POP; | |
|
1911
d9fc49956cd8
* bytecode.c (Fbyte_code): Pass the correct number of arguments to
Jim Blandy <jimb@redhat.com>
parents:
1503
diff
changeset
|
603 temp_output_buffer_show (TOP); |
| 310 | 604 TOP = v1; |
| 605 /* pop binding of standard-output */ | |
| 606 unbind_to (specpdl_ptr - specpdl - 1, Qnil); | |
| 607 break; | |
| 608 | |
| 609 case Bnth: | |
| 610 v1 = POP; | |
| 611 v2 = TOP; | |
| 612 nth_entry: | |
| 613 CHECK_NUMBER (v2, 0); | |
| 614 op = XINT (v2); | |
| 615 immediate_quit = 1; | |
| 616 while (--op >= 0) | |
| 617 { | |
| 618 if (CONSP (v1)) | |
| 619 v1 = XCONS (v1)->cdr; | |
| 944 | 620 else if (!NILP (v1)) |
| 310 | 621 { |
| 622 immediate_quit = 0; | |
| 623 v1 = wrong_type_argument (Qlistp, v1); | |
| 624 immediate_quit = 1; | |
| 625 op++; | |
| 626 } | |
| 627 } | |
| 628 immediate_quit = 0; | |
| 629 goto docar; | |
| 630 | |
| 631 case Bsymbolp: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
632 TOP = SYMBOLP (TOP) ? Qt : Qnil; |
| 310 | 633 break; |
| 634 | |
| 635 case Bconsp: | |
| 636 TOP = CONSP (TOP) ? Qt : Qnil; | |
| 637 break; | |
| 638 | |
| 639 case Bstringp: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
640 TOP = STRINGP (TOP) ? Qt : Qnil; |
| 310 | 641 break; |
| 642 | |
| 643 case Blistp: | |
| 944 | 644 TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil; |
| 310 | 645 break; |
| 646 | |
| 647 case Beq: | |
| 648 v1 = POP; | |
| 649 TOP = EQ (v1, TOP) ? Qt : Qnil; | |
| 650 break; | |
| 651 | |
| 652 case Bmemq: | |
| 653 v1 = POP; | |
| 654 TOP = Fmemq (TOP, v1); | |
| 655 break; | |
| 656 | |
| 657 case Bnot: | |
| 944 | 658 TOP = NILP (TOP) ? Qt : Qnil; |
| 310 | 659 break; |
| 660 | |
| 661 case Bcar: | |
| 662 v1 = TOP; | |
| 663 docar: | |
| 664 if (CONSP (v1)) TOP = XCONS (v1)->car; | |
| 944 | 665 else if (NILP (v1)) TOP = Qnil; |
| 310 | 666 else Fcar (wrong_type_argument (Qlistp, v1)); |
| 667 break; | |
| 668 | |
| 669 case Bcdr: | |
| 670 v1 = TOP; | |
| 671 if (CONSP (v1)) TOP = XCONS (v1)->cdr; | |
| 944 | 672 else if (NILP (v1)) TOP = Qnil; |
| 310 | 673 else Fcdr (wrong_type_argument (Qlistp, v1)); |
| 674 break; | |
| 675 | |
| 676 case Bcons: | |
| 677 v1 = POP; | |
| 678 TOP = Fcons (TOP, v1); | |
| 679 break; | |
| 680 | |
| 681 case Blist1: | |
| 682 TOP = Fcons (TOP, Qnil); | |
| 683 break; | |
| 684 | |
| 685 case Blist2: | |
| 686 v1 = POP; | |
| 687 TOP = Fcons (TOP, Fcons (v1, Qnil)); | |
| 688 break; | |
| 689 | |
| 690 case Blist3: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
691 DISCARD (2); |
| 310 | 692 TOP = Flist (3, &TOP); |
| 693 break; | |
| 694 | |
| 695 case Blist4: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
696 DISCARD (3); |
| 310 | 697 TOP = Flist (4, &TOP); |
| 698 break; | |
| 699 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
700 case BlistN: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
701 op = FETCH; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
702 DISCARD (op - 1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
703 TOP = Flist (op, &TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
704 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
705 |
| 310 | 706 case Blength: |
| 707 TOP = Flength (TOP); | |
| 708 break; | |
| 709 | |
| 710 case Baref: | |
| 711 v1 = POP; | |
| 712 TOP = Faref (TOP, v1); | |
| 713 break; | |
| 714 | |
| 715 case Baset: | |
| 716 v2 = POP; v1 = POP; | |
| 717 TOP = Faset (TOP, v1, v2); | |
| 718 break; | |
| 719 | |
| 720 case Bsymbol_value: | |
| 721 TOP = Fsymbol_value (TOP); | |
| 722 break; | |
| 723 | |
| 724 case Bsymbol_function: | |
| 725 TOP = Fsymbol_function (TOP); | |
| 726 break; | |
| 727 | |
| 728 case Bset: | |
| 729 v1 = POP; | |
| 730 TOP = Fset (TOP, v1); | |
| 731 break; | |
| 732 | |
| 733 case Bfset: | |
| 734 v1 = POP; | |
| 735 TOP = Ffset (TOP, v1); | |
| 736 break; | |
| 737 | |
| 738 case Bget: | |
| 739 v1 = POP; | |
| 740 TOP = Fget (TOP, v1); | |
| 741 break; | |
| 742 | |
| 743 case Bsubstring: | |
| 744 v2 = POP; v1 = POP; | |
| 745 TOP = Fsubstring (TOP, v1, v2); | |
| 746 break; | |
| 747 | |
| 748 case Bconcat2: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
749 DISCARD (1); |
| 310 | 750 TOP = Fconcat (2, &TOP); |
| 751 break; | |
| 752 | |
| 753 case Bconcat3: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
754 DISCARD (2); |
| 310 | 755 TOP = Fconcat (3, &TOP); |
| 756 break; | |
| 757 | |
| 758 case Bconcat4: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
759 DISCARD (3); |
| 310 | 760 TOP = Fconcat (4, &TOP); |
| 761 break; | |
| 762 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
763 case BconcatN: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
764 op = FETCH; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
765 DISCARD (op - 1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
766 TOP = Fconcat (op, &TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
767 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
768 |
| 310 | 769 case Bsub1: |
| 770 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
771 if (INTEGERP (v1)) |
| 310 | 772 { |
| 773 XSETINT (v1, XINT (v1) - 1); | |
| 774 TOP = v1; | |
| 775 } | |
| 776 else | |
| 777 TOP = Fsub1 (v1); | |
| 778 break; | |
| 779 | |
| 780 case Badd1: | |
| 781 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
782 if (INTEGERP (v1)) |
| 310 | 783 { |
| 784 XSETINT (v1, XINT (v1) + 1); | |
| 785 TOP = v1; | |
| 786 } | |
| 787 else | |
| 788 TOP = Fadd1 (v1); | |
| 789 break; | |
| 790 | |
| 791 case Beqlsign: | |
| 792 v2 = POP; v1 = TOP; | |
| 793 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1, 0); | |
| 794 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
|
795 #ifdef LISP_FLOAT_TYPE |
|
12574
bbd93011edef
(Fbyte_code): Fix variable names in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
12527
diff
changeset
|
796 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
|
797 { |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
798 double f1, f2; |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
799 |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
800 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
|
801 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
|
802 TOP = (f1 == f2 ? Qt : Qnil); |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
803 } |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
804 else |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
805 #endif |
| 12575 | 806 TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil); |
| 310 | 807 break; |
| 808 | |
| 809 case Bgtr: | |
| 810 v1 = POP; | |
| 811 TOP = Fgtr (TOP, v1); | |
| 812 break; | |
| 813 | |
| 814 case Blss: | |
| 815 v1 = POP; | |
| 816 TOP = Flss (TOP, v1); | |
| 817 break; | |
| 818 | |
| 819 case Bleq: | |
| 820 v1 = POP; | |
| 821 TOP = Fleq (TOP, v1); | |
| 822 break; | |
| 823 | |
| 824 case Bgeq: | |
| 825 v1 = POP; | |
| 826 TOP = Fgeq (TOP, v1); | |
| 827 break; | |
| 828 | |
| 829 case Bdiff: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
830 DISCARD (1); |
| 310 | 831 TOP = Fminus (2, &TOP); |
| 832 break; | |
| 833 | |
| 834 case Bnegate: | |
| 835 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
836 if (INTEGERP (v1)) |
| 310 | 837 { |
| 838 XSETINT (v1, - XINT (v1)); | |
| 839 TOP = v1; | |
| 840 } | |
| 841 else | |
| 842 TOP = Fminus (1, &TOP); | |
| 843 break; | |
| 844 | |
| 845 case Bplus: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
846 DISCARD (1); |
| 310 | 847 TOP = Fplus (2, &TOP); |
| 848 break; | |
| 849 | |
| 850 case Bmax: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
851 DISCARD (1); |
| 310 | 852 TOP = Fmax (2, &TOP); |
| 853 break; | |
| 854 | |
| 855 case Bmin: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
856 DISCARD (1); |
| 310 | 857 TOP = Fmin (2, &TOP); |
| 858 break; | |
| 859 | |
| 860 case Bmult: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
861 DISCARD (1); |
| 310 | 862 TOP = Ftimes (2, &TOP); |
| 863 break; | |
| 864 | |
| 865 case Bquo: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
866 DISCARD (1); |
| 310 | 867 TOP = Fquo (2, &TOP); |
| 868 break; | |
| 869 | |
| 870 case Brem: | |
| 871 v1 = POP; | |
| 872 TOP = Frem (TOP, v1); | |
| 873 break; | |
| 874 | |
| 875 case Bpoint: | |
|
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15873
diff
changeset
|
876 XSETFASTINT (v1, PT); |
| 310 | 877 PUSH (v1); |
| 878 break; | |
| 879 | |
| 880 case Bgoto_char: | |
| 881 TOP = Fgoto_char (TOP); | |
| 882 break; | |
| 883 | |
| 884 case Binsert: | |
| 885 TOP = Finsert (1, &TOP); | |
| 886 break; | |
| 887 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
888 case BinsertN: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
889 op = FETCH; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
890 DISCARD (op - 1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
891 TOP = Finsert (op, &TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
892 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
893 |
| 310 | 894 case Bpoint_max: |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
895 XSETFASTINT (v1, ZV); |
| 310 | 896 PUSH (v1); |
| 897 break; | |
| 898 | |
| 899 case Bpoint_min: | |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
900 XSETFASTINT (v1, BEGV); |
| 310 | 901 PUSH (v1); |
| 902 break; | |
| 903 | |
| 904 case Bchar_after: | |
| 905 TOP = Fchar_after (TOP); | |
| 906 break; | |
| 907 | |
| 908 case Bfollowing_char: | |
|
10134
c681703f7ce3
(Fbyte_code): Call Ffollowing_char and Fprevious_char
Richard M. Stallman <rms@gnu.org>
parents:
9894
diff
changeset
|
909 v1 = Ffollowing_char (); |
| 310 | 910 PUSH (v1); |
| 911 break; | |
| 912 | |
| 913 case Bpreceding_char: | |
|
10134
c681703f7ce3
(Fbyte_code): Call Ffollowing_char and Fprevious_char
Richard M. Stallman <rms@gnu.org>
parents:
9894
diff
changeset
|
914 v1 = Fprevious_char (); |
| 310 | 915 PUSH (v1); |
| 916 break; | |
| 917 | |
| 918 case Bcurrent_column: | |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
919 XSETFASTINT (v1, current_column ()); |
| 310 | 920 PUSH (v1); |
| 921 break; | |
| 922 | |
| 923 case Bindent_to: | |
| 924 TOP = Findent_to (TOP, Qnil); | |
| 925 break; | |
| 926 | |
| 927 case Beolp: | |
| 928 PUSH (Feolp ()); | |
| 929 break; | |
| 930 | |
| 931 case Beobp: | |
| 932 PUSH (Feobp ()); | |
| 933 break; | |
| 934 | |
| 935 case Bbolp: | |
| 936 PUSH (Fbolp ()); | |
| 937 break; | |
| 938 | |
| 939 case Bbobp: | |
| 940 PUSH (Fbobp ()); | |
| 941 break; | |
| 942 | |
| 943 case Bcurrent_buffer: | |
| 944 PUSH (Fcurrent_buffer ()); | |
| 945 break; | |
| 946 | |
| 947 case Bset_buffer: | |
| 948 TOP = Fset_buffer (TOP); | |
| 949 break; | |
| 950 | |
| 951 case Bread_char: | |
| 952 PUSH (Fread_char ()); | |
| 953 QUIT; | |
| 954 break; | |
| 955 | |
| 956 case Binteractive_p: | |
| 957 PUSH (Finteractive_p ()); | |
| 958 break; | |
| 959 | |
| 960 case Bforward_char: | |
| 961 TOP = Fforward_char (TOP); | |
| 962 break; | |
| 963 | |
| 964 case Bforward_word: | |
| 965 TOP = Fforward_word (TOP); | |
| 966 break; | |
| 967 | |
| 968 case Bskip_chars_forward: | |
| 969 v1 = POP; | |
| 970 TOP = Fskip_chars_forward (TOP, v1); | |
| 971 break; | |
| 972 | |
| 973 case Bskip_chars_backward: | |
| 974 v1 = POP; | |
| 975 TOP = Fskip_chars_backward (TOP, v1); | |
| 976 break; | |
| 977 | |
| 978 case Bforward_line: | |
| 979 TOP = Fforward_line (TOP); | |
| 980 break; | |
| 981 | |
| 982 case Bchar_syntax: | |
| 983 CHECK_NUMBER (TOP, 0); | |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
984 XSETFASTINT (TOP, |
|
10134
c681703f7ce3
(Fbyte_code): Call Ffollowing_char and Fprevious_char
Richard M. Stallman <rms@gnu.org>
parents:
9894
diff
changeset
|
985 syntax_code_spec[(int) SYNTAX (XINT (TOP))]); |
| 310 | 986 break; |
| 987 | |
| 988 case Bbuffer_substring: | |
| 989 v1 = POP; | |
| 990 TOP = Fbuffer_substring (TOP, v1); | |
| 991 break; | |
| 992 | |
| 993 case Bdelete_region: | |
| 994 v1 = POP; | |
| 995 TOP = Fdelete_region (TOP, v1); | |
| 996 break; | |
| 997 | |
| 998 case Bnarrow_to_region: | |
| 999 v1 = POP; | |
| 1000 TOP = Fnarrow_to_region (TOP, v1); | |
| 1001 break; | |
| 1002 | |
| 1003 case Bwiden: | |
| 1004 PUSH (Fwiden ()); | |
| 1005 break; | |
| 1006 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1007 case Bend_of_line: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1008 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
|
1009 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1010 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1011 case Bset_marker: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1012 v1 = POP; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1013 v2 = POP; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1014 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
|
1015 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1016 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1017 case Bmatch_beginning: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1018 TOP = Fmatch_beginning (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1019 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1020 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1021 case Bmatch_end: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1022 TOP = Fmatch_end (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1023 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1024 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1025 case Bupcase: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1026 TOP = Fupcase (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1027 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1028 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1029 case Bdowncase: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1030 TOP = Fdowncase (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1031 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1032 |
| 310 | 1033 case Bstringeqlsign: |
| 1034 v1 = POP; | |
| 1035 TOP = Fstring_equal (TOP, v1); | |
| 1036 break; | |
| 1037 | |
| 1038 case Bstringlss: | |
| 1039 v1 = POP; | |
| 1040 TOP = Fstring_lessp (TOP, v1); | |
| 1041 break; | |
| 1042 | |
| 1043 case Bequal: | |
| 1044 v1 = POP; | |
| 1045 TOP = Fequal (TOP, v1); | |
| 1046 break; | |
| 1047 | |
| 1048 case Bnthcdr: | |
| 1049 v1 = POP; | |
| 1050 TOP = Fnthcdr (TOP, v1); | |
| 1051 break; | |
| 1052 | |
| 1053 case Belt: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1054 if (CONSP (TOP)) |
| 310 | 1055 { |
| 1056 /* Exchange args and then do nth. */ | |
| 1057 v2 = POP; | |
| 1058 v1 = TOP; | |
| 1059 goto nth_entry; | |
| 1060 } | |
| 1061 v1 = POP; | |
| 1062 TOP = Felt (TOP, v1); | |
| 1063 break; | |
| 1064 | |
| 1065 case Bmember: | |
| 1066 v1 = POP; | |
| 1067 TOP = Fmember (TOP, v1); | |
| 1068 break; | |
| 1069 | |
| 1070 case Bassq: | |
| 1071 v1 = POP; | |
| 1072 TOP = Fassq (TOP, v1); | |
| 1073 break; | |
| 1074 | |
| 1075 case Bnreverse: | |
| 1076 TOP = Fnreverse (TOP); | |
| 1077 break; | |
| 1078 | |
| 1079 case Bsetcar: | |
| 1080 v1 = POP; | |
| 1081 TOP = Fsetcar (TOP, v1); | |
| 1082 break; | |
| 1083 | |
| 1084 case Bsetcdr: | |
| 1085 v1 = POP; | |
| 1086 TOP = Fsetcdr (TOP, v1); | |
| 1087 break; | |
| 1088 | |
| 1089 case Bcar_safe: | |
| 1090 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1091 if (CONSP (v1)) |
| 310 | 1092 TOP = XCONS (v1)->car; |
| 1093 else | |
| 1094 TOP = Qnil; | |
| 1095 break; | |
| 1096 | |
| 1097 case Bcdr_safe: | |
| 1098 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1099 if (CONSP (v1)) |
| 310 | 1100 TOP = XCONS (v1)->cdr; |
| 1101 else | |
| 1102 TOP = Qnil; | |
| 1103 break; | |
| 1104 | |
| 1105 case Bnconc: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1106 DISCARD (1); |
| 310 | 1107 TOP = Fnconc (2, &TOP); |
| 1108 break; | |
| 1109 | |
| 1110 case Bnumberp: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1111 TOP = (NUMBERP (TOP) ? Qt : Qnil); |
| 310 | 1112 break; |
| 1113 | |
| 1114 case Bintegerp: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1115 TOP = INTEGERP (TOP) ? Qt : Qnil; |
| 310 | 1116 break; |
| 1117 | |
| 1118 #ifdef BYTE_CODE_SAFE | |
| 1119 case Bset_mark: | |
| 1120 error ("set-mark is an obsolete bytecode"); | |
| 1121 break; | |
| 1122 case Bscan_buffer: | |
| 1123 error ("scan-buffer is an obsolete bytecode"); | |
| 1124 break; | |
| 1125 case Bmark: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1126 error ("mark is an obsolete bytecode"); |
| 310 | 1127 break; |
| 1128 #endif | |
| 1129 | |
| 1130 default: | |
| 1131 #ifdef BYTE_CODE_SAFE | |
| 1132 if (op < Bconstant) | |
| 1133 error ("unknown bytecode %d (byte compiler bug)", op); | |
| 1134 if ((op -= Bconstant) >= const_length) | |
| 1135 error ("no constant number %d (byte compiler bug)", op); | |
| 1136 PUSH (vectorp[op]); | |
| 1137 #else | |
| 1138 PUSH (vectorp[op - Bconstant]); | |
| 1139 #endif | |
| 1140 } | |
| 1141 } | |
| 1142 | |
| 1143 exit: | |
| 1144 UNGCPRO; | |
| 1145 /* Binds and unbinds are supposed to be compiled balanced. */ | |
| 1146 if (specpdl_ptr - specpdl != count) | |
| 1147 #ifdef BYTE_CODE_SAFE | |
| 1148 error ("binding stack not balanced (serious byte compiler bug)"); | |
| 1149 #else | |
| 1150 abort (); | |
| 1151 #endif | |
| 1152 return v1; | |
| 1153 } | |
| 1154 | |
| 1155 syms_of_bytecode () | |
| 1156 { | |
| 1157 Qbytecode = intern ("byte-code"); | |
| 1158 staticpro (&Qbytecode); | |
| 1159 | |
| 1160 defsubr (&Sbyte_code); | |
| 1161 | |
| 1162 #ifdef BYTE_CODE_METER | |
| 1163 | |
| 1164 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
|
1165 "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
|
1166 (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
|
1167 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
|
1168 (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
|
1169 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
|
1170 executed in succession."); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1171 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
|
1172 "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
|
1173 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
|
1174 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
|
1175 integer, it is incremented each time that symbol's function is called."); |
| 310 | 1176 |
| 1177 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
|
1178 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
|
1179 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
|
1180 staticpro (&Qbyte_code_meter); |
| 310 | 1181 { |
| 1182 int i = 256; | |
| 1183 while (i--) | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1184 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
|
1185 Fmake_vector (make_number (256), make_number (0)); |
| 310 | 1186 } |
| 1187 #endif | |
| 1188 } |
