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