Mercurial > emacs
annotate src/bytecode.c @ 26368:b3378aff433e
(Fbyte_code): Use BEFORE_POTENTIAL_GC and
AFTER_POTENTIAL_GC around internal_catch.
| author | Gerd Moellmann <gerd@gnu.org> |
|---|---|
| date | Fri, 05 Nov 1999 21:55:27 +0000 |
| parents | efb608f1cb10 |
| children | 5f52cc1417ab |
| 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" | |
| 23715 | 39 #include "charset.h" |
| 310 | 40 #include "syntax.h" |
| 41 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
42 /* |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
43 * 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
|
44 * debugging the byte compiler...) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
45 * |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
46 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. |
| 310 | 47 */ |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
48 /* #define BYTE_CODE_SAFE */ |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
49 /* #define BYTE_CODE_METER */ |
| 310 | 50 |
| 51 | |
| 52 #ifdef BYTE_CODE_METER | |
| 53 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
54 Lisp_Object Vbyte_code_meter, Qbyte_code_meter; |
| 310 | 55 int byte_metering_on; |
| 56 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
57 #define METER_2(code1, code2) \ |
| 310 | 58 XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \ |
| 59 ->contents[(code2)]) | |
| 60 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
61 #define METER_1(code) METER_2 (0, (code)) |
| 310 | 62 |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
63 #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
|
64 { \ |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
65 if (byte_metering_on) \ |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
66 { \ |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
67 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
|
68 METER_1 (this_code)++; \ |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
69 if (last_code \ |
|
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) != ((1<<VALBITS)-1))\ |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
71 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
|
72 } \ |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
73 } |
| 310 | 74 |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
75 #else /* no BYTE_CODE_METER */ |
| 310 | 76 |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
77 #define METER_CODE(last_code, this_code) |
| 310 | 78 |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
79 #endif /* no BYTE_CODE_METER */ |
| 310 | 80 |
| 81 | |
| 82 Lisp_Object Qbytecode; | |
| 83 | |
| 84 /* Byte codes: */ | |
| 85 | |
| 86 #define Bvarref 010 | |
| 87 #define Bvarset 020 | |
| 88 #define Bvarbind 030 | |
| 89 #define Bcall 040 | |
| 90 #define Bunbind 050 | |
| 91 | |
| 92 #define Bnth 070 | |
| 93 #define Bsymbolp 071 | |
| 94 #define Bconsp 072 | |
| 95 #define Bstringp 073 | |
| 96 #define Blistp 074 | |
| 97 #define Beq 075 | |
| 98 #define Bmemq 076 | |
| 99 #define Bnot 077 | |
| 100 #define Bcar 0100 | |
| 101 #define Bcdr 0101 | |
| 102 #define Bcons 0102 | |
| 103 #define Blist1 0103 | |
| 104 #define Blist2 0104 | |
| 105 #define Blist3 0105 | |
| 106 #define Blist4 0106 | |
| 107 #define Blength 0107 | |
| 108 #define Baref 0110 | |
| 109 #define Baset 0111 | |
| 110 #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
|
111 #define Bsymbol_function 0113 |
| 310 | 112 #define Bset 0114 |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
113 #define Bfset 0115 |
| 310 | 114 #define Bget 0116 |
| 115 #define Bsubstring 0117 | |
| 116 #define Bconcat2 0120 | |
| 117 #define Bconcat3 0121 | |
| 118 #define Bconcat4 0122 | |
| 119 #define Bsub1 0123 | |
| 120 #define Badd1 0124 | |
| 121 #define Beqlsign 0125 | |
| 122 #define Bgtr 0126 | |
| 123 #define Blss 0127 | |
| 124 #define Bleq 0130 | |
| 125 #define Bgeq 0131 | |
| 126 #define Bdiff 0132 | |
| 127 #define Bnegate 0133 | |
| 128 #define Bplus 0134 | |
| 129 #define Bmax 0135 | |
| 130 #define Bmin 0136 | |
| 131 #define Bmult 0137 | |
| 132 | |
| 133 #define Bpoint 0140 | |
|
16292
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
134 /* Was Bmark in v17. */ |
|
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
135 #define Bsave_current_buffer 0141 |
| 310 | 136 #define Bgoto_char 0142 |
| 137 #define Binsert 0143 | |
| 138 #define Bpoint_max 0144 | |
| 139 #define Bpoint_min 0145 | |
| 140 #define Bchar_after 0146 | |
| 141 #define Bfollowing_char 0147 | |
| 142 #define Bpreceding_char 0150 | |
| 143 #define Bcurrent_column 0151 | |
| 144 #define Bindent_to 0152 | |
| 145 #define Bscan_buffer 0153 /* No longer generated as of v18 */ | |
| 146 #define Beolp 0154 | |
| 147 #define Beobp 0155 | |
| 148 #define Bbolp 0156 | |
| 149 #define Bbobp 0157 | |
| 150 #define Bcurrent_buffer 0160 | |
| 151 #define Bset_buffer 0161 | |
| 18245 | 152 #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
|
153 #define Bread_char 0162 /* No longer generated as of v19 */ |
| 310 | 154 #define Bset_mark 0163 /* this loser is no longer generated as of v18 */ |
| 155 #define Binteractive_p 0164 /* Needed since interactive-p takes unevalled args */ | |
| 156 | |
| 157 #define Bforward_char 0165 | |
| 158 #define Bforward_word 0166 | |
| 159 #define Bskip_chars_forward 0167 | |
| 160 #define Bskip_chars_backward 0170 | |
| 161 #define Bforward_line 0171 | |
| 162 #define Bchar_syntax 0172 | |
| 163 #define Bbuffer_substring 0173 | |
| 164 #define Bdelete_region 0174 | |
| 165 #define Bnarrow_to_region 0175 | |
| 166 #define Bwiden 0176 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
167 #define Bend_of_line 0177 |
| 310 | 168 |
| 169 #define Bconstant2 0201 | |
| 170 #define Bgoto 0202 | |
| 171 #define Bgotoifnil 0203 | |
| 172 #define Bgotoifnonnil 0204 | |
| 173 #define Bgotoifnilelsepop 0205 | |
| 174 #define Bgotoifnonnilelsepop 0206 | |
| 175 #define Breturn 0207 | |
| 176 #define Bdiscard 0210 | |
| 177 #define Bdup 0211 | |
| 178 | |
| 179 #define Bsave_excursion 0212 | |
| 180 #define Bsave_window_excursion 0213 | |
| 181 #define Bsave_restriction 0214 | |
| 182 #define Bcatch 0215 | |
| 183 | |
| 184 #define Bunwind_protect 0216 | |
| 185 #define Bcondition_case 0217 | |
| 186 #define Btemp_output_buffer_setup 0220 | |
| 187 #define Btemp_output_buffer_show 0221 | |
| 188 | |
| 189 #define Bunbind_all 0222 | |
| 190 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
191 #define Bset_marker 0223 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
192 #define Bmatch_beginning 0224 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
193 #define Bmatch_end 0225 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
194 #define Bupcase 0226 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
195 #define Bdowncase 0227 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
196 |
| 310 | 197 #define Bstringeqlsign 0230 |
| 198 #define Bstringlss 0231 | |
| 199 #define Bequal 0232 | |
| 200 #define Bnthcdr 0233 | |
| 201 #define Belt 0234 | |
| 202 #define Bmember 0235 | |
| 203 #define Bassq 0236 | |
| 204 #define Bnreverse 0237 | |
| 205 #define Bsetcar 0240 | |
| 206 #define Bsetcdr 0241 | |
| 207 #define Bcar_safe 0242 | |
| 208 #define Bcdr_safe 0243 | |
| 209 #define Bnconc 0244 | |
| 210 #define Bquo 0245 | |
| 211 #define Brem 0246 | |
| 212 #define Bnumberp 0247 | |
| 213 #define Bintegerp 0250 | |
| 214 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
215 #define BRgoto 0252 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
216 #define BRgotoifnil 0253 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
217 #define BRgotoifnonnil 0254 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
218 #define BRgotoifnilelsepop 0255 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
219 #define BRgotoifnonnilelsepop 0256 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
220 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
221 #define BlistN 0257 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
222 #define BconcatN 0260 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
223 #define BinsertN 0261 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
224 |
| 310 | 225 #define Bconstant 0300 |
| 226 #define CONSTANTLIM 0100 | |
| 26363 | 227 |
| 228 /* Structure describing a value stack used during byte-code execution | |
| 229 in Fbyte_code. */ | |
| 230 | |
| 231 struct byte_stack | |
| 232 { | |
| 233 /* Program counter. This points into the byte_string below | |
| 234 and is relocated when that string is relocated. */ | |
| 235 unsigned char *pc; | |
| 236 | |
| 237 /* Top and bottom of stack. The bottom points to an area of memory | |
| 238 allocated with alloca in Fbyte_code. */ | |
| 239 Lisp_Object *top, *bottom; | |
| 240 | |
| 241 /* The string containing the byte-code, and its current address. | |
| 242 Storing this here protects it from GC because mark_byte_stack | |
| 243 marks it. */ | |
| 244 Lisp_Object byte_string; | |
| 245 unsigned char *byte_string_start; | |
| 246 | |
| 247 /* The vector of constants used during byte-code execution. Storing | |
| 248 this here protects it from GC because mark_byte_stack marks it. */ | |
| 249 Lisp_Object constants; | |
| 250 | |
| 251 /* Next entry in byte_stack_list. */ | |
| 252 struct byte_stack *next; | |
| 253 }; | |
| 254 | |
| 255 /* A list of currently active byte-code execution value stacks. | |
| 256 Fbyte_code adds an entry to the head of this list before it starts | |
| 257 processing byte-code, and it removed the entry again when it is | |
| 258 done. Signalling an error truncates the list analoguous to | |
| 259 gcprolist. */ | |
| 260 | |
| 261 struct byte_stack *byte_stack_list; | |
| 262 | |
| 263 /* Mark objects on byte_stack_list. Called during GC. */ | |
| 264 | |
| 265 void | |
| 266 mark_byte_stack () | |
| 267 { | |
| 268 struct byte_stack *stack; | |
| 269 Lisp_Object *obj; | |
| 270 | |
| 271 for (stack = byte_stack_list; stack; stack = stack->next) | |
| 272 { | |
| 273 if (!stack->top) | |
| 274 abort (); | |
| 275 | |
| 276 for (obj = stack->bottom; obj <= stack->top; ++obj) | |
| 277 mark_object (obj); | |
| 278 | |
| 279 mark_object (&stack->byte_string); | |
| 280 mark_object (&stack->constants); | |
| 281 } | |
| 282 } | |
| 283 | |
| 284 | |
| 285 /* Relocate program counters in the stacks on byte_stack_list. Called | |
| 286 when GC has completed. */ | |
| 287 | |
| 288 void | |
| 289 relocate_byte_pcs () | |
| 290 { | |
| 291 struct byte_stack *stack; | |
| 292 | |
| 293 for (stack = byte_stack_list; stack; stack = stack->next) | |
| 294 if (stack->byte_string_start != XSTRING (stack->byte_string)->data) | |
| 295 { | |
| 296 int offset = stack->pc - stack->byte_string_start; | |
| 297 stack->byte_string_start = XSTRING (stack->byte_string)->data; | |
| 298 stack->pc = stack->byte_string_start + offset; | |
| 299 } | |
| 300 } | |
| 301 | |
| 302 | |
| 310 | 303 |
| 304 /* Fetch the next byte from the bytecode stream */ | |
| 305 | |
| 26363 | 306 #define FETCH *stack.pc++ |
| 310 | 307 |
| 308 /* Fetch two bytes from the bytecode stream | |
| 309 and make a 16-bit number out of them */ | |
| 310 | |
| 311 #define FETCH2 (op = FETCH, op + (FETCH << 8)) | |
| 312 | |
| 313 /* Push x onto the execution stack. */ | |
| 314 | |
| 26363 | 315 /* This used to be #define PUSH(x) (*++stackp = (x)) This oddity is |
| 316 necessary because Alliant can't be bothered to compile the | |
| 317 preincrement operator properly, as of 4/91. -JimB */ | |
| 318 | |
| 319 #define PUSH(x) (top++, *top = (x)) | |
| 310 | 320 |
| 321 /* Pop a value off the execution stack. */ | |
| 322 | |
| 26363 | 323 #define POP (*top--) |
| 310 | 324 |
| 325 /* Discard n values from the execution stack. */ | |
| 326 | |
| 26363 | 327 #define DISCARD(n) (top -= (n)) |
| 328 | |
| 329 /* Get the value which is at the top of the execution stack, but don't | |
| 330 pop it. */ | |
| 310 | 331 |
| 26363 | 332 #define TOP (*top) |
| 310 | 333 |
| 26363 | 334 /* Actions that must performed before and after calling a function |
| 335 that might GC. */ | |
| 336 | |
| 337 #define BEFORE_POTENTIAL_GC() stack.top = top | |
| 338 #define AFTER_POTENTIAL_GC() stack.top = NULL | |
| 310 | 339 |
| 16628 | 340 /* Garbage collect if we have consed enough since the last time. |
| 341 We do this at every branch, to avoid loops that never GC. */ | |
| 342 | |
| 343 #define MAYBE_GC() \ | |
| 344 if (consing_since_gc > gc_cons_threshold) \ | |
|
16815
9e0f59154164
(HANDLE_RELOCATION): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16784
diff
changeset
|
345 { \ |
| 26363 | 346 BEFORE_POTENTIAL_GC (); \ |
|
16815
9e0f59154164
(HANDLE_RELOCATION): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16784
diff
changeset
|
347 Fgarbage_collect (); \ |
| 26363 | 348 AFTER_POTENTIAL_GC (); \ |
|
16815
9e0f59154164
(HANDLE_RELOCATION): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16784
diff
changeset
|
349 } \ |
|
9e0f59154164
(HANDLE_RELOCATION): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16784
diff
changeset
|
350 else |
|
9e0f59154164
(HANDLE_RELOCATION): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16784
diff
changeset
|
351 |
| 26363 | 352 /* Check for jumping out of range. */ |
| 16628 | 353 |
| 26363 | 354 #ifdef BYTE_CODE_SAFE |
| 355 | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
356 #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
|
357 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
|
358 |
| 26363 | 359 #else |
| 360 | |
| 361 #define CHECK_RANGE(ARG) | |
| 362 | |
| 363 #endif | |
| 364 | |
| 365 | |
| 310 | 366 DEFUN ("byte-code", Fbyte_code, Sbyte_code, 3, 3, 0, |
| 367 "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
|
368 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
|
369 the second, VECTOR, a vector of constants;\n\ |
|
bf43ef5a139c
(Fbyte_code): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
12575
diff
changeset
|
370 the third, MAXDEPTH, the maximum stack depth used in this function.\n\ |
| 310 | 371 If the third argument is incorrect, Emacs may crash.") |
| 372 (bytestr, vector, maxdepth) | |
| 373 Lisp_Object bytestr, vector, maxdepth; | |
| 374 { | |
| 375 int count = specpdl_ptr - specpdl; | |
| 376 #ifdef BYTE_CODE_METER | |
| 377 int this_op = 0; | |
| 378 int prev_op; | |
| 379 #endif | |
| 26363 | 380 int op; |
| 381 Lisp_Object v1, v2; | |
| 382 Lisp_Object *stackp; | |
| 383 Lisp_Object *vectorp = XVECTOR (vector)->contents; | |
| 310 | 384 #ifdef BYTE_CODE_SAFE |
| 26363 | 385 int const_length = XVECTOR (vector)->size; |
| 386 Lisp_Object *stacke; | |
| 310 | 387 #endif |
|
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
20697
diff
changeset
|
388 int bytestr_length = STRING_BYTES (XSTRING (bytestr)); |
| 26363 | 389 struct byte_stack stack; |
| 390 Lisp_Object *top; | |
| 310 | 391 |
| 392 CHECK_STRING (bytestr, 0); | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
393 if (!VECTORP (vector)) |
| 310 | 394 vector = wrong_type_argument (Qvectorp, vector); |
| 395 CHECK_NUMBER (maxdepth, 2); | |
| 396 | |
| 26363 | 397 stack.byte_string = bytestr; |
| 398 stack.pc = stack.byte_string_start = XSTRING (bytestr)->data; | |
| 399 stack.constants = vector; | |
| 400 stack.bottom = (Lisp_Object *) alloca (XFASTINT (maxdepth) | |
| 401 * sizeof (Lisp_Object)); | |
| 402 top = stack.bottom - 1; | |
| 403 stack.top = NULL; | |
| 404 stack.next = byte_stack_list; | |
| 405 byte_stack_list = &stack; | |
| 310 | 406 |
| 26363 | 407 #ifdef BYTE_CODE_SAFE |
| 408 stacke = stack.bottom - 1 + XFASTINT (maxdepth); | |
| 409 #endif | |
| 410 | |
| 310 | 411 while (1) |
| 412 { | |
| 413 #ifdef BYTE_CODE_SAFE | |
| 26363 | 414 if (top > stacks) |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
415 error ("Byte code stack overflow (byte compiler bug), pc %d, depth %d", |
| 26363 | 416 stack.pc - stack.byte_string_start, stacke - top); |
| 417 else if (top < stack.bottom - 1) | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
418 error ("Byte code stack underflow (byte compiler bug), pc %d", |
| 26363 | 419 stack.pc - stack.byte_string_start); |
| 310 | 420 #endif |
| 421 | |
| 422 #ifdef BYTE_CODE_METER | |
| 423 prev_op = this_op; | |
| 424 this_op = op = FETCH; | |
| 425 METER_CODE (prev_op, op); | |
| 426 switch (op) | |
| 427 #else | |
| 428 switch (op = FETCH) | |
| 429 #endif | |
| 430 { | |
| 431 case Bvarref+6: | |
| 432 op = FETCH; | |
| 433 goto varref; | |
| 434 | |
| 435 case Bvarref+7: | |
| 436 op = FETCH2; | |
| 437 goto varref; | |
| 438 | |
| 439 case Bvarref: case Bvarref+1: case Bvarref+2: case Bvarref+3: | |
| 440 case Bvarref+4: case Bvarref+5: | |
| 441 op = op - Bvarref; | |
| 442 varref: | |
| 443 v1 = vectorp[op]; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
444 if (!SYMBOLP (v1)) |
| 310 | 445 v2 = Fsymbol_value (v1); |
| 446 else | |
| 447 { | |
| 448 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
|
449 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
|
450 v2 = Fsymbol_value (v1); |
| 310 | 451 } |
| 452 PUSH (v2); | |
| 453 break; | |
| 454 | |
| 455 case Bvarset+6: | |
| 456 op = FETCH; | |
| 457 goto varset; | |
| 458 | |
| 459 case Bvarset+7: | |
| 460 op = FETCH2; | |
| 461 goto varset; | |
| 462 | |
| 463 case Bvarset: case Bvarset+1: case Bvarset+2: case Bvarset+3: | |
| 464 case Bvarset+4: case Bvarset+5: | |
| 465 op -= Bvarset; | |
| 466 varset: | |
| 467 Fset (vectorp[op], POP); | |
| 468 break; | |
| 469 | |
| 470 case Bvarbind+6: | |
| 471 op = FETCH; | |
| 472 goto varbind; | |
| 473 | |
| 474 case Bvarbind+7: | |
| 475 op = FETCH2; | |
| 476 goto varbind; | |
| 477 | |
| 478 case Bvarbind: case Bvarbind+1: case Bvarbind+2: case Bvarbind+3: | |
| 479 case Bvarbind+4: case Bvarbind+5: | |
| 480 op -= Bvarbind; | |
| 481 varbind: | |
| 482 specbind (vectorp[op], POP); | |
| 483 break; | |
| 484 | |
| 485 case Bcall+6: | |
| 486 op = FETCH; | |
| 487 goto docall; | |
| 488 | |
| 489 case Bcall+7: | |
| 490 op = FETCH2; | |
| 491 goto docall; | |
| 492 | |
| 493 case Bcall: case Bcall+1: case Bcall+2: case Bcall+3: | |
| 494 case Bcall+4: case Bcall+5: | |
| 495 op -= Bcall; | |
| 496 docall: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
497 DISCARD (op); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
498 #ifdef BYTE_CODE_METER |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
499 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
|
500 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
501 v1 = TOP; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
502 v2 = Fget (v1, Qbyte_code_meter); |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
503 if (INTEGERP (v2) |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
504 && 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
|
505 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
506 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
|
507 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
|
508 } |
|
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 #endif |
| 26363 | 511 BEFORE_POTENTIAL_GC (); |
| 310 | 512 TOP = Ffuncall (op + 1, &TOP); |
| 26363 | 513 AFTER_POTENTIAL_GC (); |
| 310 | 514 break; |
| 515 | |
| 516 case Bunbind+6: | |
| 517 op = FETCH; | |
| 518 goto dounbind; | |
| 519 | |
| 520 case Bunbind+7: | |
| 521 op = FETCH2; | |
| 522 goto dounbind; | |
| 523 | |
| 524 case Bunbind: case Bunbind+1: case Bunbind+2: case Bunbind+3: | |
| 525 case Bunbind+4: case Bunbind+5: | |
| 526 op -= Bunbind; | |
| 527 dounbind: | |
| 26363 | 528 BEFORE_POTENTIAL_GC (); |
| 310 | 529 unbind_to (specpdl_ptr - specpdl - op, Qnil); |
| 26363 | 530 AFTER_POTENTIAL_GC (); |
| 310 | 531 break; |
| 532 | |
| 533 case Bunbind_all: | |
| 534 /* 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
|
535 but will be needed for tail-recursion elimination. */ |
| 26363 | 536 BEFORE_POTENTIAL_GC (); |
| 310 | 537 unbind_to (count, Qnil); |
| 26363 | 538 AFTER_POTENTIAL_GC (); |
| 310 | 539 break; |
| 540 | |
| 541 case Bgoto: | |
| 16628 | 542 MAYBE_GC (); |
| 310 | 543 QUIT; |
| 544 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
|
545 CHECK_RANGE (op); |
| 26363 | 546 stack.pc = stack.byte_string_start + op; |
| 310 | 547 break; |
| 548 | |
| 549 case Bgotoifnil: | |
| 16628 | 550 MAYBE_GC (); |
| 310 | 551 op = FETCH2; |
| 944 | 552 if (NILP (POP)) |
| 310 | 553 { |
| 554 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
555 CHECK_RANGE (op); |
| 26363 | 556 stack.pc = stack.byte_string_start + op; |
| 310 | 557 } |
| 558 break; | |
| 559 | |
| 560 case Bgotoifnonnil: | |
| 16628 | 561 MAYBE_GC (); |
| 310 | 562 op = FETCH2; |
| 944 | 563 if (!NILP (POP)) |
| 310 | 564 { |
| 565 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
566 CHECK_RANGE (op); |
| 26363 | 567 stack.pc = stack.byte_string_start + op; |
| 310 | 568 } |
| 569 break; | |
| 570 | |
| 571 case Bgotoifnilelsepop: | |
| 16628 | 572 MAYBE_GC (); |
| 310 | 573 op = FETCH2; |
| 944 | 574 if (NILP (TOP)) |
| 310 | 575 { |
| 576 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
577 CHECK_RANGE (op); |
| 26363 | 578 stack.pc = stack.byte_string_start + op; |
| 310 | 579 } |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
580 else DISCARD (1); |
| 396 | 581 break; |
| 582 | |
| 934 | 583 case Bgotoifnonnilelsepop: |
| 16628 | 584 MAYBE_GC (); |
| 934 | 585 op = FETCH2; |
| 944 | 586 if (!NILP (TOP)) |
| 396 | 587 { |
| 588 QUIT; | |
|
16784
79ea730b7e20
(Fbyte_code): Add error check for jumping out of range.
Richard M. Stallman <rms@gnu.org>
parents:
16628
diff
changeset
|
589 CHECK_RANGE (op); |
| 26363 | 590 stack.pc = stack.byte_string_start + op; |
| 396 | 591 } |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
592 else DISCARD (1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
593 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
594 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
595 case BRgoto: |
| 16628 | 596 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
597 QUIT; |
| 26363 | 598 stack.pc += (int) *stack.pc - 127; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
599 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
600 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
601 case BRgotoifnil: |
| 16628 | 602 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
603 if (NILP (POP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
604 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
605 QUIT; |
| 26363 | 606 stack.pc += (int) *stack.pc - 128; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
607 } |
| 26363 | 608 stack.pc++; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
609 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
610 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
611 case BRgotoifnonnil: |
| 16628 | 612 MAYBE_GC (); |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
613 if (!NILP (POP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
614 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
615 QUIT; |
| 26363 | 616 stack.pc += (int) *stack.pc - 128; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
617 } |
| 26363 | 618 stack.pc++; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
619 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
620 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
621 case BRgotoifnilelsepop: |
| 16628 | 622 MAYBE_GC (); |
| 26363 | 623 op = *stack.pc++; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
624 if (NILP (TOP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
625 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
626 QUIT; |
| 26363 | 627 stack.pc += op - 128; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
628 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
629 else DISCARD (1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
630 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
631 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
632 case BRgotoifnonnilelsepop: |
| 16628 | 633 MAYBE_GC (); |
| 26363 | 634 op = *stack.pc++; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
635 if (!NILP (TOP)) |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
636 { |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
637 QUIT; |
| 26363 | 638 stack.pc += op - 128; |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
639 } |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
640 else DISCARD (1); |
| 396 | 641 break; |
| 642 | |
| 310 | 643 case Breturn: |
| 644 v1 = POP; | |
| 645 goto exit; | |
| 646 | |
| 647 case Bdiscard: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
648 DISCARD (1); |
| 310 | 649 break; |
| 650 | |
| 651 case Bdup: | |
| 652 v1 = TOP; | |
| 653 PUSH (v1); | |
| 654 break; | |
| 655 | |
| 656 case Bconstant2: | |
| 657 PUSH (vectorp[FETCH2]); | |
| 658 break; | |
| 659 | |
| 660 case Bsave_excursion: | |
| 661 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | |
| 662 break; | |
| 663 | |
|
16292
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
664 case Bsave_current_buffer: |
| 18245 | 665 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
|
666 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
|
667 break; |
|
86408ea93da6
(Bsave_current_buffer): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
16039
diff
changeset
|
668 |
| 310 | 669 case Bsave_window_excursion: |
| 670 TOP = Fsave_window_excursion (TOP); | |
| 671 break; | |
| 672 | |
| 673 case Bsave_restriction: | |
| 674 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | |
| 675 break; | |
| 676 | |
| 677 case Bcatch: | |
| 678 v1 = POP; | |
|
26368
b3378aff433e
(Fbyte_code): Use BEFORE_POTENTIAL_GC and
Gerd Moellmann <gerd@gnu.org>
parents:
26363
diff
changeset
|
679 BEFORE_POTENTIAL_GC (); |
| 310 | 680 TOP = internal_catch (TOP, Feval, v1); |
|
26368
b3378aff433e
(Fbyte_code): Use BEFORE_POTENTIAL_GC and
Gerd Moellmann <gerd@gnu.org>
parents:
26363
diff
changeset
|
681 AFTER_POTENTIAL_GC (); |
| 310 | 682 break; |
| 683 | |
| 684 case Bunwind_protect: | |
| 685 record_unwind_protect (0, POP); | |
| 686 (specpdl_ptr - 1)->symbol = Qnil; | |
| 687 break; | |
| 688 | |
| 689 case Bcondition_case: | |
| 690 v1 = POP; | |
| 691 v1 = Fcons (POP, v1); | |
| 26363 | 692 BEFORE_POTENTIAL_GC (); |
| 310 | 693 TOP = Fcondition_case (Fcons (TOP, v1)); |
| 26363 | 694 AFTER_POTENTIAL_GC (); |
| 310 | 695 break; |
| 696 | |
| 697 case Btemp_output_buffer_setup: | |
| 698 temp_output_buffer_setup (XSTRING (TOP)->data); | |
| 699 TOP = Vstandard_output; | |
| 700 break; | |
| 701 | |
| 702 case Btemp_output_buffer_show: | |
| 703 v1 = POP; | |
|
1911
d9fc49956cd8
* bytecode.c (Fbyte_code): Pass the correct number of arguments to
Jim Blandy <jimb@redhat.com>
parents:
1503
diff
changeset
|
704 temp_output_buffer_show (TOP); |
| 310 | 705 TOP = v1; |
| 706 /* pop binding of standard-output */ | |
| 26363 | 707 BEFORE_POTENTIAL_GC (); |
| 310 | 708 unbind_to (specpdl_ptr - specpdl - 1, Qnil); |
| 26363 | 709 AFTER_POTENTIAL_GC (); |
| 310 | 710 break; |
| 711 | |
| 712 case Bnth: | |
| 713 v1 = POP; | |
| 714 v2 = TOP; | |
| 715 nth_entry: | |
| 716 CHECK_NUMBER (v2, 0); | |
| 717 op = XINT (v2); | |
| 718 immediate_quit = 1; | |
| 719 while (--op >= 0) | |
| 720 { | |
| 721 if (CONSP (v1)) | |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23715
diff
changeset
|
722 v1 = XCDR (v1); |
| 944 | 723 else if (!NILP (v1)) |
| 310 | 724 { |
| 725 immediate_quit = 0; | |
| 726 v1 = wrong_type_argument (Qlistp, v1); | |
| 727 immediate_quit = 1; | |
| 728 op++; | |
| 729 } | |
| 730 } | |
| 731 immediate_quit = 0; | |
| 732 goto docar; | |
| 733 | |
| 734 case Bsymbolp: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
735 TOP = SYMBOLP (TOP) ? Qt : Qnil; |
| 310 | 736 break; |
| 737 | |
| 738 case Bconsp: | |
| 739 TOP = CONSP (TOP) ? Qt : Qnil; | |
| 740 break; | |
| 741 | |
| 742 case Bstringp: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
743 TOP = STRINGP (TOP) ? Qt : Qnil; |
| 310 | 744 break; |
| 745 | |
| 746 case Blistp: | |
| 944 | 747 TOP = CONSP (TOP) || NILP (TOP) ? Qt : Qnil; |
| 310 | 748 break; |
| 749 | |
| 750 case Beq: | |
| 751 v1 = POP; | |
| 752 TOP = EQ (v1, TOP) ? Qt : Qnil; | |
| 753 break; | |
| 754 | |
| 755 case Bmemq: | |
| 756 v1 = POP; | |
| 757 TOP = Fmemq (TOP, v1); | |
| 758 break; | |
| 759 | |
| 760 case Bnot: | |
| 944 | 761 TOP = NILP (TOP) ? Qt : Qnil; |
| 310 | 762 break; |
| 763 | |
| 764 case Bcar: | |
| 765 v1 = TOP; | |
| 766 docar: | |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23715
diff
changeset
|
767 if (CONSP (v1)) TOP = XCAR (v1); |
| 944 | 768 else if (NILP (v1)) TOP = Qnil; |
| 310 | 769 else Fcar (wrong_type_argument (Qlistp, v1)); |
| 770 break; | |
| 771 | |
| 772 case Bcdr: | |
| 773 v1 = TOP; | |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23715
diff
changeset
|
774 if (CONSP (v1)) TOP = XCDR (v1); |
| 944 | 775 else if (NILP (v1)) TOP = Qnil; |
| 310 | 776 else Fcdr (wrong_type_argument (Qlistp, v1)); |
| 777 break; | |
| 778 | |
| 779 case Bcons: | |
| 780 v1 = POP; | |
| 781 TOP = Fcons (TOP, v1); | |
| 782 break; | |
| 783 | |
| 784 case Blist1: | |
| 785 TOP = Fcons (TOP, Qnil); | |
| 786 break; | |
| 787 | |
| 788 case Blist2: | |
| 789 v1 = POP; | |
| 790 TOP = Fcons (TOP, Fcons (v1, Qnil)); | |
| 791 break; | |
| 792 | |
| 793 case Blist3: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
794 DISCARD (2); |
| 310 | 795 TOP = Flist (3, &TOP); |
| 796 break; | |
| 797 | |
| 798 case Blist4: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
799 DISCARD (3); |
| 310 | 800 TOP = Flist (4, &TOP); |
| 801 break; | |
| 802 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
803 case BlistN: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
804 op = FETCH; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
805 DISCARD (op - 1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
806 TOP = Flist (op, &TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
807 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
808 |
| 310 | 809 case Blength: |
| 810 TOP = Flength (TOP); | |
| 811 break; | |
| 812 | |
| 813 case Baref: | |
| 814 v1 = POP; | |
| 815 TOP = Faref (TOP, v1); | |
| 816 break; | |
| 817 | |
| 818 case Baset: | |
| 819 v2 = POP; v1 = POP; | |
| 820 TOP = Faset (TOP, v1, v2); | |
| 821 break; | |
| 822 | |
| 823 case Bsymbol_value: | |
| 824 TOP = Fsymbol_value (TOP); | |
| 825 break; | |
| 826 | |
| 827 case Bsymbol_function: | |
| 828 TOP = Fsymbol_function (TOP); | |
| 829 break; | |
| 830 | |
| 831 case Bset: | |
| 832 v1 = POP; | |
| 833 TOP = Fset (TOP, v1); | |
| 834 break; | |
| 835 | |
| 836 case Bfset: | |
| 837 v1 = POP; | |
| 838 TOP = Ffset (TOP, v1); | |
| 839 break; | |
| 840 | |
| 841 case Bget: | |
| 842 v1 = POP; | |
| 843 TOP = Fget (TOP, v1); | |
| 844 break; | |
| 845 | |
| 846 case Bsubstring: | |
| 847 v2 = POP; v1 = POP; | |
| 848 TOP = Fsubstring (TOP, v1, v2); | |
| 849 break; | |
| 850 | |
| 851 case Bconcat2: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
852 DISCARD (1); |
| 310 | 853 TOP = Fconcat (2, &TOP); |
| 854 break; | |
| 855 | |
| 856 case Bconcat3: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
857 DISCARD (2); |
| 310 | 858 TOP = Fconcat (3, &TOP); |
| 859 break; | |
| 860 | |
| 861 case Bconcat4: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
862 DISCARD (3); |
| 310 | 863 TOP = Fconcat (4, &TOP); |
| 864 break; | |
| 865 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
866 case BconcatN: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
867 op = FETCH; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
868 DISCARD (op - 1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
869 TOP = Fconcat (op, &TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
870 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
871 |
| 310 | 872 case Bsub1: |
| 873 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
874 if (INTEGERP (v1)) |
| 310 | 875 { |
| 876 XSETINT (v1, XINT (v1) - 1); | |
| 877 TOP = v1; | |
| 878 } | |
| 879 else | |
| 880 TOP = Fsub1 (v1); | |
| 881 break; | |
| 882 | |
| 883 case Badd1: | |
| 884 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
885 if (INTEGERP (v1)) |
| 310 | 886 { |
| 887 XSETINT (v1, XINT (v1) + 1); | |
| 888 TOP = v1; | |
| 889 } | |
| 890 else | |
| 891 TOP = Fadd1 (v1); | |
| 892 break; | |
| 893 | |
| 894 case Beqlsign: | |
| 895 v2 = POP; v1 = TOP; | |
| 896 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1, 0); | |
| 897 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
|
898 #ifdef LISP_FLOAT_TYPE |
|
12574
bbd93011edef
(Fbyte_code): Fix variable names in previous change.
Karl Heuer <kwzh@gnu.org>
parents:
12527
diff
changeset
|
899 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
|
900 { |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
901 double f1, f2; |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
902 |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23715
diff
changeset
|
903 f1 = (FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1)); |
|
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23715
diff
changeset
|
904 f2 = (FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2)); |
|
12527
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
905 TOP = (f1 == f2 ? Qt : Qnil); |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
906 } |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
907 else |
|
ebaf016075f1
(Fbyte_code): For Beqlsign, if both args are ints,
Karl Heuer <kwzh@gnu.org>
parents:
10134
diff
changeset
|
908 #endif |
| 12575 | 909 TOP = (XINT (v1) == XINT (v2) ? Qt : Qnil); |
| 310 | 910 break; |
| 911 | |
| 912 case Bgtr: | |
| 913 v1 = POP; | |
| 914 TOP = Fgtr (TOP, v1); | |
| 915 break; | |
| 916 | |
| 917 case Blss: | |
| 918 v1 = POP; | |
| 919 TOP = Flss (TOP, v1); | |
| 920 break; | |
| 921 | |
| 922 case Bleq: | |
| 923 v1 = POP; | |
| 924 TOP = Fleq (TOP, v1); | |
| 925 break; | |
| 926 | |
| 927 case Bgeq: | |
| 928 v1 = POP; | |
| 929 TOP = Fgeq (TOP, v1); | |
| 930 break; | |
| 931 | |
| 932 case Bdiff: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
933 DISCARD (1); |
| 310 | 934 TOP = Fminus (2, &TOP); |
| 935 break; | |
| 936 | |
| 937 case Bnegate: | |
| 938 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
939 if (INTEGERP (v1)) |
| 310 | 940 { |
| 941 XSETINT (v1, - XINT (v1)); | |
| 942 TOP = v1; | |
| 943 } | |
| 944 else | |
| 945 TOP = Fminus (1, &TOP); | |
| 946 break; | |
| 947 | |
| 948 case Bplus: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
949 DISCARD (1); |
| 310 | 950 TOP = Fplus (2, &TOP); |
| 951 break; | |
| 952 | |
| 953 case Bmax: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
954 DISCARD (1); |
| 310 | 955 TOP = Fmax (2, &TOP); |
| 956 break; | |
| 957 | |
| 958 case Bmin: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
959 DISCARD (1); |
| 310 | 960 TOP = Fmin (2, &TOP); |
| 961 break; | |
| 962 | |
| 963 case Bmult: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
964 DISCARD (1); |
| 310 | 965 TOP = Ftimes (2, &TOP); |
| 966 break; | |
| 967 | |
| 968 case Bquo: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
969 DISCARD (1); |
| 310 | 970 TOP = Fquo (2, &TOP); |
| 971 break; | |
| 972 | |
| 973 case Brem: | |
| 974 v1 = POP; | |
| 975 TOP = Frem (TOP, v1); | |
| 976 break; | |
| 977 | |
| 978 case Bpoint: | |
|
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15873
diff
changeset
|
979 XSETFASTINT (v1, PT); |
| 310 | 980 PUSH (v1); |
| 981 break; | |
| 982 | |
| 983 case Bgoto_char: | |
| 984 TOP = Fgoto_char (TOP); | |
| 985 break; | |
| 986 | |
| 987 case Binsert: | |
| 988 TOP = Finsert (1, &TOP); | |
| 989 break; | |
| 990 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
991 case BinsertN: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
992 op = FETCH; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
993 DISCARD (op - 1); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
994 TOP = Finsert (op, &TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
995 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
996 |
| 310 | 997 case Bpoint_max: |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
998 XSETFASTINT (v1, ZV); |
| 310 | 999 PUSH (v1); |
| 1000 break; | |
| 1001 | |
| 1002 case Bpoint_min: | |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
1003 XSETFASTINT (v1, BEGV); |
| 310 | 1004 PUSH (v1); |
| 1005 break; | |
| 1006 | |
| 1007 case Bchar_after: | |
| 1008 TOP = Fchar_after (TOP); | |
| 1009 break; | |
| 1010 | |
| 1011 case Bfollowing_char: | |
|
10134
c681703f7ce3
(Fbyte_code): Call Ffollowing_char and Fprevious_char
Richard M. Stallman <rms@gnu.org>
parents:
9894
diff
changeset
|
1012 v1 = Ffollowing_char (); |
| 310 | 1013 PUSH (v1); |
| 1014 break; | |
| 1015 | |
| 1016 case Bpreceding_char: | |
|
10134
c681703f7ce3
(Fbyte_code): Call Ffollowing_char and Fprevious_char
Richard M. Stallman <rms@gnu.org>
parents:
9894
diff
changeset
|
1017 v1 = Fprevious_char (); |
| 310 | 1018 PUSH (v1); |
| 1019 break; | |
| 1020 | |
| 1021 case Bcurrent_column: | |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
1022 XSETFASTINT (v1, current_column ()); |
| 310 | 1023 PUSH (v1); |
| 1024 break; | |
| 1025 | |
| 1026 case Bindent_to: | |
| 1027 TOP = Findent_to (TOP, Qnil); | |
| 1028 break; | |
| 1029 | |
| 1030 case Beolp: | |
| 1031 PUSH (Feolp ()); | |
| 1032 break; | |
| 1033 | |
| 1034 case Beobp: | |
| 1035 PUSH (Feobp ()); | |
| 1036 break; | |
| 1037 | |
| 1038 case Bbolp: | |
| 1039 PUSH (Fbolp ()); | |
| 1040 break; | |
| 1041 | |
| 1042 case Bbobp: | |
| 1043 PUSH (Fbobp ()); | |
| 1044 break; | |
| 1045 | |
| 1046 case Bcurrent_buffer: | |
| 1047 PUSH (Fcurrent_buffer ()); | |
| 1048 break; | |
| 1049 | |
| 1050 case Bset_buffer: | |
| 1051 TOP = Fset_buffer (TOP); | |
| 1052 break; | |
| 1053 | |
| 1054 case Binteractive_p: | |
| 1055 PUSH (Finteractive_p ()); | |
| 1056 break; | |
| 1057 | |
| 1058 case Bforward_char: | |
| 1059 TOP = Fforward_char (TOP); | |
| 1060 break; | |
| 1061 | |
| 1062 case Bforward_word: | |
| 1063 TOP = Fforward_word (TOP); | |
| 1064 break; | |
| 1065 | |
| 1066 case Bskip_chars_forward: | |
| 1067 v1 = POP; | |
| 1068 TOP = Fskip_chars_forward (TOP, v1); | |
| 1069 break; | |
| 1070 | |
| 1071 case Bskip_chars_backward: | |
| 1072 v1 = POP; | |
| 1073 TOP = Fskip_chars_backward (TOP, v1); | |
| 1074 break; | |
| 1075 | |
| 1076 case Bforward_line: | |
| 1077 TOP = Fforward_line (TOP); | |
| 1078 break; | |
| 1079 | |
| 1080 case Bchar_syntax: | |
| 1081 CHECK_NUMBER (TOP, 0); | |
|
9297
5151ce5ab25a
(Fbyte_code): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9139
diff
changeset
|
1082 XSETFASTINT (TOP, |
|
10134
c681703f7ce3
(Fbyte_code): Call Ffollowing_char and Fprevious_char
Richard M. Stallman <rms@gnu.org>
parents:
9894
diff
changeset
|
1083 syntax_code_spec[(int) SYNTAX (XINT (TOP))]); |
| 310 | 1084 break; |
| 1085 | |
| 1086 case Bbuffer_substring: | |
| 1087 v1 = POP; | |
| 1088 TOP = Fbuffer_substring (TOP, v1); | |
| 1089 break; | |
| 1090 | |
| 1091 case Bdelete_region: | |
| 1092 v1 = POP; | |
| 1093 TOP = Fdelete_region (TOP, v1); | |
| 1094 break; | |
| 1095 | |
| 1096 case Bnarrow_to_region: | |
| 1097 v1 = POP; | |
| 1098 TOP = Fnarrow_to_region (TOP, v1); | |
| 1099 break; | |
| 1100 | |
| 1101 case Bwiden: | |
| 1102 PUSH (Fwiden ()); | |
| 1103 break; | |
| 1104 | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1105 case Bend_of_line: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1106 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
|
1107 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1108 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1109 case Bset_marker: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1110 v1 = POP; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1111 v2 = POP; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1112 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
|
1113 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1114 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1115 case Bmatch_beginning: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1116 TOP = Fmatch_beginning (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1117 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1118 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1119 case Bmatch_end: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1120 TOP = Fmatch_end (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1121 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1122 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1123 case Bupcase: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1124 TOP = Fupcase (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1125 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1126 |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1127 case Bdowncase: |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1128 TOP = Fdowncase (TOP); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1129 break; |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1130 |
| 310 | 1131 case Bstringeqlsign: |
| 1132 v1 = POP; | |
| 1133 TOP = Fstring_equal (TOP, v1); | |
| 1134 break; | |
| 1135 | |
| 1136 case Bstringlss: | |
| 1137 v1 = POP; | |
| 1138 TOP = Fstring_lessp (TOP, v1); | |
| 1139 break; | |
| 1140 | |
| 1141 case Bequal: | |
| 1142 v1 = POP; | |
| 1143 TOP = Fequal (TOP, v1); | |
| 1144 break; | |
| 1145 | |
| 1146 case Bnthcdr: | |
| 1147 v1 = POP; | |
| 1148 TOP = Fnthcdr (TOP, v1); | |
| 1149 break; | |
| 1150 | |
| 1151 case Belt: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1152 if (CONSP (TOP)) |
| 310 | 1153 { |
| 1154 /* Exchange args and then do nth. */ | |
| 1155 v2 = POP; | |
| 1156 v1 = TOP; | |
| 1157 goto nth_entry; | |
| 1158 } | |
| 1159 v1 = POP; | |
| 1160 TOP = Felt (TOP, v1); | |
| 1161 break; | |
| 1162 | |
| 1163 case Bmember: | |
| 1164 v1 = POP; | |
| 1165 TOP = Fmember (TOP, v1); | |
| 1166 break; | |
| 1167 | |
| 1168 case Bassq: | |
| 1169 v1 = POP; | |
| 1170 TOP = Fassq (TOP, v1); | |
| 1171 break; | |
| 1172 | |
| 1173 case Bnreverse: | |
| 1174 TOP = Fnreverse (TOP); | |
| 1175 break; | |
| 1176 | |
| 1177 case Bsetcar: | |
| 1178 v1 = POP; | |
| 1179 TOP = Fsetcar (TOP, v1); | |
| 1180 break; | |
| 1181 | |
| 1182 case Bsetcdr: | |
| 1183 v1 = POP; | |
| 1184 TOP = Fsetcdr (TOP, v1); | |
| 1185 break; | |
| 1186 | |
| 1187 case Bcar_safe: | |
| 1188 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1189 if (CONSP (v1)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23715
diff
changeset
|
1190 TOP = XCAR (v1); |
| 310 | 1191 else |
| 1192 TOP = Qnil; | |
| 1193 break; | |
| 1194 | |
| 1195 case Bcdr_safe: | |
| 1196 v1 = TOP; | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1197 if (CONSP (v1)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
23715
diff
changeset
|
1198 TOP = XCDR (v1); |
| 310 | 1199 else |
| 1200 TOP = Qnil; | |
| 1201 break; | |
| 1202 | |
| 1203 case Bnconc: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1204 DISCARD (1); |
| 310 | 1205 TOP = Fnconc (2, &TOP); |
| 1206 break; | |
| 1207 | |
| 1208 case Bnumberp: | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1209 TOP = (NUMBERP (TOP) ? Qt : Qnil); |
| 310 | 1210 break; |
| 1211 | |
| 1212 case Bintegerp: | |
|
9139
127823d9444d
(Fbyte_code): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
4696
diff
changeset
|
1213 TOP = INTEGERP (TOP) ? Qt : Qnil; |
| 310 | 1214 break; |
| 1215 | |
| 1216 #ifdef BYTE_CODE_SAFE | |
| 1217 case Bset_mark: | |
| 1218 error ("set-mark is an obsolete bytecode"); | |
| 1219 break; | |
| 1220 case Bscan_buffer: | |
| 1221 error ("scan-buffer is an obsolete bytecode"); | |
| 1222 break; | |
| 1223 #endif | |
| 1224 | |
| 1225 default: | |
| 1226 #ifdef BYTE_CODE_SAFE | |
| 1227 if (op < Bconstant) | |
| 1228 error ("unknown bytecode %d (byte compiler bug)", op); | |
| 1229 if ((op -= Bconstant) >= const_length) | |
| 1230 error ("no constant number %d (byte compiler bug)", op); | |
| 1231 PUSH (vectorp[op]); | |
| 1232 #else | |
| 1233 PUSH (vectorp[op - Bconstant]); | |
| 1234 #endif | |
| 1235 } | |
| 1236 } | |
| 1237 | |
| 1238 exit: | |
| 26363 | 1239 |
| 1240 byte_stack_list = byte_stack_list->next; | |
| 1241 | |
| 310 | 1242 /* Binds and unbinds are supposed to be compiled balanced. */ |
| 1243 if (specpdl_ptr - specpdl != count) | |
| 1244 #ifdef BYTE_CODE_SAFE | |
| 1245 error ("binding stack not balanced (serious byte compiler bug)"); | |
| 1246 #else | |
| 1247 abort (); | |
| 1248 #endif | |
| 26363 | 1249 |
| 310 | 1250 return v1; |
| 1251 } | |
| 1252 | |
| 21514 | 1253 void |
| 310 | 1254 syms_of_bytecode () |
| 1255 { | |
| 1256 Qbytecode = intern ("byte-code"); | |
| 1257 staticpro (&Qbytecode); | |
| 1258 | |
| 1259 defsubr (&Sbyte_code); | |
| 1260 | |
| 1261 #ifdef BYTE_CODE_METER | |
| 1262 | |
| 1263 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
|
1264 "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
|
1265 (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
|
1266 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
|
1267 (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
|
1268 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
|
1269 executed in succession."); |
|
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1270 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
|
1271 "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
|
1272 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
|
1273 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
|
1274 integer, it is incremented each time that symbol's function is called."); |
| 310 | 1275 |
| 1276 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
|
1277 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
|
1278 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
|
1279 staticpro (&Qbyte_code_meter); |
| 310 | 1280 { |
| 1281 int i = 256; | |
| 1282 while (i--) | |
|
959
c1fc76b79275
* bytecode.c (Fbyte_code): When metering the Bcall opcodes, make
Jim Blandy <jimb@redhat.com>
parents:
944
diff
changeset
|
1283 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
|
1284 Fmake_vector (make_number (256), make_number (0)); |
| 310 | 1285 } |
| 1286 #endif | |
| 1287 } |
