Mercurial > hg > xemacs-beta
annotate src/bytecode.c @ 5125:b5df3737028a ben-lisp-object
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Feb 2010 01:58:04 -0600 |
parents | 623d57b7fbe8 fe0d3106cc36 |
children | a9c41067dd88 |
rev | line source |
---|---|
428 | 1 /* Execution of byte code produced by bytecomp.el. |
2 Implementation of compiled-function objects. | |
3 Copyright (C) 1992, 1993 Free Software Foundation, Inc. | |
814 | 4 Copyright (C) 1995, 2002 Ben Wing. |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: Mule 2.0, FSF 19.30. */ | |
24 | |
25 /* This file has been Mule-ized. */ | |
26 | |
27 | |
28 /* Authorship: | |
29 | |
30 FSF: long ago. | |
31 | |
32 hacked on by jwz@jwz.org 1991-06 | |
33 o added a compile-time switch to turn on simple sanity checking; | |
34 o put back the obsolete byte-codes for error-detection; | |
35 o added a new instruction, unbind_all, which I will use for | |
36 tail-recursion elimination; | |
37 o made temp_output_buffer_show be called with the right number | |
38 of args; | |
39 o made the new bytecodes be called with args in the right order; | |
40 o added metering support. | |
41 | |
42 by Hallvard: | |
43 o added relative jump instructions; | |
44 o all conditionals now only do QUIT if they jump. | |
45 | |
46 Ben Wing: some changes for Mule, 1995-06. | |
47 | |
48 Martin Buchholz: performance hacking, 1998-09. | |
49 See Internals Manual, Evaluation. | |
50 */ | |
51 | |
52 #include <config.h> | |
53 #include "lisp.h" | |
54 #include "backtrace.h" | |
55 #include "buffer.h" | |
56 #include "bytecode.h" | |
57 #include "opaque.h" | |
58 #include "syntax.h" | |
872 | 59 #include "window.h" |
428 | 60 |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
61 #define NUM_REMEMBERED_BYTE_OPS 100 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
62 |
3092 | 63 #ifdef NEW_GC |
64 static Lisp_Object | |
65 make_compiled_function_args (int totalargs) | |
66 { | |
67 Lisp_Compiled_Function_Args *args; | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
68 args = XCOMPILED_FUNCTION_ARGS |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
69 (alloc_sized_lrecord |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
70 (FLEXIBLE_ARRAY_STRUCT_SIZEOF (Lisp_Compiled_Function_Args, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
71 Lisp_Object, args, totalargs), |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
72 &lrecord_compiled_function_args)); |
3092 | 73 args->size = totalargs; |
74 return wrap_compiled_function_args (args); | |
75 } | |
76 | |
77 static Bytecount | |
78 size_compiled_function_args (const void *lheader) | |
79 { | |
80 return FLEXIBLE_ARRAY_STRUCT_SIZEOF (Lisp_Compiled_Function_Args, | |
81 Lisp_Object, args, | |
82 ((Lisp_Compiled_Function_Args *) | |
83 lheader)->size); | |
84 } | |
85 | |
86 static const struct memory_description compiled_function_args_description[] = { | |
87 { XD_LONG, offsetof (Lisp_Compiled_Function_Args, size) }, | |
88 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Compiled_Function_Args, args), | |
89 XD_INDIRECT(0, 0) }, | |
90 { XD_END } | |
91 }; | |
92 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
93 DEFINE_DUMPABLE_SIZABLE_INTERNAL_LISP_OBJECT ("compiled-function-args", |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
94 compiled_function_args, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
95 0, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
96 compiled_function_args_description, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
97 size_compiled_function_args, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
98 Lisp_Compiled_Function_Args); |
3092 | 99 #endif /* NEW_GC */ |
100 | |
428 | 101 EXFUN (Ffetch_bytecode, 1); |
102 | |
103 Lisp_Object Qbyte_code, Qcompiled_functionp, Qinvalid_byte_code; | |
104 | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
105 |
428 | 106 enum Opcode /* Byte codes */ |
107 { | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
108 #define OPCODE(sym, val) B##sym = val, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
109 #include "bytecode-ops.h" |
428 | 110 }; |
111 typedef enum Opcode Opcode; | |
112 | |
113 Lisp_Object * execute_rare_opcode (Lisp_Object *stack_ptr, | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
114 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
115 Lisp_Object *stack_beg, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
116 Lisp_Object *stack_end, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
117 #endif /* ERROR_CHECK_BYTE_CODE */ |
442 | 118 const Opbyte *program_ptr, |
428 | 119 Opcode opcode); |
120 | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
121 #ifndef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
122 |
4974
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
123 /* Normally we would use `x' instead of `0' in the argument list, to avoid |
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
124 problems if `x' (an expression) has side effects, and warnings if `x' |
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
125 contains variables or parameters that are otherwise unused. But in |
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
126 this case `x' contains references to vars and params that exist only |
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
127 when ERROR_CHECK_BYTE_CODE, and leaving in `x' would result in compile |
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
128 errors. */ |
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
129 # define bytecode_assert(x) disabled_assert (0) |
fe0d3106cc36
fix compile problems in bytecode.c when no error-check-byte-code (issue 666)
Ben Wing <ben@xemacs.org>
parents:
4970
diff
changeset
|
130 # define bytecode_assert_with_message(x, msg) disabled_assert(0) |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
131 # define bytecode_abort_with_message(msg) abort_with_message (msg) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
132 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
133 #else /* ERROR_CHECK_BYTE_CODE */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
134 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
135 # define bytecode_assert(x) \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
136 ((x) ? (void) 0 : assert_failed_with_remembered_ops (__FILE__, __LINE__, #x)) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
137 # define bytecode_assert_with_message(x, msg) \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
138 ((x) ? (void) 0 : assert_failed_with_remembered_ops (__FILE__, __LINE__, msg)) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
139 # define bytecode_abort_with_message(msg) \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
140 assert_failed_with_remembered_ops (__FILE__, __LINE__, msg) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
141 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
142 /* Table mapping opcodes to their names. This handles opcodes like |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
143 Bvarref+7, but it doesn't list any of the Bconstant+N opcodes; those |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
144 are handled specially. */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
145 Ascbyte *opcode_name_table[256]; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
146 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
147 /* Circular queue remembering the most recent operations. */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
148 Opcode remembered_ops[NUM_REMEMBERED_BYTE_OPS]; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
149 int remembered_op_next_pos, num_remembered; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
150 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
151 static void |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
152 remember_operation (Opcode op) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
153 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
154 remembered_ops[remembered_op_next_pos] = op; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
155 remembered_op_next_pos = |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
156 (remembered_op_next_pos + 1) % NUM_REMEMBERED_BYTE_OPS; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
157 if (num_remembered < NUM_REMEMBERED_BYTE_OPS) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
158 num_remembered++; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
159 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
160 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
161 static void |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
162 assert_failed_with_remembered_ops (const Ascbyte *file, int line, |
4970 | 163 const Ascbyte *msg_to_abort_with) |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
164 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
165 Ascbyte *msg = |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
166 alloca_array (Ascbyte, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
167 NUM_REMEMBERED_BYTE_OPS*50 + strlen (msg_to_abort_with)); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
168 int i; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
169 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
170 if (msg_to_abort_with) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
171 strcpy (msg, msg_to_abort_with); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
172 strcat (msg, "\n\nRecent bytecodes, oldest first:\n\n"); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
173 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
174 for (i = 0; i < num_remembered; i++) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
175 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
176 Ascbyte msg2[50]; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
177 int pos; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
178 Opcode op; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
179 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
180 sprintf (msg2, "%5d: ", i - num_remembered + 1); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
181 strcat (msg, msg2); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
182 pos = (remembered_op_next_pos + NUM_REMEMBERED_BYTE_OPS + |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
183 i - num_remembered) % NUM_REMEMBERED_BYTE_OPS; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
184 op = remembered_ops[pos]; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
185 if (op >= Bconstant) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
186 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
187 sprintf (msg2, "constant+%d", op - Bconstant); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
188 strcat (msg, msg2); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
189 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
190 else |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
191 { |
4970 | 192 const Ascbyte *opname = opcode_name_table[op]; |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
193 if (!opname) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
194 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
195 stderr_out ("Internal error! NULL pointer in opcode_name_table, opcode %d\n", op); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
196 strcat (msg, "NULL"); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
197 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
198 else |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
199 strcat (msg, opname); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
200 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
201 sprintf (msg2, " (%d)\n", op); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
202 strcat (msg, msg2); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
203 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
204 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
205 assert_failed (file, line, msg); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
206 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
207 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
208 #endif /* ERROR_CHECK_BYTE_CODE */ |
428 | 209 |
210 | |
211 #ifdef BYTE_CODE_METER | |
212 | |
213 Lisp_Object Vbyte_code_meter, Qbyte_code_meter; | |
214 int byte_metering_on; | |
215 | |
216 static void | |
217 meter_code (Opcode prev_opcode, Opcode this_opcode) | |
218 { | |
219 if (byte_metering_on) | |
220 { | |
221 Lisp_Object *p = XVECTOR_DATA (XVECTOR_DATA (Vbyte_code_meter)[this_opcode]); | |
222 p[0] = INT_PLUS1 (p[0]); | |
223 if (prev_opcode) | |
224 p[prev_opcode] = INT_PLUS1 (p[prev_opcode]); | |
225 } | |
226 } | |
227 | |
228 #endif /* BYTE_CODE_METER */ | |
229 | |
230 | |
231 static Lisp_Object | |
232 bytecode_negate (Lisp_Object obj) | |
233 { | |
234 retry: | |
235 | |
1983 | 236 if (INTP (obj)) return make_integer (- XINT (obj)); |
428 | 237 if (FLOATP (obj)) return make_float (- XFLOAT_DATA (obj)); |
1983 | 238 if (CHARP (obj)) return make_integer (- ((int) XCHAR (obj))); |
239 if (MARKERP (obj)) return make_integer (- ((int) marker_position (obj))); | |
240 #ifdef HAVE_BIGNUM | |
241 if (BIGNUMP (obj)) BIGNUM_ARITH_RETURN (obj, neg); | |
242 #endif | |
243 #ifdef HAVE_RATIO | |
244 if (RATIOP (obj)) RATIO_ARITH_RETURN (obj, neg); | |
245 #endif | |
4678
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
246 #ifdef HAVE_BIGFLOAT |
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
247 if (BIGFLOATP (obj)) BIGFLOAT_ARITH_RETURN (obj, neg); |
1983 | 248 #endif |
428 | 249 |
250 obj = wrong_type_argument (Qnumber_char_or_marker_p, obj); | |
251 goto retry; | |
252 } | |
253 | |
254 static Lisp_Object | |
255 bytecode_nreverse (Lisp_Object list) | |
256 { | |
257 REGISTER Lisp_Object prev = Qnil; | |
258 REGISTER Lisp_Object tail = list; | |
259 | |
260 while (!NILP (tail)) | |
261 { | |
262 REGISTER Lisp_Object next; | |
263 CHECK_CONS (tail); | |
264 next = XCDR (tail); | |
265 XCDR (tail) = prev; | |
266 prev = tail; | |
267 tail = next; | |
268 } | |
269 return prev; | |
270 } | |
271 | |
272 | |
273 /* We have our own two-argument versions of various arithmetic ops. | |
274 Only two-argument arithmetic operations have their own byte codes. */ | |
4910
6bc1f3f6cf0d
Make canoncase visible to Lisp; use it with chars in internal_equalp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4906
diff
changeset
|
275 int |
428 | 276 bytecode_arithcompare (Lisp_Object obj1, Lisp_Object obj2) |
277 { | |
1983 | 278 #ifdef WITH_NUMBER_TYPES |
279 switch (promote_args (&obj1, &obj2)) | |
280 { | |
281 case FIXNUM_T: | |
282 { | |
283 EMACS_INT ival1 = XREALINT (obj1), ival2 = XREALINT (obj2); | |
284 return ival1 < ival2 ? -1 : ival1 > ival2 ? 1 : 0; | |
285 } | |
286 #ifdef HAVE_BIGNUM | |
287 case BIGNUM_T: | |
288 return bignum_cmp (XBIGNUM_DATA (obj1), XBIGNUM_DATA (obj2)); | |
289 #endif | |
290 #ifdef HAVE_RATIO | |
291 case RATIO_T: | |
292 return ratio_cmp (XRATIO_DATA (obj1), XRATIO_DATA (obj2)); | |
293 #endif | |
1995 | 294 #ifdef HAVE_BIGFLOAT |
295 case BIGFLOAT_T: | |
296 return bigfloat_cmp (XBIGFLOAT_DATA (obj1), XBIGFLOAT_DATA (obj2)); | |
297 #endif | |
298 default: /* FLOAT_T */ | |
1983 | 299 { |
300 double dval1 = XFLOAT_DATA (obj1), dval2 = XFLOAT_DATA (obj2); | |
301 return dval1 < dval2 ? -1 : dval1 > dval2 ? 1 : 0; | |
302 } | |
303 } | |
304 #else /* !WITH_NUMBER_TYPES */ | |
428 | 305 retry: |
306 | |
307 { | |
308 EMACS_INT ival1, ival2; | |
309 | |
310 if (INTP (obj1)) ival1 = XINT (obj1); | |
311 else if (CHARP (obj1)) ival1 = XCHAR (obj1); | |
312 else if (MARKERP (obj1)) ival1 = marker_position (obj1); | |
313 else goto arithcompare_float; | |
314 | |
315 if (INTP (obj2)) ival2 = XINT (obj2); | |
316 else if (CHARP (obj2)) ival2 = XCHAR (obj2); | |
317 else if (MARKERP (obj2)) ival2 = marker_position (obj2); | |
318 else goto arithcompare_float; | |
319 | |
320 return ival1 < ival2 ? -1 : ival1 > ival2 ? 1 : 0; | |
321 } | |
322 | |
323 arithcompare_float: | |
324 | |
325 { | |
326 double dval1, dval2; | |
327 | |
328 if (FLOATP (obj1)) dval1 = XFLOAT_DATA (obj1); | |
329 else if (INTP (obj1)) dval1 = (double) XINT (obj1); | |
330 else if (CHARP (obj1)) dval1 = (double) XCHAR (obj1); | |
331 else if (MARKERP (obj1)) dval1 = (double) marker_position (obj1); | |
332 else | |
333 { | |
334 obj1 = wrong_type_argument (Qnumber_char_or_marker_p, obj1); | |
335 goto retry; | |
336 } | |
337 | |
338 if (FLOATP (obj2)) dval2 = XFLOAT_DATA (obj2); | |
339 else if (INTP (obj2)) dval2 = (double) XINT (obj2); | |
340 else if (CHARP (obj2)) dval2 = (double) XCHAR (obj2); | |
341 else if (MARKERP (obj2)) dval2 = (double) marker_position (obj2); | |
342 else | |
343 { | |
344 obj2 = wrong_type_argument (Qnumber_char_or_marker_p, obj2); | |
345 goto retry; | |
346 } | |
347 | |
348 return dval1 < dval2 ? -1 : dval1 > dval2 ? 1 : 0; | |
349 } | |
1983 | 350 #endif /* WITH_NUMBER_TYPES */ |
428 | 351 } |
352 | |
353 static Lisp_Object | |
354 bytecode_arithop (Lisp_Object obj1, Lisp_Object obj2, Opcode opcode) | |
355 { | |
1983 | 356 #ifdef WITH_NUMBER_TYPES |
357 switch (promote_args (&obj1, &obj2)) | |
358 { | |
359 case FIXNUM_T: | |
360 { | |
361 EMACS_INT ival1 = XREALINT (obj1), ival2 = XREALINT (obj2); | |
362 switch (opcode) | |
363 { | |
364 case Bplus: ival1 += ival2; break; | |
365 case Bdiff: ival1 -= ival2; break; | |
366 case Bmult: | |
367 #ifdef HAVE_BIGNUM | |
368 /* Due to potential overflow, we compute using bignums */ | |
369 bignum_set_long (scratch_bignum, ival1); | |
370 bignum_set_long (scratch_bignum2, ival2); | |
371 bignum_mul (scratch_bignum, scratch_bignum, scratch_bignum2); | |
372 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); | |
373 #else | |
374 ival1 *= ival2; break; | |
375 #endif | |
376 case Bquo: | |
4717
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
377 if (ival2 == 0) |
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
378 signal_error_2 (Qarith_error, "division by zero", obj1, obj2); |
1983 | 379 ival1 /= ival2; |
380 break; | |
381 case Bmax: if (ival1 < ival2) ival1 = ival2; break; | |
382 case Bmin: if (ival1 > ival2) ival1 = ival2; break; | |
383 } | |
384 return make_integer (ival1); | |
385 } | |
386 #ifdef HAVE_BIGNUM | |
387 case BIGNUM_T: | |
388 switch (opcode) | |
389 { | |
390 case Bplus: | |
391 bignum_add (scratch_bignum, XBIGNUM_DATA (obj1), | |
392 XBIGNUM_DATA (obj2)); | |
393 break; | |
394 case Bdiff: | |
395 bignum_sub (scratch_bignum, XBIGNUM_DATA (obj1), | |
396 XBIGNUM_DATA (obj2)); | |
397 break; | |
398 case Bmult: | |
399 bignum_mul (scratch_bignum, XBIGNUM_DATA (obj1), | |
400 XBIGNUM_DATA (obj2)); | |
401 break; | |
402 case Bquo: | |
403 if (bignum_sign (XBIGNUM_DATA (obj2)) == 0) | |
4717
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
404 signal_error_2 (Qarith_error, "division by zero", obj1, obj2); |
1983 | 405 bignum_div (scratch_bignum, XBIGNUM_DATA (obj1), |
406 XBIGNUM_DATA (obj2)); | |
407 break; | |
408 case Bmax: | |
409 return bignum_gt (XBIGNUM_DATA (obj1), XBIGNUM_DATA (obj2)) | |
410 ? obj1 : obj2; | |
411 case Bmin: | |
412 return bignum_lt (XBIGNUM_DATA (obj1), XBIGNUM_DATA (obj2)) | |
413 ? obj1 : obj2; | |
414 } | |
415 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); | |
416 #endif | |
417 #ifdef HAVE_RATIO | |
418 case RATIO_T: | |
419 switch (opcode) | |
420 { | |
421 case Bplus: | |
422 ratio_add (scratch_ratio, XRATIO_DATA (obj1), XRATIO_DATA (obj2)); | |
423 break; | |
424 case Bdiff: | |
425 ratio_sub (scratch_ratio, XRATIO_DATA (obj1), XRATIO_DATA (obj2)); | |
426 break; | |
427 case Bmult: | |
428 ratio_mul (scratch_ratio, XRATIO_DATA (obj1), XRATIO_DATA (obj2)); | |
429 break; | |
430 case Bquo: | |
431 if (ratio_sign (XRATIO_DATA (obj2)) == 0) | |
4717
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
432 signal_error_2 (Qarith_error, "division by zero", obj1, obj2); |
1983 | 433 ratio_div (scratch_ratio, XRATIO_DATA (obj1), XRATIO_DATA (obj2)); |
434 break; | |
435 case Bmax: | |
436 return ratio_gt (XRATIO_DATA (obj1), XRATIO_DATA (obj2)) | |
437 ? obj1 : obj2; | |
438 case Bmin: | |
439 return ratio_lt (XRATIO_DATA (obj1), XRATIO_DATA (obj2)) | |
440 ? obj1 : obj2; | |
441 } | |
442 return make_ratio_rt (scratch_ratio); | |
443 #endif | |
444 #ifdef HAVE_BIGFLOAT | |
445 case BIGFLOAT_T: | |
446 bigfloat_set_prec (scratch_bigfloat, max (XBIGFLOAT_GET_PREC (obj1), | |
447 XBIGFLOAT_GET_PREC (obj2))); | |
448 switch (opcode) | |
449 { | |
450 case Bplus: | |
451 bigfloat_add (scratch_bigfloat, XBIGFLOAT_DATA (obj1), | |
452 XBIGFLOAT_DATA (obj2)); | |
453 break; | |
454 case Bdiff: | |
455 bigfloat_sub (scratch_bigfloat, XBIGFLOAT_DATA (obj1), | |
456 XBIGFLOAT_DATA (obj2)); | |
457 break; | |
458 case Bmult: | |
459 bigfloat_mul (scratch_bigfloat, XBIGFLOAT_DATA (obj1), | |
460 XBIGFLOAT_DATA (obj2)); | |
461 break; | |
462 case Bquo: | |
463 if (bigfloat_sign (XBIGFLOAT_DATA (obj2)) == 0) | |
4717
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
464 signal_error_2 (Qarith_error, "division by zero", obj1, obj2); |
1983 | 465 bigfloat_div (scratch_bigfloat, XBIGFLOAT_DATA (obj1), |
466 XBIGFLOAT_DATA (obj2)); | |
467 break; | |
468 case Bmax: | |
469 return bigfloat_gt (XBIGFLOAT_DATA (obj1), XBIGFLOAT_DATA (obj2)) | |
470 ? obj1 : obj2; | |
471 case Bmin: | |
472 return bigfloat_lt (XBIGFLOAT_DATA (obj1), XBIGFLOAT_DATA (obj2)) | |
473 ? obj1 : obj2; | |
474 } | |
475 return make_bigfloat_bf (scratch_bigfloat); | |
476 #endif | |
1995 | 477 default: /* FLOAT_T */ |
478 { | |
479 double dval1 = XFLOAT_DATA (obj1), dval2 = XFLOAT_DATA (obj2); | |
480 switch (opcode) | |
481 { | |
482 case Bplus: dval1 += dval2; break; | |
483 case Bdiff: dval1 -= dval2; break; | |
484 case Bmult: dval1 *= dval2; break; | |
485 case Bquo: | |
4717
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
486 if (dval2 == 0.0) |
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
487 signal_error_2 (Qarith_error, "division by zero", obj1, obj2); |
1995 | 488 dval1 /= dval2; |
489 break; | |
490 case Bmax: if (dval1 < dval2) dval1 = dval2; break; | |
491 case Bmin: if (dval1 > dval2) dval1 = dval2; break; | |
492 } | |
493 return make_float (dval1); | |
494 } | |
1983 | 495 } |
496 #else /* !WITH_NUMBER_TYPES */ | |
428 | 497 EMACS_INT ival1, ival2; |
498 int float_p; | |
499 | |
500 retry: | |
501 | |
502 float_p = 0; | |
503 | |
504 if (INTP (obj1)) ival1 = XINT (obj1); | |
505 else if (CHARP (obj1)) ival1 = XCHAR (obj1); | |
506 else if (MARKERP (obj1)) ival1 = marker_position (obj1); | |
507 else if (FLOATP (obj1)) ival1 = 0, float_p = 1; | |
508 else | |
509 { | |
510 obj1 = wrong_type_argument (Qnumber_char_or_marker_p, obj1); | |
511 goto retry; | |
512 } | |
513 | |
514 if (INTP (obj2)) ival2 = XINT (obj2); | |
515 else if (CHARP (obj2)) ival2 = XCHAR (obj2); | |
516 else if (MARKERP (obj2)) ival2 = marker_position (obj2); | |
517 else if (FLOATP (obj2)) ival2 = 0, float_p = 1; | |
518 else | |
519 { | |
520 obj2 = wrong_type_argument (Qnumber_char_or_marker_p, obj2); | |
521 goto retry; | |
522 } | |
523 | |
524 if (!float_p) | |
525 { | |
526 switch (opcode) | |
527 { | |
528 case Bplus: ival1 += ival2; break; | |
529 case Bdiff: ival1 -= ival2; break; | |
530 case Bmult: ival1 *= ival2; break; | |
531 case Bquo: | |
4717
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
532 if (ival2 == 0) |
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
533 signal_error_2 (Qarith_error, "division by zero", obj1, obj2); |
428 | 534 ival1 /= ival2; |
535 break; | |
536 case Bmax: if (ival1 < ival2) ival1 = ival2; break; | |
537 case Bmin: if (ival1 > ival2) ival1 = ival2; break; | |
538 } | |
539 return make_int (ival1); | |
540 } | |
541 else | |
542 { | |
543 double dval1 = FLOATP (obj1) ? XFLOAT_DATA (obj1) : (double) ival1; | |
544 double dval2 = FLOATP (obj2) ? XFLOAT_DATA (obj2) : (double) ival2; | |
545 switch (opcode) | |
546 { | |
547 case Bplus: dval1 += dval2; break; | |
548 case Bdiff: dval1 -= dval2; break; | |
549 case Bmult: dval1 *= dval2; break; | |
550 case Bquo: | |
4717
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
551 if (dval2 == 0) |
fcc7e89d5e68
Properly handle continuable divide-by-zero errors. Fix truncation of a
Jerry James <james@xemacs.org>
parents:
4678
diff
changeset
|
552 signal_error_2 (Qarith_error, "division by zero", obj1, obj2); |
428 | 553 dval1 /= dval2; |
554 break; | |
555 case Bmax: if (dval1 < dval2) dval1 = dval2; break; | |
556 case Bmin: if (dval1 > dval2) dval1 = dval2; break; | |
557 } | |
558 return make_float (dval1); | |
559 } | |
1983 | 560 #endif /* WITH_NUMBER_TYPES */ |
428 | 561 } |
562 | |
563 | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
564 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
565 /*********************** The instruction array *********************/ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
566 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
567 /* Check that there are at least LEN elements left in the end of the |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
568 instruction array before fetching them. Note that we allow for |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
569 PROGRAM_PTR == PROGRAM_END after the fetch -- that means there are |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
570 no more elements to fetch next time around, but we might exit before |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
571 next time comes. |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
572 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
573 When checking the destination if jumps, however, we don't allow |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
574 PROGRAM_PTR to equal PROGRAM_END, since we will always be fetching |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
575 another instruction after the jump. */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
576 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
577 #define CHECK_OPCODE_SPACE(len) \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
578 bytecode_assert (program_ptr + len <= program_end) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
579 |
428 | 580 /* Read next uint8 from the instruction stream. */ |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
581 #define READ_UINT_1 \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
582 (CHECK_OPCODE_SPACE (1), (unsigned int) (unsigned char) *program_ptr++) |
428 | 583 |
584 /* Read next uint16 from the instruction stream. */ | |
585 #define READ_UINT_2 \ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
586 (CHECK_OPCODE_SPACE (2), \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
587 program_ptr += 2, \ |
428 | 588 (((unsigned int) (unsigned char) program_ptr[-1]) * 256 + \ |
589 ((unsigned int) (unsigned char) program_ptr[-2]))) | |
590 | |
591 /* Read next int8 from the instruction stream. */ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
592 #define READ_INT_1 \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
593 (CHECK_OPCODE_SPACE (1), (int) (signed char) *program_ptr++) |
428 | 594 |
595 /* Read next int16 from the instruction stream. */ | |
596 #define READ_INT_2 \ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
597 (CHECK_OPCODE_SPACE (2), \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
598 program_ptr += 2, \ |
428 | 599 (((int) ( signed char) program_ptr[-1]) * 256 + \ |
600 ((int) (unsigned char) program_ptr[-2]))) | |
601 | |
602 /* Read next int8 from instruction stream; don't advance program_pointer */ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
603 #define PEEK_INT_1 \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
604 (CHECK_OPCODE_SPACE (1), (int) (signed char) program_ptr[0]) |
428 | 605 |
606 /* Read next int16 from instruction stream; don't advance program_pointer */ | |
607 #define PEEK_INT_2 \ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
608 (CHECK_OPCODE_SPACE (2), \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
609 (((int) ( signed char) program_ptr[1]) * 256) | \ |
428 | 610 ((int) (unsigned char) program_ptr[0])) |
611 | |
612 /* Do relative jumps from the current location. | |
613 We only do a QUIT if we jump backwards, for efficiency. | |
614 No infloops without backward jumps! */ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
615 #define JUMP_RELATIVE(jump) do { \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
616 int _JR_jump = (jump); \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
617 if (_JR_jump < 0) QUIT; \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
618 /* Check that where we're going to is in range. Note that we don't use \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
619 CHECK_OPCODE_SPACE() -- that only checks the end, and it allows \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
620 program_ptr == program_end, which we don't allow. */ \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
621 bytecode_assert (program_ptr + _JR_jump >= program && \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
622 program_ptr + _JR_jump < program_end); \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
623 program_ptr += _JR_jump; \ |
428 | 624 } while (0) |
625 | |
626 #define JUMP JUMP_RELATIVE (PEEK_INT_2) | |
627 #define JUMPR JUMP_RELATIVE (PEEK_INT_1) | |
628 | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
629 #define JUMP_NEXT (CHECK_OPCODE_SPACE (2), (void) (program_ptr += 2)) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
630 #define JUMPR_NEXT (CHECK_OPCODE_SPACE (1), (void) (program_ptr += 1)) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
631 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
632 /*********************** The stack array *********************/ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
633 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
634 /* NOTE: The stack array doesn't work quite like you'd expect. |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
635 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
636 STACK_PTR points to the value on the top of the stack. Popping a value |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
637 fetches the value from the STACK_PTR and then decrements it. Pushing a |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
638 value first increments it, then writes the new value. STACK_PTR - |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
639 STACK_BEG is the number of elements on the stack. |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
640 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
641 This means that when STACK_PTR == STACK_BEG, the stack is empty, and |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
642 the space at STACK_BEG is never written to -- the first push will write |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
643 into the space directly after STACK_BEG. This is why the call to |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
644 alloca_array() below has a count of `stack_depth + 1', and why |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
645 we GCPRO1 (stack_ptr[1]) -- the value at stack_ptr[0] is unused and |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
646 uninitialized. |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
647 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
648 Also, STACK_END actually points to the last usable storage location, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
649 and does not point past the end, like you'd expect. */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
650 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
651 #define CHECK_STACKPTR_OFFSET(len) \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
652 bytecode_assert (stack_ptr + (len) >= stack_beg && \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
653 stack_ptr + (len) <= stack_end) |
428 | 654 |
655 /* Push x onto the execution stack. */ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
656 #define PUSH(x) (CHECK_STACKPTR_OFFSET (1), *++stack_ptr = (x)) |
428 | 657 |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
658 /* Pop a value, which may be multiple, off the execution stack. */ |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
659 #define POP_WITH_MULTIPLE_VALUES (CHECK_STACKPTR_OFFSET (-1), *stack_ptr--) |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
660 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
661 /* Pop a value off the execution stack, treating multiple values as single. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
662 #define POP (IGNORE_MULTIPLE_VALUES (POP_WITH_MULTIPLE_VALUES)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
663 |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
664 /* ..._UNSAFE() means it evaluates its argument more than once. */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
665 #define DISCARD_PRESERVING_MULTIPLE_VALUES_UNSAFE(n) \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
666 (CHECK_STACKPTR_OFFSET (-(n)), stack_ptr -= (n)) |
428 | 667 |
668 /* Discard n values from the execution stack. */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
669 #define DISCARD(n) do { \ |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
670 int _discard_n = (n); \ |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
671 if (1 != multiple_value_current_limit) \ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
672 { \ |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
673 int i; \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
674 for (i = 0; i < _discard_n; i++) \ |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
675 { \ |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
676 CHECK_STACKPTR_OFFSET (-1); \ |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
677 *stack_ptr = ignore_multiple_values (*stack_ptr); \ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
678 stack_ptr--; \ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
679 } \ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
680 } \ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
681 else \ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
682 { \ |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
683 CHECK_STACKPTR_OFFSET (-_discard_n); \ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
684 stack_ptr -= _discard_n; \ |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
685 } \ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
686 } while (0) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
687 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
688 /* Get the value, which may be multiple, at the top of the execution stack; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
689 and leave it there. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
690 #define TOP_WITH_MULTIPLE_VALUES (*stack_ptr) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
691 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
692 #define TOP_ADDRESS (stack_ptr) |
428 | 693 |
694 /* Get the value which is at the top of the execution stack, | |
695 but don't pop it. */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
696 #define TOP (IGNORE_MULTIPLE_VALUES (TOP_WITH_MULTIPLE_VALUES)) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
697 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
698 #define TOP_LVALUE (*stack_ptr) |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
699 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
700 |
428 | 701 |
1920 | 702 /* See comment before the big switch in execute_optimized_program(). */ |
1884 | 703 #define GCPRO_STACK (gcpro1.nvars = stack_ptr - stack_beg) |
704 | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
705 |
428 | 706 /* The actual interpreter for byte code. |
707 This function has been seriously optimized for performance. | |
708 Don't change the constructs unless you are willing to do | |
709 real benchmarking and profiling work -- martin */ | |
710 | |
711 | |
814 | 712 Lisp_Object |
442 | 713 execute_optimized_program (const Opbyte *program, |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
714 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
715 Elemcount program_length, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
716 #endif |
428 | 717 int stack_depth, |
718 Lisp_Object *constants_data) | |
719 { | |
720 /* This function can GC */ | |
442 | 721 REGISTER const Opbyte *program_ptr = (Opbyte *) program; |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
722 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
723 const Opbyte *program_end = program_ptr + program_length; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
724 #endif |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
725 /* See comment above explaining the `+ 1' */ |
1884 | 726 Lisp_Object *stack_beg = alloca_array (Lisp_Object, stack_depth + 1); |
727 REGISTER Lisp_Object *stack_ptr = stack_beg; | |
428 | 728 int speccount = specpdl_depth (); |
729 struct gcpro gcpro1; | |
730 | |
731 #ifdef BYTE_CODE_METER | |
4925 | 732 Opcode this_opcode = (Opcode) 0; |
428 | 733 Opcode prev_opcode; |
734 #endif | |
735 | |
736 #ifdef ERROR_CHECK_BYTE_CODE | |
737 Lisp_Object *stack_end = stack_beg + stack_depth; | |
738 #endif | |
739 | |
1920 | 740 /* We used to GCPRO the whole interpreter stack before entering this while |
741 loop (21.5.14 and before), but that interferes with collection of weakly | |
742 referenced objects. Although strictly speaking there's no promise that | |
743 weak references will disappear by any given point in time, they should | |
744 be collected at the first opportunity. Waiting until exit from the | |
745 function caused test failures because "stale" objects "above" the top of | |
746 the stack were still GCPROed, and they were not getting collected until | |
747 after exit from the (byte-compiled) test! | |
748 | |
749 Now the idea is to dynamically adjust the array of GCPROed objects to | |
750 include only the "active" region of the stack. | |
751 | |
752 We use the "GCPRO1 the array base and set the nvars member" method. It | |
753 would be slightly inefficient but correct to use GCPRO1_ARRAY here. It | |
754 would just redundantly set nvars. | |
755 #### Maybe it would be clearer to use GCPRO1_ARRAY and do GCPRO_STACK | |
756 after the switch? | |
757 | |
758 GCPRO_STACK is something of a misnomer, because it suggests that a | |
759 struct gcpro is initialized each time. This is false; only the nvars | |
760 member of a single struct gcpro is being adjusted. This works because | |
761 each time a new object is assigned to a stack location, the old object | |
762 loses its reference and is effectively UNGCPROed, and the new object is | |
763 automatically GCPROed as long as nvars is correct. Only when we | |
764 return from the interpreter do we need to finalize the struct gcpro | |
765 itself, and that's done at case Breturn. | |
766 */ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
767 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
768 /* See comment above explaining the `[1]' */ |
428 | 769 GCPRO1 (stack_ptr[1]); |
1758 | 770 |
428 | 771 while (1) |
772 { | |
773 REGISTER Opcode opcode = (Opcode) READ_UINT_1; | |
1920 | 774 |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
775 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
776 remember_operation (opcode); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
777 #endif |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
778 |
1920 | 779 GCPRO_STACK; /* Get nvars right before maybe signaling. */ |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
780 /* #### NOTE: This code should probably never get triggered, since we |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
781 now catch the problems earlier, farther down, before we ever set |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
782 a bad value for STACK_PTR. */ |
428 | 783 #ifdef ERROR_CHECK_BYTE_CODE |
784 if (stack_ptr > stack_end) | |
563 | 785 stack_overflow ("byte code stack overflow", Qunbound); |
428 | 786 if (stack_ptr < stack_beg) |
563 | 787 stack_overflow ("byte code stack underflow", Qunbound); |
428 | 788 #endif |
789 | |
790 #ifdef BYTE_CODE_METER | |
791 prev_opcode = this_opcode; | |
792 this_opcode = opcode; | |
793 meter_code (prev_opcode, this_opcode); | |
794 #endif | |
795 | |
796 switch (opcode) | |
797 { | |
798 REGISTER int n; | |
799 | |
800 default: | |
801 if (opcode >= Bconstant) | |
802 PUSH (constants_data[opcode - Bconstant]); | |
803 else | |
1884 | 804 { |
805 /* We're not sure what these do, so better safe than sorry. */ | |
806 /* GCPRO_STACK; */ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
807 stack_ptr = execute_rare_opcode (stack_ptr, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
808 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
809 stack_beg, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
810 stack_end, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
811 #endif /* ERROR_CHECK_BYTE_CODE */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
812 program_ptr, opcode); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
813 CHECK_STACKPTR_OFFSET (0); |
1884 | 814 } |
428 | 815 break; |
816 | |
817 case Bvarref: | |
818 case Bvarref+1: | |
819 case Bvarref+2: | |
820 case Bvarref+3: | |
821 case Bvarref+4: | |
822 case Bvarref+5: n = opcode - Bvarref; goto do_varref; | |
823 case Bvarref+7: n = READ_UINT_2; goto do_varref; | |
824 case Bvarref+6: n = READ_UINT_1; /* most common */ | |
825 do_varref: | |
826 { | |
827 Lisp_Object symbol = constants_data[n]; | |
828 Lisp_Object value = XSYMBOL (symbol)->value; | |
829 if (SYMBOL_VALUE_MAGIC_P (value)) | |
1920 | 830 /* I GCPRO_STACKed Fsymbol_value elsewhere, but I dunno why. */ |
831 /* GCPRO_STACK; */ | |
428 | 832 value = Fsymbol_value (symbol); |
833 PUSH (value); | |
834 break; | |
835 } | |
836 | |
837 case Bvarset: | |
838 case Bvarset+1: | |
839 case Bvarset+2: | |
840 case Bvarset+3: | |
841 case Bvarset+4: | |
842 case Bvarset+5: n = opcode - Bvarset; goto do_varset; | |
843 case Bvarset+7: n = READ_UINT_2; goto do_varset; | |
844 case Bvarset+6: n = READ_UINT_1; /* most common */ | |
845 do_varset: | |
846 { | |
847 Lisp_Object symbol = constants_data[n]; | |
440 | 848 Lisp_Symbol *symbol_ptr = XSYMBOL (symbol); |
428 | 849 Lisp_Object old_value = symbol_ptr->value; |
850 Lisp_Object new_value = POP; | |
1661 | 851 if (!SYMBOL_VALUE_MAGIC_P (old_value) || UNBOUNDP (old_value)) |
428 | 852 symbol_ptr->value = new_value; |
1884 | 853 else { |
854 /* Fset may call magic handlers */ | |
855 /* GCPRO_STACK; */ | |
428 | 856 Fset (symbol, new_value); |
1884 | 857 } |
858 | |
428 | 859 break; |
860 } | |
861 | |
862 case Bvarbind: | |
863 case Bvarbind+1: | |
864 case Bvarbind+2: | |
865 case Bvarbind+3: | |
866 case Bvarbind+4: | |
867 case Bvarbind+5: n = opcode - Bvarbind; goto do_varbind; | |
868 case Bvarbind+7: n = READ_UINT_2; goto do_varbind; | |
869 case Bvarbind+6: n = READ_UINT_1; /* most common */ | |
870 do_varbind: | |
871 { | |
872 Lisp_Object symbol = constants_data[n]; | |
440 | 873 Lisp_Symbol *symbol_ptr = XSYMBOL (symbol); |
428 | 874 Lisp_Object old_value = symbol_ptr->value; |
875 Lisp_Object new_value = POP; | |
876 if (!SYMBOL_VALUE_MAGIC_P (old_value) || UNBOUNDP (old_value)) | |
877 { | |
878 specpdl_ptr->symbol = symbol; | |
879 specpdl_ptr->old_value = old_value; | |
880 specpdl_ptr->func = 0; | |
881 specpdl_ptr++; | |
882 specpdl_depth_counter++; | |
883 | |
884 symbol_ptr->value = new_value; | |
853 | 885 |
886 #ifdef ERROR_CHECK_CATCH | |
887 check_specbind_stack_sanity (); | |
888 #endif | |
428 | 889 } |
890 else | |
1884 | 891 { |
892 /* does an Fset, may call magic handlers */ | |
893 /* GCPRO_STACK; */ | |
894 specbind_magic (symbol, new_value); | |
895 } | |
428 | 896 break; |
897 } | |
898 | |
899 case Bcall: | |
900 case Bcall+1: | |
901 case Bcall+2: | |
902 case Bcall+3: | |
903 case Bcall+4: | |
904 case Bcall+5: | |
905 case Bcall+6: | |
906 case Bcall+7: | |
907 n = (opcode < Bcall+6 ? opcode - Bcall : | |
908 opcode == Bcall+6 ? READ_UINT_1 : READ_UINT_2); | |
1920 | 909 /* #### Shouldn't this be just before the Ffuncall? |
910 Neither Fget nor Fput can GC. */ | |
1884 | 911 /* GCPRO_STACK; */ |
428 | 912 DISCARD (n); |
913 #ifdef BYTE_CODE_METER | |
914 if (byte_metering_on && SYMBOLP (TOP)) | |
915 { | |
916 Lisp_Object val = Fget (TOP, Qbyte_code_meter, Qnil); | |
917 if (INTP (val)) | |
918 Fput (TOP, Qbyte_code_meter, make_int (XINT (val) + 1)); | |
919 } | |
920 #endif | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
921 TOP_LVALUE = TOP; /* Ignore multiple values. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
922 TOP_LVALUE = Ffuncall (n + 1, TOP_ADDRESS); |
428 | 923 break; |
924 | |
925 case Bunbind: | |
926 case Bunbind+1: | |
927 case Bunbind+2: | |
928 case Bunbind+3: | |
929 case Bunbind+4: | |
930 case Bunbind+5: | |
931 case Bunbind+6: | |
932 case Bunbind+7: | |
933 UNBIND_TO (specpdl_depth() - | |
934 (opcode < Bunbind+6 ? opcode-Bunbind : | |
935 opcode == Bunbind+6 ? READ_UINT_1 : READ_UINT_2)); | |
936 break; | |
937 | |
938 | |
939 case Bgoto: | |
940 JUMP; | |
941 break; | |
942 | |
943 case Bgotoifnil: | |
944 if (NILP (POP)) | |
945 JUMP; | |
946 else | |
947 JUMP_NEXT; | |
948 break; | |
949 | |
950 case Bgotoifnonnil: | |
951 if (!NILP (POP)) | |
952 JUMP; | |
953 else | |
954 JUMP_NEXT; | |
955 break; | |
956 | |
957 case Bgotoifnilelsepop: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
958 /* Discard any multiple value: */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
959 if (NILP (TOP_LVALUE = TOP)) |
428 | 960 JUMP; |
961 else | |
962 { | |
963 DISCARD (1); | |
964 JUMP_NEXT; | |
965 } | |
966 break; | |
967 | |
968 case Bgotoifnonnilelsepop: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
969 /* Discard any multiple value: */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
970 if (!NILP (TOP_LVALUE = TOP)) |
428 | 971 JUMP; |
972 else | |
973 { | |
974 DISCARD (1); | |
975 JUMP_NEXT; | |
976 } | |
977 break; | |
978 | |
979 | |
980 case BRgoto: | |
981 JUMPR; | |
982 break; | |
983 | |
984 case BRgotoifnil: | |
985 if (NILP (POP)) | |
986 JUMPR; | |
987 else | |
988 JUMPR_NEXT; | |
989 break; | |
990 | |
991 case BRgotoifnonnil: | |
992 if (!NILP (POP)) | |
993 JUMPR; | |
994 else | |
995 JUMPR_NEXT; | |
996 break; | |
997 | |
998 case BRgotoifnilelsepop: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
999 if (NILP (TOP_LVALUE = TOP)) |
428 | 1000 JUMPR; |
1001 else | |
1002 { | |
1003 DISCARD (1); | |
1004 JUMPR_NEXT; | |
1005 } | |
1006 break; | |
1007 | |
1008 case BRgotoifnonnilelsepop: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1009 if (!NILP (TOP_LVALUE = TOP)) |
428 | 1010 JUMPR; |
1011 else | |
1012 { | |
1013 DISCARD (1); | |
1014 JUMPR_NEXT; | |
1015 } | |
1016 break; | |
1017 | |
1018 case Breturn: | |
1019 UNGCPRO; | |
1020 #ifdef ERROR_CHECK_BYTE_CODE | |
1021 /* Binds and unbinds are supposed to be compiled balanced. */ | |
1022 if (specpdl_depth() != speccount) | |
563 | 1023 invalid_byte_code ("unbalanced specbinding stack", Qunbound); |
428 | 1024 #endif |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1025 return TOP_WITH_MULTIPLE_VALUES; |
428 | 1026 |
1027 case Bdiscard: | |
1028 DISCARD (1); | |
1029 break; | |
1030 | |
1031 case Bdup: | |
1032 { | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1033 Lisp_Object arg = TOP_WITH_MULTIPLE_VALUES; |
428 | 1034 PUSH (arg); |
1035 break; | |
1036 } | |
1037 | |
1038 case Bconstant2: | |
1039 PUSH (constants_data[READ_UINT_2]); | |
1040 break; | |
1041 | |
1042 case Bcar: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1043 { |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1044 /* Fcar can GC via wrong_type_argument. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1045 /* GCPRO_STACK; */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1046 Lisp_Object arg = TOP; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1047 TOP_LVALUE = CONSP (arg) ? XCAR (arg) : Fcar (arg); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1048 break; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1049 } |
428 | 1050 |
1051 case Bcdr: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1052 { |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1053 /* Fcdr can GC via wrong_type_argument. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1054 /* GCPRO_STACK; */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1055 Lisp_Object arg = TOP; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1056 TOP_LVALUE = CONSP (arg) ? XCDR (arg) : Fcdr (arg); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1057 break; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1058 } |
428 | 1059 |
1060 case Bunbind_all: | |
1061 /* To unbind back to the beginning of this frame. Not used yet, | |
1062 but will be needed for tail-recursion elimination. */ | |
771 | 1063 unbind_to (speccount); |
428 | 1064 break; |
1065 | |
1066 case Bnth: | |
1067 { | |
1068 Lisp_Object arg = POP; | |
1920 | 1069 /* Fcar and Fnthcdr can GC via wrong_type_argument. */ |
1070 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1071 TOP_LVALUE = Fcar (Fnthcdr (TOP, arg)); |
428 | 1072 break; |
1073 } | |
1074 | |
1075 case Bsymbolp: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1076 TOP_LVALUE = SYMBOLP (TOP) ? Qt : Qnil; |
428 | 1077 break; |
1078 | |
1079 case Bconsp: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1080 TOP_LVALUE = CONSP (TOP) ? Qt : Qnil; |
428 | 1081 break; |
1082 | |
1083 case Bstringp: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1084 TOP_LVALUE = STRINGP (TOP) ? Qt : Qnil; |
428 | 1085 break; |
1086 | |
1087 case Blistp: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1088 TOP_LVALUE = LISTP (TOP) ? Qt : Qnil; |
428 | 1089 break; |
1090 | |
1091 case Bnumberp: | |
1983 | 1092 #ifdef WITH_NUMBER_TYPES |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1093 TOP_LVALUE = NUMBERP (TOP) ? Qt : Qnil; |
1983 | 1094 #else |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1095 TOP_LVALUE = INT_OR_FLOATP (TOP) ? Qt : Qnil; |
1983 | 1096 #endif |
428 | 1097 break; |
1098 | |
4885
6772ce4d982b
Fix hash tables, #'member*, #'assoc*, #'eql compiler macros if bignums
Aidan Kehoe <kehoea@parhasard.net>
parents:
4775
diff
changeset
|
1099 case Bfixnump: |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1100 TOP_LVALUE = INTP (TOP) ? Qt : Qnil; |
428 | 1101 break; |
1102 | |
1103 case Beq: | |
1104 { | |
1105 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1106 TOP_LVALUE = EQ_WITH_EBOLA_NOTICE (TOP, arg) ? Qt : Qnil; |
428 | 1107 break; |
1108 } | |
1109 | |
1110 case Bnot: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1111 TOP_LVALUE = NILP (TOP) ? Qt : Qnil; |
428 | 1112 break; |
1113 | |
1114 case Bcons: | |
1115 { | |
1116 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1117 TOP_LVALUE = Fcons (TOP, arg); |
428 | 1118 break; |
1119 } | |
1120 | |
1121 case Blist1: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1122 TOP_LVALUE = Fcons (TOP, Qnil); |
428 | 1123 break; |
1124 | |
1125 | |
1126 case BlistN: | |
1127 n = READ_UINT_1; | |
1128 goto do_list; | |
1129 | |
1130 case Blist2: | |
1131 case Blist3: | |
1132 case Blist4: | |
1133 /* common case */ | |
1134 n = opcode - (Blist1 - 1); | |
1135 do_list: | |
1136 { | |
1137 Lisp_Object list = Qnil; | |
1138 list_loop: | |
1139 list = Fcons (TOP, list); | |
1140 if (--n) | |
1141 { | |
1142 DISCARD (1); | |
1143 goto list_loop; | |
1144 } | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1145 TOP_LVALUE = list; |
428 | 1146 break; |
1147 } | |
1148 | |
1149 | |
1150 case Bconcat2: | |
1151 case Bconcat3: | |
1152 case Bconcat4: | |
1153 n = opcode - (Bconcat2 - 2); | |
1154 goto do_concat; | |
1155 | |
1156 case BconcatN: | |
1157 /* common case */ | |
1158 n = READ_UINT_1; | |
1159 do_concat: | |
1160 DISCARD (n - 1); | |
1920 | 1161 /* Apparently `concat' can GC; Fconcat GCPROs its arguments. */ |
1162 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1163 TOP_LVALUE = TOP; /* Ignore multiple values. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1164 TOP_LVALUE = Fconcat (n, TOP_ADDRESS); |
428 | 1165 break; |
1166 | |
1167 | |
1168 case Blength: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1169 TOP_LVALUE = Flength (TOP); |
428 | 1170 break; |
1171 | |
1172 case Baset: | |
1173 { | |
1174 Lisp_Object arg2 = POP; | |
1175 Lisp_Object arg1 = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1176 TOP_LVALUE = Faset (TOP, arg1, arg2); |
428 | 1177 break; |
1178 } | |
1179 | |
1180 case Bsymbol_value: | |
1920 | 1181 /* Why does this need GCPRO_STACK? If not, remove others, too. */ |
1884 | 1182 /* GCPRO_STACK; */ |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1183 TOP_LVALUE = Fsymbol_value (TOP); |
428 | 1184 break; |
1185 | |
1186 case Bsymbol_function: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1187 TOP_LVALUE = Fsymbol_function (TOP); |
428 | 1188 break; |
1189 | |
1190 case Bget: | |
1191 { | |
1192 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1193 TOP_LVALUE = Fget (TOP, arg, Qnil); |
428 | 1194 break; |
1195 } | |
1196 | |
1197 case Bsub1: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1198 { |
1983 | 1199 #ifdef HAVE_BIGNUM |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1200 TOP_LVALUE = Fsub1 (TOP); |
1983 | 1201 #else |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1202 Lisp_Object arg = TOP; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1203 TOP_LVALUE = INTP (arg) ? INT_MINUS1 (arg) : Fsub1 (arg); |
1983 | 1204 #endif |
428 | 1205 break; |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1206 } |
428 | 1207 case Badd1: |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1208 { |
1983 | 1209 #ifdef HAVE_BIGNUM |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1210 TOP_LVALUE = Fadd1 (TOP); |
1983 | 1211 #else |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1212 Lisp_Object arg = TOP; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1213 TOP_LVALUE = INTP (arg) ? INT_PLUS1 (arg) : Fadd1 (arg); |
1983 | 1214 #endif |
428 | 1215 break; |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1216 } |
428 | 1217 |
1218 case Beqlsign: | |
1219 { | |
1220 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1221 TOP_LVALUE = bytecode_arithcompare (TOP, arg) == 0 ? Qt : Qnil; |
428 | 1222 break; |
1223 } | |
1224 | |
1225 case Bgtr: | |
1226 { | |
1227 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1228 TOP_LVALUE = bytecode_arithcompare (TOP, arg) > 0 ? Qt : Qnil; |
428 | 1229 break; |
1230 } | |
1231 | |
1232 case Blss: | |
1233 { | |
1234 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1235 TOP_LVALUE = bytecode_arithcompare (TOP, arg) < 0 ? Qt : Qnil; |
428 | 1236 break; |
1237 } | |
1238 | |
1239 case Bleq: | |
1240 { | |
1241 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1242 TOP_LVALUE = bytecode_arithcompare (TOP, arg) <= 0 ? Qt : Qnil; |
428 | 1243 break; |
1244 } | |
1245 | |
1246 case Bgeq: | |
1247 { | |
1248 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1249 TOP_LVALUE = bytecode_arithcompare (TOP, arg) >= 0 ? Qt : Qnil; |
428 | 1250 break; |
1251 } | |
1252 | |
1253 | |
1254 case Bnegate: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1255 TOP_LVALUE = bytecode_negate (TOP); |
428 | 1256 break; |
1257 | |
1258 case Bnconc: | |
1259 DISCARD (1); | |
1920 | 1260 /* nconc2 GCPROs before calling this. */ |
1261 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1262 TOP_LVALUE = TOP; /* Ignore multiple values. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1263 TOP_LVALUE = bytecode_nconc2 (TOP_ADDRESS); |
428 | 1264 break; |
1265 | |
1266 case Bplus: | |
1267 { | |
1268 Lisp_Object arg2 = POP; | |
1269 Lisp_Object arg1 = TOP; | |
1983 | 1270 #ifdef HAVE_BIGNUM |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1271 TOP_LVALUE = bytecode_arithop (arg1, arg2, opcode); |
1983 | 1272 #else |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1273 TOP_LVALUE = INTP (arg1) && INTP (arg2) ? |
428 | 1274 INT_PLUS (arg1, arg2) : |
1275 bytecode_arithop (arg1, arg2, opcode); | |
1983 | 1276 #endif |
428 | 1277 break; |
1278 } | |
1279 | |
1280 case Bdiff: | |
1281 { | |
1282 Lisp_Object arg2 = POP; | |
1283 Lisp_Object arg1 = TOP; | |
1983 | 1284 #ifdef HAVE_BIGNUM |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1285 TOP_LVALUE = bytecode_arithop (arg1, arg2, opcode); |
1983 | 1286 #else |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1287 TOP_LVALUE = INTP (arg1) && INTP (arg2) ? |
428 | 1288 INT_MINUS (arg1, arg2) : |
1289 bytecode_arithop (arg1, arg2, opcode); | |
1983 | 1290 #endif |
428 | 1291 break; |
1292 } | |
1293 | |
1294 case Bmult: | |
1295 case Bquo: | |
1296 case Bmax: | |
1297 case Bmin: | |
1298 { | |
1299 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1300 TOP_LVALUE = bytecode_arithop (TOP, arg, opcode); |
428 | 1301 break; |
1302 } | |
1303 | |
1304 case Bpoint: | |
1305 PUSH (make_int (BUF_PT (current_buffer))); | |
1306 break; | |
1307 | |
1308 case Binsert: | |
1920 | 1309 /* Says it can GC. */ |
1310 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1311 TOP_LVALUE = TOP; /* Ignore multiple values. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1312 TOP_LVALUE = Finsert (1, TOP_ADDRESS); |
428 | 1313 break; |
1314 | |
1315 case BinsertN: | |
1316 n = READ_UINT_1; | |
1317 DISCARD (n - 1); | |
1920 | 1318 /* See Binsert. */ |
1319 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1320 TOP_LVALUE = TOP; /* Ignore multiple values. */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1321 TOP_LVALUE = Finsert (n, TOP_ADDRESS); |
428 | 1322 break; |
1323 | |
1324 case Baref: | |
1325 { | |
1326 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1327 TOP_LVALUE = Faref (TOP, arg); |
428 | 1328 break; |
1329 } | |
1330 | |
1331 case Bmemq: | |
1332 { | |
1333 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1334 TOP_LVALUE = Fmemq (TOP, arg); |
428 | 1335 break; |
1336 } | |
1337 | |
1338 case Bset: | |
1339 { | |
1340 Lisp_Object arg = POP; | |
1884 | 1341 /* Fset may call magic handlers */ |
1342 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1343 TOP_LVALUE = Fset (TOP, arg); |
428 | 1344 break; |
1345 } | |
1346 | |
1347 case Bequal: | |
1348 { | |
1349 Lisp_Object arg = POP; | |
1920 | 1350 /* Can QUIT, so can GC, right? */ |
1351 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1352 TOP_LVALUE = Fequal (TOP, arg); |
428 | 1353 break; |
1354 } | |
1355 | |
1356 case Bnthcdr: | |
1357 { | |
1358 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1359 TOP_LVALUE = Fnthcdr (TOP, arg); |
428 | 1360 break; |
1361 } | |
1362 | |
1363 case Belt: | |
1364 { | |
1365 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1366 TOP_LVALUE = Felt (TOP, arg); |
428 | 1367 break; |
1368 } | |
1369 | |
1370 case Bmember: | |
1371 { | |
1372 Lisp_Object arg = POP; | |
1920 | 1373 /* Can QUIT, so can GC, right? */ |
1374 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1375 TOP_LVALUE = Fmember (TOP, arg); |
428 | 1376 break; |
1377 } | |
1378 | |
1379 case Bgoto_char: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1380 TOP_LVALUE = Fgoto_char (TOP, Qnil); |
428 | 1381 break; |
1382 | |
1383 case Bcurrent_buffer: | |
1384 { | |
793 | 1385 Lisp_Object buffer = wrap_buffer (current_buffer); |
1386 | |
428 | 1387 PUSH (buffer); |
1388 break; | |
1389 } | |
1390 | |
1391 case Bset_buffer: | |
1884 | 1392 /* #### WAG: set-buffer may cause Fset's of buffer locals |
1393 Didn't prevent crash. :-( */ | |
1394 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1395 TOP_LVALUE = Fset_buffer (TOP); |
428 | 1396 break; |
1397 | |
1398 case Bpoint_max: | |
1399 PUSH (make_int (BUF_ZV (current_buffer))); | |
1400 break; | |
1401 | |
1402 case Bpoint_min: | |
1403 PUSH (make_int (BUF_BEGV (current_buffer))); | |
1404 break; | |
1405 | |
1406 case Bskip_chars_forward: | |
1407 { | |
1408 Lisp_Object arg = POP; | |
1920 | 1409 /* Can QUIT, so can GC, right? */ |
1410 /* GCPRO_STACK; */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1411 TOP_LVALUE = Fskip_chars_forward (TOP, arg, Qnil); |
428 | 1412 break; |
1413 } | |
1414 | |
1415 case Bassq: | |
1416 { | |
1417 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1418 TOP_LVALUE = Fassq (TOP, arg); |
428 | 1419 break; |
1420 } | |
1421 | |
1422 case Bsetcar: | |
1423 { | |
1424 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1425 TOP_LVALUE = Fsetcar (TOP, arg); |
428 | 1426 break; |
1427 } | |
1428 | |
1429 case Bsetcdr: | |
1430 { | |
1431 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1432 TOP_LVALUE = Fsetcdr (TOP, arg); |
428 | 1433 break; |
1434 } | |
1435 | |
1436 case Bnreverse: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1437 TOP_LVALUE = bytecode_nreverse (TOP); |
428 | 1438 break; |
1439 | |
1440 case Bcar_safe: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1441 TOP_LVALUE = CONSP (TOP) ? XCAR (TOP) : Qnil; |
428 | 1442 break; |
1443 | |
1444 case Bcdr_safe: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1445 TOP_LVALUE = CONSP (TOP) ? XCDR (TOP) : Qnil; |
428 | 1446 break; |
1447 | |
1448 } | |
1449 } | |
1450 } | |
1451 | |
1452 /* It makes a worthwhile performance difference (5%) to shunt | |
1453 lesser-used opcodes off to a subroutine, to keep the switch in | |
1454 execute_optimized_program small. If you REALLY care about | |
1455 performance, you want to keep your heavily executed code away from | |
1456 rarely executed code, to minimize cache misses. | |
1457 | |
1458 Don't make this function static, since then the compiler might inline it. */ | |
1459 Lisp_Object * | |
1460 execute_rare_opcode (Lisp_Object *stack_ptr, | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1461 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1462 Lisp_Object *stack_beg, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1463 Lisp_Object *stack_end, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1464 #endif /* ERROR_CHECK_BYTE_CODE */ |
2286 | 1465 const Opbyte *UNUSED (program_ptr), |
428 | 1466 Opcode opcode) |
1467 { | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1468 REGISTER int n; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1469 |
428 | 1470 switch (opcode) |
1471 { | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1472 |
428 | 1473 case Bsave_excursion: |
1474 record_unwind_protect (save_excursion_restore, | |
1475 save_excursion_save ()); | |
1476 break; | |
1477 | |
4775
1d61580e0cf7
Remove Fsave_window_excursion from window.c, it's overridden by Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4717
diff
changeset
|
1478 /* This bytecode will eventually go away, once we no longer encounter |
1d61580e0cf7
Remove Fsave_window_excursion from window.c, it's overridden by Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4717
diff
changeset
|
1479 byte code from 21.4. In 21.5.10 and newer, save-window-excursion is |
1d61580e0cf7
Remove Fsave_window_excursion from window.c, it's overridden by Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4717
diff
changeset
|
1480 a macro. */ |
428 | 1481 case Bsave_window_excursion: |
1482 { | |
1483 int count = specpdl_depth (); | |
4775
1d61580e0cf7
Remove Fsave_window_excursion from window.c, it's overridden by Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4717
diff
changeset
|
1484 record_unwind_protect (Feval, |
1d61580e0cf7
Remove Fsave_window_excursion from window.c, it's overridden by Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4717
diff
changeset
|
1485 list2 (Qset_window_configuration, |
1d61580e0cf7
Remove Fsave_window_excursion from window.c, it's overridden by Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4717
diff
changeset
|
1486 call0 (Qcurrent_window_configuration))); |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1487 TOP_LVALUE = Fprogn (TOP); |
771 | 1488 unbind_to (count); |
428 | 1489 break; |
1490 } | |
1491 | |
1492 case Bsave_restriction: | |
1493 record_unwind_protect (save_restriction_restore, | |
844 | 1494 save_restriction_save (current_buffer)); |
428 | 1495 break; |
1496 | |
1497 case Bcatch: | |
1498 { | |
1499 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1500 TOP_LVALUE = internal_catch (TOP, Feval, arg, 0, 0, 0); |
428 | 1501 break; |
1502 } | |
1503 | |
1504 case Bskip_chars_backward: | |
1505 { | |
1506 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1507 TOP_LVALUE = Fskip_chars_backward (TOP, arg, Qnil); |
428 | 1508 break; |
1509 } | |
1510 | |
1511 case Bunwind_protect: | |
1512 record_unwind_protect (Fprogn, POP); | |
1513 break; | |
1514 | |
1515 case Bcondition_case: | |
1516 { | |
1517 Lisp_Object arg2 = POP; /* handlers */ | |
1518 Lisp_Object arg1 = POP; /* bodyform */ | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1519 TOP_LVALUE = condition_case_3 (arg1, TOP, arg2); |
428 | 1520 break; |
1521 } | |
1522 | |
1523 case Bset_marker: | |
1524 { | |
1525 Lisp_Object arg2 = POP; | |
1526 Lisp_Object arg1 = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1527 TOP_LVALUE = Fset_marker (TOP, arg1, arg2); |
428 | 1528 break; |
1529 } | |
1530 | |
1531 case Brem: | |
1532 { | |
1533 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1534 TOP_LVALUE = Frem (TOP, arg); |
428 | 1535 break; |
1536 } | |
1537 | |
1538 case Bmatch_beginning: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1539 TOP_LVALUE = Fmatch_beginning (TOP); |
428 | 1540 break; |
1541 | |
1542 case Bmatch_end: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1543 TOP_LVALUE = Fmatch_end (TOP); |
428 | 1544 break; |
1545 | |
1546 case Bupcase: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1547 TOP_LVALUE = Fupcase (TOP, Qnil); |
428 | 1548 break; |
1549 | |
1550 case Bdowncase: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1551 TOP_LVALUE = Fdowncase (TOP, Qnil); |
428 | 1552 break; |
1553 | |
1554 case Bfset: | |
1555 { | |
1556 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1557 TOP_LVALUE = Ffset (TOP, arg); |
428 | 1558 break; |
1559 } | |
1560 | |
1561 case Bstring_equal: | |
1562 { | |
1563 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1564 TOP_LVALUE = Fstring_equal (TOP, arg); |
428 | 1565 break; |
1566 } | |
1567 | |
1568 case Bstring_lessp: | |
1569 { | |
1570 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1571 TOP_LVALUE = Fstring_lessp (TOP, arg); |
428 | 1572 break; |
1573 } | |
1574 | |
1575 case Bsubstring: | |
1576 { | |
1577 Lisp_Object arg2 = POP; | |
1578 Lisp_Object arg1 = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1579 TOP_LVALUE = Fsubstring (TOP, arg1, arg2); |
428 | 1580 break; |
1581 } | |
1582 | |
1583 case Bcurrent_column: | |
1584 PUSH (make_int (current_column (current_buffer))); | |
1585 break; | |
1586 | |
1587 case Bchar_after: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1588 TOP_LVALUE = Fchar_after (TOP, Qnil); |
428 | 1589 break; |
1590 | |
1591 case Bindent_to: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1592 TOP_LVALUE = Findent_to (TOP, Qnil, Qnil); |
428 | 1593 break; |
1594 | |
1595 case Bwiden: | |
1596 PUSH (Fwiden (Qnil)); | |
1597 break; | |
1598 | |
1599 case Bfollowing_char: | |
1600 PUSH (Ffollowing_char (Qnil)); | |
1601 break; | |
1602 | |
1603 case Bpreceding_char: | |
1604 PUSH (Fpreceding_char (Qnil)); | |
1605 break; | |
1606 | |
1607 case Beolp: | |
1608 PUSH (Feolp (Qnil)); | |
1609 break; | |
1610 | |
1611 case Beobp: | |
1612 PUSH (Feobp (Qnil)); | |
1613 break; | |
1614 | |
1615 case Bbolp: | |
1616 PUSH (Fbolp (Qnil)); | |
1617 break; | |
1618 | |
1619 case Bbobp: | |
1620 PUSH (Fbobp (Qnil)); | |
1621 break; | |
1622 | |
1623 case Bsave_current_buffer: | |
1624 record_unwind_protect (save_current_buffer_restore, | |
1625 Fcurrent_buffer ()); | |
1626 break; | |
1627 | |
1628 case Binteractive_p: | |
1629 PUSH (Finteractive_p ()); | |
1630 break; | |
1631 | |
1632 case Bforward_char: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1633 TOP_LVALUE = Fforward_char (TOP, Qnil); |
428 | 1634 break; |
1635 | |
1636 case Bforward_word: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1637 TOP_LVALUE = Fforward_word (TOP, Qnil); |
428 | 1638 break; |
1639 | |
1640 case Bforward_line: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1641 TOP_LVALUE = Fforward_line (TOP, Qnil); |
428 | 1642 break; |
1643 | |
1644 case Bchar_syntax: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1645 TOP_LVALUE = Fchar_syntax (TOP, Qnil); |
428 | 1646 break; |
1647 | |
1648 case Bbuffer_substring: | |
1649 { | |
1650 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1651 TOP_LVALUE = Fbuffer_substring (TOP, arg, Qnil); |
428 | 1652 break; |
1653 } | |
1654 | |
1655 case Bdelete_region: | |
1656 { | |
1657 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1658 TOP_LVALUE = Fdelete_region (TOP, arg, Qnil); |
428 | 1659 break; |
1660 } | |
1661 | |
1662 case Bnarrow_to_region: | |
1663 { | |
1664 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1665 TOP_LVALUE = Fnarrow_to_region (TOP, arg, Qnil); |
428 | 1666 break; |
1667 } | |
1668 | |
1669 case Bend_of_line: | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1670 TOP_LVALUE = Fend_of_line (TOP, Qnil); |
428 | 1671 break; |
1672 | |
1673 case Btemp_output_buffer_setup: | |
1674 temp_output_buffer_setup (TOP); | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1675 TOP_LVALUE = Vstandard_output; |
428 | 1676 break; |
1677 | |
1678 case Btemp_output_buffer_show: | |
1679 { | |
1680 Lisp_Object arg = POP; | |
1681 temp_output_buffer_show (TOP, Qnil); | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1682 TOP_LVALUE = arg; |
428 | 1683 /* GAG ME!! */ |
1684 /* pop binding of standard-output */ | |
771 | 1685 unbind_to (specpdl_depth() - 1); |
428 | 1686 break; |
1687 } | |
1688 | |
1689 case Bold_eq: | |
1690 { | |
1691 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1692 TOP_LVALUE = HACKEQ_UNSAFE (TOP, arg) ? Qt : Qnil; |
428 | 1693 break; |
1694 } | |
1695 | |
1696 case Bold_memq: | |
1697 { | |
1698 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1699 TOP_LVALUE = Fold_memq (TOP, arg); |
428 | 1700 break; |
1701 } | |
1702 | |
1703 case Bold_equal: | |
1704 { | |
1705 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1706 TOP_LVALUE = Fold_equal (TOP, arg); |
428 | 1707 break; |
1708 } | |
1709 | |
1710 case Bold_member: | |
1711 { | |
1712 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1713 TOP_LVALUE = Fold_member (TOP, arg); |
428 | 1714 break; |
1715 } | |
1716 | |
1717 case Bold_assq: | |
1718 { | |
1719 Lisp_Object arg = POP; | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1720 TOP_LVALUE = Fold_assq (TOP, arg); |
428 | 1721 break; |
1722 } | |
1723 | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1724 case Bbind_multiple_value_limits: |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1725 { |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1726 Lisp_Object upper = POP, first = TOP, speccount; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1727 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1728 CHECK_NATNUM (upper); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1729 CHECK_NATNUM (first); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1730 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1731 speccount = make_int (bind_multiple_value_limits (XINT (first), |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1732 XINT (upper))); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1733 PUSH (upper); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1734 PUSH (speccount); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1735 break; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1736 } |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1737 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1738 case Bmultiple_value_call: |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1739 { |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1740 n = XINT (POP); |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1741 DISCARD_PRESERVING_MULTIPLE_VALUES_UNSAFE (n - 1); |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1742 /* Discard multiple values for the first (function) argument: */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1743 TOP_LVALUE = TOP; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1744 TOP_LVALUE = multiple_value_call (n, TOP_ADDRESS); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1745 break; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1746 } |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1747 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1748 case Bmultiple_value_list_internal: |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1749 { |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1750 DISCARD_PRESERVING_MULTIPLE_VALUES_UNSAFE (3); |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1751 TOP_LVALUE = multiple_value_list_internal (4, TOP_ADDRESS); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1752 break; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1753 } |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1754 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1755 case Bthrow: |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1756 { |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1757 Lisp_Object arg = POP_WITH_MULTIPLE_VALUES; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1758 |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1759 /* We never throw to a catch tag that is a multiple value: */ |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1760 throw_or_bomb_out (TOP, arg, 0, Qnil, Qnil); |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1761 break; |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1762 } |
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3263
diff
changeset
|
1763 |
428 | 1764 default: |
4914
1628e3b9601a
When aborting due to unknown opcode, output more descriptive msg
Ben Wing <ben@xemacs.org>
parents:
4910
diff
changeset
|
1765 { |
1628e3b9601a
When aborting due to unknown opcode, output more descriptive msg
Ben Wing <ben@xemacs.org>
parents:
4910
diff
changeset
|
1766 Ascbyte msg[100]; |
1628e3b9601a
When aborting due to unknown opcode, output more descriptive msg
Ben Wing <ben@xemacs.org>
parents:
4910
diff
changeset
|
1767 sprintf (msg, "Unknown opcode %d", opcode); |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1768 bytecode_abort_with_message (msg); |
4914
1628e3b9601a
When aborting due to unknown opcode, output more descriptive msg
Ben Wing <ben@xemacs.org>
parents:
4910
diff
changeset
|
1769 } |
428 | 1770 break; |
1771 } | |
1772 return stack_ptr; | |
1773 } | |
1774 | |
1775 | |
563 | 1776 DOESNT_RETURN |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4775
diff
changeset
|
1777 invalid_byte_code (const Ascbyte *reason, Lisp_Object frob) |
428 | 1778 { |
563 | 1779 signal_error (Qinvalid_byte_code, reason, frob); |
428 | 1780 } |
1781 | |
1782 /* Check for valid opcodes. Change this when adding new opcodes. */ | |
1783 static void | |
1784 check_opcode (Opcode opcode) | |
1785 { | |
1786 if ((opcode < Bvarref) || | |
1787 (opcode == 0251) || | |
1788 (opcode > Bassq && opcode < Bconstant)) | |
563 | 1789 invalid_byte_code ("invalid opcode in instruction stream", |
1790 make_int (opcode)); | |
428 | 1791 } |
1792 | |
1793 /* Check that IDX is a valid offset into the `constants' vector */ | |
1794 static void | |
1795 check_constants_index (int idx, Lisp_Object constants) | |
1796 { | |
1797 if (idx < 0 || idx >= XVECTOR_LENGTH (constants)) | |
563 | 1798 signal_ferror |
1799 (Qinvalid_byte_code, | |
1800 "reference %d to constants array out of range 0, %ld", | |
428 | 1801 idx, XVECTOR_LENGTH (constants) - 1); |
1802 } | |
1803 | |
1804 /* Get next character from Lisp instructions string. */ | |
563 | 1805 #define READ_INSTRUCTION_CHAR(lvalue) do { \ |
867 | 1806 (lvalue) = itext_ichar (ptr); \ |
1807 INC_IBYTEPTR (ptr); \ | |
563 | 1808 *icounts_ptr++ = program_ptr - program; \ |
1809 if (lvalue > UCHAR_MAX) \ | |
1810 invalid_byte_code \ | |
1811 ("Invalid character in byte code string", make_char (lvalue)); \ | |
428 | 1812 } while (0) |
1813 | |
1814 /* Get opcode from Lisp instructions string. */ | |
1815 #define READ_OPCODE do { \ | |
1816 unsigned int c; \ | |
1817 READ_INSTRUCTION_CHAR (c); \ | |
1818 opcode = (Opcode) c; \ | |
1819 } while (0) | |
1820 | |
1821 /* Get next operand, a uint8, from Lisp instructions string. */ | |
1822 #define READ_OPERAND_1 do { \ | |
1823 READ_INSTRUCTION_CHAR (arg); \ | |
1824 argsize = 1; \ | |
1825 } while (0) | |
1826 | |
1827 /* Get next operand, a uint16, from Lisp instructions string. */ | |
1828 #define READ_OPERAND_2 do { \ | |
1829 unsigned int arg1, arg2; \ | |
1830 READ_INSTRUCTION_CHAR (arg1); \ | |
1831 READ_INSTRUCTION_CHAR (arg2); \ | |
1832 arg = arg1 + (arg2 << 8); \ | |
1833 argsize = 2; \ | |
1834 } while (0) | |
1835 | |
1836 /* Write 1 byte to PTR, incrementing PTR */ | |
1837 #define WRITE_INT8(value, ptr) do { \ | |
1838 *((ptr)++) = (value); \ | |
1839 } while (0) | |
1840 | |
1841 /* Write 2 bytes to PTR, incrementing PTR */ | |
1842 #define WRITE_INT16(value, ptr) do { \ | |
1843 WRITE_INT8 (((unsigned) (value)) & 0x00ff, (ptr)); \ | |
1844 WRITE_INT8 (((unsigned) (value)) >> 8 , (ptr)); \ | |
1845 } while (0) | |
1846 | |
1847 /* We've changed our minds about the opcode we've already written. */ | |
1848 #define REWRITE_OPCODE(new_opcode) ((void) (program_ptr[-1] = new_opcode)) | |
1849 | |
1850 /* Encode an op arg within the opcode, or as a 1 or 2-byte operand. */ | |
1851 #define WRITE_NARGS(base_opcode) do { \ | |
1852 if (arg <= 5) \ | |
1853 { \ | |
1854 REWRITE_OPCODE (base_opcode + arg); \ | |
1855 } \ | |
1856 else if (arg <= UCHAR_MAX) \ | |
1857 { \ | |
1858 REWRITE_OPCODE (base_opcode + 6); \ | |
1859 WRITE_INT8 (arg, program_ptr); \ | |
1860 } \ | |
1861 else \ | |
1862 { \ | |
1863 REWRITE_OPCODE (base_opcode + 7); \ | |
1864 WRITE_INT16 (arg, program_ptr); \ | |
1865 } \ | |
1866 } while (0) | |
1867 | |
1868 /* Encode a constants reference within the opcode, or as a 2-byte operand. */ | |
1869 #define WRITE_CONSTANT do { \ | |
1870 check_constants_index(arg, constants); \ | |
1871 if (arg <= UCHAR_MAX - Bconstant) \ | |
1872 { \ | |
1873 REWRITE_OPCODE (Bconstant + arg); \ | |
1874 } \ | |
1875 else \ | |
1876 { \ | |
1877 REWRITE_OPCODE (Bconstant2); \ | |
1878 WRITE_INT16 (arg, program_ptr); \ | |
1879 } \ | |
1880 } while (0) | |
1881 | |
1882 #define WRITE_OPCODE WRITE_INT8 (opcode, program_ptr) | |
1883 | |
1884 /* Compile byte code instructions into free space provided by caller, with | |
1885 size >= (2 * string_char_length (instructions) + 1) * sizeof (Opbyte). | |
1886 Returns length of compiled code. */ | |
1887 static void | |
1888 optimize_byte_code (/* in */ | |
1889 Lisp_Object instructions, | |
1890 Lisp_Object constants, | |
1891 /* out */ | |
442 | 1892 Opbyte * const program, |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1893 Elemcount * const program_length, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
1894 Elemcount * const varbind_count) |
428 | 1895 { |
647 | 1896 Bytecount instructions_length = XSTRING_LENGTH (instructions); |
665 | 1897 Elemcount comfy_size = (Elemcount) (2 * instructions_length); |
428 | 1898 |
442 | 1899 int * const icounts = alloca_array (int, comfy_size); |
428 | 1900 int * icounts_ptr = icounts; |
1901 | |
1902 /* We maintain a table of jumps in the source code. */ | |
1903 struct jump | |
1904 { | |
1905 int from; | |
1906 int to; | |
1907 }; | |
442 | 1908 struct jump * const jumps = alloca_array (struct jump, comfy_size); |
428 | 1909 struct jump *jumps_ptr = jumps; |
1910 | |
1911 Opbyte *program_ptr = program; | |
1912 | |
867 | 1913 const Ibyte *ptr = XSTRING_DATA (instructions); |
1914 const Ibyte * const end = ptr + instructions_length; | |
428 | 1915 |
1916 *varbind_count = 0; | |
1917 | |
1918 while (ptr < end) | |
1919 { | |
1920 Opcode opcode; | |
1921 int arg; | |
1922 int argsize = 0; | |
1923 READ_OPCODE; | |
1924 WRITE_OPCODE; | |
1925 | |
1926 switch (opcode) | |
1927 { | |
1928 Lisp_Object val; | |
1929 | |
1930 case Bvarref+7: READ_OPERAND_2; goto do_varref; | |
1931 case Bvarref+6: READ_OPERAND_1; goto do_varref; | |
1932 case Bvarref: case Bvarref+1: case Bvarref+2: | |
1933 case Bvarref+3: case Bvarref+4: case Bvarref+5: | |
1934 arg = opcode - Bvarref; | |
1935 do_varref: | |
1936 check_constants_index (arg, constants); | |
1937 val = XVECTOR_DATA (constants) [arg]; | |
1938 if (!SYMBOLP (val)) | |
563 | 1939 invalid_byte_code ("variable reference to non-symbol", val); |
428 | 1940 if (EQ (val, Qnil) || EQ (val, Qt) || (SYMBOL_IS_KEYWORD (val))) |
563 | 1941 invalid_byte_code ("variable reference to constant symbol", val); |
428 | 1942 WRITE_NARGS (Bvarref); |
1943 break; | |
1944 | |
1945 case Bvarset+7: READ_OPERAND_2; goto do_varset; | |
1946 case Bvarset+6: READ_OPERAND_1; goto do_varset; | |
1947 case Bvarset: case Bvarset+1: case Bvarset+2: | |
1948 case Bvarset+3: case Bvarset+4: case Bvarset+5: | |
1949 arg = opcode - Bvarset; | |
1950 do_varset: | |
1951 check_constants_index (arg, constants); | |
1952 val = XVECTOR_DATA (constants) [arg]; | |
1953 if (!SYMBOLP (val)) | |
563 | 1954 wtaerror ("attempt to set non-symbol", val); |
428 | 1955 if (EQ (val, Qnil) || EQ (val, Qt)) |
563 | 1956 signal_error (Qsetting_constant, 0, val); |
428 | 1957 /* Ignore assignments to keywords by converting to Bdiscard. |
1958 For backward compatibility only - we'd like to make this an error. */ | |
1959 if (SYMBOL_IS_KEYWORD (val)) | |
1960 REWRITE_OPCODE (Bdiscard); | |
1961 else | |
1962 WRITE_NARGS (Bvarset); | |
1963 break; | |
1964 | |
1965 case Bvarbind+7: READ_OPERAND_2; goto do_varbind; | |
1966 case Bvarbind+6: READ_OPERAND_1; goto do_varbind; | |
1967 case Bvarbind: case Bvarbind+1: case Bvarbind+2: | |
1968 case Bvarbind+3: case Bvarbind+4: case Bvarbind+5: | |
1969 arg = opcode - Bvarbind; | |
1970 do_varbind: | |
1971 (*varbind_count)++; | |
1972 check_constants_index (arg, constants); | |
1973 val = XVECTOR_DATA (constants) [arg]; | |
1974 if (!SYMBOLP (val)) | |
563 | 1975 wtaerror ("attempt to let-bind non-symbol", val); |
428 | 1976 if (EQ (val, Qnil) || EQ (val, Qt) || (SYMBOL_IS_KEYWORD (val))) |
563 | 1977 signal_error (Qsetting_constant, |
1978 "attempt to let-bind constant symbol", val); | |
428 | 1979 WRITE_NARGS (Bvarbind); |
1980 break; | |
1981 | |
1982 case Bcall+7: READ_OPERAND_2; goto do_call; | |
1983 case Bcall+6: READ_OPERAND_1; goto do_call; | |
1984 case Bcall: case Bcall+1: case Bcall+2: | |
1985 case Bcall+3: case Bcall+4: case Bcall+5: | |
1986 arg = opcode - Bcall; | |
1987 do_call: | |
1988 WRITE_NARGS (Bcall); | |
1989 break; | |
1990 | |
1991 case Bunbind+7: READ_OPERAND_2; goto do_unbind; | |
1992 case Bunbind+6: READ_OPERAND_1; goto do_unbind; | |
1993 case Bunbind: case Bunbind+1: case Bunbind+2: | |
1994 case Bunbind+3: case Bunbind+4: case Bunbind+5: | |
1995 arg = opcode - Bunbind; | |
1996 do_unbind: | |
1997 WRITE_NARGS (Bunbind); | |
1998 break; | |
1999 | |
2000 case Bgoto: | |
2001 case Bgotoifnil: | |
2002 case Bgotoifnonnil: | |
2003 case Bgotoifnilelsepop: | |
2004 case Bgotoifnonnilelsepop: | |
2005 READ_OPERAND_2; | |
2006 /* Make program_ptr-relative */ | |
2007 arg += icounts - (icounts_ptr - argsize); | |
2008 goto do_jump; | |
2009 | |
2010 case BRgoto: | |
2011 case BRgotoifnil: | |
2012 case BRgotoifnonnil: | |
2013 case BRgotoifnilelsepop: | |
2014 case BRgotoifnonnilelsepop: | |
2015 READ_OPERAND_1; | |
2016 /* Make program_ptr-relative */ | |
2017 arg -= 127; | |
2018 do_jump: | |
2019 /* Record program-relative goto addresses in `jumps' table */ | |
2020 jumps_ptr->from = icounts_ptr - icounts - argsize; | |
2021 jumps_ptr->to = jumps_ptr->from + arg; | |
2022 jumps_ptr++; | |
2023 if (arg >= -1 && arg <= argsize) | |
563 | 2024 invalid_byte_code ("goto instruction is its own target", Qunbound); |
428 | 2025 if (arg <= SCHAR_MIN || |
2026 arg > SCHAR_MAX) | |
2027 { | |
2028 if (argsize == 1) | |
2029 REWRITE_OPCODE (opcode + Bgoto - BRgoto); | |
2030 WRITE_INT16 (arg, program_ptr); | |
2031 } | |
2032 else | |
2033 { | |
2034 if (argsize == 2) | |
2035 REWRITE_OPCODE (opcode + BRgoto - Bgoto); | |
2036 WRITE_INT8 (arg, program_ptr); | |
2037 } | |
2038 break; | |
2039 | |
2040 case Bconstant2: | |
2041 READ_OPERAND_2; | |
2042 WRITE_CONSTANT; | |
2043 break; | |
2044 | |
2045 case BlistN: | |
2046 case BconcatN: | |
2047 case BinsertN: | |
2048 READ_OPERAND_1; | |
2049 WRITE_INT8 (arg, program_ptr); | |
2050 break; | |
2051 | |
2052 default: | |
2053 if (opcode < Bconstant) | |
2054 check_opcode (opcode); | |
2055 else | |
2056 { | |
2057 arg = opcode - Bconstant; | |
2058 WRITE_CONSTANT; | |
2059 } | |
2060 break; | |
2061 } | |
2062 } | |
2063 | |
2064 /* Fix up jumps table to refer to NEW offsets. */ | |
2065 { | |
2066 struct jump *j; | |
2067 for (j = jumps; j < jumps_ptr; j++) | |
2068 { | |
2069 #ifdef ERROR_CHECK_BYTE_CODE | |
2070 assert (j->from < icounts_ptr - icounts); | |
2071 assert (j->to < icounts_ptr - icounts); | |
2072 #endif | |
2073 j->from = icounts[j->from]; | |
2074 j->to = icounts[j->to]; | |
2075 #ifdef ERROR_CHECK_BYTE_CODE | |
2076 assert (j->from < program_ptr - program); | |
2077 assert (j->to < program_ptr - program); | |
2078 check_opcode ((Opcode) (program[j->from-1])); | |
2079 #endif | |
2080 check_opcode ((Opcode) (program[j->to])); | |
2081 } | |
2082 } | |
2083 | |
2084 /* Fixup jumps in byte-code until no more fixups needed */ | |
2085 { | |
2086 int more_fixups_needed = 1; | |
2087 | |
2088 while (more_fixups_needed) | |
2089 { | |
2090 struct jump *j; | |
2091 more_fixups_needed = 0; | |
2092 for (j = jumps; j < jumps_ptr; j++) | |
2093 { | |
2094 int from = j->from; | |
2095 int to = j->to; | |
2096 int jump = to - from; | |
2097 Opbyte *p = program + from; | |
2098 Opcode opcode = (Opcode) p[-1]; | |
2099 if (!more_fixups_needed) | |
2100 check_opcode ((Opcode) p[jump]); | |
2101 assert (to >= 0 && program + to < program_ptr); | |
2102 switch (opcode) | |
2103 { | |
2104 case Bgoto: | |
2105 case Bgotoifnil: | |
2106 case Bgotoifnonnil: | |
2107 case Bgotoifnilelsepop: | |
2108 case Bgotoifnonnilelsepop: | |
2109 WRITE_INT16 (jump, p); | |
2110 break; | |
2111 | |
2112 case BRgoto: | |
2113 case BRgotoifnil: | |
2114 case BRgotoifnonnil: | |
2115 case BRgotoifnilelsepop: | |
2116 case BRgotoifnonnilelsepop: | |
2117 if (jump > SCHAR_MIN && | |
2118 jump <= SCHAR_MAX) | |
2119 { | |
2120 WRITE_INT8 (jump, p); | |
2121 } | |
2122 else /* barf */ | |
2123 { | |
2124 struct jump *jj; | |
2125 for (jj = jumps; jj < jumps_ptr; jj++) | |
2126 { | |
2127 assert (jj->from < program_ptr - program); | |
2128 assert (jj->to < program_ptr - program); | |
2129 if (jj->from > from) jj->from++; | |
2130 if (jj->to > from) jj->to++; | |
2131 } | |
2132 p[-1] += Bgoto - BRgoto; | |
2133 more_fixups_needed = 1; | |
2134 memmove (p+1, p, program_ptr++ - p); | |
2135 WRITE_INT16 (jump, p); | |
2136 } | |
2137 break; | |
2138 | |
2139 default: | |
2500 | 2140 ABORT(); |
428 | 2141 break; |
2142 } | |
2143 } | |
2144 } | |
2145 } | |
2146 | |
2147 /* *program_ptr++ = 0; */ | |
2148 *program_length = program_ptr - program; | |
2149 } | |
2150 | |
2151 /* Optimize the byte code and store the optimized program, only | |
2152 understood by bytecode.c, in an opaque object in the | |
2153 instructions slot of the Compiled_Function object. */ | |
2154 void | |
2155 optimize_compiled_function (Lisp_Object compiled_function) | |
2156 { | |
2157 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (compiled_function); | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2158 Elemcount program_length; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2159 Elemcount varbind_count; |
428 | 2160 Opbyte *program; |
2161 | |
1737 | 2162 { |
2163 int minargs = 0, maxargs = 0, totalargs = 0; | |
2164 int optional_p = 0, rest_p = 0, i = 0; | |
2165 { | |
2166 LIST_LOOP_2 (arg, f->arglist) | |
2167 { | |
2168 if (EQ (arg, Qand_optional)) | |
2169 optional_p = 1; | |
2170 else if (EQ (arg, Qand_rest)) | |
2171 rest_p = 1; | |
2172 else | |
2173 { | |
2174 if (rest_p) | |
2175 { | |
2176 maxargs = MANY; | |
2177 totalargs++; | |
2178 break; | |
2179 } | |
2180 if (!optional_p) | |
2181 minargs++; | |
2182 maxargs++; | |
2183 totalargs++; | |
2184 } | |
2185 } | |
2186 } | |
2187 | |
2188 if (totalargs) | |
3092 | 2189 #ifdef NEW_GC |
2190 f->arguments = make_compiled_function_args (totalargs); | |
2191 #else /* not NEW_GC */ | |
1737 | 2192 f->args = xnew_array (Lisp_Object, totalargs); |
3092 | 2193 #endif /* not NEW_GC */ |
1737 | 2194 |
2195 { | |
2196 LIST_LOOP_2 (arg, f->arglist) | |
2197 { | |
2198 if (!EQ (arg, Qand_optional) && !EQ (arg, Qand_rest)) | |
3092 | 2199 #ifdef NEW_GC |
2200 XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i++] = arg; | |
2201 #else /* not NEW_GC */ | |
1737 | 2202 f->args[i++] = arg; |
3092 | 2203 #endif /* not NEW_GC */ |
1737 | 2204 } |
2205 } | |
2206 | |
2207 f->max_args = maxargs; | |
2208 f->min_args = minargs; | |
2209 f->args_in_array = totalargs; | |
2210 } | |
2211 | |
428 | 2212 /* If we have not actually read the bytecode string |
2213 and constants vector yet, fetch them from the file. */ | |
2214 if (CONSP (f->instructions)) | |
2215 Ffetch_bytecode (compiled_function); | |
2216 | |
2217 if (STRINGP (f->instructions)) | |
2218 { | |
826 | 2219 /* XSTRING_LENGTH() is more efficient than string_char_length(), |
428 | 2220 which would be slightly more `proper' */ |
2221 program = alloca_array (Opbyte, 1 + 2 * XSTRING_LENGTH (f->instructions)); | |
2222 optimize_byte_code (f->instructions, f->constants, | |
2223 program, &program_length, &varbind_count); | |
2500 | 2224 f->specpdl_depth = (unsigned short) (XINT (Flength (f->arglist)) + |
2225 varbind_count); | |
428 | 2226 f->instructions = |
440 | 2227 make_opaque (program, program_length * sizeof (Opbyte)); |
428 | 2228 } |
2229 | |
2230 assert (OPAQUEP (f->instructions)); | |
2231 } | |
2232 | |
2233 /************************************************************************/ | |
2234 /* The compiled-function object type */ | |
2235 /************************************************************************/ | |
3092 | 2236 |
428 | 2237 static void |
2238 print_compiled_function (Lisp_Object obj, Lisp_Object printcharfun, | |
2239 int escapeflag) | |
2240 { | |
2241 /* This function can GC */ | |
2242 Lisp_Compiled_Function *f = | |
2243 XCOMPILED_FUNCTION (obj); /* GC doesn't relocate */ | |
2244 int docp = f->flags.documentationp; | |
2245 int intp = f->flags.interactivep; | |
2246 struct gcpro gcpro1, gcpro2; | |
2247 GCPRO2 (obj, printcharfun); | |
2248 | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4775
diff
changeset
|
2249 write_ascstring (printcharfun, print_readably ? "#[" : "#<compiled-function "); |
428 | 2250 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK |
2251 if (!print_readably) | |
2252 { | |
2253 Lisp_Object ann = compiled_function_annotation (f); | |
2254 if (!NILP (ann)) | |
800 | 2255 write_fmt_string_lisp (printcharfun, "(from %S) ", 1, ann); |
428 | 2256 } |
2257 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */ | |
2258 /* COMPILED_ARGLIST = 0 */ | |
2259 print_internal (compiled_function_arglist (f), printcharfun, escapeflag); | |
2260 | |
2261 /* COMPILED_INSTRUCTIONS = 1 */ | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4775
diff
changeset
|
2262 write_ascstring (printcharfun, " "); |
428 | 2263 { |
2264 struct gcpro ngcpro1; | |
2265 Lisp_Object instructions = compiled_function_instructions (f); | |
2266 NGCPRO1 (instructions); | |
2267 if (STRINGP (instructions) && !print_readably) | |
2268 { | |
2269 /* We don't usually want to see that junk in the bytecode. */ | |
800 | 2270 write_fmt_string (printcharfun, "\"...(%ld)\"", |
826 | 2271 (long) string_char_length (instructions)); |
428 | 2272 } |
2273 else | |
2274 print_internal (instructions, printcharfun, escapeflag); | |
2275 NUNGCPRO; | |
2276 } | |
2277 | |
2278 /* COMPILED_CONSTANTS = 2 */ | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4775
diff
changeset
|
2279 write_ascstring (printcharfun, " "); |
428 | 2280 print_internal (compiled_function_constants (f), printcharfun, escapeflag); |
2281 | |
2282 /* COMPILED_STACK_DEPTH = 3 */ | |
800 | 2283 write_fmt_string (printcharfun, " %d", compiled_function_stack_depth (f)); |
428 | 2284 |
2285 /* COMPILED_DOC_STRING = 4 */ | |
2286 if (docp || intp) | |
2287 { | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4775
diff
changeset
|
2288 write_ascstring (printcharfun, " "); |
428 | 2289 print_internal (compiled_function_documentation (f), printcharfun, |
2290 escapeflag); | |
2291 } | |
2292 | |
2293 /* COMPILED_INTERACTIVE = 5 */ | |
2294 if (intp) | |
2295 { | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4775
diff
changeset
|
2296 write_ascstring (printcharfun, " "); |
428 | 2297 print_internal (compiled_function_interactive (f), printcharfun, |
2298 escapeflag); | |
2299 } | |
2300 | |
2301 UNGCPRO; | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4775
diff
changeset
|
2302 write_ascstring (printcharfun, print_readably ? "]" : ">"); |
428 | 2303 } |
2304 | |
2305 | |
2306 static Lisp_Object | |
2307 mark_compiled_function (Lisp_Object obj) | |
2308 { | |
2309 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (obj); | |
814 | 2310 int i; |
428 | 2311 |
2312 mark_object (f->instructions); | |
2313 mark_object (f->arglist); | |
2314 mark_object (f->doc_and_interactive); | |
2315 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK | |
2316 mark_object (f->annotated); | |
2317 #endif | |
814 | 2318 for (i = 0; i < f->args_in_array; i++) |
3092 | 2319 #ifdef NEW_GC |
2320 mark_object (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i]); | |
2321 #else /* not NEW_GC */ | |
814 | 2322 mark_object (f->args[i]); |
3092 | 2323 #endif /* not NEW_GC */ |
814 | 2324 |
428 | 2325 /* tail-recurse on constants */ |
2326 return f->constants; | |
2327 } | |
2328 | |
2329 static int | |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4885
diff
changeset
|
2330 compiled_function_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4885
diff
changeset
|
2331 int UNUSED (foldcase)) |
428 | 2332 { |
2333 Lisp_Compiled_Function *f1 = XCOMPILED_FUNCTION (obj1); | |
2334 Lisp_Compiled_Function *f2 = XCOMPILED_FUNCTION (obj2); | |
2335 return | |
2336 (f1->flags.documentationp == f2->flags.documentationp && | |
2337 f1->flags.interactivep == f2->flags.interactivep && | |
2338 f1->flags.domainp == f2->flags.domainp && /* I18N3 */ | |
2339 internal_equal (compiled_function_instructions (f1), | |
2340 compiled_function_instructions (f2), depth + 1) && | |
2341 internal_equal (f1->constants, f2->constants, depth + 1) && | |
2342 internal_equal (f1->arglist, f2->arglist, depth + 1) && | |
2343 internal_equal (f1->doc_and_interactive, | |
2344 f2->doc_and_interactive, depth + 1)); | |
2345 } | |
2346 | |
665 | 2347 static Hashcode |
428 | 2348 compiled_function_hash (Lisp_Object obj, int depth) |
2349 { | |
2350 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (obj); | |
2351 return HASH3 ((f->flags.documentationp << 2) + | |
2352 (f->flags.interactivep << 1) + | |
2353 f->flags.domainp, | |
2354 internal_hash (f->instructions, depth + 1), | |
2355 internal_hash (f->constants, depth + 1)); | |
2356 } | |
2357 | |
1204 | 2358 static const struct memory_description compiled_function_description[] = { |
814 | 2359 { XD_INT, offsetof (Lisp_Compiled_Function, args_in_array) }, |
3092 | 2360 #ifdef NEW_GC |
2361 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, arguments) }, | |
2362 #else /* not NEW_GC */ | |
2363 { XD_BLOCK_PTR, offsetof (Lisp_Compiled_Function, args), | |
2551 | 2364 XD_INDIRECT (0, 0), { &lisp_object_description } }, |
3092 | 2365 #endif /* not NEW_GC */ |
440 | 2366 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, instructions) }, |
2367 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, constants) }, | |
2368 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, arglist) }, | |
2369 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, doc_and_interactive) }, | |
428 | 2370 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK |
440 | 2371 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, annotated) }, |
428 | 2372 #endif |
2373 { XD_END } | |
2374 }; | |
2375 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2376 DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT ("compiled-function", compiled_function, |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2377 mark_compiled_function, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2378 print_compiled_function, 0, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2379 compiled_function_equal, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2380 compiled_function_hash, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2381 compiled_function_description, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
2382 Lisp_Compiled_Function); |
3092 | 2383 |
428 | 2384 |
2385 DEFUN ("compiled-function-p", Fcompiled_function_p, 1, 1, 0, /* | |
2386 Return t if OBJECT is a byte-compiled function object. | |
2387 */ | |
2388 (object)) | |
2389 { | |
2390 return COMPILED_FUNCTIONP (object) ? Qt : Qnil; | |
2391 } | |
2392 | |
2393 /************************************************************************/ | |
2394 /* compiled-function object accessor functions */ | |
2395 /************************************************************************/ | |
2396 | |
2397 Lisp_Object | |
2398 compiled_function_arglist (Lisp_Compiled_Function *f) | |
2399 { | |
2400 return f->arglist; | |
2401 } | |
2402 | |
2403 Lisp_Object | |
2404 compiled_function_instructions (Lisp_Compiled_Function *f) | |
2405 { | |
2406 if (! OPAQUEP (f->instructions)) | |
2407 return f->instructions; | |
2408 | |
2409 { | |
2410 /* Invert action performed by optimize_byte_code() */ | |
2411 Lisp_Opaque *opaque = XOPAQUE (f->instructions); | |
2412 | |
867 | 2413 Ibyte * const buffer = |
2367 | 2414 alloca_ibytes (OPAQUE_SIZE (opaque) * MAX_ICHAR_LEN); |
867 | 2415 Ibyte *bp = buffer; |
428 | 2416 |
442 | 2417 const Opbyte * const program = (const Opbyte *) OPAQUE_DATA (opaque); |
2418 const Opbyte *program_ptr = program; | |
2419 const Opbyte * const program_end = program_ptr + OPAQUE_SIZE (opaque); | |
428 | 2420 |
2421 while (program_ptr < program_end) | |
2422 { | |
2423 Opcode opcode = (Opcode) READ_UINT_1; | |
867 | 2424 bp += set_itext_ichar (bp, opcode); |
428 | 2425 switch (opcode) |
2426 { | |
2427 case Bvarref+7: | |
2428 case Bvarset+7: | |
2429 case Bvarbind+7: | |
2430 case Bcall+7: | |
2431 case Bunbind+7: | |
2432 case Bconstant2: | |
867 | 2433 bp += set_itext_ichar (bp, READ_UINT_1); |
2434 bp += set_itext_ichar (bp, READ_UINT_1); | |
428 | 2435 break; |
2436 | |
2437 case Bvarref+6: | |
2438 case Bvarset+6: | |
2439 case Bvarbind+6: | |
2440 case Bcall+6: | |
2441 case Bunbind+6: | |
2442 case BlistN: | |
2443 case BconcatN: | |
2444 case BinsertN: | |
867 | 2445 bp += set_itext_ichar (bp, READ_UINT_1); |
428 | 2446 break; |
2447 | |
2448 case Bgoto: | |
2449 case Bgotoifnil: | |
2450 case Bgotoifnonnil: | |
2451 case Bgotoifnilelsepop: | |
2452 case Bgotoifnonnilelsepop: | |
2453 { | |
2454 int jump = READ_INT_2; | |
2455 Opbyte buf2[2]; | |
2456 Opbyte *buf2p = buf2; | |
2457 /* Convert back to program-relative address */ | |
2458 WRITE_INT16 (jump + (program_ptr - 2 - program), buf2p); | |
867 | 2459 bp += set_itext_ichar (bp, buf2[0]); |
2460 bp += set_itext_ichar (bp, buf2[1]); | |
428 | 2461 break; |
2462 } | |
2463 | |
2464 case BRgoto: | |
2465 case BRgotoifnil: | |
2466 case BRgotoifnonnil: | |
2467 case BRgotoifnilelsepop: | |
2468 case BRgotoifnonnilelsepop: | |
867 | 2469 bp += set_itext_ichar (bp, READ_INT_1 + 127); |
428 | 2470 break; |
2471 | |
2472 default: | |
2473 break; | |
2474 } | |
2475 } | |
2476 return make_string (buffer, bp - buffer); | |
2477 } | |
2478 } | |
2479 | |
2480 Lisp_Object | |
2481 compiled_function_constants (Lisp_Compiled_Function *f) | |
2482 { | |
2483 return f->constants; | |
2484 } | |
2485 | |
2486 int | |
2487 compiled_function_stack_depth (Lisp_Compiled_Function *f) | |
2488 { | |
2489 return f->stack_depth; | |
2490 } | |
2491 | |
2492 /* The compiled_function->doc_and_interactive slot uses the minimal | |
2493 number of conses, based on compiled_function->flags; it may take | |
2494 any of the following forms: | |
2495 | |
2496 doc | |
2497 interactive | |
2498 domain | |
2499 (doc . interactive) | |
2500 (doc . domain) | |
2501 (interactive . domain) | |
2502 (doc . (interactive . domain)) | |
2503 */ | |
2504 | |
2505 /* Caller must check flags.interactivep first */ | |
2506 Lisp_Object | |
2507 compiled_function_interactive (Lisp_Compiled_Function *f) | |
2508 { | |
2509 assert (f->flags.interactivep); | |
2510 if (f->flags.documentationp && f->flags.domainp) | |
2511 return XCAR (XCDR (f->doc_and_interactive)); | |
2512 else if (f->flags.documentationp) | |
2513 return XCDR (f->doc_and_interactive); | |
2514 else if (f->flags.domainp) | |
2515 return XCAR (f->doc_and_interactive); | |
2516 else | |
2517 return f->doc_and_interactive; | |
2518 } | |
2519 | |
2520 /* Caller need not check flags.documentationp first */ | |
2521 Lisp_Object | |
2522 compiled_function_documentation (Lisp_Compiled_Function *f) | |
2523 { | |
2524 if (! f->flags.documentationp) | |
2525 return Qnil; | |
2526 else if (f->flags.interactivep && f->flags.domainp) | |
2527 return XCAR (f->doc_and_interactive); | |
2528 else if (f->flags.interactivep) | |
2529 return XCAR (f->doc_and_interactive); | |
2530 else if (f->flags.domainp) | |
2531 return XCAR (f->doc_and_interactive); | |
2532 else | |
2533 return f->doc_and_interactive; | |
2534 } | |
2535 | |
2536 /* Caller need not check flags.domainp first */ | |
2537 Lisp_Object | |
2538 compiled_function_domain (Lisp_Compiled_Function *f) | |
2539 { | |
2540 if (! f->flags.domainp) | |
2541 return Qnil; | |
2542 else if (f->flags.documentationp && f->flags.interactivep) | |
2543 return XCDR (XCDR (f->doc_and_interactive)); | |
2544 else if (f->flags.documentationp) | |
2545 return XCDR (f->doc_and_interactive); | |
2546 else if (f->flags.interactivep) | |
2547 return XCDR (f->doc_and_interactive); | |
2548 else | |
2549 return f->doc_and_interactive; | |
2550 } | |
2551 | |
2552 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK | |
2553 | |
2554 Lisp_Object | |
2555 compiled_function_annotation (Lisp_Compiled_Function *f) | |
2556 { | |
2557 return f->annotated; | |
2558 } | |
2559 | |
2560 #endif | |
2561 | |
2562 /* used only by Snarf-documentation; there must be doc already. */ | |
2563 void | |
2564 set_compiled_function_documentation (Lisp_Compiled_Function *f, | |
2565 Lisp_Object new_doc) | |
2566 { | |
2567 assert (f->flags.documentationp); | |
2568 assert (INTP (new_doc) || STRINGP (new_doc)); | |
2569 | |
2570 if (f->flags.interactivep && f->flags.domainp) | |
2571 XCAR (f->doc_and_interactive) = new_doc; | |
2572 else if (f->flags.interactivep) | |
2573 XCAR (f->doc_and_interactive) = new_doc; | |
2574 else if (f->flags.domainp) | |
2575 XCAR (f->doc_and_interactive) = new_doc; | |
2576 else | |
2577 f->doc_and_interactive = new_doc; | |
2578 } | |
2579 | |
2580 | |
2581 DEFUN ("compiled-function-arglist", Fcompiled_function_arglist, 1, 1, 0, /* | |
2582 Return the argument list of the compiled-function object FUNCTION. | |
2583 */ | |
2584 (function)) | |
2585 { | |
2586 CHECK_COMPILED_FUNCTION (function); | |
2587 return compiled_function_arglist (XCOMPILED_FUNCTION (function)); | |
2588 } | |
2589 | |
2590 DEFUN ("compiled-function-instructions", Fcompiled_function_instructions, 1, 1, 0, /* | |
2591 Return the byte-opcode string of the compiled-function object FUNCTION. | |
2592 */ | |
2593 (function)) | |
2594 { | |
2595 CHECK_COMPILED_FUNCTION (function); | |
2596 return compiled_function_instructions (XCOMPILED_FUNCTION (function)); | |
2597 } | |
2598 | |
2599 DEFUN ("compiled-function-constants", Fcompiled_function_constants, 1, 1, 0, /* | |
2600 Return the constants vector of the compiled-function object FUNCTION. | |
2601 */ | |
2602 (function)) | |
2603 { | |
2604 CHECK_COMPILED_FUNCTION (function); | |
2605 return compiled_function_constants (XCOMPILED_FUNCTION (function)); | |
2606 } | |
2607 | |
2608 DEFUN ("compiled-function-stack-depth", Fcompiled_function_stack_depth, 1, 1, 0, /* | |
444 | 2609 Return the maximum stack depth of the compiled-function object FUNCTION. |
428 | 2610 */ |
2611 (function)) | |
2612 { | |
2613 CHECK_COMPILED_FUNCTION (function); | |
2614 return make_int (compiled_function_stack_depth (XCOMPILED_FUNCTION (function))); | |
2615 } | |
2616 | |
2617 DEFUN ("compiled-function-doc-string", Fcompiled_function_doc_string, 1, 1, 0, /* | |
2618 Return the doc string of the compiled-function object FUNCTION, if available. | |
2619 Functions that had their doc strings snarfed into the DOC file will have | |
2620 an integer returned instead of a string. | |
2621 */ | |
2622 (function)) | |
2623 { | |
2624 CHECK_COMPILED_FUNCTION (function); | |
2625 return compiled_function_documentation (XCOMPILED_FUNCTION (function)); | |
2626 } | |
2627 | |
2628 DEFUN ("compiled-function-interactive", Fcompiled_function_interactive, 1, 1, 0, /* | |
2629 Return the interactive spec of the compiled-function object FUNCTION, or nil. | |
2630 If non-nil, the return value will be a list whose first element is | |
2631 `interactive' and whose second element is the interactive spec. | |
2632 */ | |
2633 (function)) | |
2634 { | |
2635 CHECK_COMPILED_FUNCTION (function); | |
2636 return XCOMPILED_FUNCTION (function)->flags.interactivep | |
2637 ? list2 (Qinteractive, | |
2638 compiled_function_interactive (XCOMPILED_FUNCTION (function))) | |
2639 : Qnil; | |
2640 } | |
2641 | |
2642 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK | |
2643 | |
826 | 2644 DEFUN ("compiled-function-annotation", Fcompiled_function_annotation, 1, 1, 0, /* |
428 | 2645 Return the annotation of the compiled-function object FUNCTION, or nil. |
2646 The annotation is a piece of information indicating where this | |
2647 compiled-function object came from. Generally this will be | |
2648 a symbol naming a function; or a string naming a file, if the | |
2649 compiled-function object was not defined in a function; or nil, | |
2650 if the compiled-function object was not created as a result of | |
2651 a `load'. | |
2652 */ | |
2653 (function)) | |
2654 { | |
2655 CHECK_COMPILED_FUNCTION (function); | |
2656 return compiled_function_annotation (XCOMPILED_FUNCTION (function)); | |
2657 } | |
2658 | |
2659 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */ | |
2660 | |
2661 DEFUN ("compiled-function-domain", Fcompiled_function_domain, 1, 1, 0, /* | |
2662 Return the domain of the compiled-function object FUNCTION, or nil. | |
2663 This is only meaningful if I18N3 was enabled when emacs was compiled. | |
2664 */ | |
2665 (function)) | |
2666 { | |
2667 CHECK_COMPILED_FUNCTION (function); | |
2668 return XCOMPILED_FUNCTION (function)->flags.domainp | |
2669 ? compiled_function_domain (XCOMPILED_FUNCTION (function)) | |
2670 : Qnil; | |
2671 } | |
2672 | |
2673 | |
2674 | |
2675 DEFUN ("fetch-bytecode", Ffetch_bytecode, 1, 1, 0, /* | |
2676 If the byte code for compiled function FUNCTION is lazy-loaded, fetch it now. | |
2677 */ | |
2678 (function)) | |
2679 { | |
2680 Lisp_Compiled_Function *f; | |
2681 CHECK_COMPILED_FUNCTION (function); | |
2682 f = XCOMPILED_FUNCTION (function); | |
2683 | |
2684 if (OPAQUEP (f->instructions) || STRINGP (f->instructions)) | |
2685 return function; | |
2686 | |
2687 if (CONSP (f->instructions)) | |
2688 { | |
2689 Lisp_Object tem = read_doc_string (f->instructions); | |
2690 if (!CONSP (tem)) | |
563 | 2691 signal_error (Qinvalid_byte_code, |
2692 "Invalid lazy-loaded byte code", tem); | |
428 | 2693 /* v18 or v19 bytecode file. Need to Ebolify. */ |
2694 if (f->flags.ebolified && VECTORP (XCDR (tem))) | |
2695 ebolify_bytecode_constants (XCDR (tem)); | |
2696 f->instructions = XCAR (tem); | |
2697 f->constants = XCDR (tem); | |
2698 return function; | |
2699 } | |
2500 | 2700 ABORT (); |
801 | 2701 return Qnil; /* not (usually) reached */ |
428 | 2702 } |
2703 | |
2704 DEFUN ("optimize-compiled-function", Foptimize_compiled_function, 1, 1, 0, /* | |
2705 Convert compiled function FUNCTION into an optimized internal form. | |
2706 */ | |
2707 (function)) | |
2708 { | |
2709 Lisp_Compiled_Function *f; | |
2710 CHECK_COMPILED_FUNCTION (function); | |
2711 f = XCOMPILED_FUNCTION (function); | |
2712 | |
2713 if (OPAQUEP (f->instructions)) /* Already optimized? */ | |
2714 return Qnil; | |
2715 | |
2716 optimize_compiled_function (function); | |
2717 return Qnil; | |
2718 } | |
2719 | |
2720 DEFUN ("byte-code", Fbyte_code, 3, 3, 0, /* | |
2721 Function used internally in byte-compiled code. | |
2722 First argument INSTRUCTIONS is a string of byte code. | |
2723 Second argument CONSTANTS is a vector of constants. | |
2724 Third argument STACK-DEPTH is the maximum stack depth used in this function. | |
2725 If STACK-DEPTH is incorrect, Emacs may crash. | |
2726 */ | |
2727 (instructions, constants, stack_depth)) | |
2728 { | |
2729 /* This function can GC */ | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2730 Elemcount varbind_count; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2731 Elemcount program_length; |
428 | 2732 Opbyte *program; |
2733 | |
2734 CHECK_STRING (instructions); | |
2735 CHECK_VECTOR (constants); | |
2736 CHECK_NATNUM (stack_depth); | |
2737 | |
2738 /* Optimize the `instructions' string, just like when executing a | |
2739 regular compiled function, but don't save it for later since this is | |
2740 likely to only be executed once. */ | |
2741 program = alloca_array (Opbyte, 1 + 2 * XSTRING_LENGTH (instructions)); | |
2742 optimize_byte_code (instructions, constants, program, | |
2743 &program_length, &varbind_count); | |
2744 SPECPDL_RESERVE (varbind_count); | |
2745 return execute_optimized_program (program, | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2746 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2747 program_length, |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2748 #endif |
428 | 2749 XINT (stack_depth), |
2750 XVECTOR_DATA (constants)); | |
2751 } | |
2752 | |
2753 | |
2754 void | |
2755 syms_of_bytecode (void) | |
2756 { | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
2720
diff
changeset
|
2757 INIT_LISP_OBJECT (compiled_function); |
3092 | 2758 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
2759 INIT_LISP_OBJECT (compiled_function_args); |
3092 | 2760 #endif /* NEW_GC */ |
442 | 2761 |
2762 DEFERROR_STANDARD (Qinvalid_byte_code, Qinvalid_state); | |
563 | 2763 DEFSYMBOL (Qbyte_code); |
2764 DEFSYMBOL_MULTIWORD_PREDICATE (Qcompiled_functionp); | |
428 | 2765 |
2766 DEFSUBR (Fbyte_code); | |
2767 DEFSUBR (Ffetch_bytecode); | |
2768 DEFSUBR (Foptimize_compiled_function); | |
2769 | |
2770 DEFSUBR (Fcompiled_function_p); | |
2771 DEFSUBR (Fcompiled_function_instructions); | |
2772 DEFSUBR (Fcompiled_function_constants); | |
2773 DEFSUBR (Fcompiled_function_stack_depth); | |
2774 DEFSUBR (Fcompiled_function_arglist); | |
2775 DEFSUBR (Fcompiled_function_interactive); | |
2776 DEFSUBR (Fcompiled_function_doc_string); | |
2777 DEFSUBR (Fcompiled_function_domain); | |
2778 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK | |
2779 DEFSUBR (Fcompiled_function_annotation); | |
2780 #endif | |
2781 | |
2782 #ifdef BYTE_CODE_METER | |
563 | 2783 DEFSYMBOL (Qbyte_code_meter); |
428 | 2784 #endif |
2785 } | |
2786 | |
2787 void | |
2788 vars_of_bytecode (void) | |
2789 { | |
2790 #ifdef BYTE_CODE_METER | |
2791 DEFVAR_LISP ("byte-code-meter", &Vbyte_code_meter /* | |
2792 A vector of vectors which holds a histogram of byte code usage. | |
2793 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte | |
2794 opcode CODE has been executed. | |
2795 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0, | |
2796 indicates how many times the byte opcodes CODE1 and CODE2 have been | |
2797 executed in succession. | |
2798 */ ); | |
2799 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on /* | |
2800 If non-nil, keep profiling information on byte code usage. | |
2801 The variable `byte-code-meter' indicates how often each byte opcode is used. | |
2802 If a symbol has a property named `byte-code-meter' whose value is an | |
2803 integer, it is incremented each time that symbol's function is called. | |
2804 */ ); | |
2805 | |
2806 byte_metering_on = 0; | |
2807 Vbyte_code_meter = make_vector (256, Qzero); | |
2808 { | |
2809 int i = 256; | |
2810 while (i--) | |
2811 XVECTOR_DATA (Vbyte_code_meter)[i] = make_vector (256, Qzero); | |
2812 } | |
2813 #endif /* BYTE_CODE_METER */ | |
2814 } | |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2815 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2816 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2817 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2818 /* Initialize the opcodes in the table that correspond to a base opcode |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2819 plus an offset (except for Bconstant). */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2820 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2821 static void |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2822 init_opcode_table_multi_op (Opcode op) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2823 { |
4970 | 2824 const Ascbyte *basename = opcode_name_table[op]; |
4921
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2825 Ascbyte temp[300]; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2826 int i; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2827 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2828 for (i = 1; i < 7; i++) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2829 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2830 assert (!opcode_name_table[op + i]); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2831 sprintf (temp, "%s+%d", basename, i); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2832 opcode_name_table[op + i] = xstrdup (temp); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2833 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2834 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2835 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2836 #endif /* ERROR_CHECK_BYTE_CODE */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2837 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2838 void |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2839 reinit_vars_of_bytecode (void) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2840 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2841 #ifdef ERROR_CHECK_BYTE_CODE |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2842 int i; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2843 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2844 #define OPCODE(sym, val) opcode_name_table[val] = xstrdup (#sym); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2845 #include "bytecode-ops.h" |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2846 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2847 for (i = 0; i < countof (opcode_name_table); i++) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2848 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2849 int j; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2850 Ascbyte *name = opcode_name_table[i]; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2851 if (name) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2852 { |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2853 Bytecount len = strlen (name); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2854 /* Prettify the name by converting underscores to hyphens, similar |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2855 to what happens with DEFSYMBOL. */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2856 for (j = 0; j < len; j++) |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2857 if (name[j] == '_') |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2858 name[j] = '-'; |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2859 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2860 } |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2861 |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2862 init_opcode_table_multi_op (Bvarref); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2863 init_opcode_table_multi_op (Bvarset); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2864 init_opcode_table_multi_op (Bvarbind); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2865 init_opcode_table_multi_op (Bcall); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2866 init_opcode_table_multi_op (Bunbind); |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2867 #endif /* ERROR_CHECK_BYTE_CODE */ |
17362f371cc2
add more byte-code assertions and better failure output
Ben Wing <ben@xemacs.org>
parents:
4914
diff
changeset
|
2868 } |