annotate src/bytecode.c @ 400:a86b2b5e0111 r21-2-30

Import from CVS: tag r21-2-30
author cvs
date Mon, 13 Aug 2007 11:14:34 +0200
parents 74fd4e045ea6
children de805c49cfc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Execution of byte code produced by bytecomp.el.
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2 Implementation of compiled-function objects.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Mule 2.0, FSF 19.30. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
24 /* This file has been Mule-ized. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
25
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
26
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 /* Authorship:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 FSF: long ago.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
31 hacked on by jwz@jwz.org 1991-06
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 o added a compile-time switch to turn on simple sanity checking;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 o put back the obsolete byte-codes for error-detection;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
34 o added a new instruction, unbind_all, which I will use for
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 tail-recursion elimination;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 o made temp_output_buffer_show be called with the right number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 of args;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 o made the new bytecodes be called with args in the right order;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 o added metering support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 by Hallvard:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 o added relative jump instructions;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 o all conditionals now only do QUIT if they jump.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
44
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
45 Ben Wing: some changes for Mule, 1995-06.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
46
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
47 Martin Buchholz: performance hacking, 1998-09.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
48 See Internals Manual, Evaluation.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #include "lisp.h"
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
53 #include "backtrace.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #include "buffer.h"
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
55 #include "bytecode.h"
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
56 #include "opaque.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #include "syntax.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
59 #include <limits.h>
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
60
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
61 EXFUN (Ffetch_bytecode, 1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
62
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
63 Lisp_Object Qbyte_code, Qcompiled_functionp, Qinvalid_byte_code;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
64
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
65 enum Opcode /* Byte codes */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
66 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
67 Bvarref = 010,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
68 Bvarset = 020,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
69 Bvarbind = 030,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
70 Bcall = 040,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
71 Bunbind = 050,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
72
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
73 Bnth = 070,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
74 Bsymbolp = 071,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
75 Bconsp = 072,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
76 Bstringp = 073,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
77 Blistp = 074,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
78 Bold_eq = 075,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
79 Bold_memq = 076,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
80 Bnot = 077,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
81 Bcar = 0100,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
82 Bcdr = 0101,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
83 Bcons = 0102,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
84 Blist1 = 0103,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
85 Blist2 = 0104,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
86 Blist3 = 0105,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
87 Blist4 = 0106,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
88 Blength = 0107,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
89 Baref = 0110,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
90 Baset = 0111,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
91 Bsymbol_value = 0112,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
92 Bsymbol_function = 0113,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
93 Bset = 0114,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
94 Bfset = 0115,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
95 Bget = 0116,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
96 Bsubstring = 0117,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
97 Bconcat2 = 0120,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
98 Bconcat3 = 0121,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
99 Bconcat4 = 0122,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
100 Bsub1 = 0123,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
101 Badd1 = 0124,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
102 Beqlsign = 0125,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
103 Bgtr = 0126,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
104 Blss = 0127,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
105 Bleq = 0130,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
106 Bgeq = 0131,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
107 Bdiff = 0132,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
108 Bnegate = 0133,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
109 Bplus = 0134,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
110 Bmax = 0135,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
111 Bmin = 0136,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
112 Bmult = 0137,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
113
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
114 Bpoint = 0140,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
115 Beq = 0141, /* was Bmark,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
116 but no longer generated as of v18 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
117 Bgoto_char = 0142,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
118 Binsert = 0143,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
119 Bpoint_max = 0144,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
120 Bpoint_min = 0145,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
121 Bchar_after = 0146,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
122 Bfollowing_char = 0147,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
123 Bpreceding_char = 0150,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
124 Bcurrent_column = 0151,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
125 Bindent_to = 0152,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
126 Bequal = 0153, /* was Bscan_buffer,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
127 but no longer generated as of v18 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
128 Beolp = 0154,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
129 Beobp = 0155,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
130 Bbolp = 0156,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
131 Bbobp = 0157,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
132 Bcurrent_buffer = 0160,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
133 Bset_buffer = 0161,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
134 Bsave_current_buffer = 0162, /* was Bread_char,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
135 but no longer generated as of v19 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
136 Bmemq = 0163, /* was Bset_mark,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
137 but no longer generated as of v18 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
138 Binteractive_p = 0164, /* Needed since interactive-p takes
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
139 unevalled args */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
140 Bforward_char = 0165,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
141 Bforward_word = 0166,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
142 Bskip_chars_forward = 0167,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
143 Bskip_chars_backward = 0170,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
144 Bforward_line = 0171,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
145 Bchar_syntax = 0172,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
146 Bbuffer_substring = 0173,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
147 Bdelete_region = 0174,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
148 Bnarrow_to_region = 0175,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
149 Bwiden = 0176,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
150 Bend_of_line = 0177,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
151
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
152 Bconstant2 = 0201,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
153 Bgoto = 0202,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
154 Bgotoifnil = 0203,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
155 Bgotoifnonnil = 0204,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
156 Bgotoifnilelsepop = 0205,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
157 Bgotoifnonnilelsepop = 0206,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
158 Breturn = 0207,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
159 Bdiscard = 0210,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
160 Bdup = 0211,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
161
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
162 Bsave_excursion = 0212,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
163 Bsave_window_excursion= 0213,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
164 Bsave_restriction = 0214,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
165 Bcatch = 0215,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
166
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
167 Bunwind_protect = 0216,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
168 Bcondition_case = 0217,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
169 Btemp_output_buffer_setup = 0220,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
170 Btemp_output_buffer_show = 0221,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
171
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
172 Bunbind_all = 0222,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
173
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
174 Bset_marker = 0223,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
175 Bmatch_beginning = 0224,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
176 Bmatch_end = 0225,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
177 Bupcase = 0226,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
178 Bdowncase = 0227,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
179
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
180 Bstring_equal = 0230,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
181 Bstring_lessp = 0231,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
182 Bold_equal = 0232,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
183 Bnthcdr = 0233,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
184 Belt = 0234,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
185 Bold_member = 0235,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
186 Bold_assq = 0236,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
187 Bnreverse = 0237,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
188 Bsetcar = 0240,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
189 Bsetcdr = 0241,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
190 Bcar_safe = 0242,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
191 Bcdr_safe = 0243,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
192 Bnconc = 0244,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
193 Bquo = 0245,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
194 Brem = 0246,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
195 Bnumberp = 0247,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
196 Bintegerp = 0250,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
197
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
198 BRgoto = 0252,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
199 BRgotoifnil = 0253,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
200 BRgotoifnonnil = 0254,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
201 BRgotoifnilelsepop = 0255,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
202 BRgotoifnonnilelsepop = 0256,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
203
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
204 BlistN = 0257,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
205 BconcatN = 0260,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
206 BinsertN = 0261,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
207 Bmember = 0266, /* new in v20 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
208 Bassq = 0267, /* new in v20 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
209
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
210 Bconstant = 0300
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
211 };
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
212 typedef enum Opcode Opcode;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
213 typedef unsigned char Opbyte;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
214
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
215
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
216 static void invalid_byte_code_error (char *error_message, ...);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
217
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
218 Lisp_Object * execute_rare_opcode (Lisp_Object *stack_ptr,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
219 const Opbyte *program_ptr,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
220 Opcode opcode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
221
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
222 static Lisp_Object execute_optimized_program (const Opbyte *program,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
223 int stack_depth,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
224 Lisp_Object *constants_data);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
225
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
226 extern Lisp_Object Qand_rest, Qand_optional;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
227
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
228 /* Define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
229 This isn't defined in FSF Emacs and isn't defined in XEmacs v19. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 /* #define BYTE_CODE_METER */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 #ifdef BYTE_CODE_METER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 Lisp_Object Vbyte_code_meter, Qbyte_code_meter;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 int byte_metering_on;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
238 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
239 meter_code (Opcode prev_opcode, Opcode this_opcode)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
240 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
241 if (byte_metering_on)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
242 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
243 Lisp_Object *p = XVECTOR_DATA (XVECTOR_DATA (Vbyte_code_meter)[this_opcode]);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
244 p[0] = INT_PLUS1 (p[0]);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
245 if (prev_opcode)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
246 p[prev_opcode] = INT_PLUS1 (p[prev_opcode]);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
247 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
248 }
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
249
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
250 #endif /* BYTE_CODE_METER */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
251
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
252
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
253 static Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
254 bytecode_negate (Lisp_Object obj)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
255 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
256 retry:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
257
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
258 if (INTP (obj)) return make_int (- XINT (obj));
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
259 #ifdef LISP_FLOAT_TYPE
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
260 if (FLOATP (obj)) return make_float (- XFLOAT_DATA (obj));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
261 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
262 if (CHARP (obj)) return make_int (- ((int) XCHAR (obj)));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
263 if (MARKERP (obj)) return make_int (- ((int) marker_position (obj)));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
264
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
265 obj = wrong_type_argument (Qnumber_char_or_marker_p, obj);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
266 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
267 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
268
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
269 static Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
270 bytecode_nreverse (Lisp_Object list)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
271 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
272 REGISTER Lisp_Object prev = Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
273 REGISTER Lisp_Object tail = list;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
274
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
275 while (!NILP (tail))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
276 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
277 REGISTER Lisp_Object next;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
278 CHECK_CONS (tail);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
279 next = XCDR (tail);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
280 XCDR (tail) = prev;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
281 prev = tail;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
282 tail = next;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
283 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
284 return prev;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
285 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
286
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
287
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
288 /* We have our own two-argument versions of various arithmetic ops.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
289 Only two-argument arithmetic operations have their own byte codes. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
290 static int
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
291 bytecode_arithcompare (Lisp_Object obj1, Lisp_Object obj2)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
292 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
293 retry:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
294
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
295 #ifdef LISP_FLOAT_TYPE
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
296 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
297 EMACS_INT ival1, ival2;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
298
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
299 if (INTP (obj1)) ival1 = XINT (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
300 else if (CHARP (obj1)) ival1 = XCHAR (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
301 else if (MARKERP (obj1)) ival1 = marker_position (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
302 else goto arithcompare_float;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
303
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
304 if (INTP (obj2)) ival2 = XINT (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
305 else if (CHARP (obj2)) ival2 = XCHAR (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
306 else if (MARKERP (obj2)) ival2 = marker_position (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
307 else goto arithcompare_float;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
308
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
309 return ival1 < ival2 ? -1 : ival1 > ival2 ? 1 : 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
310 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
311
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
312 arithcompare_float:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
313
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
314 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
315 double dval1, dval2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
316
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
317 if (FLOATP (obj1)) dval1 = XFLOAT_DATA (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
318 else if (INTP (obj1)) dval1 = (double) XINT (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
319 else if (CHARP (obj1)) dval1 = (double) XCHAR (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
320 else if (MARKERP (obj1)) dval1 = (double) marker_position (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
321 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
322 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
323 obj1 = wrong_type_argument (Qnumber_char_or_marker_p, obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
324 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
325 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
326
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
327 if (FLOATP (obj2)) dval2 = XFLOAT_DATA (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
328 else if (INTP (obj2)) dval2 = (double) XINT (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
329 else if (CHARP (obj2)) dval2 = (double) XCHAR (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
330 else if (MARKERP (obj2)) dval2 = (double) marker_position (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
331 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
332 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
333 obj2 = wrong_type_argument (Qnumber_char_or_marker_p, obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
334 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
335 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
336
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
337 return dval1 < dval2 ? -1 : dval1 > dval2 ? 1 : 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
338 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
339 #else /* !LISP_FLOAT_TYPE */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
340 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
341 EMACS_INT ival1, ival2;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
342
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
343 if (INTP (obj1)) ival1 = XINT (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
344 else if (CHARP (obj1)) ival1 = XCHAR (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
345 else if (MARKERP (obj1)) ival1 = marker_position (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
346 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
347 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
348 obj1 = wrong_type_argument (Qnumber_char_or_marker_p, obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
349 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
350 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
351
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
352 if (INTP (obj2)) ival2 = XINT (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
353 else if (CHARP (obj2)) ival2 = XCHAR (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
354 else if (MARKERP (obj2)) ival2 = marker_position (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
355 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
356 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
357 obj2 = wrong_type_argument (Qnumber_char_or_marker_p, obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
358 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
359 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
360
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
361 return ival1 < ival2 ? -1 : ival1 > ival2 ? 1 : 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
362 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
363 #endif /* !LISP_FLOAT_TYPE */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
366 static Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
367 bytecode_arithop (Lisp_Object obj1, Lisp_Object obj2, Opcode opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
368 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
369 #ifdef LISP_FLOAT_TYPE
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
370 EMACS_INT ival1, ival2;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
371 int float_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
373 retry:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
374
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
375 float_p = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
377 if (INTP (obj1)) ival1 = XINT (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
378 else if (CHARP (obj1)) ival1 = XCHAR (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
379 else if (MARKERP (obj1)) ival1 = marker_position (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
380 else if (FLOATP (obj1)) ival1 = 0, float_p = 1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
381 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
382 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
383 obj1 = wrong_type_argument (Qnumber_char_or_marker_p, obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
384 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
385 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
387 if (INTP (obj2)) ival2 = XINT (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
388 else if (CHARP (obj2)) ival2 = XCHAR (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
389 else if (MARKERP (obj2)) ival2 = marker_position (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
390 else if (FLOATP (obj2)) ival2 = 0, float_p = 1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
391 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
392 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
393 obj2 = wrong_type_argument (Qnumber_char_or_marker_p, obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
394 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
395 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
397 if (!float_p)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
398 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
399 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
400 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
401 case Bplus: ival1 += ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
402 case Bdiff: ival1 -= ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
403 case Bmult: ival1 *= ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
404 case Bquo:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
405 if (ival2 == 0) Fsignal (Qarith_error, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
406 ival1 /= ival2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
407 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
408 case Bmax: if (ival1 < ival2) ival1 = ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
409 case Bmin: if (ival1 > ival2) ival1 = ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
410 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
411 return make_int (ival1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
412 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
413 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
414 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
415 double dval1 = FLOATP (obj1) ? XFLOAT_DATA (obj1) : (double) ival1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
416 double dval2 = FLOATP (obj2) ? XFLOAT_DATA (obj2) : (double) ival2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
417 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
418 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
419 case Bplus: dval1 += dval2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
420 case Bdiff: dval1 -= dval2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
421 case Bmult: dval1 *= dval2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
422 case Bquo:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
423 if (dval2 == 0) Fsignal (Qarith_error, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
424 dval1 /= dval2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
425 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
426 case Bmax: if (dval1 < dval2) dval1 = dval2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
427 case Bmin: if (dval1 > dval2) dval1 = dval2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
428 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
429 return make_float (dval1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
430 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
431 #else /* !LISP_FLOAT_TYPE */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
432 EMACS_INT ival1, ival2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
434 retry:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
435
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
436 if (INTP (obj1)) ival1 = XINT (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
437 else if (CHARP (obj1)) ival1 = XCHAR (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
438 else if (MARKERP (obj1)) ival1 = marker_position (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
439 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
440 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
441 obj1 = wrong_type_argument (Qnumber_char_or_marker_p, obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
442 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
443 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
444
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
445 if (INTP (obj2)) ival2 = XINT (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
446 else if (CHARP (obj2)) ival2 = XCHAR (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
447 else if (MARKERP (obj2)) ival2 = marker_position (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
448 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
449 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
450 obj2 = wrong_type_argument (Qnumber_char_or_marker_p, obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
451 goto retry;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
452 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
454 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
455 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
456 case Bplus: ival1 += ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
457 case Bdiff: ival1 -= ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
458 case Bmult: ival1 *= ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
459 case Bquo:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
460 if (ival2 == 0) Fsignal (Qarith_error, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
461 ival1 /= ival2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
462 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
463 case Bmax: if (ival1 < ival2) ival1 = ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
464 case Bmin: if (ival1 > ival2) ival1 = ival2; break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
465 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
466 return make_int (ival1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
467 #endif /* !LISP_FLOAT_TYPE */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
468 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
469
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
470 /* Apply compiled-function object FUN to the NARGS evaluated arguments
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
471 in ARGS, and return the result of evaluation. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
472 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
473 funcall_compiled_function (Lisp_Object fun, int nargs, Lisp_Object args[])
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
474 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
475 /* This function can GC */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
476 Lisp_Object symbol, tail;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
477 int speccount = specpdl_depth();
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
478 REGISTER int i = 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
479 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
480 int optional = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
482 if (!OPAQUEP (f->instructions))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
483 /* Lazily munge the instructions into a more efficient form */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
484 optimize_compiled_function (fun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
485
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
486 /* optimize_compiled_function() guaranteed that f->specpdl_depth is
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
487 the required space on the specbinding stack for binding the args
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
488 and local variables of fun. So just reserve it once. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
489 SPECPDL_RESERVE (f->specpdl_depth);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
491 /* Fmake_byte_code() guaranteed that f->arglist is a valid list
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
492 containing only non-constant symbols. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
493 LIST_LOOP_3 (symbol, f->arglist, tail)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
494 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
495 if (EQ (symbol, Qand_rest))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
496 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
497 tail = XCDR (tail);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
498 symbol = XCAR (tail);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
499 SPECBIND_FAST_UNSAFE (symbol, Flist (nargs - i, &args[i]));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
500 goto run_code;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
501 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
502 else if (EQ (symbol, Qand_optional))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
503 optional = 1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
504 else if (i == nargs && !optional)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
505 goto wrong_number_of_arguments;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
506 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
507 SPECBIND_FAST_UNSAFE (symbol, i < nargs ? args[i++] : Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
508 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
510 if (i < nargs)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
511 goto wrong_number_of_arguments;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
512
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
513 run_code:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
514
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
515 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
516 Lisp_Object value =
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
517 execute_optimized_program ((Opbyte *) XOPAQUE_DATA (f->instructions),
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
518 f->stack_depth,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
519 XVECTOR_DATA (f->constants));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
520
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 382
diff changeset
521 /* The attempt to optimize this by only unbinding variables failed
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 382
diff changeset
522 because using buffer-local variables as function parameters
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 382
diff changeset
523 leads to specpdl_ptr->func != 0 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 382
diff changeset
524 /* UNBIND_TO_GCPRO_VARIABLES_ONLY (speccount, value); */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 382
diff changeset
525 UNBIND_TO_GCPRO (speccount, value);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
526 return value;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
527 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
528
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
529 wrong_number_of_arguments:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
530 /* The actual printed compiled_function object is incomprehensible.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
531 Check the backtrace to see if we can get a more meaningful symbol. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
532 if (EQ (fun, indirect_function (*backtrace_list->function, 0)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
533 fun = *backtrace_list->function;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
534 return Fsignal (Qwrong_number_of_arguments, list2 (fun, make_int (nargs)));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
535 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
536
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
537
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
538 /* Read next uint8 from the instruction stream. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
539 #define READ_UINT_1 ((unsigned int) (unsigned char) *program_ptr++)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
540
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
541 /* Read next uint16 from the instruction stream. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
542 #define READ_UINT_2 \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
543 (program_ptr += 2, \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
544 (((unsigned int) (unsigned char) program_ptr[-1]) * 256 + \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
545 ((unsigned int) (unsigned char) program_ptr[-2])))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
547 /* Read next int8 from the instruction stream. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
548 #define READ_INT_1 ((int) (signed char) *program_ptr++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
550 /* Read next int16 from the instruction stream. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
551 #define READ_INT_2 \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
552 (program_ptr += 2, \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
553 (((int) ( signed char) program_ptr[-1]) * 256 + \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
554 ((int) (unsigned char) program_ptr[-2])))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
555
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
556 /* Read next int8 from instruction stream; don't advance program_pointer */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
557 #define PEEK_INT_1 ((int) (signed char) program_ptr[0])
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
559 /* Read next int16 from instruction stream; don't advance program_pointer */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
560 #define PEEK_INT_2 \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
561 ((((int) ( signed char) program_ptr[1]) * 256) | \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
562 ((int) (unsigned char) program_ptr[0]))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
564 /* Do relative jumps from the current location.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
565 We only do a QUIT if we jump backwards, for efficiency.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
566 No infloops without backward jumps! */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
567 #define JUMP_RELATIVE(jump) do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
568 int JR_jump = (jump); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
569 if (JR_jump < 0) QUIT; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
570 program_ptr += JR_jump; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
571 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
573 #define JUMP JUMP_RELATIVE (PEEK_INT_2)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
574 #define JUMPR JUMP_RELATIVE (PEEK_INT_1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
576 #define JUMP_NEXT ((void) (program_ptr += 2))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
577 #define JUMPR_NEXT ((void) (program_ptr += 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 /* Push x onto the execution stack. */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
580 #define PUSH(x) (*++stack_ptr = (x))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
582 /* Pop a value off the execution stack. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
583 #define POP (*stack_ptr--)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 /* Discard n values from the execution stack. */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
586 #define DISCARD(n) (stack_ptr -= (n))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 /* Get the value which is at the top of the execution stack,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 but don't pop it. */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
590 #define TOP (*stack_ptr)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
592 /* The actual interpreter for byte code.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
593 This function has been seriously optimized for performance.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
594 Don't change the constructs unless you are willing to do
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
595 real benchmarking and profiling work -- martin */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
596
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
597
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
598 static Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
599 execute_optimized_program (const Opbyte *program,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
600 int stack_depth,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
601 Lisp_Object *constants_data)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 /* This function can GC */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
604 REGISTER const Opbyte *program_ptr = (Opbyte *) program;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
605 REGISTER Lisp_Object *stack_ptr
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
606 = alloca_array (Lisp_Object, stack_depth + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 int speccount = specpdl_depth ();
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
608 struct gcpro gcpro1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
609
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 #ifdef BYTE_CODE_METER
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
611 Opcode this_opcode = 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
612 Opcode prev_opcode;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
615 #ifdef ERROR_CHECK_BYTE_CODE
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
616 Lisp_Object *stack_beg = stack_ptr;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
617 Lisp_Object *stack_end = stack_beg + stack_depth;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
618 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
620 /* Initialize all the objects on the stack to Qnil,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
621 so we can GCPRO the whole stack.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
622 The first element of the stack is actually a dummy. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
623 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
624 int i;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
625 Lisp_Object *p;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
626 for (i = stack_depth, p = stack_ptr; i--;)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
627 *++p = Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
628 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
630 GCPRO1 (stack_ptr[1]);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
631 gcpro1.nvars = stack_depth;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 169
diff changeset
632
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
635 REGISTER Opcode opcode = (Opcode) READ_UINT_1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
636 #ifdef ERROR_CHECK_BYTE_CODE
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
637 if (stack_ptr > stack_end)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
638 invalid_byte_code_error ("byte code stack overflow");
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
639 if (stack_ptr < stack_beg)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
640 invalid_byte_code_error ("byte code stack underflow");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 #ifdef BYTE_CODE_METER
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
644 prev_opcode = this_opcode;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
645 this_opcode = opcode;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
646 meter_code (prev_opcode, this_opcode);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
649 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
650 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
651 REGISTER int n;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
653 default:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
654 if (opcode >= Bconstant)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
655 PUSH (constants_data[opcode - Bconstant]);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 else
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
657 stack_ptr = execute_rare_opcode (stack_ptr, program_ptr, opcode);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
660 case Bvarref:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
661 case Bvarref+1:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
662 case Bvarref+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
663 case Bvarref+3:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
664 case Bvarref+4:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
665 case Bvarref+5: n = opcode - Bvarref; goto do_varref;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
666 case Bvarref+7: n = READ_UINT_2; goto do_varref;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
667 case Bvarref+6: n = READ_UINT_1; /* most common */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
668 do_varref:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
669 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
670 Lisp_Object symbol = constants_data[n];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
671 Lisp_Object value = XSYMBOL (symbol)->value;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
672 if (SYMBOL_VALUE_MAGIC_P (value))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
673 value = Fsymbol_value (symbol);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
674 PUSH (value);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
675 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
676 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
678 case Bvarset:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
679 case Bvarset+1:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
680 case Bvarset+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
681 case Bvarset+3:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
682 case Bvarset+4:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
683 case Bvarset+5: n = opcode - Bvarset; goto do_varset;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
684 case Bvarset+7: n = READ_UINT_2; goto do_varset;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
685 case Bvarset+6: n = READ_UINT_1; /* most common */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
686 do_varset:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
687 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
688 Lisp_Object symbol = constants_data[n];
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
689 Lisp_Symbol *symbol_ptr = XSYMBOL (symbol);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
690 Lisp_Object old_value = symbol_ptr->value;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
691 Lisp_Object new_value = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
692 if (!SYMBOL_VALUE_MAGIC_P (old_value) || UNBOUNDP (old_value))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
693 symbol_ptr->value = new_value;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
694 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
695 Fset (symbol, new_value);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 break;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
697 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
699 case Bvarbind:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
700 case Bvarbind+1:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
701 case Bvarbind+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
702 case Bvarbind+3:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
703 case Bvarbind+4:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
704 case Bvarbind+5: n = opcode - Bvarbind; goto do_varbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
705 case Bvarbind+7: n = READ_UINT_2; goto do_varbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
706 case Bvarbind+6: n = READ_UINT_1; /* most common */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
707 do_varbind:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
708 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
709 Lisp_Object symbol = constants_data[n];
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
710 Lisp_Symbol *symbol_ptr = XSYMBOL (symbol);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
711 Lisp_Object old_value = symbol_ptr->value;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
712 Lisp_Object new_value = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
713 if (!SYMBOL_VALUE_MAGIC_P (old_value) || UNBOUNDP (old_value))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
714 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
715 specpdl_ptr->symbol = symbol;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
716 specpdl_ptr->old_value = old_value;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
717 specpdl_ptr->func = 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
718 specpdl_ptr++;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
719 specpdl_depth_counter++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
721 symbol_ptr->value = new_value;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
722 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
723 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
724 specbind_magic (symbol, new_value);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 break;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
726 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
728 case Bcall:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
729 case Bcall+1:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
730 case Bcall+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
731 case Bcall+3:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
732 case Bcall+4:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
733 case Bcall+5:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 case Bcall+6:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 case Bcall+7:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
736 n = (opcode < Bcall+6 ? opcode - Bcall :
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
737 opcode == Bcall+6 ? READ_UINT_1 : READ_UINT_2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
738 DISCARD (n);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 #ifdef BYTE_CODE_METER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 if (byte_metering_on && SYMBOLP (TOP))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
742 Lisp_Object val = Fget (TOP, Qbyte_code_meter, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
743 if (INTP (val))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
744 Fput (TOP, Qbyte_code_meter, make_int (XINT (val) + 1));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 }
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
746 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
747 TOP = Ffuncall (n + 1, &TOP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
748 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
749
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
750 case Bunbind:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
751 case Bunbind+1:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
752 case Bunbind+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
753 case Bunbind+3:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
754 case Bunbind+4:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
755 case Bunbind+5:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
756 case Bunbind+6:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
757 case Bunbind+7:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
758 UNBIND_TO (specpdl_depth() -
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
759 (opcode < Bunbind+6 ? opcode-Bunbind :
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
760 opcode == Bunbind+6 ? READ_UINT_1 : READ_UINT_2));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
761 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
762
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
763
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
764 case Bgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
765 JUMP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
766 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
767
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
768 case Bgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
769 if (NILP (POP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
770 JUMP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
771 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
772 JUMP_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
773 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
774
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
775 case Bgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
776 if (!NILP (POP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
777 JUMP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
778 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
779 JUMP_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
780 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
781
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
782 case Bgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
783 if (NILP (TOP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
784 JUMP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
785 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
786 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
787 DISCARD (1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
788 JUMP_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
789 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
790 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
791
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
792 case Bgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
793 if (!NILP (TOP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
794 JUMP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
795 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
796 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
797 DISCARD (1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
798 JUMP_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
799 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
800 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
801
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
802
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
803 case BRgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
804 JUMPR;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
807 case BRgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
808 if (NILP (POP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
809 JUMPR;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
810 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
811 JUMPR_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
812 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
813
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
814 case BRgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
815 if (!NILP (POP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
816 JUMPR;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
817 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
818 JUMPR_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
819 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
820
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
821 case BRgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
822 if (NILP (TOP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
823 JUMPR;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
824 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
825 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
826 DISCARD (1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
827 JUMPR_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
828 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
829 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
831 case BRgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
832 if (!NILP (TOP))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
833 JUMPR;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
834 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
835 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
836 DISCARD (1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
837 JUMPR_NEXT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
838 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
839 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
840
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
841 case Breturn:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
842 UNGCPRO;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
843 #ifdef ERROR_CHECK_BYTE_CODE
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
844 /* Binds and unbinds are supposed to be compiled balanced. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
845 if (specpdl_depth() != speccount)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
846 invalid_byte_code_error ("unbalanced specbinding stack");
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
847 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
848 return TOP;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
850 case Bdiscard:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
851 DISCARD (1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
854 case Bdup:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
855 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
856 Lisp_Object arg = TOP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
857 PUSH (arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
858 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
859 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
860
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
861 case Bconstant2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
862 PUSH (constants_data[READ_UINT_2]);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
863 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
864
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
865 case Bcar:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
866 TOP = CONSP (TOP) ? XCAR (TOP) : Fcar (TOP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
867 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
868
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
869 case Bcdr:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
870 TOP = CONSP (TOP) ? XCDR (TOP) : Fcdr (TOP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
871 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
872
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
873
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 case Bunbind_all:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 /* To unbind back to the beginning of this frame. Not used yet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 but will be needed for tail-recursion elimination. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 unbind_to (speccount, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 case Bnth:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
881 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
882 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
883 TOP = Fcar (Fnthcdr (TOP, arg));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
884 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
885 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 case Bsymbolp:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
888 TOP = SYMBOLP (TOP) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 case Bconsp:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
892 TOP = CONSP (TOP) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 case Bstringp:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
896 TOP = STRINGP (TOP) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 case Blistp:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
900 TOP = LISTP (TOP) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
903 case Bnumberp:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
904 TOP = INT_OR_FLOATP (TOP) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
907 case Bintegerp:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
908 TOP = INTP (TOP) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
911 case Beq:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
912 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
913 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
914 TOP = EQ_WITH_EBOLA_NOTICE (TOP, arg) ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
915 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
916 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
917
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 case Bnot:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 TOP = NILP (TOP) ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 case Bcons:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
923 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
924 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
925 TOP = Fcons (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
926 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
927 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 case Blist1:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 TOP = Fcons (TOP, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
933
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
934 case BlistN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
935 n = READ_UINT_1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
936 goto do_list;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
937
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 case Blist2:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
939 case Blist3:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
940 case Blist4:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
941 /* common case */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
942 n = opcode - (Blist1 - 1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
943 do_list:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
944 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
945 Lisp_Object list = Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
946 list_loop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
947 list = Fcons (TOP, list);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
948 if (--n)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
949 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
950 DISCARD (1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
951 goto list_loop;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
952 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
953 TOP = list;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
954 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
955 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
957
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
958 case Bconcat2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
959 case Bconcat3:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
960 case Bconcat4:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
961 n = opcode - (Bconcat2 - 2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
962 goto do_concat;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
963
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
964 case BconcatN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
965 /* common case */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
966 n = READ_UINT_1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
967 do_concat:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
968 DISCARD (n - 1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
969 TOP = Fconcat (n, &TOP);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 case Blength:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 TOP = Flength (TOP);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 case Baset:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
978 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
979 Lisp_Object arg2 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
980 Lisp_Object arg1 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
981 TOP = Faset (TOP, arg1, arg2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
982 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
983 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 case Bsymbol_value:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 TOP = Fsymbol_value (TOP);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 case Bsymbol_function:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 TOP = Fsymbol_function (TOP);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 case Bget:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
994 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
995 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
996 TOP = Fget (TOP, arg, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
997 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
998 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 case Bsub1:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1001 TOP = INTP (TOP) ? INT_MINUS1 (TOP) : Fsub1 (TOP);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 case Badd1:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1005 TOP = INTP (TOP) ? INT_PLUS1 (TOP) : Fadd1 (TOP);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1008
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 case Beqlsign:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1010 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1011 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1012 TOP = bytecode_arithcompare (TOP, arg) == 0 ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1013 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1014 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 case Bgtr:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1017 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1018 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1019 TOP = bytecode_arithcompare (TOP, arg) > 0 ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1020 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1021 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 case Blss:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1024 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1025 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1026 TOP = bytecode_arithcompare (TOP, arg) < 0 ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1027 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1028 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 case Bleq:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1031 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1032 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1033 TOP = bytecode_arithcompare (TOP, arg) <= 0 ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1034 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1035 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 case Bgeq:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1038 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1039 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1040 TOP = bytecode_arithcompare (TOP, arg) >= 0 ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1041 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1042 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1044
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1045 case Bnegate:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1046 TOP = bytecode_negate (TOP);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1049 case Bnconc:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1050 DISCARD (1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1051 TOP = bytecode_nconc2 (&TOP);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 case Bplus:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1055 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1056 Lisp_Object arg2 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1057 Lisp_Object arg1 = TOP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1058 TOP = INTP (arg1) && INTP (arg2) ?
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1059 INT_PLUS (arg1, arg2) :
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1060 bytecode_arithop (arg1, arg2, opcode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1061 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1062 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1064 case Bdiff:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1065 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1066 Lisp_Object arg2 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1067 Lisp_Object arg1 = TOP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1068 TOP = INTP (arg1) && INTP (arg2) ?
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1069 INT_MINUS (arg1, arg2) :
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1070 bytecode_arithop (arg1, arg2, opcode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1071 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1072 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 case Bmult:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 case Bquo:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1076 case Bmax:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1077 case Bmin:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1078 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1079 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1080 TOP = bytecode_arithop (TOP, arg, opcode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1081 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1082 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 case Bpoint:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1085 PUSH (make_int (BUF_PT (current_buffer)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 case Binsert:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 TOP = Finsert (1, &TOP);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 case BinsertN:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1093 n = READ_UINT_1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1094 DISCARD (n - 1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1095 TOP = Finsert (n, &TOP);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1098 case Baref:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1099 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1100 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1101 TOP = Faref (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1102 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1103 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1105 case Bmemq:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1106 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1107 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1108 TOP = Fmemq (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1109 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1110 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1112 case Bset:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1113 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1114 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1115 TOP = Fset (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1116 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1117 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1119 case Bequal:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1120 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1121 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1122 TOP = Fequal (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1123 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1124 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1125
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1126 case Bnthcdr:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1127 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1128 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1129 TOP = Fnthcdr (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1130 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1131 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1133 case Belt:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1134 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1135 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1136 TOP = Felt (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1137 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1138 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1140 case Bmember:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1141 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1142 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1143 TOP = Fmember (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1144 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1145 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1147 case Bgoto_char:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1148 TOP = Fgoto_char (TOP, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 case Bcurrent_buffer:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1152 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1153 Lisp_Object buffer;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1154 XSETBUFFER (buffer, current_buffer);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1155 PUSH (buffer);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1156 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1157 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 case Bset_buffer:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 TOP = Fset_buffer (TOP);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1163 case Bpoint_max:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1164 PUSH (make_int (BUF_ZV (current_buffer)));
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 161
diff changeset
1165 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1167 case Bpoint_min:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1168 PUSH (make_int (BUF_BEGV (current_buffer)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 case Bskip_chars_forward:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1172 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1173 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1174 TOP = Fskip_chars_forward (TOP, arg, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1175 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1176 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
1177
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 case Bassq:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1179 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1180 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1181 TOP = Fassq (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1182 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1183 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1185 case Bsetcar:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1186 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1187 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1188 TOP = Fsetcar (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1189 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1190 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1191
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1192 case Bsetcdr:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1193 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1194 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1195 TOP = Fsetcdr (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1196 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1197 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
1198
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 case Bnreverse:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1200 TOP = bytecode_nreverse (TOP);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 case Bcar_safe:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1204 TOP = CONSP (TOP) ? XCAR (TOP) : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 case Bcdr_safe:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1208 TOP = CONSP (TOP) ? XCDR (TOP) : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1211 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1212 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1213 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1214
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1215 /* It makes a worthwhile performance difference (5%) to shunt
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1216 lesser-used opcodes off to a subroutine, to keep the switch in
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1217 execute_optimized_program small. If you REALLY care about
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1218 performance, you want to keep your heavily executed code away from
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1219 rarely executed code, to minimize cache misses.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1220
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1221 Don't make this function static, since then the compiler might inline it. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1222 Lisp_Object *
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1223 execute_rare_opcode (Lisp_Object *stack_ptr,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1224 const Opbyte *program_ptr,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1225 Opcode opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1226 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1227 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1228 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1229
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1230 case Bsave_excursion:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1231 record_unwind_protect (save_excursion_restore,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1232 save_excursion_save ());
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1233 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1234
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1235 case Bsave_window_excursion:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1236 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1237 int count = specpdl_depth ();
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1238 record_unwind_protect (save_window_excursion_unwind,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1239 Fcurrent_window_configuration (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1240 TOP = Fprogn (TOP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1241 unbind_to (count, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1242 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1243 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1244
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1245 case Bsave_restriction:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1246 record_unwind_protect (save_restriction_restore,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1247 save_restriction_save ());
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1248 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1249
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1250 case Bcatch:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1251 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1252 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1253 TOP = internal_catch (TOP, Feval, arg, 0);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1254 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1255 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1256
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1257 case Bskip_chars_backward:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1258 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1259 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1260 TOP = Fskip_chars_backward (TOP, arg, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1261 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1262 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1263
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1264 case Bunwind_protect:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1265 record_unwind_protect (Fprogn, POP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1266 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1267
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1268 case Bcondition_case:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1269 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1270 Lisp_Object arg2 = POP; /* handlers */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1271 Lisp_Object arg1 = POP; /* bodyform */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1272 TOP = condition_case_3 (arg1, TOP, arg2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1273 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1274 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1275
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1276 case Bset_marker:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1277 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1278 Lisp_Object arg2 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1279 Lisp_Object arg1 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1280 TOP = Fset_marker (TOP, arg1, arg2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1281 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1282 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1283
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1284 case Brem:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1285 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1286 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1287 TOP = Frem (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1288 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1289 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1290
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1291 case Bmatch_beginning:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1292 TOP = Fmatch_beginning (TOP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1293 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1294
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1295 case Bmatch_end:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1296 TOP = Fmatch_end (TOP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1297 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1298
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1299 case Bupcase:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1300 TOP = Fupcase (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1301 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1302
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1303 case Bdowncase:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1304 TOP = Fdowncase (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1305 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1306
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1307 case Bfset:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1308 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1309 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1310 TOP = Ffset (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1311 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1312 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1313
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1314 case Bstring_equal:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1315 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1316 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1317 TOP = Fstring_equal (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1318 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1319 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1320
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1321 case Bstring_lessp:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1322 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1323 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1324 TOP = Fstring_lessp (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1325 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1326 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1327
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1328 case Bsubstring:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1329 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1330 Lisp_Object arg2 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1331 Lisp_Object arg1 = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1332 TOP = Fsubstring (TOP, arg1, arg2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1333 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1334 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1335
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1336 case Bcurrent_column:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1337 PUSH (make_int (current_column (current_buffer)));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1338 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1339
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1340 case Bchar_after:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1341 TOP = Fchar_after (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1342 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1343
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1344 case Bindent_to:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1345 TOP = Findent_to (TOP, Qnil, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1346 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1347
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1348 case Bwiden:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1349 PUSH (Fwiden (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1350 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1351
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1352 case Bfollowing_char:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1353 PUSH (Ffollowing_char (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1354 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1355
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1356 case Bpreceding_char:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1357 PUSH (Fpreceding_char (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1358 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1359
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1360 case Beolp:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1361 PUSH (Feolp (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1362 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1363
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1364 case Beobp:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1365 PUSH (Feobp (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1366 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1367
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1368 case Bbolp:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1369 PUSH (Fbolp (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1370 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1371
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1372 case Bbobp:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1373 PUSH (Fbobp (Qnil));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1374 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1375
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1376 case Bsave_current_buffer:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1377 record_unwind_protect (save_current_buffer_restore,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1378 Fcurrent_buffer ());
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1379 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1381 case Binteractive_p:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1382 PUSH (Finteractive_p ());
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1383 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1384
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1385 case Bforward_char:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1386 TOP = Fforward_char (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1387 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1388
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1389 case Bforward_word:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1390 TOP = Fforward_word (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1391 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1392
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1393 case Bforward_line:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1394 TOP = Fforward_line (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1395 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1396
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1397 case Bchar_syntax:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1398 TOP = Fchar_syntax (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1399 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1400
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1401 case Bbuffer_substring:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1402 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1403 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1404 TOP = Fbuffer_substring (TOP, arg, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1405 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1406 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1407
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1408 case Bdelete_region:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1409 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1410 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1411 TOP = Fdelete_region (TOP, arg, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1412 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1413 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1414
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1415 case Bnarrow_to_region:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1416 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1417 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1418 TOP = Fnarrow_to_region (TOP, arg, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1419 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1420 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1421
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1422 case Bend_of_line:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1423 TOP = Fend_of_line (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1424 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1425
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1426 case Btemp_output_buffer_setup:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1427 temp_output_buffer_setup (TOP);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1428 TOP = Vstandard_output;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1429 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1430
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1431 case Btemp_output_buffer_show:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1432 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1433 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1434 temp_output_buffer_show (TOP, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1435 TOP = arg;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1436 /* GAG ME!! */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1437 /* pop binding of standard-output */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1438 unbind_to (specpdl_depth() - 1, Qnil);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1439 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1440 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1441
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1442 case Bold_eq:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1443 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1444 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1445 TOP = HACKEQ_UNSAFE (TOP, arg) ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1446 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1447 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1448
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1449 case Bold_memq:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1450 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1451 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1452 TOP = Fold_memq (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1453 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1454 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1455
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1456 case Bold_equal:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1457 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1458 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1459 TOP = Fold_equal (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1460 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1461 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1462
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1463 case Bold_member:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1464 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1465 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1466 TOP = Fold_member (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1467 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1468 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1469
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1470 case Bold_assq:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1471 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1472 Lisp_Object arg = POP;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1473 TOP = Fold_assq (TOP, arg);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1474 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1475 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1476
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1477 default:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1478 abort();
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1479 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1480 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1481 return stack_ptr;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1482 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1483
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1484
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1485 static void
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1486 invalid_byte_code_error (char *error_message, ...)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1487 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1488 Lisp_Object obj;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1489 va_list args;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1490 char *buf = alloca_array (char, strlen (error_message) + 128);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1491
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1492 sprintf (buf, "%s", error_message);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1493 va_start (args, error_message);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1494 obj = emacs_doprnt_string_va ((const Bufbyte *) GETTEXT (buf), Qnil, -1,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1495 args);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1496 va_end (args);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1497
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1498 signal_error (Qinvalid_byte_code, list1 (obj));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1499 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1500
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1501 /* Check for valid opcodes. Change this when adding new opcodes. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1502 static void
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1503 check_opcode (Opcode opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1504 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1505 if ((opcode < Bvarref) ||
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1506 (opcode == 0251) ||
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1507 (opcode > Bassq && opcode < Bconstant))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1508 invalid_byte_code_error
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1509 ("invalid opcode %d in instruction stream", opcode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1510 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1511
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1512 /* Check that IDX is a valid offset into the `constants' vector */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1513 static void
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1514 check_constants_index (int idx, Lisp_Object constants)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1515 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1516 if (idx < 0 || idx >= XVECTOR_LENGTH (constants))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1517 invalid_byte_code_error
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1518 ("reference %d to constants array out of range 0, %d",
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1519 idx, XVECTOR_LENGTH (constants) - 1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1520 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1521
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1522 /* Get next character from Lisp instructions string. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1523 #define READ_INSTRUCTION_CHAR(lvalue) do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1524 (lvalue) = charptr_emchar (ptr); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1525 INC_CHARPTR (ptr); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1526 *icounts_ptr++ = program_ptr - program; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1527 if (lvalue > UCHAR_MAX) \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1528 invalid_byte_code_error \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1529 ("Invalid character %c in byte code string"); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1530 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1531
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1532 /* Get opcode from Lisp instructions string. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1533 #define READ_OPCODE do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1534 unsigned int c; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1535 READ_INSTRUCTION_CHAR (c); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1536 opcode = (Opcode) c; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1537 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1538
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1539 /* Get next operand, a uint8, from Lisp instructions string. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1540 #define READ_OPERAND_1 do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1541 READ_INSTRUCTION_CHAR (arg); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1542 argsize = 1; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1543 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1544
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1545 /* Get next operand, a uint16, from Lisp instructions string. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1546 #define READ_OPERAND_2 do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1547 unsigned int arg1, arg2; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1548 READ_INSTRUCTION_CHAR (arg1); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1549 READ_INSTRUCTION_CHAR (arg2); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1550 arg = arg1 + (arg2 << 8); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1551 argsize = 2; \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1552 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1553
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1554 /* Write 1 byte to PTR, incrementing PTR */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1555 #define WRITE_INT8(value, ptr) do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1556 *((ptr)++) = (value); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1557 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1558
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1559 /* Write 2 bytes to PTR, incrementing PTR */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1560 #define WRITE_INT16(value, ptr) do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1561 WRITE_INT8 (((unsigned) (value)) & 0x00ff, (ptr)); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1562 WRITE_INT8 (((unsigned) (value)) >> 8 , (ptr)); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1563 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1564
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1565 /* We've changed our minds about the opcode we've already written. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1566 #define REWRITE_OPCODE(new_opcode) ((void) (program_ptr[-1] = new_opcode))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1567
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1568 /* Encode an op arg within the opcode, or as a 1 or 2-byte operand. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1569 #define WRITE_NARGS(base_opcode) do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1570 if (arg <= 5) \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1571 { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1572 REWRITE_OPCODE (base_opcode + arg); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1573 } \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1574 else if (arg <= UCHAR_MAX) \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1575 { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1576 REWRITE_OPCODE (base_opcode + 6); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1577 WRITE_INT8 (arg, program_ptr); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1578 } \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1579 else \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1580 { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1581 REWRITE_OPCODE (base_opcode + 7); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1582 WRITE_INT16 (arg, program_ptr); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1583 } \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1584 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1585
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1586 /* Encode a constants reference within the opcode, or as a 2-byte operand. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1587 #define WRITE_CONSTANT do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1588 check_constants_index(arg, constants); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1589 if (arg <= UCHAR_MAX - Bconstant) \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1590 { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1591 REWRITE_OPCODE (Bconstant + arg); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1592 } \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1593 else \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1594 { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1595 REWRITE_OPCODE (Bconstant2); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1596 WRITE_INT16 (arg, program_ptr); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1597 } \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1598 } while (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1599
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1600 #define WRITE_OPCODE WRITE_INT8 (opcode, program_ptr)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1601
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1602 /* Compile byte code instructions into free space provided by caller, with
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1603 size >= (2 * string_char_length (instructions) + 1) * sizeof (Opbyte).
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1604 Returns length of compiled code. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1605 static void
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1606 optimize_byte_code (/* in */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1607 Lisp_Object instructions,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1608 Lisp_Object constants,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1609 /* out */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1610 Opbyte * const program,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1611 int * const program_length,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1612 int * const varbind_count)
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1613 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1614 size_t instructions_length = XSTRING_LENGTH (instructions);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1615 size_t comfy_size = 2 * instructions_length;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1616
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1617 int * const icounts = alloca_array (int, comfy_size);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1618 int * icounts_ptr = icounts;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1619
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1620 /* We maintain a table of jumps in the source code. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1621 struct jump
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1622 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1623 int from;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1624 int to;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1625 };
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1626 struct jump * const jumps = alloca_array (struct jump, comfy_size);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1627 struct jump *jumps_ptr = jumps;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1628
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1629 Opbyte *program_ptr = program;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1630
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1631 const Bufbyte *ptr = XSTRING_DATA (instructions);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1632 const Bufbyte * const end = ptr + instructions_length;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1633
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1634 *varbind_count = 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1635
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1636 while (ptr < end)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1637 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1638 Opcode opcode;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1639 int arg;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1640 int argsize = 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1641 READ_OPCODE;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1642 WRITE_OPCODE;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1643
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1644 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1645 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1646 Lisp_Object val;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1647
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1648 case Bvarref+7: READ_OPERAND_2; goto do_varref;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1649 case Bvarref+6: READ_OPERAND_1; goto do_varref;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1650 case Bvarref: case Bvarref+1: case Bvarref+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1651 case Bvarref+3: case Bvarref+4: case Bvarref+5:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1652 arg = opcode - Bvarref;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1653 do_varref:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1654 check_constants_index (arg, constants);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1655 val = XVECTOR_DATA (constants) [arg];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1656 if (!SYMBOLP (val))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1657 invalid_byte_code_error ("variable reference to non-symbol %S", val);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1658 if (EQ (val, Qnil) || EQ (val, Qt) || (SYMBOL_IS_KEYWORD (val)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1659 invalid_byte_code_error ("variable reference to constant symbol %s",
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1660 string_data (XSYMBOL (val)->name));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1661 WRITE_NARGS (Bvarref);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1662 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1663
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1664 case Bvarset+7: READ_OPERAND_2; goto do_varset;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1665 case Bvarset+6: READ_OPERAND_1; goto do_varset;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1666 case Bvarset: case Bvarset+1: case Bvarset+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1667 case Bvarset+3: case Bvarset+4: case Bvarset+5:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1668 arg = opcode - Bvarset;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1669 do_varset:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1670 check_constants_index (arg, constants);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1671 val = XVECTOR_DATA (constants) [arg];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1672 if (!SYMBOLP (val))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1673 invalid_byte_code_error ("attempt to set non-symbol %S", val);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1674 if (EQ (val, Qnil) || EQ (val, Qt))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1675 invalid_byte_code_error ("attempt to set constant symbol %s",
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1676 string_data (XSYMBOL (val)->name));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1677 /* Ignore assignments to keywords by converting to Bdiscard.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1678 For backward compatibility only - we'd like to make this an error. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1679 if (SYMBOL_IS_KEYWORD (val))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1680 REWRITE_OPCODE (Bdiscard);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1681 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1682 WRITE_NARGS (Bvarset);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1685 case Bvarbind+7: READ_OPERAND_2; goto do_varbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1686 case Bvarbind+6: READ_OPERAND_1; goto do_varbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1687 case Bvarbind: case Bvarbind+1: case Bvarbind+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1688 case Bvarbind+3: case Bvarbind+4: case Bvarbind+5:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1689 arg = opcode - Bvarbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1690 do_varbind:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1691 (*varbind_count)++;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1692 check_constants_index (arg, constants);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1693 val = XVECTOR_DATA (constants) [arg];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1694 if (!SYMBOLP (val))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1695 invalid_byte_code_error ("attempt to let-bind non-symbol %S", val);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1696 if (EQ (val, Qnil) || EQ (val, Qt) || (SYMBOL_IS_KEYWORD (val)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1697 invalid_byte_code_error ("attempt to let-bind constant symbol %s",
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1698 string_data (XSYMBOL (val)->name));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1699 WRITE_NARGS (Bvarbind);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1700 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1701
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1702 case Bcall+7: READ_OPERAND_2; goto do_call;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1703 case Bcall+6: READ_OPERAND_1; goto do_call;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1704 case Bcall: case Bcall+1: case Bcall+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1705 case Bcall+3: case Bcall+4: case Bcall+5:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1706 arg = opcode - Bcall;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1707 do_call:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1708 WRITE_NARGS (Bcall);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1709 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1710
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1711 case Bunbind+7: READ_OPERAND_2; goto do_unbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1712 case Bunbind+6: READ_OPERAND_1; goto do_unbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1713 case Bunbind: case Bunbind+1: case Bunbind+2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1714 case Bunbind+3: case Bunbind+4: case Bunbind+5:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1715 arg = opcode - Bunbind;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1716 do_unbind:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1717 WRITE_NARGS (Bunbind);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1720 case Bgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1721 case Bgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1722 case Bgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1723 case Bgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1724 case Bgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1725 READ_OPERAND_2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1726 /* Make program_ptr-relative */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1727 arg += icounts - (icounts_ptr - argsize);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1728 goto do_jump;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1729
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1730 case BRgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1731 case BRgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1732 case BRgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1733 case BRgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1734 case BRgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1735 READ_OPERAND_1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1736 /* Make program_ptr-relative */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1737 arg -= 127;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1738 do_jump:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1739 /* Record program-relative goto addresses in `jumps' table */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1740 jumps_ptr->from = icounts_ptr - icounts - argsize;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1741 jumps_ptr->to = jumps_ptr->from + arg;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1742 jumps_ptr++;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1743 if (arg >= -1 && arg <= argsize)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1744 invalid_byte_code_error
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1745 ("goto instruction is its own target");
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1746 if (arg <= SCHAR_MIN ||
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1747 arg > SCHAR_MAX)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1748 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1749 if (argsize == 1)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1750 REWRITE_OPCODE (opcode + Bgoto - BRgoto);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1751 WRITE_INT16 (arg, program_ptr);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1752 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1753 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1754 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1755 if (argsize == 2)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1756 REWRITE_OPCODE (opcode + BRgoto - Bgoto);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1757 WRITE_INT8 (arg, program_ptr);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1758 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1759 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1760
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1761 case Bconstant2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1762 READ_OPERAND_2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1763 WRITE_CONSTANT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1764 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1765
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1766 case BlistN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1767 case BconcatN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1768 case BinsertN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1769 READ_OPERAND_1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1770 WRITE_INT8 (arg, program_ptr);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 default:
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1774 if (opcode < Bconstant)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1775 check_opcode (opcode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1776 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1777 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1778 arg = opcode - Bconstant;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1779 WRITE_CONSTANT;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1780 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1781 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1785 /* Fix up jumps table to refer to NEW offsets. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1786 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1787 struct jump *j;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1788 for (j = jumps; j < jumps_ptr; j++)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1789 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1790 #ifdef ERROR_CHECK_BYTE_CODE
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1791 assert (j->from < icounts_ptr - icounts);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1792 assert (j->to < icounts_ptr - icounts);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1793 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1794 j->from = icounts[j->from];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1795 j->to = icounts[j->to];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1796 #ifdef ERROR_CHECK_BYTE_CODE
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1797 assert (j->from < program_ptr - program);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1798 assert (j->to < program_ptr - program);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1799 check_opcode ((Opcode) (program[j->from-1]));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1800 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1801 check_opcode ((Opcode) (program[j->to]));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1802 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1803 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1804
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1805 /* Fixup jumps in byte-code until no more fixups needed */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1806 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1807 int more_fixups_needed = 1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1808
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1809 while (more_fixups_needed)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1810 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1811 struct jump *j;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1812 more_fixups_needed = 0;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1813 for (j = jumps; j < jumps_ptr; j++)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1814 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1815 int from = j->from;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1816 int to = j->to;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1817 int jump = to - from;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1818 Opbyte *p = program + from;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1819 Opcode opcode = (Opcode) p[-1];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1820 if (!more_fixups_needed)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1821 check_opcode ((Opcode) p[jump]);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1822 assert (to >= 0 && program + to < program_ptr);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1823 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1824 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1825 case Bgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1826 case Bgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1827 case Bgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1828 case Bgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1829 case Bgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1830 WRITE_INT16 (jump, p);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1831 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1832
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1833 case BRgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1834 case BRgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1835 case BRgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1836 case BRgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1837 case BRgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1838 if (jump > SCHAR_MIN &&
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1839 jump <= SCHAR_MAX)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1840 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1841 WRITE_INT8 (jump, p);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1842 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1843 else /* barf */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1844 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1845 struct jump *jj;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1846 for (jj = jumps; jj < jumps_ptr; jj++)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1847 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1848 assert (jj->from < program_ptr - program);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1849 assert (jj->to < program_ptr - program);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1850 if (jj->from > from) jj->from++;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1851 if (jj->to > from) jj->to++;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1852 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1853 p[-1] += Bgoto - BRgoto;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1854 more_fixups_needed = 1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1855 memmove (p+1, p, program_ptr++ - p);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1856 WRITE_INT16 (jump, p);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1857 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1858 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1859
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1860 default:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1861 abort();
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1862 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1863 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1864 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1865 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1866 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1867
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1868 /* *program_ptr++ = 0; */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1869 *program_length = program_ptr - program;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1870 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1871
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1872 /* Optimize the byte code and store the optimized program, only
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1873 understood by bytecode.c, in an opaque object in the
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1874 instructions slot of the Compiled_Function object. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1875 void
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1876 optimize_compiled_function (Lisp_Object compiled_function)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1877 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1878 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (compiled_function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1879 int program_length;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1880 int varbind_count;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1881 Opbyte *program;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1882
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1883 /* If we have not actually read the bytecode string
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1884 and constants vector yet, fetch them from the file. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1885 if (CONSP (f->instructions))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1886 Ffetch_bytecode (compiled_function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1887
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1888 if (STRINGP (f->instructions))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1889 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1890 /* XSTRING_LENGTH() is more efficient than XSTRING_CHAR_LENGTH(),
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1891 which would be slightly more `proper' */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1892 program = alloca_array (Opbyte, 1 + 2 * XSTRING_LENGTH (f->instructions));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1893 optimize_byte_code (f->instructions, f->constants,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1894 program, &program_length, &varbind_count);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1895 f->specpdl_depth = XINT (Flength (f->arglist)) + varbind_count;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1896 f->instructions =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1897 make_opaque (program, program_length * sizeof (Opbyte));
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1898 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1899
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1900 assert (OPAQUEP (f->instructions));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1901 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1902
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1903 /************************************************************************/
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1904 /* The compiled-function object type */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1905 /************************************************************************/
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1906 static void
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1907 print_compiled_function (Lisp_Object obj, Lisp_Object printcharfun,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1908 int escapeflag)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1909 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1910 /* This function can GC */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1911 Lisp_Compiled_Function *f =
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1912 XCOMPILED_FUNCTION (obj); /* GC doesn't relocate */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1913 int docp = f->flags.documentationp;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1914 int intp = f->flags.interactivep;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1915 struct gcpro gcpro1, gcpro2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1916 char buf[100];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1917 GCPRO2 (obj, printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1918
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1919 write_c_string (print_readably ? "#[" : "#<compiled-function ", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1920 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1921 if (!print_readably)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1922 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1923 Lisp_Object ann = compiled_function_annotation (f);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1924 if (!NILP (ann))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1925 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1926 write_c_string ("(from ", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1927 print_internal (ann, printcharfun, 1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1928 write_c_string (") ", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1929 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1930 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1931 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1932 /* COMPILED_ARGLIST = 0 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1933 print_internal (compiled_function_arglist (f), printcharfun, escapeflag);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1934
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1935 /* COMPILED_INSTRUCTIONS = 1 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1936 write_c_string (" ", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1937 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1938 struct gcpro ngcpro1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1939 Lisp_Object instructions = compiled_function_instructions (f);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1940 NGCPRO1 (instructions);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1941 if (STRINGP (instructions) && !print_readably)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1942 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1943 /* We don't usually want to see that junk in the bytecode. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1944 sprintf (buf, "\"...(%ld)\"",
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1945 (long) XSTRING_CHAR_LENGTH (instructions));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1946 write_c_string (buf, printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1947 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1948 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1949 print_internal (instructions, printcharfun, escapeflag);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1950 NUNGCPRO;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1951 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1952
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1953 /* COMPILED_CONSTANTS = 2 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1954 write_c_string (" ", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1955 print_internal (compiled_function_constants (f), printcharfun, escapeflag);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1956
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1957 /* COMPILED_STACK_DEPTH = 3 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1958 sprintf (buf, " %d", compiled_function_stack_depth (f));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1959 write_c_string (buf, printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1960
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1961 /* COMPILED_DOC_STRING = 4 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1962 if (docp || intp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1963 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1964 write_c_string (" ", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1965 print_internal (compiled_function_documentation (f), printcharfun,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1966 escapeflag);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1967 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1968
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1969 /* COMPILED_INTERACTIVE = 5 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1970 if (intp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1971 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1972 write_c_string (" ", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1973 print_internal (compiled_function_interactive (f), printcharfun,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1974 escapeflag);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1975 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1976
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 UNGCPRO;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1978 write_c_string (print_readably ? "]" : ">", printcharfun);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1979 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1980
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1981
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1982 static Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1983 mark_compiled_function (Lisp_Object obj)
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1984 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1985 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (obj);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1986
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1987 mark_object (f->instructions);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1988 mark_object (f->arglist);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1989 mark_object (f->doc_and_interactive);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1990 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
1991 mark_object (f->annotated);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1992 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1993 /* tail-recurse on constants */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1994 return f->constants;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1995 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1996
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1997 static int
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1998 compiled_function_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
1999 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2000 Lisp_Compiled_Function *f1 = XCOMPILED_FUNCTION (obj1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2001 Lisp_Compiled_Function *f2 = XCOMPILED_FUNCTION (obj2);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2002 return
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2003 (f1->flags.documentationp == f2->flags.documentationp &&
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2004 f1->flags.interactivep == f2->flags.interactivep &&
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2005 f1->flags.domainp == f2->flags.domainp && /* I18N3 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2006 internal_equal (compiled_function_instructions (f1),
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2007 compiled_function_instructions (f2), depth + 1) &&
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2008 internal_equal (f1->constants, f2->constants, depth + 1) &&
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2009 internal_equal (f1->arglist, f2->arglist, depth + 1) &&
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2010 internal_equal (f1->doc_and_interactive,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2011 f2->doc_and_interactive, depth + 1));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2012 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2013
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2014 static unsigned long
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2015 compiled_function_hash (Lisp_Object obj, int depth)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2016 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2017 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (obj);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2018 return HASH3 ((f->flags.documentationp << 2) +
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2019 (f->flags.interactivep << 1) +
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2020 f->flags.domainp,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2021 internal_hash (f->instructions, depth + 1),
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2022 internal_hash (f->constants, depth + 1));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2023 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2024
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2025 static const struct lrecord_description compiled_function_description[] = {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2026 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, instructions) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2027 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, constants) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2028 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, arglist) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2029 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, doc_and_interactive) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2030 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2031 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, annotated) },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2032 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2033 { XD_END }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2034 };
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2035
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2036 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("compiled-function", compiled_function,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2037 mark_compiled_function,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2038 print_compiled_function, 0,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2039 compiled_function_equal,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2040 compiled_function_hash,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2041 compiled_function_description,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2042 Lisp_Compiled_Function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2043
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2044 DEFUN ("compiled-function-p", Fcompiled_function_p, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2045 Return t if OBJECT is a byte-compiled function object.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2046 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2047 (object))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2048 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2049 return COMPILED_FUNCTIONP (object) ? Qt : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2050 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2051
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2052 /************************************************************************/
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2053 /* compiled-function object accessor functions */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2054 /************************************************************************/
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2055
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2056 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2057 compiled_function_arglist (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2058 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2059 return f->arglist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2062 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2063 compiled_function_instructions (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2064 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2065 if (! OPAQUEP (f->instructions))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2066 return f->instructions;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2067
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2068 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2069 /* Invert action performed by optimize_byte_code() */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2070 Lisp_Opaque *opaque = XOPAQUE (f->instructions);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2071
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2072 Bufbyte * const buffer =
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2073 alloca_array (Bufbyte, OPAQUE_SIZE (opaque) * MAX_EMCHAR_LEN);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2074 Bufbyte *bp = buffer;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2075
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2076 const Opbyte * const program = (const Opbyte *) OPAQUE_DATA (opaque);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2077 const Opbyte *program_ptr = program;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2078 const Opbyte * const program_end = program_ptr + OPAQUE_SIZE (opaque);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2079
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2080 while (program_ptr < program_end)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2081 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2082 Opcode opcode = (Opcode) READ_UINT_1;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2083 bp += set_charptr_emchar (bp, opcode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2084 switch (opcode)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2085 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2086 case Bvarref+7:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2087 case Bvarset+7:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2088 case Bvarbind+7:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2089 case Bcall+7:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2090 case Bunbind+7:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2091 case Bconstant2:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2092 bp += set_charptr_emchar (bp, READ_UINT_1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2093 bp += set_charptr_emchar (bp, READ_UINT_1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2094 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2095
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2096 case Bvarref+6:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2097 case Bvarset+6:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2098 case Bvarbind+6:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2099 case Bcall+6:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2100 case Bunbind+6:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2101 case BlistN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2102 case BconcatN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2103 case BinsertN:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2104 bp += set_charptr_emchar (bp, READ_UINT_1);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2105 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2106
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2107 case Bgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2108 case Bgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2109 case Bgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2110 case Bgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2111 case Bgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2112 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2113 int jump = READ_INT_2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2114 Opbyte buf2[2];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2115 Opbyte *buf2p = buf2;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2116 /* Convert back to program-relative address */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2117 WRITE_INT16 (jump + (program_ptr - 2 - program), buf2p);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2118 bp += set_charptr_emchar (bp, buf2[0]);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2119 bp += set_charptr_emchar (bp, buf2[1]);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2120 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2121 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2122
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2123 case BRgoto:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2124 case BRgotoifnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2125 case BRgotoifnonnil:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2126 case BRgotoifnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2127 case BRgotoifnonnilelsepop:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2128 bp += set_charptr_emchar (bp, READ_INT_1 + 127);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2129 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2130
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2131 default:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2132 break;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2133 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2134 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2135 return make_string (buffer, bp - buffer);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2136 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2137 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2138
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2139 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2140 compiled_function_constants (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2141 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2142 return f->constants;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2143 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2144
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2145 int
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2146 compiled_function_stack_depth (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2147 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2148 return f->stack_depth;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2149 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2150
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2151 /* The compiled_function->doc_and_interactive slot uses the minimal
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2152 number of conses, based on compiled_function->flags; it may take
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2153 any of the following forms:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2154
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2155 doc
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2156 interactive
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2157 domain
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2158 (doc . interactive)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2159 (doc . domain)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2160 (interactive . domain)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2161 (doc . (interactive . domain))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2162 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2163
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2164 /* Caller must check flags.interactivep first */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2165 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2166 compiled_function_interactive (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2167 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2168 assert (f->flags.interactivep);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2169 if (f->flags.documentationp && f->flags.domainp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2170 return XCAR (XCDR (f->doc_and_interactive));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2171 else if (f->flags.documentationp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2172 return XCDR (f->doc_and_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2173 else if (f->flags.domainp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2174 return XCAR (f->doc_and_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2175 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2176 return f->doc_and_interactive;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2177 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2178
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2179 /* Caller need not check flags.documentationp first */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2180 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2181 compiled_function_documentation (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2182 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2183 if (! f->flags.documentationp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2184 return Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2185 else if (f->flags.interactivep && f->flags.domainp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2186 return XCAR (f->doc_and_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2187 else if (f->flags.interactivep)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2188 return XCAR (f->doc_and_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2189 else if (f->flags.domainp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2190 return XCAR (f->doc_and_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2191 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2192 return f->doc_and_interactive;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2193 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2194
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2195 /* Caller need not check flags.domainp first */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2196 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2197 compiled_function_domain (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2198 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2199 if (! f->flags.domainp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2200 return Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2201 else if (f->flags.documentationp && f->flags.interactivep)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2202 return XCDR (XCDR (f->doc_and_interactive));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2203 else if (f->flags.documentationp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2204 return XCDR (f->doc_and_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2205 else if (f->flags.interactivep)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2206 return XCDR (f->doc_and_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2207 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2208 return f->doc_and_interactive;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2209 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2210
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2211 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2212
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2213 Lisp_Object
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2214 compiled_function_annotation (Lisp_Compiled_Function *f)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2215 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2216 return f->annotated;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2217 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2218
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2219 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2220
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2221 /* used only by Snarf-documentation; there must be doc already. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2222 void
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2223 set_compiled_function_documentation (Lisp_Compiled_Function *f,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2224 Lisp_Object new_doc)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2225 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2226 assert (f->flags.documentationp);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2227 assert (INTP (new_doc) || STRINGP (new_doc));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2228
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2229 if (f->flags.interactivep && f->flags.domainp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2230 XCAR (f->doc_and_interactive) = new_doc;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2231 else if (f->flags.interactivep)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2232 XCAR (f->doc_and_interactive) = new_doc;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2233 else if (f->flags.domainp)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2234 XCAR (f->doc_and_interactive) = new_doc;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2235 else
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2236 f->doc_and_interactive = new_doc;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2237 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2238
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2239
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2240 DEFUN ("compiled-function-arglist", Fcompiled_function_arglist, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2241 Return the argument list of the compiled-function object FUNCTION.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2242 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2243 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2244 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2245 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2246 return compiled_function_arglist (XCOMPILED_FUNCTION (function));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2247 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2248
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2249 DEFUN ("compiled-function-instructions", Fcompiled_function_instructions, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2250 Return the byte-opcode string of the compiled-function object FUNCTION.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2251 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2252 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2253 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2254 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2255 return compiled_function_instructions (XCOMPILED_FUNCTION (function));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2256 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2257
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2258 DEFUN ("compiled-function-constants", Fcompiled_function_constants, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2259 Return the constants vector of the compiled-function object FUNCTION.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2260 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2261 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2262 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2263 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2264 return compiled_function_constants (XCOMPILED_FUNCTION (function));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2265 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2266
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2267 DEFUN ("compiled-function-stack-depth", Fcompiled_function_stack_depth, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2268 Return the max stack depth of the compiled-function object FUNCTION.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2269 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2270 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2271 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2272 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2273 return make_int (compiled_function_stack_depth (XCOMPILED_FUNCTION (function)));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2274 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2275
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2276 DEFUN ("compiled-function-doc-string", Fcompiled_function_doc_string, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2277 Return the doc string of the compiled-function object FUNCTION, if available.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2278 Functions that had their doc strings snarfed into the DOC file will have
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2279 an integer returned instead of a string.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2280 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2281 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2282 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2283 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2284 return compiled_function_documentation (XCOMPILED_FUNCTION (function));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2285 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2286
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2287 DEFUN ("compiled-function-interactive", Fcompiled_function_interactive, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2288 Return the interactive spec of the compiled-function object FUNCTION, or nil.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2289 If non-nil, the return value will be a list whose first element is
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2290 `interactive' and whose second element is the interactive spec.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2291 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2292 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2293 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2294 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2295 return XCOMPILED_FUNCTION (function)->flags.interactivep
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2296 ? list2 (Qinteractive,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2297 compiled_function_interactive (XCOMPILED_FUNCTION (function)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2298 : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2299 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2300
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2301 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2302
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2303 /* Remove the `xx' if you wish to restore this feature */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2304 xxDEFUN ("compiled-function-annotation", Fcompiled_function_annotation, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2305 Return the annotation of the compiled-function object FUNCTION, or nil.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2306 The annotation is a piece of information indicating where this
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2307 compiled-function object came from. Generally this will be
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2308 a symbol naming a function; or a string naming a file, if the
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2309 compiled-function object was not defined in a function; or nil,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2310 if the compiled-function object was not created as a result of
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2311 a `load'.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2312 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2313 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2314 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2315 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2316 return compiled_function_annotation (XCOMPILED_FUNCTION (function));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2317 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2318
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2319 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2320
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2321 DEFUN ("compiled-function-domain", Fcompiled_function_domain, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2322 Return the domain of the compiled-function object FUNCTION, or nil.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2323 This is only meaningful if I18N3 was enabled when emacs was compiled.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2324 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2325 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2326 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2327 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2328 return XCOMPILED_FUNCTION (function)->flags.domainp
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2329 ? compiled_function_domain (XCOMPILED_FUNCTION (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2330 : Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2331 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2332
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2333
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2334
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2335 DEFUN ("fetch-bytecode", Ffetch_bytecode, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2336 If the byte code for compiled function FUNCTION is lazy-loaded, fetch it now.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2337 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2338 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2339 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2340 Lisp_Compiled_Function *f;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2341 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2342 f = XCOMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2343
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2344 if (OPAQUEP (f->instructions) || STRINGP (f->instructions))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2345 return function;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2346
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
2347 if (CONSP (f->instructions))
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2348 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2349 Lisp_Object tem = read_doc_string (f->instructions);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2350 if (!CONSP (tem))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2351 signal_simple_error ("Invalid lazy-loaded byte code", tem);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2352 /* v18 or v19 bytecode file. Need to Ebolify. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2353 if (f->flags.ebolified && VECTORP (XCDR (tem)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2354 ebolify_bytecode_constants (XCDR (tem));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2355 f->instructions = XCAR (tem);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
2356 f->constants = XCDR (tem);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2357 return function;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2358 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2359 abort ();
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2360 return Qnil; /* not reached */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2361 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2362
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2363 DEFUN ("optimize-compiled-function", Foptimize_compiled_function, 1, 1, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2364 Convert compiled function FUNCTION into an optimized internal form.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2365 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2366 (function))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2367 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2368 Lisp_Compiled_Function *f;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2369 CHECK_COMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2370 f = XCOMPILED_FUNCTION (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2371
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2372 if (OPAQUEP (f->instructions)) /* Already optimized? */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2373 return Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2374
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2375 optimize_compiled_function (function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2376 return Qnil;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2377 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2378
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2379 DEFUN ("byte-code", Fbyte_code, 3, 3, 0, /*
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2380 Function used internally in byte-compiled code.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2381 First argument INSTRUCTIONS is a string of byte code.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2382 Second argument CONSTANTS is a vector of constants.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2383 Third argument STACK-DEPTH is the maximum stack depth used in this function.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2384 If STACK-DEPTH is incorrect, Emacs may crash.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2385 */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2386 (instructions, constants, stack_depth))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2387 {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2388 /* This function can GC */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2389 int varbind_count;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2390 int program_length;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2391 Opbyte *program;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2392
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2393 CHECK_STRING (instructions);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2394 CHECK_VECTOR (constants);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2395 CHECK_NATNUM (stack_depth);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2396
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2397 /* Optimize the `instructions' string, just like when executing a
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2398 regular compiled function, but don't save it for later since this is
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2399 likely to only be executed once. */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2400 program = alloca_array (Opbyte, 1 + 2 * XSTRING_LENGTH (instructions));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2401 optimize_byte_code (instructions, constants, program,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2402 &program_length, &varbind_count);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2403 SPECPDL_RESERVE (varbind_count);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2404 return execute_optimized_program (program,
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2405 XINT (stack_depth),
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2406 XVECTOR_DATA (constants));
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2407 }
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2408
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2409
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 syms_of_bytecode (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 {
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
2413 INIT_LRECORD_IMPLEMENTATION (compiled_function);
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
2414
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2415 deferror (&Qinvalid_byte_code, "invalid-byte-code",
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2416 "Invalid byte code", Qerror);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 defsymbol (&Qbyte_code, "byte-code");
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2418 defsymbol (&Qcompiled_functionp, "compiled-function-p");
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2419
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
2420 DEFSUBR (Fbyte_code);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2421 DEFSUBR (Ffetch_bytecode);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2422 DEFSUBR (Foptimize_compiled_function);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2423
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2424 DEFSUBR (Fcompiled_function_p);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2425 DEFSUBR (Fcompiled_function_instructions);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2426 DEFSUBR (Fcompiled_function_constants);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2427 DEFSUBR (Fcompiled_function_stack_depth);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2428 DEFSUBR (Fcompiled_function_arglist);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2429 DEFSUBR (Fcompiled_function_interactive);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2430 DEFSUBR (Fcompiled_function_doc_string);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2431 DEFSUBR (Fcompiled_function_domain);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2432 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2433 DEFSUBR (Fcompiled_function_annotation);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2434 #endif
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2435
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 #ifdef BYTE_CODE_METER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 defsymbol (&Qbyte_code_meter, "byte-code-meter");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 vars_of_bytecode (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 #ifdef BYTE_CODE_METER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter /*
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2447 A vector of vectors which holds a histogram of byte code usage.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
2448 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 opcode CODE has been executed.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
2450 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 indicates how many times the byte opcodes CODE1 and CODE2 have been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 executed in succession.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 If non-nil, keep profiling information on byte code usage.
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2456 The variable `byte-code-meter' indicates how often each byte opcode is used.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 If a symbol has a property named `byte-code-meter' whose value is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 integer, it is incremented each time that symbol's function is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 byte_metering_on = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 Vbyte_code_meter = make_vector (256, Qzero);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 int i = 256;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 while (i--)
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2466 XVECTOR_DATA (Vbyte_code_meter)[i] = make_vector (256, Qzero);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 }
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 280
diff changeset
2468 #endif /* BYTE_CODE_METER */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 }